mutation.go 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273
  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/addwechatfriendlog"
  10. "wechat-api/ent/agent"
  11. "wechat-api/ent/agentbase"
  12. "wechat-api/ent/aliyunavatar"
  13. "wechat-api/ent/allocagent"
  14. "wechat-api/ent/apikey"
  15. "wechat-api/ent/batchmsg"
  16. "wechat-api/ent/category"
  17. "wechat-api/ent/chatrecords"
  18. "wechat-api/ent/chatsession"
  19. "wechat-api/ent/compapiasynctask"
  20. "wechat-api/ent/contact"
  21. "wechat-api/ent/contactfield"
  22. "wechat-api/ent/contactfieldtemplate"
  23. "wechat-api/ent/creditbalance"
  24. "wechat-api/ent/creditusage"
  25. "wechat-api/ent/custom_types"
  26. "wechat-api/ent/employee"
  27. "wechat-api/ent/employeeconfig"
  28. "wechat-api/ent/label"
  29. "wechat-api/ent/labellog"
  30. "wechat-api/ent/labelrelationship"
  31. "wechat-api/ent/labeltagging"
  32. "wechat-api/ent/message"
  33. "wechat-api/ent/messagerecords"
  34. "wechat-api/ent/msg"
  35. "wechat-api/ent/payrecharge"
  36. "wechat-api/ent/predicate"
  37. "wechat-api/ent/server"
  38. "wechat-api/ent/sopnode"
  39. "wechat-api/ent/sopstage"
  40. "wechat-api/ent/soptask"
  41. "wechat-api/ent/token"
  42. "wechat-api/ent/tutorial"
  43. "wechat-api/ent/usagedetail"
  44. "wechat-api/ent/usagestatisticday"
  45. "wechat-api/ent/usagestatistichour"
  46. "wechat-api/ent/usagestatisticmonth"
  47. "wechat-api/ent/usagetotal"
  48. "wechat-api/ent/whatsapp"
  49. "wechat-api/ent/whatsappchannel"
  50. "wechat-api/ent/workexperience"
  51. "wechat-api/ent/wpchatroom"
  52. "wechat-api/ent/wpchatroommember"
  53. "wechat-api/ent/wx"
  54. "wechat-api/ent/wxcard"
  55. "wechat-api/ent/wxcarduser"
  56. "wechat-api/ent/wxcardvisit"
  57. "wechat-api/ent/xunji"
  58. "wechat-api/ent/xunjiservice"
  59. "entgo.io/ent"
  60. "entgo.io/ent/dialect/sql"
  61. )
  62. const (
  63. // Operation types.
  64. OpCreate = ent.OpCreate
  65. OpDelete = ent.OpDelete
  66. OpDeleteOne = ent.OpDeleteOne
  67. OpUpdate = ent.OpUpdate
  68. OpUpdateOne = ent.OpUpdateOne
  69. // Node types.
  70. TypeAddWechatFriendLog = "AddWechatFriendLog"
  71. TypeAgent = "Agent"
  72. TypeAgentBase = "AgentBase"
  73. TypeAliyunAvatar = "AliyunAvatar"
  74. TypeAllocAgent = "AllocAgent"
  75. TypeApiKey = "ApiKey"
  76. TypeBatchMsg = "BatchMsg"
  77. TypeCategory = "Category"
  78. TypeChatRecords = "ChatRecords"
  79. TypeChatSession = "ChatSession"
  80. TypeCompapiAsynctask = "CompapiAsynctask"
  81. TypeContact = "Contact"
  82. TypeContactField = "ContactField"
  83. TypeContactFieldTemplate = "ContactFieldTemplate"
  84. TypeCreditBalance = "CreditBalance"
  85. TypeCreditUsage = "CreditUsage"
  86. TypeEmployee = "Employee"
  87. TypeEmployeeConfig = "EmployeeConfig"
  88. TypeLabel = "Label"
  89. TypeLabelLog = "LabelLog"
  90. TypeLabelRelationship = "LabelRelationship"
  91. TypeLabelTagging = "LabelTagging"
  92. TypeMessage = "Message"
  93. TypeMessageRecords = "MessageRecords"
  94. TypeMsg = "Msg"
  95. TypePayRecharge = "PayRecharge"
  96. TypeServer = "Server"
  97. TypeSopNode = "SopNode"
  98. TypeSopStage = "SopStage"
  99. TypeSopTask = "SopTask"
  100. TypeToken = "Token"
  101. TypeTutorial = "Tutorial"
  102. TypeUsageDetail = "UsageDetail"
  103. TypeUsageStatisticDay = "UsageStatisticDay"
  104. TypeUsageStatisticHour = "UsageStatisticHour"
  105. TypeUsageStatisticMonth = "UsageStatisticMonth"
  106. TypeUsageTotal = "UsageTotal"
  107. TypeWhatsapp = "Whatsapp"
  108. TypeWhatsappChannel = "WhatsappChannel"
  109. TypeWorkExperience = "WorkExperience"
  110. TypeWpChatroom = "WpChatroom"
  111. TypeWpChatroomMember = "WpChatroomMember"
  112. TypeWx = "Wx"
  113. TypeWxCard = "WxCard"
  114. TypeWxCardUser = "WxCardUser"
  115. TypeWxCardVisit = "WxCardVisit"
  116. TypeXunji = "Xunji"
  117. TypeXunjiService = "XunjiService"
  118. )
  119. // AddWechatFriendLogMutation represents an operation that mutates the AddWechatFriendLog nodes in the graph.
  120. type AddWechatFriendLogMutation struct {
  121. config
  122. op Op
  123. typ string
  124. id *int64
  125. owner_wx_id *string
  126. owner_wx_type *int
  127. addowner_wx_type *int
  128. find_content *string
  129. message *string
  130. find_request *map[string]interface{}
  131. find_result *map[string]interface{}
  132. is_can_add *int
  133. addis_can_add *int
  134. task_id *int64
  135. addtask_id *int64
  136. add_request *map[string]interface{}
  137. add_result *map[string]interface{}
  138. created_at *int64
  139. addcreated_at *int64
  140. updated_at *int64
  141. addupdated_at *int64
  142. clearedFields map[string]struct{}
  143. done bool
  144. oldValue func(context.Context) (*AddWechatFriendLog, error)
  145. predicates []predicate.AddWechatFriendLog
  146. }
  147. var _ ent.Mutation = (*AddWechatFriendLogMutation)(nil)
  148. // addwechatfriendlogOption allows management of the mutation configuration using functional options.
  149. type addwechatfriendlogOption func(*AddWechatFriendLogMutation)
  150. // newAddWechatFriendLogMutation creates new mutation for the AddWechatFriendLog entity.
  151. func newAddWechatFriendLogMutation(c config, op Op, opts ...addwechatfriendlogOption) *AddWechatFriendLogMutation {
  152. m := &AddWechatFriendLogMutation{
  153. config: c,
  154. op: op,
  155. typ: TypeAddWechatFriendLog,
  156. clearedFields: make(map[string]struct{}),
  157. }
  158. for _, opt := range opts {
  159. opt(m)
  160. }
  161. return m
  162. }
  163. // withAddWechatFriendLogID sets the ID field of the mutation.
  164. func withAddWechatFriendLogID(id int64) addwechatfriendlogOption {
  165. return func(m *AddWechatFriendLogMutation) {
  166. var (
  167. err error
  168. once sync.Once
  169. value *AddWechatFriendLog
  170. )
  171. m.oldValue = func(ctx context.Context) (*AddWechatFriendLog, error) {
  172. once.Do(func() {
  173. if m.done {
  174. err = errors.New("querying old values post mutation is not allowed")
  175. } else {
  176. value, err = m.Client().AddWechatFriendLog.Get(ctx, id)
  177. }
  178. })
  179. return value, err
  180. }
  181. m.id = &id
  182. }
  183. }
  184. // withAddWechatFriendLog sets the old AddWechatFriendLog of the mutation.
  185. func withAddWechatFriendLog(node *AddWechatFriendLog) addwechatfriendlogOption {
  186. return func(m *AddWechatFriendLogMutation) {
  187. m.oldValue = func(context.Context) (*AddWechatFriendLog, error) {
  188. return node, nil
  189. }
  190. m.id = &node.ID
  191. }
  192. }
  193. // Client returns a new `ent.Client` from the mutation. If the mutation was
  194. // executed in a transaction (ent.Tx), a transactional client is returned.
  195. func (m AddWechatFriendLogMutation) Client() *Client {
  196. client := &Client{config: m.config}
  197. client.init()
  198. return client
  199. }
  200. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  201. // it returns an error otherwise.
  202. func (m AddWechatFriendLogMutation) Tx() (*Tx, error) {
  203. if _, ok := m.driver.(*txDriver); !ok {
  204. return nil, errors.New("ent: mutation is not running in a transaction")
  205. }
  206. tx := &Tx{config: m.config}
  207. tx.init()
  208. return tx, nil
  209. }
  210. // SetID sets the value of the id field. Note that this
  211. // operation is only accepted on creation of AddWechatFriendLog entities.
  212. func (m *AddWechatFriendLogMutation) SetID(id int64) {
  213. m.id = &id
  214. }
  215. // ID returns the ID value in the mutation. Note that the ID is only available
  216. // if it was provided to the builder or after it was returned from the database.
  217. func (m *AddWechatFriendLogMutation) ID() (id int64, exists bool) {
  218. if m.id == nil {
  219. return
  220. }
  221. return *m.id, true
  222. }
  223. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  224. // That means, if the mutation is applied within a transaction with an isolation level such
  225. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  226. // or updated by the mutation.
  227. func (m *AddWechatFriendLogMutation) IDs(ctx context.Context) ([]int64, error) {
  228. switch {
  229. case m.op.Is(OpUpdateOne | OpDeleteOne):
  230. id, exists := m.ID()
  231. if exists {
  232. return []int64{id}, nil
  233. }
  234. fallthrough
  235. case m.op.Is(OpUpdate | OpDelete):
  236. return m.Client().AddWechatFriendLog.Query().Where(m.predicates...).IDs(ctx)
  237. default:
  238. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  239. }
  240. }
  241. // SetOwnerWxID sets the "owner_wx_id" field.
  242. func (m *AddWechatFriendLogMutation) SetOwnerWxID(s string) {
  243. m.owner_wx_id = &s
  244. }
  245. // OwnerWxID returns the value of the "owner_wx_id" field in the mutation.
  246. func (m *AddWechatFriendLogMutation) OwnerWxID() (r string, exists bool) {
  247. v := m.owner_wx_id
  248. if v == nil {
  249. return
  250. }
  251. return *v, true
  252. }
  253. // OldOwnerWxID returns the old "owner_wx_id" field's value of the AddWechatFriendLog entity.
  254. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  256. func (m *AddWechatFriendLogMutation) OldOwnerWxID(ctx context.Context) (v string, err error) {
  257. if !m.op.Is(OpUpdateOne) {
  258. return v, errors.New("OldOwnerWxID is only allowed on UpdateOne operations")
  259. }
  260. if m.id == nil || m.oldValue == nil {
  261. return v, errors.New("OldOwnerWxID requires an ID field in the mutation")
  262. }
  263. oldValue, err := m.oldValue(ctx)
  264. if err != nil {
  265. return v, fmt.Errorf("querying old value for OldOwnerWxID: %w", err)
  266. }
  267. return oldValue.OwnerWxID, nil
  268. }
  269. // ResetOwnerWxID resets all changes to the "owner_wx_id" field.
  270. func (m *AddWechatFriendLogMutation) ResetOwnerWxID() {
  271. m.owner_wx_id = nil
  272. }
  273. // SetOwnerWxType sets the "owner_wx_type" field.
  274. func (m *AddWechatFriendLogMutation) SetOwnerWxType(i int) {
  275. m.owner_wx_type = &i
  276. m.addowner_wx_type = nil
  277. }
  278. // OwnerWxType returns the value of the "owner_wx_type" field in the mutation.
  279. func (m *AddWechatFriendLogMutation) OwnerWxType() (r int, exists bool) {
  280. v := m.owner_wx_type
  281. if v == nil {
  282. return
  283. }
  284. return *v, true
  285. }
  286. // OldOwnerWxType returns the old "owner_wx_type" field's value of the AddWechatFriendLog entity.
  287. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  289. func (m *AddWechatFriendLogMutation) OldOwnerWxType(ctx context.Context) (v int, err error) {
  290. if !m.op.Is(OpUpdateOne) {
  291. return v, errors.New("OldOwnerWxType is only allowed on UpdateOne operations")
  292. }
  293. if m.id == nil || m.oldValue == nil {
  294. return v, errors.New("OldOwnerWxType requires an ID field in the mutation")
  295. }
  296. oldValue, err := m.oldValue(ctx)
  297. if err != nil {
  298. return v, fmt.Errorf("querying old value for OldOwnerWxType: %w", err)
  299. }
  300. return oldValue.OwnerWxType, nil
  301. }
  302. // AddOwnerWxType adds i to the "owner_wx_type" field.
  303. func (m *AddWechatFriendLogMutation) AddOwnerWxType(i int) {
  304. if m.addowner_wx_type != nil {
  305. *m.addowner_wx_type += i
  306. } else {
  307. m.addowner_wx_type = &i
  308. }
  309. }
  310. // AddedOwnerWxType returns the value that was added to the "owner_wx_type" field in this mutation.
  311. func (m *AddWechatFriendLogMutation) AddedOwnerWxType() (r int, exists bool) {
  312. v := m.addowner_wx_type
  313. if v == nil {
  314. return
  315. }
  316. return *v, true
  317. }
  318. // ResetOwnerWxType resets all changes to the "owner_wx_type" field.
  319. func (m *AddWechatFriendLogMutation) ResetOwnerWxType() {
  320. m.owner_wx_type = nil
  321. m.addowner_wx_type = nil
  322. }
  323. // SetFindContent sets the "find_content" field.
  324. func (m *AddWechatFriendLogMutation) SetFindContent(s string) {
  325. m.find_content = &s
  326. }
  327. // FindContent returns the value of the "find_content" field in the mutation.
  328. func (m *AddWechatFriendLogMutation) FindContent() (r string, exists bool) {
  329. v := m.find_content
  330. if v == nil {
  331. return
  332. }
  333. return *v, true
  334. }
  335. // OldFindContent returns the old "find_content" field's value of the AddWechatFriendLog entity.
  336. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  338. func (m *AddWechatFriendLogMutation) OldFindContent(ctx context.Context) (v string, err error) {
  339. if !m.op.Is(OpUpdateOne) {
  340. return v, errors.New("OldFindContent is only allowed on UpdateOne operations")
  341. }
  342. if m.id == nil || m.oldValue == nil {
  343. return v, errors.New("OldFindContent requires an ID field in the mutation")
  344. }
  345. oldValue, err := m.oldValue(ctx)
  346. if err != nil {
  347. return v, fmt.Errorf("querying old value for OldFindContent: %w", err)
  348. }
  349. return oldValue.FindContent, nil
  350. }
  351. // ResetFindContent resets all changes to the "find_content" field.
  352. func (m *AddWechatFriendLogMutation) ResetFindContent() {
  353. m.find_content = nil
  354. }
  355. // SetMessage sets the "message" field.
  356. func (m *AddWechatFriendLogMutation) SetMessage(s string) {
  357. m.message = &s
  358. }
  359. // Message returns the value of the "message" field in the mutation.
  360. func (m *AddWechatFriendLogMutation) Message() (r string, exists bool) {
  361. v := m.message
  362. if v == nil {
  363. return
  364. }
  365. return *v, true
  366. }
  367. // OldMessage returns the old "message" field's value of the AddWechatFriendLog entity.
  368. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  370. func (m *AddWechatFriendLogMutation) OldMessage(ctx context.Context) (v string, err error) {
  371. if !m.op.Is(OpUpdateOne) {
  372. return v, errors.New("OldMessage is only allowed on UpdateOne operations")
  373. }
  374. if m.id == nil || m.oldValue == nil {
  375. return v, errors.New("OldMessage requires an ID field in the mutation")
  376. }
  377. oldValue, err := m.oldValue(ctx)
  378. if err != nil {
  379. return v, fmt.Errorf("querying old value for OldMessage: %w", err)
  380. }
  381. return oldValue.Message, nil
  382. }
  383. // ResetMessage resets all changes to the "message" field.
  384. func (m *AddWechatFriendLogMutation) ResetMessage() {
  385. m.message = nil
  386. }
  387. // SetFindRequest sets the "find_request" field.
  388. func (m *AddWechatFriendLogMutation) SetFindRequest(value map[string]interface{}) {
  389. m.find_request = &value
  390. }
  391. // FindRequest returns the value of the "find_request" field in the mutation.
  392. func (m *AddWechatFriendLogMutation) FindRequest() (r map[string]interface{}, exists bool) {
  393. v := m.find_request
  394. if v == nil {
  395. return
  396. }
  397. return *v, true
  398. }
  399. // OldFindRequest returns the old "find_request" field's value of the AddWechatFriendLog entity.
  400. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  402. func (m *AddWechatFriendLogMutation) OldFindRequest(ctx context.Context) (v map[string]interface{}, err error) {
  403. if !m.op.Is(OpUpdateOne) {
  404. return v, errors.New("OldFindRequest is only allowed on UpdateOne operations")
  405. }
  406. if m.id == nil || m.oldValue == nil {
  407. return v, errors.New("OldFindRequest requires an ID field in the mutation")
  408. }
  409. oldValue, err := m.oldValue(ctx)
  410. if err != nil {
  411. return v, fmt.Errorf("querying old value for OldFindRequest: %w", err)
  412. }
  413. return oldValue.FindRequest, nil
  414. }
  415. // ClearFindRequest clears the value of the "find_request" field.
  416. func (m *AddWechatFriendLogMutation) ClearFindRequest() {
  417. m.find_request = nil
  418. m.clearedFields[addwechatfriendlog.FieldFindRequest] = struct{}{}
  419. }
  420. // FindRequestCleared returns if the "find_request" field was cleared in this mutation.
  421. func (m *AddWechatFriendLogMutation) FindRequestCleared() bool {
  422. _, ok := m.clearedFields[addwechatfriendlog.FieldFindRequest]
  423. return ok
  424. }
  425. // ResetFindRequest resets all changes to the "find_request" field.
  426. func (m *AddWechatFriendLogMutation) ResetFindRequest() {
  427. m.find_request = nil
  428. delete(m.clearedFields, addwechatfriendlog.FieldFindRequest)
  429. }
  430. // SetFindResult sets the "find_result" field.
  431. func (m *AddWechatFriendLogMutation) SetFindResult(value map[string]interface{}) {
  432. m.find_result = &value
  433. }
  434. // FindResult returns the value of the "find_result" field in the mutation.
  435. func (m *AddWechatFriendLogMutation) FindResult() (r map[string]interface{}, exists bool) {
  436. v := m.find_result
  437. if v == nil {
  438. return
  439. }
  440. return *v, true
  441. }
  442. // OldFindResult returns the old "find_result" field's value of the AddWechatFriendLog entity.
  443. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  445. func (m *AddWechatFriendLogMutation) OldFindResult(ctx context.Context) (v map[string]interface{}, err error) {
  446. if !m.op.Is(OpUpdateOne) {
  447. return v, errors.New("OldFindResult is only allowed on UpdateOne operations")
  448. }
  449. if m.id == nil || m.oldValue == nil {
  450. return v, errors.New("OldFindResult requires an ID field in the mutation")
  451. }
  452. oldValue, err := m.oldValue(ctx)
  453. if err != nil {
  454. return v, fmt.Errorf("querying old value for OldFindResult: %w", err)
  455. }
  456. return oldValue.FindResult, nil
  457. }
  458. // ClearFindResult clears the value of the "find_result" field.
  459. func (m *AddWechatFriendLogMutation) ClearFindResult() {
  460. m.find_result = nil
  461. m.clearedFields[addwechatfriendlog.FieldFindResult] = struct{}{}
  462. }
  463. // FindResultCleared returns if the "find_result" field was cleared in this mutation.
  464. func (m *AddWechatFriendLogMutation) FindResultCleared() bool {
  465. _, ok := m.clearedFields[addwechatfriendlog.FieldFindResult]
  466. return ok
  467. }
  468. // ResetFindResult resets all changes to the "find_result" field.
  469. func (m *AddWechatFriendLogMutation) ResetFindResult() {
  470. m.find_result = nil
  471. delete(m.clearedFields, addwechatfriendlog.FieldFindResult)
  472. }
  473. // SetIsCanAdd sets the "is_can_add" field.
  474. func (m *AddWechatFriendLogMutation) SetIsCanAdd(i int) {
  475. m.is_can_add = &i
  476. m.addis_can_add = nil
  477. }
  478. // IsCanAdd returns the value of the "is_can_add" field in the mutation.
  479. func (m *AddWechatFriendLogMutation) IsCanAdd() (r int, exists bool) {
  480. v := m.is_can_add
  481. if v == nil {
  482. return
  483. }
  484. return *v, true
  485. }
  486. // OldIsCanAdd returns the old "is_can_add" field's value of the AddWechatFriendLog entity.
  487. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  489. func (m *AddWechatFriendLogMutation) OldIsCanAdd(ctx context.Context) (v int, err error) {
  490. if !m.op.Is(OpUpdateOne) {
  491. return v, errors.New("OldIsCanAdd is only allowed on UpdateOne operations")
  492. }
  493. if m.id == nil || m.oldValue == nil {
  494. return v, errors.New("OldIsCanAdd requires an ID field in the mutation")
  495. }
  496. oldValue, err := m.oldValue(ctx)
  497. if err != nil {
  498. return v, fmt.Errorf("querying old value for OldIsCanAdd: %w", err)
  499. }
  500. return oldValue.IsCanAdd, nil
  501. }
  502. // AddIsCanAdd adds i to the "is_can_add" field.
  503. func (m *AddWechatFriendLogMutation) AddIsCanAdd(i int) {
  504. if m.addis_can_add != nil {
  505. *m.addis_can_add += i
  506. } else {
  507. m.addis_can_add = &i
  508. }
  509. }
  510. // AddedIsCanAdd returns the value that was added to the "is_can_add" field in this mutation.
  511. func (m *AddWechatFriendLogMutation) AddedIsCanAdd() (r int, exists bool) {
  512. v := m.addis_can_add
  513. if v == nil {
  514. return
  515. }
  516. return *v, true
  517. }
  518. // ResetIsCanAdd resets all changes to the "is_can_add" field.
  519. func (m *AddWechatFriendLogMutation) ResetIsCanAdd() {
  520. m.is_can_add = nil
  521. m.addis_can_add = nil
  522. }
  523. // SetTaskID sets the "task_id" field.
  524. func (m *AddWechatFriendLogMutation) SetTaskID(i int64) {
  525. m.task_id = &i
  526. m.addtask_id = nil
  527. }
  528. // TaskID returns the value of the "task_id" field in the mutation.
  529. func (m *AddWechatFriendLogMutation) TaskID() (r int64, exists bool) {
  530. v := m.task_id
  531. if v == nil {
  532. return
  533. }
  534. return *v, true
  535. }
  536. // OldTaskID returns the old "task_id" field's value of the AddWechatFriendLog entity.
  537. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  539. func (m *AddWechatFriendLogMutation) OldTaskID(ctx context.Context) (v int64, err error) {
  540. if !m.op.Is(OpUpdateOne) {
  541. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  542. }
  543. if m.id == nil || m.oldValue == nil {
  544. return v, errors.New("OldTaskID requires an ID field in the mutation")
  545. }
  546. oldValue, err := m.oldValue(ctx)
  547. if err != nil {
  548. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  549. }
  550. return oldValue.TaskID, nil
  551. }
  552. // AddTaskID adds i to the "task_id" field.
  553. func (m *AddWechatFriendLogMutation) AddTaskID(i int64) {
  554. if m.addtask_id != nil {
  555. *m.addtask_id += i
  556. } else {
  557. m.addtask_id = &i
  558. }
  559. }
  560. // AddedTaskID returns the value that was added to the "task_id" field in this mutation.
  561. func (m *AddWechatFriendLogMutation) AddedTaskID() (r int64, exists bool) {
  562. v := m.addtask_id
  563. if v == nil {
  564. return
  565. }
  566. return *v, true
  567. }
  568. // ResetTaskID resets all changes to the "task_id" field.
  569. func (m *AddWechatFriendLogMutation) ResetTaskID() {
  570. m.task_id = nil
  571. m.addtask_id = nil
  572. }
  573. // SetAddRequest sets the "add_request" field.
  574. func (m *AddWechatFriendLogMutation) SetAddRequest(value map[string]interface{}) {
  575. m.add_request = &value
  576. }
  577. // AddRequest returns the value of the "add_request" field in the mutation.
  578. func (m *AddWechatFriendLogMutation) AddRequest() (r map[string]interface{}, exists bool) {
  579. v := m.add_request
  580. if v == nil {
  581. return
  582. }
  583. return *v, true
  584. }
  585. // OldAddRequest returns the old "add_request" field's value of the AddWechatFriendLog entity.
  586. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  588. func (m *AddWechatFriendLogMutation) OldAddRequest(ctx context.Context) (v map[string]interface{}, err error) {
  589. if !m.op.Is(OpUpdateOne) {
  590. return v, errors.New("OldAddRequest is only allowed on UpdateOne operations")
  591. }
  592. if m.id == nil || m.oldValue == nil {
  593. return v, errors.New("OldAddRequest requires an ID field in the mutation")
  594. }
  595. oldValue, err := m.oldValue(ctx)
  596. if err != nil {
  597. return v, fmt.Errorf("querying old value for OldAddRequest: %w", err)
  598. }
  599. return oldValue.AddRequest, nil
  600. }
  601. // ClearAddRequest clears the value of the "add_request" field.
  602. func (m *AddWechatFriendLogMutation) ClearAddRequest() {
  603. m.add_request = nil
  604. m.clearedFields[addwechatfriendlog.FieldAddRequest] = struct{}{}
  605. }
  606. // AddRequestCleared returns if the "add_request" field was cleared in this mutation.
  607. func (m *AddWechatFriendLogMutation) AddRequestCleared() bool {
  608. _, ok := m.clearedFields[addwechatfriendlog.FieldAddRequest]
  609. return ok
  610. }
  611. // ResetAddRequest resets all changes to the "add_request" field.
  612. func (m *AddWechatFriendLogMutation) ResetAddRequest() {
  613. m.add_request = nil
  614. delete(m.clearedFields, addwechatfriendlog.FieldAddRequest)
  615. }
  616. // SetAddResult sets the "add_result" field.
  617. func (m *AddWechatFriendLogMutation) SetAddResult(value map[string]interface{}) {
  618. m.add_result = &value
  619. }
  620. // AddResult returns the value of the "add_result" field in the mutation.
  621. func (m *AddWechatFriendLogMutation) AddResult() (r map[string]interface{}, exists bool) {
  622. v := m.add_result
  623. if v == nil {
  624. return
  625. }
  626. return *v, true
  627. }
  628. // OldAddResult returns the old "add_result" field's value of the AddWechatFriendLog entity.
  629. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  631. func (m *AddWechatFriendLogMutation) OldAddResult(ctx context.Context) (v map[string]interface{}, err error) {
  632. if !m.op.Is(OpUpdateOne) {
  633. return v, errors.New("OldAddResult is only allowed on UpdateOne operations")
  634. }
  635. if m.id == nil || m.oldValue == nil {
  636. return v, errors.New("OldAddResult requires an ID field in the mutation")
  637. }
  638. oldValue, err := m.oldValue(ctx)
  639. if err != nil {
  640. return v, fmt.Errorf("querying old value for OldAddResult: %w", err)
  641. }
  642. return oldValue.AddResult, nil
  643. }
  644. // ClearAddResult clears the value of the "add_result" field.
  645. func (m *AddWechatFriendLogMutation) ClearAddResult() {
  646. m.add_result = nil
  647. m.clearedFields[addwechatfriendlog.FieldAddResult] = struct{}{}
  648. }
  649. // AddResultCleared returns if the "add_result" field was cleared in this mutation.
  650. func (m *AddWechatFriendLogMutation) AddResultCleared() bool {
  651. _, ok := m.clearedFields[addwechatfriendlog.FieldAddResult]
  652. return ok
  653. }
  654. // ResetAddResult resets all changes to the "add_result" field.
  655. func (m *AddWechatFriendLogMutation) ResetAddResult() {
  656. m.add_result = nil
  657. delete(m.clearedFields, addwechatfriendlog.FieldAddResult)
  658. }
  659. // SetCreatedAt sets the "created_at" field.
  660. func (m *AddWechatFriendLogMutation) SetCreatedAt(i int64) {
  661. m.created_at = &i
  662. m.addcreated_at = nil
  663. }
  664. // CreatedAt returns the value of the "created_at" field in the mutation.
  665. func (m *AddWechatFriendLogMutation) CreatedAt() (r int64, exists bool) {
  666. v := m.created_at
  667. if v == nil {
  668. return
  669. }
  670. return *v, true
  671. }
  672. // OldCreatedAt returns the old "created_at" field's value of the AddWechatFriendLog entity.
  673. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  675. func (m *AddWechatFriendLogMutation) OldCreatedAt(ctx context.Context) (v int64, err error) {
  676. if !m.op.Is(OpUpdateOne) {
  677. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  678. }
  679. if m.id == nil || m.oldValue == nil {
  680. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  681. }
  682. oldValue, err := m.oldValue(ctx)
  683. if err != nil {
  684. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  685. }
  686. return oldValue.CreatedAt, nil
  687. }
  688. // AddCreatedAt adds i to the "created_at" field.
  689. func (m *AddWechatFriendLogMutation) AddCreatedAt(i int64) {
  690. if m.addcreated_at != nil {
  691. *m.addcreated_at += i
  692. } else {
  693. m.addcreated_at = &i
  694. }
  695. }
  696. // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation.
  697. func (m *AddWechatFriendLogMutation) AddedCreatedAt() (r int64, exists bool) {
  698. v := m.addcreated_at
  699. if v == nil {
  700. return
  701. }
  702. return *v, true
  703. }
  704. // ResetCreatedAt resets all changes to the "created_at" field.
  705. func (m *AddWechatFriendLogMutation) ResetCreatedAt() {
  706. m.created_at = nil
  707. m.addcreated_at = nil
  708. }
  709. // SetUpdatedAt sets the "updated_at" field.
  710. func (m *AddWechatFriendLogMutation) SetUpdatedAt(i int64) {
  711. m.updated_at = &i
  712. m.addupdated_at = nil
  713. }
  714. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  715. func (m *AddWechatFriendLogMutation) UpdatedAt() (r int64, exists bool) {
  716. v := m.updated_at
  717. if v == nil {
  718. return
  719. }
  720. return *v, true
  721. }
  722. // OldUpdatedAt returns the old "updated_at" field's value of the AddWechatFriendLog entity.
  723. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  725. func (m *AddWechatFriendLogMutation) OldUpdatedAt(ctx context.Context) (v int64, err error) {
  726. if !m.op.Is(OpUpdateOne) {
  727. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  728. }
  729. if m.id == nil || m.oldValue == nil {
  730. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  731. }
  732. oldValue, err := m.oldValue(ctx)
  733. if err != nil {
  734. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  735. }
  736. return oldValue.UpdatedAt, nil
  737. }
  738. // AddUpdatedAt adds i to the "updated_at" field.
  739. func (m *AddWechatFriendLogMutation) AddUpdatedAt(i int64) {
  740. if m.addupdated_at != nil {
  741. *m.addupdated_at += i
  742. } else {
  743. m.addupdated_at = &i
  744. }
  745. }
  746. // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation.
  747. func (m *AddWechatFriendLogMutation) AddedUpdatedAt() (r int64, exists bool) {
  748. v := m.addupdated_at
  749. if v == nil {
  750. return
  751. }
  752. return *v, true
  753. }
  754. // ResetUpdatedAt resets all changes to the "updated_at" field.
  755. func (m *AddWechatFriendLogMutation) ResetUpdatedAt() {
  756. m.updated_at = nil
  757. m.addupdated_at = nil
  758. }
  759. // Where appends a list predicates to the AddWechatFriendLogMutation builder.
  760. func (m *AddWechatFriendLogMutation) Where(ps ...predicate.AddWechatFriendLog) {
  761. m.predicates = append(m.predicates, ps...)
  762. }
  763. // WhereP appends storage-level predicates to the AddWechatFriendLogMutation builder. Using this method,
  764. // users can use type-assertion to append predicates that do not depend on any generated package.
  765. func (m *AddWechatFriendLogMutation) WhereP(ps ...func(*sql.Selector)) {
  766. p := make([]predicate.AddWechatFriendLog, len(ps))
  767. for i := range ps {
  768. p[i] = ps[i]
  769. }
  770. m.Where(p...)
  771. }
  772. // Op returns the operation name.
  773. func (m *AddWechatFriendLogMutation) Op() Op {
  774. return m.op
  775. }
  776. // SetOp allows setting the mutation operation.
  777. func (m *AddWechatFriendLogMutation) SetOp(op Op) {
  778. m.op = op
  779. }
  780. // Type returns the node type of this mutation (AddWechatFriendLog).
  781. func (m *AddWechatFriendLogMutation) Type() string {
  782. return m.typ
  783. }
  784. // Fields returns all fields that were changed during this mutation. Note that in
  785. // order to get all numeric fields that were incremented/decremented, call
  786. // AddedFields().
  787. func (m *AddWechatFriendLogMutation) Fields() []string {
  788. fields := make([]string, 0, 12)
  789. if m.owner_wx_id != nil {
  790. fields = append(fields, addwechatfriendlog.FieldOwnerWxID)
  791. }
  792. if m.owner_wx_type != nil {
  793. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  794. }
  795. if m.find_content != nil {
  796. fields = append(fields, addwechatfriendlog.FieldFindContent)
  797. }
  798. if m.message != nil {
  799. fields = append(fields, addwechatfriendlog.FieldMessage)
  800. }
  801. if m.find_request != nil {
  802. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  803. }
  804. if m.find_result != nil {
  805. fields = append(fields, addwechatfriendlog.FieldFindResult)
  806. }
  807. if m.is_can_add != nil {
  808. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  809. }
  810. if m.task_id != nil {
  811. fields = append(fields, addwechatfriendlog.FieldTaskID)
  812. }
  813. if m.add_request != nil {
  814. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  815. }
  816. if m.add_result != nil {
  817. fields = append(fields, addwechatfriendlog.FieldAddResult)
  818. }
  819. if m.created_at != nil {
  820. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  821. }
  822. if m.updated_at != nil {
  823. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  824. }
  825. return fields
  826. }
  827. // Field returns the value of a field with the given name. The second boolean
  828. // return value indicates that this field was not set, or was not defined in the
  829. // schema.
  830. func (m *AddWechatFriendLogMutation) Field(name string) (ent.Value, bool) {
  831. switch name {
  832. case addwechatfriendlog.FieldOwnerWxID:
  833. return m.OwnerWxID()
  834. case addwechatfriendlog.FieldOwnerWxType:
  835. return m.OwnerWxType()
  836. case addwechatfriendlog.FieldFindContent:
  837. return m.FindContent()
  838. case addwechatfriendlog.FieldMessage:
  839. return m.Message()
  840. case addwechatfriendlog.FieldFindRequest:
  841. return m.FindRequest()
  842. case addwechatfriendlog.FieldFindResult:
  843. return m.FindResult()
  844. case addwechatfriendlog.FieldIsCanAdd:
  845. return m.IsCanAdd()
  846. case addwechatfriendlog.FieldTaskID:
  847. return m.TaskID()
  848. case addwechatfriendlog.FieldAddRequest:
  849. return m.AddRequest()
  850. case addwechatfriendlog.FieldAddResult:
  851. return m.AddResult()
  852. case addwechatfriendlog.FieldCreatedAt:
  853. return m.CreatedAt()
  854. case addwechatfriendlog.FieldUpdatedAt:
  855. return m.UpdatedAt()
  856. }
  857. return nil, false
  858. }
  859. // OldField returns the old value of the field from the database. An error is
  860. // returned if the mutation operation is not UpdateOne, or the query to the
  861. // database failed.
  862. func (m *AddWechatFriendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  863. switch name {
  864. case addwechatfriendlog.FieldOwnerWxID:
  865. return m.OldOwnerWxID(ctx)
  866. case addwechatfriendlog.FieldOwnerWxType:
  867. return m.OldOwnerWxType(ctx)
  868. case addwechatfriendlog.FieldFindContent:
  869. return m.OldFindContent(ctx)
  870. case addwechatfriendlog.FieldMessage:
  871. return m.OldMessage(ctx)
  872. case addwechatfriendlog.FieldFindRequest:
  873. return m.OldFindRequest(ctx)
  874. case addwechatfriendlog.FieldFindResult:
  875. return m.OldFindResult(ctx)
  876. case addwechatfriendlog.FieldIsCanAdd:
  877. return m.OldIsCanAdd(ctx)
  878. case addwechatfriendlog.FieldTaskID:
  879. return m.OldTaskID(ctx)
  880. case addwechatfriendlog.FieldAddRequest:
  881. return m.OldAddRequest(ctx)
  882. case addwechatfriendlog.FieldAddResult:
  883. return m.OldAddResult(ctx)
  884. case addwechatfriendlog.FieldCreatedAt:
  885. return m.OldCreatedAt(ctx)
  886. case addwechatfriendlog.FieldUpdatedAt:
  887. return m.OldUpdatedAt(ctx)
  888. }
  889. return nil, fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  890. }
  891. // SetField sets the value of a field with the given name. It returns an error if
  892. // the field is not defined in the schema, or if the type mismatched the field
  893. // type.
  894. func (m *AddWechatFriendLogMutation) SetField(name string, value ent.Value) error {
  895. switch name {
  896. case addwechatfriendlog.FieldOwnerWxID:
  897. v, ok := value.(string)
  898. if !ok {
  899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  900. }
  901. m.SetOwnerWxID(v)
  902. return nil
  903. case addwechatfriendlog.FieldOwnerWxType:
  904. v, ok := value.(int)
  905. if !ok {
  906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  907. }
  908. m.SetOwnerWxType(v)
  909. return nil
  910. case addwechatfriendlog.FieldFindContent:
  911. v, ok := value.(string)
  912. if !ok {
  913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  914. }
  915. m.SetFindContent(v)
  916. return nil
  917. case addwechatfriendlog.FieldMessage:
  918. v, ok := value.(string)
  919. if !ok {
  920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  921. }
  922. m.SetMessage(v)
  923. return nil
  924. case addwechatfriendlog.FieldFindRequest:
  925. v, ok := value.(map[string]interface{})
  926. if !ok {
  927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  928. }
  929. m.SetFindRequest(v)
  930. return nil
  931. case addwechatfriendlog.FieldFindResult:
  932. v, ok := value.(map[string]interface{})
  933. if !ok {
  934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  935. }
  936. m.SetFindResult(v)
  937. return nil
  938. case addwechatfriendlog.FieldIsCanAdd:
  939. v, ok := value.(int)
  940. if !ok {
  941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  942. }
  943. m.SetIsCanAdd(v)
  944. return nil
  945. case addwechatfriendlog.FieldTaskID:
  946. v, ok := value.(int64)
  947. if !ok {
  948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  949. }
  950. m.SetTaskID(v)
  951. return nil
  952. case addwechatfriendlog.FieldAddRequest:
  953. v, ok := value.(map[string]interface{})
  954. if !ok {
  955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  956. }
  957. m.SetAddRequest(v)
  958. return nil
  959. case addwechatfriendlog.FieldAddResult:
  960. v, ok := value.(map[string]interface{})
  961. if !ok {
  962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  963. }
  964. m.SetAddResult(v)
  965. return nil
  966. case addwechatfriendlog.FieldCreatedAt:
  967. v, ok := value.(int64)
  968. if !ok {
  969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  970. }
  971. m.SetCreatedAt(v)
  972. return nil
  973. case addwechatfriendlog.FieldUpdatedAt:
  974. v, ok := value.(int64)
  975. if !ok {
  976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  977. }
  978. m.SetUpdatedAt(v)
  979. return nil
  980. }
  981. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  982. }
  983. // AddedFields returns all numeric fields that were incremented/decremented during
  984. // this mutation.
  985. func (m *AddWechatFriendLogMutation) AddedFields() []string {
  986. var fields []string
  987. if m.addowner_wx_type != nil {
  988. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  989. }
  990. if m.addis_can_add != nil {
  991. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  992. }
  993. if m.addtask_id != nil {
  994. fields = append(fields, addwechatfriendlog.FieldTaskID)
  995. }
  996. if m.addcreated_at != nil {
  997. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  998. }
  999. if m.addupdated_at != nil {
  1000. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  1001. }
  1002. return fields
  1003. }
  1004. // AddedField returns the numeric value that was incremented/decremented on a field
  1005. // with the given name. The second boolean return value indicates that this field
  1006. // was not set, or was not defined in the schema.
  1007. func (m *AddWechatFriendLogMutation) AddedField(name string) (ent.Value, bool) {
  1008. switch name {
  1009. case addwechatfriendlog.FieldOwnerWxType:
  1010. return m.AddedOwnerWxType()
  1011. case addwechatfriendlog.FieldIsCanAdd:
  1012. return m.AddedIsCanAdd()
  1013. case addwechatfriendlog.FieldTaskID:
  1014. return m.AddedTaskID()
  1015. case addwechatfriendlog.FieldCreatedAt:
  1016. return m.AddedCreatedAt()
  1017. case addwechatfriendlog.FieldUpdatedAt:
  1018. return m.AddedUpdatedAt()
  1019. }
  1020. return nil, false
  1021. }
  1022. // AddField adds the value to the field with the given name. It returns an error if
  1023. // the field is not defined in the schema, or if the type mismatched the field
  1024. // type.
  1025. func (m *AddWechatFriendLogMutation) AddField(name string, value ent.Value) error {
  1026. switch name {
  1027. case addwechatfriendlog.FieldOwnerWxType:
  1028. v, ok := value.(int)
  1029. if !ok {
  1030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1031. }
  1032. m.AddOwnerWxType(v)
  1033. return nil
  1034. case addwechatfriendlog.FieldIsCanAdd:
  1035. v, ok := value.(int)
  1036. if !ok {
  1037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1038. }
  1039. m.AddIsCanAdd(v)
  1040. return nil
  1041. case addwechatfriendlog.FieldTaskID:
  1042. v, ok := value.(int64)
  1043. if !ok {
  1044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1045. }
  1046. m.AddTaskID(v)
  1047. return nil
  1048. case addwechatfriendlog.FieldCreatedAt:
  1049. v, ok := value.(int64)
  1050. if !ok {
  1051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1052. }
  1053. m.AddCreatedAt(v)
  1054. return nil
  1055. case addwechatfriendlog.FieldUpdatedAt:
  1056. v, ok := value.(int64)
  1057. if !ok {
  1058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1059. }
  1060. m.AddUpdatedAt(v)
  1061. return nil
  1062. }
  1063. return fmt.Errorf("unknown AddWechatFriendLog numeric field %s", name)
  1064. }
  1065. // ClearedFields returns all nullable fields that were cleared during this
  1066. // mutation.
  1067. func (m *AddWechatFriendLogMutation) ClearedFields() []string {
  1068. var fields []string
  1069. if m.FieldCleared(addwechatfriendlog.FieldFindRequest) {
  1070. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  1071. }
  1072. if m.FieldCleared(addwechatfriendlog.FieldFindResult) {
  1073. fields = append(fields, addwechatfriendlog.FieldFindResult)
  1074. }
  1075. if m.FieldCleared(addwechatfriendlog.FieldAddRequest) {
  1076. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  1077. }
  1078. if m.FieldCleared(addwechatfriendlog.FieldAddResult) {
  1079. fields = append(fields, addwechatfriendlog.FieldAddResult)
  1080. }
  1081. return fields
  1082. }
  1083. // FieldCleared returns a boolean indicating if a field with the given name was
  1084. // cleared in this mutation.
  1085. func (m *AddWechatFriendLogMutation) FieldCleared(name string) bool {
  1086. _, ok := m.clearedFields[name]
  1087. return ok
  1088. }
  1089. // ClearField clears the value of the field with the given name. It returns an
  1090. // error if the field is not defined in the schema.
  1091. func (m *AddWechatFriendLogMutation) ClearField(name string) error {
  1092. switch name {
  1093. case addwechatfriendlog.FieldFindRequest:
  1094. m.ClearFindRequest()
  1095. return nil
  1096. case addwechatfriendlog.FieldFindResult:
  1097. m.ClearFindResult()
  1098. return nil
  1099. case addwechatfriendlog.FieldAddRequest:
  1100. m.ClearAddRequest()
  1101. return nil
  1102. case addwechatfriendlog.FieldAddResult:
  1103. m.ClearAddResult()
  1104. return nil
  1105. }
  1106. return fmt.Errorf("unknown AddWechatFriendLog nullable field %s", name)
  1107. }
  1108. // ResetField resets all changes in the mutation for the field with the given name.
  1109. // It returns an error if the field is not defined in the schema.
  1110. func (m *AddWechatFriendLogMutation) ResetField(name string) error {
  1111. switch name {
  1112. case addwechatfriendlog.FieldOwnerWxID:
  1113. m.ResetOwnerWxID()
  1114. return nil
  1115. case addwechatfriendlog.FieldOwnerWxType:
  1116. m.ResetOwnerWxType()
  1117. return nil
  1118. case addwechatfriendlog.FieldFindContent:
  1119. m.ResetFindContent()
  1120. return nil
  1121. case addwechatfriendlog.FieldMessage:
  1122. m.ResetMessage()
  1123. return nil
  1124. case addwechatfriendlog.FieldFindRequest:
  1125. m.ResetFindRequest()
  1126. return nil
  1127. case addwechatfriendlog.FieldFindResult:
  1128. m.ResetFindResult()
  1129. return nil
  1130. case addwechatfriendlog.FieldIsCanAdd:
  1131. m.ResetIsCanAdd()
  1132. return nil
  1133. case addwechatfriendlog.FieldTaskID:
  1134. m.ResetTaskID()
  1135. return nil
  1136. case addwechatfriendlog.FieldAddRequest:
  1137. m.ResetAddRequest()
  1138. return nil
  1139. case addwechatfriendlog.FieldAddResult:
  1140. m.ResetAddResult()
  1141. return nil
  1142. case addwechatfriendlog.FieldCreatedAt:
  1143. m.ResetCreatedAt()
  1144. return nil
  1145. case addwechatfriendlog.FieldUpdatedAt:
  1146. m.ResetUpdatedAt()
  1147. return nil
  1148. }
  1149. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1150. }
  1151. // AddedEdges returns all edge names that were set/added in this mutation.
  1152. func (m *AddWechatFriendLogMutation) AddedEdges() []string {
  1153. edges := make([]string, 0, 0)
  1154. return edges
  1155. }
  1156. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1157. // name in this mutation.
  1158. func (m *AddWechatFriendLogMutation) AddedIDs(name string) []ent.Value {
  1159. return nil
  1160. }
  1161. // RemovedEdges returns all edge names that were removed in this mutation.
  1162. func (m *AddWechatFriendLogMutation) RemovedEdges() []string {
  1163. edges := make([]string, 0, 0)
  1164. return edges
  1165. }
  1166. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1167. // the given name in this mutation.
  1168. func (m *AddWechatFriendLogMutation) RemovedIDs(name string) []ent.Value {
  1169. return nil
  1170. }
  1171. // ClearedEdges returns all edge names that were cleared in this mutation.
  1172. func (m *AddWechatFriendLogMutation) ClearedEdges() []string {
  1173. edges := make([]string, 0, 0)
  1174. return edges
  1175. }
  1176. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1177. // was cleared in this mutation.
  1178. func (m *AddWechatFriendLogMutation) EdgeCleared(name string) bool {
  1179. return false
  1180. }
  1181. // ClearEdge clears the value of the edge with the given name. It returns an error
  1182. // if that edge is not defined in the schema.
  1183. func (m *AddWechatFriendLogMutation) ClearEdge(name string) error {
  1184. return fmt.Errorf("unknown AddWechatFriendLog unique edge %s", name)
  1185. }
  1186. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1187. // It returns an error if the edge is not defined in the schema.
  1188. func (m *AddWechatFriendLogMutation) ResetEdge(name string) error {
  1189. return fmt.Errorf("unknown AddWechatFriendLog edge %s", name)
  1190. }
  1191. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  1192. type AgentMutation struct {
  1193. config
  1194. op Op
  1195. typ string
  1196. id *uint64
  1197. created_at *time.Time
  1198. updated_at *time.Time
  1199. deleted_at *time.Time
  1200. name *string
  1201. role *string
  1202. status *int
  1203. addstatus *int
  1204. background *string
  1205. examples *string
  1206. organization_id *uint64
  1207. addorganization_id *int64
  1208. dataset_id *string
  1209. collection_id *string
  1210. model *string
  1211. api_base *string
  1212. api_key *string
  1213. _type *int
  1214. add_type *int
  1215. clearedFields map[string]struct{}
  1216. wx_agent map[uint64]struct{}
  1217. removedwx_agent map[uint64]struct{}
  1218. clearedwx_agent bool
  1219. token_agent map[uint64]struct{}
  1220. removedtoken_agent map[uint64]struct{}
  1221. clearedtoken_agent bool
  1222. wa_agent map[uint64]struct{}
  1223. removedwa_agent map[uint64]struct{}
  1224. clearedwa_agent bool
  1225. xjs_agent map[uint64]struct{}
  1226. removedxjs_agent map[uint64]struct{}
  1227. clearedxjs_agent bool
  1228. key_agent map[uint64]struct{}
  1229. removedkey_agent map[uint64]struct{}
  1230. clearedkey_agent bool
  1231. done bool
  1232. oldValue func(context.Context) (*Agent, error)
  1233. predicates []predicate.Agent
  1234. }
  1235. var _ ent.Mutation = (*AgentMutation)(nil)
  1236. // agentOption allows management of the mutation configuration using functional options.
  1237. type agentOption func(*AgentMutation)
  1238. // newAgentMutation creates new mutation for the Agent entity.
  1239. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  1240. m := &AgentMutation{
  1241. config: c,
  1242. op: op,
  1243. typ: TypeAgent,
  1244. clearedFields: make(map[string]struct{}),
  1245. }
  1246. for _, opt := range opts {
  1247. opt(m)
  1248. }
  1249. return m
  1250. }
  1251. // withAgentID sets the ID field of the mutation.
  1252. func withAgentID(id uint64) agentOption {
  1253. return func(m *AgentMutation) {
  1254. var (
  1255. err error
  1256. once sync.Once
  1257. value *Agent
  1258. )
  1259. m.oldValue = func(ctx context.Context) (*Agent, error) {
  1260. once.Do(func() {
  1261. if m.done {
  1262. err = errors.New("querying old values post mutation is not allowed")
  1263. } else {
  1264. value, err = m.Client().Agent.Get(ctx, id)
  1265. }
  1266. })
  1267. return value, err
  1268. }
  1269. m.id = &id
  1270. }
  1271. }
  1272. // withAgent sets the old Agent of the mutation.
  1273. func withAgent(node *Agent) agentOption {
  1274. return func(m *AgentMutation) {
  1275. m.oldValue = func(context.Context) (*Agent, error) {
  1276. return node, nil
  1277. }
  1278. m.id = &node.ID
  1279. }
  1280. }
  1281. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1282. // executed in a transaction (ent.Tx), a transactional client is returned.
  1283. func (m AgentMutation) Client() *Client {
  1284. client := &Client{config: m.config}
  1285. client.init()
  1286. return client
  1287. }
  1288. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1289. // it returns an error otherwise.
  1290. func (m AgentMutation) Tx() (*Tx, error) {
  1291. if _, ok := m.driver.(*txDriver); !ok {
  1292. return nil, errors.New("ent: mutation is not running in a transaction")
  1293. }
  1294. tx := &Tx{config: m.config}
  1295. tx.init()
  1296. return tx, nil
  1297. }
  1298. // SetID sets the value of the id field. Note that this
  1299. // operation is only accepted on creation of Agent entities.
  1300. func (m *AgentMutation) SetID(id uint64) {
  1301. m.id = &id
  1302. }
  1303. // ID returns the ID value in the mutation. Note that the ID is only available
  1304. // if it was provided to the builder or after it was returned from the database.
  1305. func (m *AgentMutation) ID() (id uint64, exists bool) {
  1306. if m.id == nil {
  1307. return
  1308. }
  1309. return *m.id, true
  1310. }
  1311. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1312. // That means, if the mutation is applied within a transaction with an isolation level such
  1313. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1314. // or updated by the mutation.
  1315. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  1316. switch {
  1317. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1318. id, exists := m.ID()
  1319. if exists {
  1320. return []uint64{id}, nil
  1321. }
  1322. fallthrough
  1323. case m.op.Is(OpUpdate | OpDelete):
  1324. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  1325. default:
  1326. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1327. }
  1328. }
  1329. // SetCreatedAt sets the "created_at" field.
  1330. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  1331. m.created_at = &t
  1332. }
  1333. // CreatedAt returns the value of the "created_at" field in the mutation.
  1334. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  1335. v := m.created_at
  1336. if v == nil {
  1337. return
  1338. }
  1339. return *v, true
  1340. }
  1341. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  1342. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1344. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1345. if !m.op.Is(OpUpdateOne) {
  1346. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1347. }
  1348. if m.id == nil || m.oldValue == nil {
  1349. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1350. }
  1351. oldValue, err := m.oldValue(ctx)
  1352. if err != nil {
  1353. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1354. }
  1355. return oldValue.CreatedAt, nil
  1356. }
  1357. // ResetCreatedAt resets all changes to the "created_at" field.
  1358. func (m *AgentMutation) ResetCreatedAt() {
  1359. m.created_at = nil
  1360. }
  1361. // SetUpdatedAt sets the "updated_at" field.
  1362. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  1363. m.updated_at = &t
  1364. }
  1365. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1366. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  1367. v := m.updated_at
  1368. if v == nil {
  1369. return
  1370. }
  1371. return *v, true
  1372. }
  1373. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  1374. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1376. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1377. if !m.op.Is(OpUpdateOne) {
  1378. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1379. }
  1380. if m.id == nil || m.oldValue == nil {
  1381. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1382. }
  1383. oldValue, err := m.oldValue(ctx)
  1384. if err != nil {
  1385. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1386. }
  1387. return oldValue.UpdatedAt, nil
  1388. }
  1389. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1390. func (m *AgentMutation) ResetUpdatedAt() {
  1391. m.updated_at = nil
  1392. }
  1393. // SetDeletedAt sets the "deleted_at" field.
  1394. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  1395. m.deleted_at = &t
  1396. }
  1397. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1398. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  1399. v := m.deleted_at
  1400. if v == nil {
  1401. return
  1402. }
  1403. return *v, true
  1404. }
  1405. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  1406. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1408. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1409. if !m.op.Is(OpUpdateOne) {
  1410. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1411. }
  1412. if m.id == nil || m.oldValue == nil {
  1413. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1414. }
  1415. oldValue, err := m.oldValue(ctx)
  1416. if err != nil {
  1417. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1418. }
  1419. return oldValue.DeletedAt, nil
  1420. }
  1421. // ClearDeletedAt clears the value of the "deleted_at" field.
  1422. func (m *AgentMutation) ClearDeletedAt() {
  1423. m.deleted_at = nil
  1424. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  1425. }
  1426. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1427. func (m *AgentMutation) DeletedAtCleared() bool {
  1428. _, ok := m.clearedFields[agent.FieldDeletedAt]
  1429. return ok
  1430. }
  1431. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1432. func (m *AgentMutation) ResetDeletedAt() {
  1433. m.deleted_at = nil
  1434. delete(m.clearedFields, agent.FieldDeletedAt)
  1435. }
  1436. // SetName sets the "name" field.
  1437. func (m *AgentMutation) SetName(s string) {
  1438. m.name = &s
  1439. }
  1440. // Name returns the value of the "name" field in the mutation.
  1441. func (m *AgentMutation) Name() (r string, exists bool) {
  1442. v := m.name
  1443. if v == nil {
  1444. return
  1445. }
  1446. return *v, true
  1447. }
  1448. // OldName returns the old "name" field's value of the Agent entity.
  1449. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1451. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  1452. if !m.op.Is(OpUpdateOne) {
  1453. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1454. }
  1455. if m.id == nil || m.oldValue == nil {
  1456. return v, errors.New("OldName requires an ID field in the mutation")
  1457. }
  1458. oldValue, err := m.oldValue(ctx)
  1459. if err != nil {
  1460. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1461. }
  1462. return oldValue.Name, nil
  1463. }
  1464. // ResetName resets all changes to the "name" field.
  1465. func (m *AgentMutation) ResetName() {
  1466. m.name = nil
  1467. }
  1468. // SetRole sets the "role" field.
  1469. func (m *AgentMutation) SetRole(s string) {
  1470. m.role = &s
  1471. }
  1472. // Role returns the value of the "role" field in the mutation.
  1473. func (m *AgentMutation) Role() (r string, exists bool) {
  1474. v := m.role
  1475. if v == nil {
  1476. return
  1477. }
  1478. return *v, true
  1479. }
  1480. // OldRole returns the old "role" field's value of the Agent entity.
  1481. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1483. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  1484. if !m.op.Is(OpUpdateOne) {
  1485. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  1486. }
  1487. if m.id == nil || m.oldValue == nil {
  1488. return v, errors.New("OldRole requires an ID field in the mutation")
  1489. }
  1490. oldValue, err := m.oldValue(ctx)
  1491. if err != nil {
  1492. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  1493. }
  1494. return oldValue.Role, nil
  1495. }
  1496. // ClearRole clears the value of the "role" field.
  1497. func (m *AgentMutation) ClearRole() {
  1498. m.role = nil
  1499. m.clearedFields[agent.FieldRole] = struct{}{}
  1500. }
  1501. // RoleCleared returns if the "role" field was cleared in this mutation.
  1502. func (m *AgentMutation) RoleCleared() bool {
  1503. _, ok := m.clearedFields[agent.FieldRole]
  1504. return ok
  1505. }
  1506. // ResetRole resets all changes to the "role" field.
  1507. func (m *AgentMutation) ResetRole() {
  1508. m.role = nil
  1509. delete(m.clearedFields, agent.FieldRole)
  1510. }
  1511. // SetStatus sets the "status" field.
  1512. func (m *AgentMutation) SetStatus(i int) {
  1513. m.status = &i
  1514. m.addstatus = nil
  1515. }
  1516. // Status returns the value of the "status" field in the mutation.
  1517. func (m *AgentMutation) Status() (r int, exists bool) {
  1518. v := m.status
  1519. if v == nil {
  1520. return
  1521. }
  1522. return *v, true
  1523. }
  1524. // OldStatus returns the old "status" field's value of the Agent entity.
  1525. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1527. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  1528. if !m.op.Is(OpUpdateOne) {
  1529. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1530. }
  1531. if m.id == nil || m.oldValue == nil {
  1532. return v, errors.New("OldStatus requires an ID field in the mutation")
  1533. }
  1534. oldValue, err := m.oldValue(ctx)
  1535. if err != nil {
  1536. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1537. }
  1538. return oldValue.Status, nil
  1539. }
  1540. // AddStatus adds i to the "status" field.
  1541. func (m *AgentMutation) AddStatus(i int) {
  1542. if m.addstatus != nil {
  1543. *m.addstatus += i
  1544. } else {
  1545. m.addstatus = &i
  1546. }
  1547. }
  1548. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1549. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  1550. v := m.addstatus
  1551. if v == nil {
  1552. return
  1553. }
  1554. return *v, true
  1555. }
  1556. // ClearStatus clears the value of the "status" field.
  1557. func (m *AgentMutation) ClearStatus() {
  1558. m.status = nil
  1559. m.addstatus = nil
  1560. m.clearedFields[agent.FieldStatus] = struct{}{}
  1561. }
  1562. // StatusCleared returns if the "status" field was cleared in this mutation.
  1563. func (m *AgentMutation) StatusCleared() bool {
  1564. _, ok := m.clearedFields[agent.FieldStatus]
  1565. return ok
  1566. }
  1567. // ResetStatus resets all changes to the "status" field.
  1568. func (m *AgentMutation) ResetStatus() {
  1569. m.status = nil
  1570. m.addstatus = nil
  1571. delete(m.clearedFields, agent.FieldStatus)
  1572. }
  1573. // SetBackground sets the "background" field.
  1574. func (m *AgentMutation) SetBackground(s string) {
  1575. m.background = &s
  1576. }
  1577. // Background returns the value of the "background" field in the mutation.
  1578. func (m *AgentMutation) Background() (r string, exists bool) {
  1579. v := m.background
  1580. if v == nil {
  1581. return
  1582. }
  1583. return *v, true
  1584. }
  1585. // OldBackground returns the old "background" field's value of the Agent entity.
  1586. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1588. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  1589. if !m.op.Is(OpUpdateOne) {
  1590. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  1591. }
  1592. if m.id == nil || m.oldValue == nil {
  1593. return v, errors.New("OldBackground requires an ID field in the mutation")
  1594. }
  1595. oldValue, err := m.oldValue(ctx)
  1596. if err != nil {
  1597. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  1598. }
  1599. return oldValue.Background, nil
  1600. }
  1601. // ClearBackground clears the value of the "background" field.
  1602. func (m *AgentMutation) ClearBackground() {
  1603. m.background = nil
  1604. m.clearedFields[agent.FieldBackground] = struct{}{}
  1605. }
  1606. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  1607. func (m *AgentMutation) BackgroundCleared() bool {
  1608. _, ok := m.clearedFields[agent.FieldBackground]
  1609. return ok
  1610. }
  1611. // ResetBackground resets all changes to the "background" field.
  1612. func (m *AgentMutation) ResetBackground() {
  1613. m.background = nil
  1614. delete(m.clearedFields, agent.FieldBackground)
  1615. }
  1616. // SetExamples sets the "examples" field.
  1617. func (m *AgentMutation) SetExamples(s string) {
  1618. m.examples = &s
  1619. }
  1620. // Examples returns the value of the "examples" field in the mutation.
  1621. func (m *AgentMutation) Examples() (r string, exists bool) {
  1622. v := m.examples
  1623. if v == nil {
  1624. return
  1625. }
  1626. return *v, true
  1627. }
  1628. // OldExamples returns the old "examples" field's value of the Agent entity.
  1629. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1631. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  1632. if !m.op.Is(OpUpdateOne) {
  1633. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  1634. }
  1635. if m.id == nil || m.oldValue == nil {
  1636. return v, errors.New("OldExamples requires an ID field in the mutation")
  1637. }
  1638. oldValue, err := m.oldValue(ctx)
  1639. if err != nil {
  1640. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  1641. }
  1642. return oldValue.Examples, nil
  1643. }
  1644. // ClearExamples clears the value of the "examples" field.
  1645. func (m *AgentMutation) ClearExamples() {
  1646. m.examples = nil
  1647. m.clearedFields[agent.FieldExamples] = struct{}{}
  1648. }
  1649. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  1650. func (m *AgentMutation) ExamplesCleared() bool {
  1651. _, ok := m.clearedFields[agent.FieldExamples]
  1652. return ok
  1653. }
  1654. // ResetExamples resets all changes to the "examples" field.
  1655. func (m *AgentMutation) ResetExamples() {
  1656. m.examples = nil
  1657. delete(m.clearedFields, agent.FieldExamples)
  1658. }
  1659. // SetOrganizationID sets the "organization_id" field.
  1660. func (m *AgentMutation) SetOrganizationID(u uint64) {
  1661. m.organization_id = &u
  1662. m.addorganization_id = nil
  1663. }
  1664. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1665. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  1666. v := m.organization_id
  1667. if v == nil {
  1668. return
  1669. }
  1670. return *v, true
  1671. }
  1672. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  1673. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1675. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1676. if !m.op.Is(OpUpdateOne) {
  1677. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1678. }
  1679. if m.id == nil || m.oldValue == nil {
  1680. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1681. }
  1682. oldValue, err := m.oldValue(ctx)
  1683. if err != nil {
  1684. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1685. }
  1686. return oldValue.OrganizationID, nil
  1687. }
  1688. // AddOrganizationID adds u to the "organization_id" field.
  1689. func (m *AgentMutation) AddOrganizationID(u int64) {
  1690. if m.addorganization_id != nil {
  1691. *m.addorganization_id += u
  1692. } else {
  1693. m.addorganization_id = &u
  1694. }
  1695. }
  1696. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1697. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  1698. v := m.addorganization_id
  1699. if v == nil {
  1700. return
  1701. }
  1702. return *v, true
  1703. }
  1704. // ResetOrganizationID resets all changes to the "organization_id" field.
  1705. func (m *AgentMutation) ResetOrganizationID() {
  1706. m.organization_id = nil
  1707. m.addorganization_id = nil
  1708. }
  1709. // SetDatasetID sets the "dataset_id" field.
  1710. func (m *AgentMutation) SetDatasetID(s string) {
  1711. m.dataset_id = &s
  1712. }
  1713. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1714. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  1715. v := m.dataset_id
  1716. if v == nil {
  1717. return
  1718. }
  1719. return *v, true
  1720. }
  1721. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  1722. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1724. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1725. if !m.op.Is(OpUpdateOne) {
  1726. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1727. }
  1728. if m.id == nil || m.oldValue == nil {
  1729. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1730. }
  1731. oldValue, err := m.oldValue(ctx)
  1732. if err != nil {
  1733. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1734. }
  1735. return oldValue.DatasetID, nil
  1736. }
  1737. // ResetDatasetID resets all changes to the "dataset_id" field.
  1738. func (m *AgentMutation) ResetDatasetID() {
  1739. m.dataset_id = nil
  1740. }
  1741. // SetCollectionID sets the "collection_id" field.
  1742. func (m *AgentMutation) SetCollectionID(s string) {
  1743. m.collection_id = &s
  1744. }
  1745. // CollectionID returns the value of the "collection_id" field in the mutation.
  1746. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  1747. v := m.collection_id
  1748. if v == nil {
  1749. return
  1750. }
  1751. return *v, true
  1752. }
  1753. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  1754. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1756. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1757. if !m.op.Is(OpUpdateOne) {
  1758. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1759. }
  1760. if m.id == nil || m.oldValue == nil {
  1761. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1762. }
  1763. oldValue, err := m.oldValue(ctx)
  1764. if err != nil {
  1765. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1766. }
  1767. return oldValue.CollectionID, nil
  1768. }
  1769. // ResetCollectionID resets all changes to the "collection_id" field.
  1770. func (m *AgentMutation) ResetCollectionID() {
  1771. m.collection_id = nil
  1772. }
  1773. // SetModel sets the "model" field.
  1774. func (m *AgentMutation) SetModel(s string) {
  1775. m.model = &s
  1776. }
  1777. // Model returns the value of the "model" field in the mutation.
  1778. func (m *AgentMutation) Model() (r string, exists bool) {
  1779. v := m.model
  1780. if v == nil {
  1781. return
  1782. }
  1783. return *v, true
  1784. }
  1785. // OldModel returns the old "model" field's value of the Agent entity.
  1786. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1788. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  1789. if !m.op.Is(OpUpdateOne) {
  1790. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  1791. }
  1792. if m.id == nil || m.oldValue == nil {
  1793. return v, errors.New("OldModel requires an ID field in the mutation")
  1794. }
  1795. oldValue, err := m.oldValue(ctx)
  1796. if err != nil {
  1797. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  1798. }
  1799. return oldValue.Model, nil
  1800. }
  1801. // ClearModel clears the value of the "model" field.
  1802. func (m *AgentMutation) ClearModel() {
  1803. m.model = nil
  1804. m.clearedFields[agent.FieldModel] = struct{}{}
  1805. }
  1806. // ModelCleared returns if the "model" field was cleared in this mutation.
  1807. func (m *AgentMutation) ModelCleared() bool {
  1808. _, ok := m.clearedFields[agent.FieldModel]
  1809. return ok
  1810. }
  1811. // ResetModel resets all changes to the "model" field.
  1812. func (m *AgentMutation) ResetModel() {
  1813. m.model = nil
  1814. delete(m.clearedFields, agent.FieldModel)
  1815. }
  1816. // SetAPIBase sets the "api_base" field.
  1817. func (m *AgentMutation) SetAPIBase(s string) {
  1818. m.api_base = &s
  1819. }
  1820. // APIBase returns the value of the "api_base" field in the mutation.
  1821. func (m *AgentMutation) APIBase() (r string, exists bool) {
  1822. v := m.api_base
  1823. if v == nil {
  1824. return
  1825. }
  1826. return *v, true
  1827. }
  1828. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  1829. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1831. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  1832. if !m.op.Is(OpUpdateOne) {
  1833. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  1834. }
  1835. if m.id == nil || m.oldValue == nil {
  1836. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  1837. }
  1838. oldValue, err := m.oldValue(ctx)
  1839. if err != nil {
  1840. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  1841. }
  1842. return oldValue.APIBase, nil
  1843. }
  1844. // ClearAPIBase clears the value of the "api_base" field.
  1845. func (m *AgentMutation) ClearAPIBase() {
  1846. m.api_base = nil
  1847. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  1848. }
  1849. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  1850. func (m *AgentMutation) APIBaseCleared() bool {
  1851. _, ok := m.clearedFields[agent.FieldAPIBase]
  1852. return ok
  1853. }
  1854. // ResetAPIBase resets all changes to the "api_base" field.
  1855. func (m *AgentMutation) ResetAPIBase() {
  1856. m.api_base = nil
  1857. delete(m.clearedFields, agent.FieldAPIBase)
  1858. }
  1859. // SetAPIKey sets the "api_key" field.
  1860. func (m *AgentMutation) SetAPIKey(s string) {
  1861. m.api_key = &s
  1862. }
  1863. // APIKey returns the value of the "api_key" field in the mutation.
  1864. func (m *AgentMutation) APIKey() (r string, exists bool) {
  1865. v := m.api_key
  1866. if v == nil {
  1867. return
  1868. }
  1869. return *v, true
  1870. }
  1871. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  1872. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1874. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  1875. if !m.op.Is(OpUpdateOne) {
  1876. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  1877. }
  1878. if m.id == nil || m.oldValue == nil {
  1879. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  1880. }
  1881. oldValue, err := m.oldValue(ctx)
  1882. if err != nil {
  1883. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  1884. }
  1885. return oldValue.APIKey, nil
  1886. }
  1887. // ClearAPIKey clears the value of the "api_key" field.
  1888. func (m *AgentMutation) ClearAPIKey() {
  1889. m.api_key = nil
  1890. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  1891. }
  1892. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  1893. func (m *AgentMutation) APIKeyCleared() bool {
  1894. _, ok := m.clearedFields[agent.FieldAPIKey]
  1895. return ok
  1896. }
  1897. // ResetAPIKey resets all changes to the "api_key" field.
  1898. func (m *AgentMutation) ResetAPIKey() {
  1899. m.api_key = nil
  1900. delete(m.clearedFields, agent.FieldAPIKey)
  1901. }
  1902. // SetType sets the "type" field.
  1903. func (m *AgentMutation) SetType(i int) {
  1904. m._type = &i
  1905. m.add_type = nil
  1906. }
  1907. // GetType returns the value of the "type" field in the mutation.
  1908. func (m *AgentMutation) GetType() (r int, exists bool) {
  1909. v := m._type
  1910. if v == nil {
  1911. return
  1912. }
  1913. return *v, true
  1914. }
  1915. // OldType returns the old "type" field's value of the Agent entity.
  1916. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1918. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  1919. if !m.op.Is(OpUpdateOne) {
  1920. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1921. }
  1922. if m.id == nil || m.oldValue == nil {
  1923. return v, errors.New("OldType requires an ID field in the mutation")
  1924. }
  1925. oldValue, err := m.oldValue(ctx)
  1926. if err != nil {
  1927. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1928. }
  1929. return oldValue.Type, nil
  1930. }
  1931. // AddType adds i to the "type" field.
  1932. func (m *AgentMutation) AddType(i int) {
  1933. if m.add_type != nil {
  1934. *m.add_type += i
  1935. } else {
  1936. m.add_type = &i
  1937. }
  1938. }
  1939. // AddedType returns the value that was added to the "type" field in this mutation.
  1940. func (m *AgentMutation) AddedType() (r int, exists bool) {
  1941. v := m.add_type
  1942. if v == nil {
  1943. return
  1944. }
  1945. return *v, true
  1946. }
  1947. // ClearType clears the value of the "type" field.
  1948. func (m *AgentMutation) ClearType() {
  1949. m._type = nil
  1950. m.add_type = nil
  1951. m.clearedFields[agent.FieldType] = struct{}{}
  1952. }
  1953. // TypeCleared returns if the "type" field was cleared in this mutation.
  1954. func (m *AgentMutation) TypeCleared() bool {
  1955. _, ok := m.clearedFields[agent.FieldType]
  1956. return ok
  1957. }
  1958. // ResetType resets all changes to the "type" field.
  1959. func (m *AgentMutation) ResetType() {
  1960. m._type = nil
  1961. m.add_type = nil
  1962. delete(m.clearedFields, agent.FieldType)
  1963. }
  1964. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1965. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  1966. if m.wx_agent == nil {
  1967. m.wx_agent = make(map[uint64]struct{})
  1968. }
  1969. for i := range ids {
  1970. m.wx_agent[ids[i]] = struct{}{}
  1971. }
  1972. }
  1973. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1974. func (m *AgentMutation) ClearWxAgent() {
  1975. m.clearedwx_agent = true
  1976. }
  1977. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1978. func (m *AgentMutation) WxAgentCleared() bool {
  1979. return m.clearedwx_agent
  1980. }
  1981. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1982. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  1983. if m.removedwx_agent == nil {
  1984. m.removedwx_agent = make(map[uint64]struct{})
  1985. }
  1986. for i := range ids {
  1987. delete(m.wx_agent, ids[i])
  1988. m.removedwx_agent[ids[i]] = struct{}{}
  1989. }
  1990. }
  1991. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1992. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  1993. for id := range m.removedwx_agent {
  1994. ids = append(ids, id)
  1995. }
  1996. return
  1997. }
  1998. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1999. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  2000. for id := range m.wx_agent {
  2001. ids = append(ids, id)
  2002. }
  2003. return
  2004. }
  2005. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2006. func (m *AgentMutation) ResetWxAgent() {
  2007. m.wx_agent = nil
  2008. m.clearedwx_agent = false
  2009. m.removedwx_agent = nil
  2010. }
  2011. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  2012. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  2013. if m.token_agent == nil {
  2014. m.token_agent = make(map[uint64]struct{})
  2015. }
  2016. for i := range ids {
  2017. m.token_agent[ids[i]] = struct{}{}
  2018. }
  2019. }
  2020. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  2021. func (m *AgentMutation) ClearTokenAgent() {
  2022. m.clearedtoken_agent = true
  2023. }
  2024. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  2025. func (m *AgentMutation) TokenAgentCleared() bool {
  2026. return m.clearedtoken_agent
  2027. }
  2028. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  2029. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  2030. if m.removedtoken_agent == nil {
  2031. m.removedtoken_agent = make(map[uint64]struct{})
  2032. }
  2033. for i := range ids {
  2034. delete(m.token_agent, ids[i])
  2035. m.removedtoken_agent[ids[i]] = struct{}{}
  2036. }
  2037. }
  2038. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  2039. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  2040. for id := range m.removedtoken_agent {
  2041. ids = append(ids, id)
  2042. }
  2043. return
  2044. }
  2045. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  2046. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  2047. for id := range m.token_agent {
  2048. ids = append(ids, id)
  2049. }
  2050. return
  2051. }
  2052. // ResetTokenAgent resets all changes to the "token_agent" edge.
  2053. func (m *AgentMutation) ResetTokenAgent() {
  2054. m.token_agent = nil
  2055. m.clearedtoken_agent = false
  2056. m.removedtoken_agent = nil
  2057. }
  2058. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  2059. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  2060. if m.wa_agent == nil {
  2061. m.wa_agent = make(map[uint64]struct{})
  2062. }
  2063. for i := range ids {
  2064. m.wa_agent[ids[i]] = struct{}{}
  2065. }
  2066. }
  2067. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  2068. func (m *AgentMutation) ClearWaAgent() {
  2069. m.clearedwa_agent = true
  2070. }
  2071. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  2072. func (m *AgentMutation) WaAgentCleared() bool {
  2073. return m.clearedwa_agent
  2074. }
  2075. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  2076. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  2077. if m.removedwa_agent == nil {
  2078. m.removedwa_agent = make(map[uint64]struct{})
  2079. }
  2080. for i := range ids {
  2081. delete(m.wa_agent, ids[i])
  2082. m.removedwa_agent[ids[i]] = struct{}{}
  2083. }
  2084. }
  2085. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  2086. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  2087. for id := range m.removedwa_agent {
  2088. ids = append(ids, id)
  2089. }
  2090. return
  2091. }
  2092. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  2093. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  2094. for id := range m.wa_agent {
  2095. ids = append(ids, id)
  2096. }
  2097. return
  2098. }
  2099. // ResetWaAgent resets all changes to the "wa_agent" edge.
  2100. func (m *AgentMutation) ResetWaAgent() {
  2101. m.wa_agent = nil
  2102. m.clearedwa_agent = false
  2103. m.removedwa_agent = nil
  2104. }
  2105. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  2106. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  2107. if m.xjs_agent == nil {
  2108. m.xjs_agent = make(map[uint64]struct{})
  2109. }
  2110. for i := range ids {
  2111. m.xjs_agent[ids[i]] = struct{}{}
  2112. }
  2113. }
  2114. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  2115. func (m *AgentMutation) ClearXjsAgent() {
  2116. m.clearedxjs_agent = true
  2117. }
  2118. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  2119. func (m *AgentMutation) XjsAgentCleared() bool {
  2120. return m.clearedxjs_agent
  2121. }
  2122. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  2123. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  2124. if m.removedxjs_agent == nil {
  2125. m.removedxjs_agent = make(map[uint64]struct{})
  2126. }
  2127. for i := range ids {
  2128. delete(m.xjs_agent, ids[i])
  2129. m.removedxjs_agent[ids[i]] = struct{}{}
  2130. }
  2131. }
  2132. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  2133. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  2134. for id := range m.removedxjs_agent {
  2135. ids = append(ids, id)
  2136. }
  2137. return
  2138. }
  2139. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  2140. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  2141. for id := range m.xjs_agent {
  2142. ids = append(ids, id)
  2143. }
  2144. return
  2145. }
  2146. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  2147. func (m *AgentMutation) ResetXjsAgent() {
  2148. m.xjs_agent = nil
  2149. m.clearedxjs_agent = false
  2150. m.removedxjs_agent = nil
  2151. }
  2152. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  2153. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  2154. if m.key_agent == nil {
  2155. m.key_agent = make(map[uint64]struct{})
  2156. }
  2157. for i := range ids {
  2158. m.key_agent[ids[i]] = struct{}{}
  2159. }
  2160. }
  2161. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  2162. func (m *AgentMutation) ClearKeyAgent() {
  2163. m.clearedkey_agent = true
  2164. }
  2165. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  2166. func (m *AgentMutation) KeyAgentCleared() bool {
  2167. return m.clearedkey_agent
  2168. }
  2169. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  2170. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  2171. if m.removedkey_agent == nil {
  2172. m.removedkey_agent = make(map[uint64]struct{})
  2173. }
  2174. for i := range ids {
  2175. delete(m.key_agent, ids[i])
  2176. m.removedkey_agent[ids[i]] = struct{}{}
  2177. }
  2178. }
  2179. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  2180. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  2181. for id := range m.removedkey_agent {
  2182. ids = append(ids, id)
  2183. }
  2184. return
  2185. }
  2186. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  2187. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  2188. for id := range m.key_agent {
  2189. ids = append(ids, id)
  2190. }
  2191. return
  2192. }
  2193. // ResetKeyAgent resets all changes to the "key_agent" edge.
  2194. func (m *AgentMutation) ResetKeyAgent() {
  2195. m.key_agent = nil
  2196. m.clearedkey_agent = false
  2197. m.removedkey_agent = nil
  2198. }
  2199. // Where appends a list predicates to the AgentMutation builder.
  2200. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  2201. m.predicates = append(m.predicates, ps...)
  2202. }
  2203. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  2204. // users can use type-assertion to append predicates that do not depend on any generated package.
  2205. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  2206. p := make([]predicate.Agent, len(ps))
  2207. for i := range ps {
  2208. p[i] = ps[i]
  2209. }
  2210. m.Where(p...)
  2211. }
  2212. // Op returns the operation name.
  2213. func (m *AgentMutation) Op() Op {
  2214. return m.op
  2215. }
  2216. // SetOp allows setting the mutation operation.
  2217. func (m *AgentMutation) SetOp(op Op) {
  2218. m.op = op
  2219. }
  2220. // Type returns the node type of this mutation (Agent).
  2221. func (m *AgentMutation) Type() string {
  2222. return m.typ
  2223. }
  2224. // Fields returns all fields that were changed during this mutation. Note that in
  2225. // order to get all numeric fields that were incremented/decremented, call
  2226. // AddedFields().
  2227. func (m *AgentMutation) Fields() []string {
  2228. fields := make([]string, 0, 15)
  2229. if m.created_at != nil {
  2230. fields = append(fields, agent.FieldCreatedAt)
  2231. }
  2232. if m.updated_at != nil {
  2233. fields = append(fields, agent.FieldUpdatedAt)
  2234. }
  2235. if m.deleted_at != nil {
  2236. fields = append(fields, agent.FieldDeletedAt)
  2237. }
  2238. if m.name != nil {
  2239. fields = append(fields, agent.FieldName)
  2240. }
  2241. if m.role != nil {
  2242. fields = append(fields, agent.FieldRole)
  2243. }
  2244. if m.status != nil {
  2245. fields = append(fields, agent.FieldStatus)
  2246. }
  2247. if m.background != nil {
  2248. fields = append(fields, agent.FieldBackground)
  2249. }
  2250. if m.examples != nil {
  2251. fields = append(fields, agent.FieldExamples)
  2252. }
  2253. if m.organization_id != nil {
  2254. fields = append(fields, agent.FieldOrganizationID)
  2255. }
  2256. if m.dataset_id != nil {
  2257. fields = append(fields, agent.FieldDatasetID)
  2258. }
  2259. if m.collection_id != nil {
  2260. fields = append(fields, agent.FieldCollectionID)
  2261. }
  2262. if m.model != nil {
  2263. fields = append(fields, agent.FieldModel)
  2264. }
  2265. if m.api_base != nil {
  2266. fields = append(fields, agent.FieldAPIBase)
  2267. }
  2268. if m.api_key != nil {
  2269. fields = append(fields, agent.FieldAPIKey)
  2270. }
  2271. if m._type != nil {
  2272. fields = append(fields, agent.FieldType)
  2273. }
  2274. return fields
  2275. }
  2276. // Field returns the value of a field with the given name. The second boolean
  2277. // return value indicates that this field was not set, or was not defined in the
  2278. // schema.
  2279. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  2280. switch name {
  2281. case agent.FieldCreatedAt:
  2282. return m.CreatedAt()
  2283. case agent.FieldUpdatedAt:
  2284. return m.UpdatedAt()
  2285. case agent.FieldDeletedAt:
  2286. return m.DeletedAt()
  2287. case agent.FieldName:
  2288. return m.Name()
  2289. case agent.FieldRole:
  2290. return m.Role()
  2291. case agent.FieldStatus:
  2292. return m.Status()
  2293. case agent.FieldBackground:
  2294. return m.Background()
  2295. case agent.FieldExamples:
  2296. return m.Examples()
  2297. case agent.FieldOrganizationID:
  2298. return m.OrganizationID()
  2299. case agent.FieldDatasetID:
  2300. return m.DatasetID()
  2301. case agent.FieldCollectionID:
  2302. return m.CollectionID()
  2303. case agent.FieldModel:
  2304. return m.Model()
  2305. case agent.FieldAPIBase:
  2306. return m.APIBase()
  2307. case agent.FieldAPIKey:
  2308. return m.APIKey()
  2309. case agent.FieldType:
  2310. return m.GetType()
  2311. }
  2312. return nil, false
  2313. }
  2314. // OldField returns the old value of the field from the database. An error is
  2315. // returned if the mutation operation is not UpdateOne, or the query to the
  2316. // database failed.
  2317. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2318. switch name {
  2319. case agent.FieldCreatedAt:
  2320. return m.OldCreatedAt(ctx)
  2321. case agent.FieldUpdatedAt:
  2322. return m.OldUpdatedAt(ctx)
  2323. case agent.FieldDeletedAt:
  2324. return m.OldDeletedAt(ctx)
  2325. case agent.FieldName:
  2326. return m.OldName(ctx)
  2327. case agent.FieldRole:
  2328. return m.OldRole(ctx)
  2329. case agent.FieldStatus:
  2330. return m.OldStatus(ctx)
  2331. case agent.FieldBackground:
  2332. return m.OldBackground(ctx)
  2333. case agent.FieldExamples:
  2334. return m.OldExamples(ctx)
  2335. case agent.FieldOrganizationID:
  2336. return m.OldOrganizationID(ctx)
  2337. case agent.FieldDatasetID:
  2338. return m.OldDatasetID(ctx)
  2339. case agent.FieldCollectionID:
  2340. return m.OldCollectionID(ctx)
  2341. case agent.FieldModel:
  2342. return m.OldModel(ctx)
  2343. case agent.FieldAPIBase:
  2344. return m.OldAPIBase(ctx)
  2345. case agent.FieldAPIKey:
  2346. return m.OldAPIKey(ctx)
  2347. case agent.FieldType:
  2348. return m.OldType(ctx)
  2349. }
  2350. return nil, fmt.Errorf("unknown Agent field %s", name)
  2351. }
  2352. // SetField sets the value of a field with the given name. It returns an error if
  2353. // the field is not defined in the schema, or if the type mismatched the field
  2354. // type.
  2355. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  2356. switch name {
  2357. case agent.FieldCreatedAt:
  2358. v, ok := value.(time.Time)
  2359. if !ok {
  2360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2361. }
  2362. m.SetCreatedAt(v)
  2363. return nil
  2364. case agent.FieldUpdatedAt:
  2365. v, ok := value.(time.Time)
  2366. if !ok {
  2367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2368. }
  2369. m.SetUpdatedAt(v)
  2370. return nil
  2371. case agent.FieldDeletedAt:
  2372. v, ok := value.(time.Time)
  2373. if !ok {
  2374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2375. }
  2376. m.SetDeletedAt(v)
  2377. return nil
  2378. case agent.FieldName:
  2379. v, ok := value.(string)
  2380. if !ok {
  2381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2382. }
  2383. m.SetName(v)
  2384. return nil
  2385. case agent.FieldRole:
  2386. v, ok := value.(string)
  2387. if !ok {
  2388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2389. }
  2390. m.SetRole(v)
  2391. return nil
  2392. case agent.FieldStatus:
  2393. v, ok := value.(int)
  2394. if !ok {
  2395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2396. }
  2397. m.SetStatus(v)
  2398. return nil
  2399. case agent.FieldBackground:
  2400. v, ok := value.(string)
  2401. if !ok {
  2402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2403. }
  2404. m.SetBackground(v)
  2405. return nil
  2406. case agent.FieldExamples:
  2407. v, ok := value.(string)
  2408. if !ok {
  2409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2410. }
  2411. m.SetExamples(v)
  2412. return nil
  2413. case agent.FieldOrganizationID:
  2414. v, ok := value.(uint64)
  2415. if !ok {
  2416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2417. }
  2418. m.SetOrganizationID(v)
  2419. return nil
  2420. case agent.FieldDatasetID:
  2421. v, ok := value.(string)
  2422. if !ok {
  2423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2424. }
  2425. m.SetDatasetID(v)
  2426. return nil
  2427. case agent.FieldCollectionID:
  2428. v, ok := value.(string)
  2429. if !ok {
  2430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2431. }
  2432. m.SetCollectionID(v)
  2433. return nil
  2434. case agent.FieldModel:
  2435. v, ok := value.(string)
  2436. if !ok {
  2437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2438. }
  2439. m.SetModel(v)
  2440. return nil
  2441. case agent.FieldAPIBase:
  2442. v, ok := value.(string)
  2443. if !ok {
  2444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2445. }
  2446. m.SetAPIBase(v)
  2447. return nil
  2448. case agent.FieldAPIKey:
  2449. v, ok := value.(string)
  2450. if !ok {
  2451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2452. }
  2453. m.SetAPIKey(v)
  2454. return nil
  2455. case agent.FieldType:
  2456. v, ok := value.(int)
  2457. if !ok {
  2458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2459. }
  2460. m.SetType(v)
  2461. return nil
  2462. }
  2463. return fmt.Errorf("unknown Agent field %s", name)
  2464. }
  2465. // AddedFields returns all numeric fields that were incremented/decremented during
  2466. // this mutation.
  2467. func (m *AgentMutation) AddedFields() []string {
  2468. var fields []string
  2469. if m.addstatus != nil {
  2470. fields = append(fields, agent.FieldStatus)
  2471. }
  2472. if m.addorganization_id != nil {
  2473. fields = append(fields, agent.FieldOrganizationID)
  2474. }
  2475. if m.add_type != nil {
  2476. fields = append(fields, agent.FieldType)
  2477. }
  2478. return fields
  2479. }
  2480. // AddedField returns the numeric value that was incremented/decremented on a field
  2481. // with the given name. The second boolean return value indicates that this field
  2482. // was not set, or was not defined in the schema.
  2483. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  2484. switch name {
  2485. case agent.FieldStatus:
  2486. return m.AddedStatus()
  2487. case agent.FieldOrganizationID:
  2488. return m.AddedOrganizationID()
  2489. case agent.FieldType:
  2490. return m.AddedType()
  2491. }
  2492. return nil, false
  2493. }
  2494. // AddField adds the value to the field with the given name. It returns an error if
  2495. // the field is not defined in the schema, or if the type mismatched the field
  2496. // type.
  2497. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  2498. switch name {
  2499. case agent.FieldStatus:
  2500. v, ok := value.(int)
  2501. if !ok {
  2502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2503. }
  2504. m.AddStatus(v)
  2505. return nil
  2506. case agent.FieldOrganizationID:
  2507. v, ok := value.(int64)
  2508. if !ok {
  2509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2510. }
  2511. m.AddOrganizationID(v)
  2512. return nil
  2513. case agent.FieldType:
  2514. v, ok := value.(int)
  2515. if !ok {
  2516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2517. }
  2518. m.AddType(v)
  2519. return nil
  2520. }
  2521. return fmt.Errorf("unknown Agent numeric field %s", name)
  2522. }
  2523. // ClearedFields returns all nullable fields that were cleared during this
  2524. // mutation.
  2525. func (m *AgentMutation) ClearedFields() []string {
  2526. var fields []string
  2527. if m.FieldCleared(agent.FieldDeletedAt) {
  2528. fields = append(fields, agent.FieldDeletedAt)
  2529. }
  2530. if m.FieldCleared(agent.FieldRole) {
  2531. fields = append(fields, agent.FieldRole)
  2532. }
  2533. if m.FieldCleared(agent.FieldStatus) {
  2534. fields = append(fields, agent.FieldStatus)
  2535. }
  2536. if m.FieldCleared(agent.FieldBackground) {
  2537. fields = append(fields, agent.FieldBackground)
  2538. }
  2539. if m.FieldCleared(agent.FieldExamples) {
  2540. fields = append(fields, agent.FieldExamples)
  2541. }
  2542. if m.FieldCleared(agent.FieldModel) {
  2543. fields = append(fields, agent.FieldModel)
  2544. }
  2545. if m.FieldCleared(agent.FieldAPIBase) {
  2546. fields = append(fields, agent.FieldAPIBase)
  2547. }
  2548. if m.FieldCleared(agent.FieldAPIKey) {
  2549. fields = append(fields, agent.FieldAPIKey)
  2550. }
  2551. if m.FieldCleared(agent.FieldType) {
  2552. fields = append(fields, agent.FieldType)
  2553. }
  2554. return fields
  2555. }
  2556. // FieldCleared returns a boolean indicating if a field with the given name was
  2557. // cleared in this mutation.
  2558. func (m *AgentMutation) FieldCleared(name string) bool {
  2559. _, ok := m.clearedFields[name]
  2560. return ok
  2561. }
  2562. // ClearField clears the value of the field with the given name. It returns an
  2563. // error if the field is not defined in the schema.
  2564. func (m *AgentMutation) ClearField(name string) error {
  2565. switch name {
  2566. case agent.FieldDeletedAt:
  2567. m.ClearDeletedAt()
  2568. return nil
  2569. case agent.FieldRole:
  2570. m.ClearRole()
  2571. return nil
  2572. case agent.FieldStatus:
  2573. m.ClearStatus()
  2574. return nil
  2575. case agent.FieldBackground:
  2576. m.ClearBackground()
  2577. return nil
  2578. case agent.FieldExamples:
  2579. m.ClearExamples()
  2580. return nil
  2581. case agent.FieldModel:
  2582. m.ClearModel()
  2583. return nil
  2584. case agent.FieldAPIBase:
  2585. m.ClearAPIBase()
  2586. return nil
  2587. case agent.FieldAPIKey:
  2588. m.ClearAPIKey()
  2589. return nil
  2590. case agent.FieldType:
  2591. m.ClearType()
  2592. return nil
  2593. }
  2594. return fmt.Errorf("unknown Agent nullable field %s", name)
  2595. }
  2596. // ResetField resets all changes in the mutation for the field with the given name.
  2597. // It returns an error if the field is not defined in the schema.
  2598. func (m *AgentMutation) ResetField(name string) error {
  2599. switch name {
  2600. case agent.FieldCreatedAt:
  2601. m.ResetCreatedAt()
  2602. return nil
  2603. case agent.FieldUpdatedAt:
  2604. m.ResetUpdatedAt()
  2605. return nil
  2606. case agent.FieldDeletedAt:
  2607. m.ResetDeletedAt()
  2608. return nil
  2609. case agent.FieldName:
  2610. m.ResetName()
  2611. return nil
  2612. case agent.FieldRole:
  2613. m.ResetRole()
  2614. return nil
  2615. case agent.FieldStatus:
  2616. m.ResetStatus()
  2617. return nil
  2618. case agent.FieldBackground:
  2619. m.ResetBackground()
  2620. return nil
  2621. case agent.FieldExamples:
  2622. m.ResetExamples()
  2623. return nil
  2624. case agent.FieldOrganizationID:
  2625. m.ResetOrganizationID()
  2626. return nil
  2627. case agent.FieldDatasetID:
  2628. m.ResetDatasetID()
  2629. return nil
  2630. case agent.FieldCollectionID:
  2631. m.ResetCollectionID()
  2632. return nil
  2633. case agent.FieldModel:
  2634. m.ResetModel()
  2635. return nil
  2636. case agent.FieldAPIBase:
  2637. m.ResetAPIBase()
  2638. return nil
  2639. case agent.FieldAPIKey:
  2640. m.ResetAPIKey()
  2641. return nil
  2642. case agent.FieldType:
  2643. m.ResetType()
  2644. return nil
  2645. }
  2646. return fmt.Errorf("unknown Agent field %s", name)
  2647. }
  2648. // AddedEdges returns all edge names that were set/added in this mutation.
  2649. func (m *AgentMutation) AddedEdges() []string {
  2650. edges := make([]string, 0, 5)
  2651. if m.wx_agent != nil {
  2652. edges = append(edges, agent.EdgeWxAgent)
  2653. }
  2654. if m.token_agent != nil {
  2655. edges = append(edges, agent.EdgeTokenAgent)
  2656. }
  2657. if m.wa_agent != nil {
  2658. edges = append(edges, agent.EdgeWaAgent)
  2659. }
  2660. if m.xjs_agent != nil {
  2661. edges = append(edges, agent.EdgeXjsAgent)
  2662. }
  2663. if m.key_agent != nil {
  2664. edges = append(edges, agent.EdgeKeyAgent)
  2665. }
  2666. return edges
  2667. }
  2668. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2669. // name in this mutation.
  2670. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  2671. switch name {
  2672. case agent.EdgeWxAgent:
  2673. ids := make([]ent.Value, 0, len(m.wx_agent))
  2674. for id := range m.wx_agent {
  2675. ids = append(ids, id)
  2676. }
  2677. return ids
  2678. case agent.EdgeTokenAgent:
  2679. ids := make([]ent.Value, 0, len(m.token_agent))
  2680. for id := range m.token_agent {
  2681. ids = append(ids, id)
  2682. }
  2683. return ids
  2684. case agent.EdgeWaAgent:
  2685. ids := make([]ent.Value, 0, len(m.wa_agent))
  2686. for id := range m.wa_agent {
  2687. ids = append(ids, id)
  2688. }
  2689. return ids
  2690. case agent.EdgeXjsAgent:
  2691. ids := make([]ent.Value, 0, len(m.xjs_agent))
  2692. for id := range m.xjs_agent {
  2693. ids = append(ids, id)
  2694. }
  2695. return ids
  2696. case agent.EdgeKeyAgent:
  2697. ids := make([]ent.Value, 0, len(m.key_agent))
  2698. for id := range m.key_agent {
  2699. ids = append(ids, id)
  2700. }
  2701. return ids
  2702. }
  2703. return nil
  2704. }
  2705. // RemovedEdges returns all edge names that were removed in this mutation.
  2706. func (m *AgentMutation) RemovedEdges() []string {
  2707. edges := make([]string, 0, 5)
  2708. if m.removedwx_agent != nil {
  2709. edges = append(edges, agent.EdgeWxAgent)
  2710. }
  2711. if m.removedtoken_agent != nil {
  2712. edges = append(edges, agent.EdgeTokenAgent)
  2713. }
  2714. if m.removedwa_agent != nil {
  2715. edges = append(edges, agent.EdgeWaAgent)
  2716. }
  2717. if m.removedxjs_agent != nil {
  2718. edges = append(edges, agent.EdgeXjsAgent)
  2719. }
  2720. if m.removedkey_agent != nil {
  2721. edges = append(edges, agent.EdgeKeyAgent)
  2722. }
  2723. return edges
  2724. }
  2725. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2726. // the given name in this mutation.
  2727. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  2728. switch name {
  2729. case agent.EdgeWxAgent:
  2730. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2731. for id := range m.removedwx_agent {
  2732. ids = append(ids, id)
  2733. }
  2734. return ids
  2735. case agent.EdgeTokenAgent:
  2736. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  2737. for id := range m.removedtoken_agent {
  2738. ids = append(ids, id)
  2739. }
  2740. return ids
  2741. case agent.EdgeWaAgent:
  2742. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  2743. for id := range m.removedwa_agent {
  2744. ids = append(ids, id)
  2745. }
  2746. return ids
  2747. case agent.EdgeXjsAgent:
  2748. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  2749. for id := range m.removedxjs_agent {
  2750. ids = append(ids, id)
  2751. }
  2752. return ids
  2753. case agent.EdgeKeyAgent:
  2754. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  2755. for id := range m.removedkey_agent {
  2756. ids = append(ids, id)
  2757. }
  2758. return ids
  2759. }
  2760. return nil
  2761. }
  2762. // ClearedEdges returns all edge names that were cleared in this mutation.
  2763. func (m *AgentMutation) ClearedEdges() []string {
  2764. edges := make([]string, 0, 5)
  2765. if m.clearedwx_agent {
  2766. edges = append(edges, agent.EdgeWxAgent)
  2767. }
  2768. if m.clearedtoken_agent {
  2769. edges = append(edges, agent.EdgeTokenAgent)
  2770. }
  2771. if m.clearedwa_agent {
  2772. edges = append(edges, agent.EdgeWaAgent)
  2773. }
  2774. if m.clearedxjs_agent {
  2775. edges = append(edges, agent.EdgeXjsAgent)
  2776. }
  2777. if m.clearedkey_agent {
  2778. edges = append(edges, agent.EdgeKeyAgent)
  2779. }
  2780. return edges
  2781. }
  2782. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2783. // was cleared in this mutation.
  2784. func (m *AgentMutation) EdgeCleared(name string) bool {
  2785. switch name {
  2786. case agent.EdgeWxAgent:
  2787. return m.clearedwx_agent
  2788. case agent.EdgeTokenAgent:
  2789. return m.clearedtoken_agent
  2790. case agent.EdgeWaAgent:
  2791. return m.clearedwa_agent
  2792. case agent.EdgeXjsAgent:
  2793. return m.clearedxjs_agent
  2794. case agent.EdgeKeyAgent:
  2795. return m.clearedkey_agent
  2796. }
  2797. return false
  2798. }
  2799. // ClearEdge clears the value of the edge with the given name. It returns an error
  2800. // if that edge is not defined in the schema.
  2801. func (m *AgentMutation) ClearEdge(name string) error {
  2802. switch name {
  2803. }
  2804. return fmt.Errorf("unknown Agent unique edge %s", name)
  2805. }
  2806. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2807. // It returns an error if the edge is not defined in the schema.
  2808. func (m *AgentMutation) ResetEdge(name string) error {
  2809. switch name {
  2810. case agent.EdgeWxAgent:
  2811. m.ResetWxAgent()
  2812. return nil
  2813. case agent.EdgeTokenAgent:
  2814. m.ResetTokenAgent()
  2815. return nil
  2816. case agent.EdgeWaAgent:
  2817. m.ResetWaAgent()
  2818. return nil
  2819. case agent.EdgeXjsAgent:
  2820. m.ResetXjsAgent()
  2821. return nil
  2822. case agent.EdgeKeyAgent:
  2823. m.ResetKeyAgent()
  2824. return nil
  2825. }
  2826. return fmt.Errorf("unknown Agent edge %s", name)
  2827. }
  2828. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  2829. type AgentBaseMutation struct {
  2830. config
  2831. op Op
  2832. typ string
  2833. id *string
  2834. q *string
  2835. a *string
  2836. chunk_index *uint64
  2837. addchunk_index *int64
  2838. indexes *[]string
  2839. appendindexes []string
  2840. dataset_id *string
  2841. collection_id *string
  2842. source_name *string
  2843. can_write *[]bool
  2844. appendcan_write []bool
  2845. is_owner *[]bool
  2846. appendis_owner []bool
  2847. clearedFields map[string]struct{}
  2848. wx_agent map[uint64]struct{}
  2849. removedwx_agent map[uint64]struct{}
  2850. clearedwx_agent bool
  2851. done bool
  2852. oldValue func(context.Context) (*AgentBase, error)
  2853. predicates []predicate.AgentBase
  2854. }
  2855. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  2856. // agentbaseOption allows management of the mutation configuration using functional options.
  2857. type agentbaseOption func(*AgentBaseMutation)
  2858. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  2859. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  2860. m := &AgentBaseMutation{
  2861. config: c,
  2862. op: op,
  2863. typ: TypeAgentBase,
  2864. clearedFields: make(map[string]struct{}),
  2865. }
  2866. for _, opt := range opts {
  2867. opt(m)
  2868. }
  2869. return m
  2870. }
  2871. // withAgentBaseID sets the ID field of the mutation.
  2872. func withAgentBaseID(id string) agentbaseOption {
  2873. return func(m *AgentBaseMutation) {
  2874. var (
  2875. err error
  2876. once sync.Once
  2877. value *AgentBase
  2878. )
  2879. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  2880. once.Do(func() {
  2881. if m.done {
  2882. err = errors.New("querying old values post mutation is not allowed")
  2883. } else {
  2884. value, err = m.Client().AgentBase.Get(ctx, id)
  2885. }
  2886. })
  2887. return value, err
  2888. }
  2889. m.id = &id
  2890. }
  2891. }
  2892. // withAgentBase sets the old AgentBase of the mutation.
  2893. func withAgentBase(node *AgentBase) agentbaseOption {
  2894. return func(m *AgentBaseMutation) {
  2895. m.oldValue = func(context.Context) (*AgentBase, error) {
  2896. return node, nil
  2897. }
  2898. m.id = &node.ID
  2899. }
  2900. }
  2901. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2902. // executed in a transaction (ent.Tx), a transactional client is returned.
  2903. func (m AgentBaseMutation) Client() *Client {
  2904. client := &Client{config: m.config}
  2905. client.init()
  2906. return client
  2907. }
  2908. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2909. // it returns an error otherwise.
  2910. func (m AgentBaseMutation) Tx() (*Tx, error) {
  2911. if _, ok := m.driver.(*txDriver); !ok {
  2912. return nil, errors.New("ent: mutation is not running in a transaction")
  2913. }
  2914. tx := &Tx{config: m.config}
  2915. tx.init()
  2916. return tx, nil
  2917. }
  2918. // SetID sets the value of the id field. Note that this
  2919. // operation is only accepted on creation of AgentBase entities.
  2920. func (m *AgentBaseMutation) SetID(id string) {
  2921. m.id = &id
  2922. }
  2923. // ID returns the ID value in the mutation. Note that the ID is only available
  2924. // if it was provided to the builder or after it was returned from the database.
  2925. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  2926. if m.id == nil {
  2927. return
  2928. }
  2929. return *m.id, true
  2930. }
  2931. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2932. // That means, if the mutation is applied within a transaction with an isolation level such
  2933. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2934. // or updated by the mutation.
  2935. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  2936. switch {
  2937. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2938. id, exists := m.ID()
  2939. if exists {
  2940. return []string{id}, nil
  2941. }
  2942. fallthrough
  2943. case m.op.Is(OpUpdate | OpDelete):
  2944. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  2945. default:
  2946. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2947. }
  2948. }
  2949. // SetQ sets the "q" field.
  2950. func (m *AgentBaseMutation) SetQ(s string) {
  2951. m.q = &s
  2952. }
  2953. // Q returns the value of the "q" field in the mutation.
  2954. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  2955. v := m.q
  2956. if v == nil {
  2957. return
  2958. }
  2959. return *v, true
  2960. }
  2961. // OldQ returns the old "q" field's value of the AgentBase entity.
  2962. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2964. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  2965. if !m.op.Is(OpUpdateOne) {
  2966. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  2967. }
  2968. if m.id == nil || m.oldValue == nil {
  2969. return v, errors.New("OldQ requires an ID field in the mutation")
  2970. }
  2971. oldValue, err := m.oldValue(ctx)
  2972. if err != nil {
  2973. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  2974. }
  2975. return oldValue.Q, nil
  2976. }
  2977. // ClearQ clears the value of the "q" field.
  2978. func (m *AgentBaseMutation) ClearQ() {
  2979. m.q = nil
  2980. m.clearedFields[agentbase.FieldQ] = struct{}{}
  2981. }
  2982. // QCleared returns if the "q" field was cleared in this mutation.
  2983. func (m *AgentBaseMutation) QCleared() bool {
  2984. _, ok := m.clearedFields[agentbase.FieldQ]
  2985. return ok
  2986. }
  2987. // ResetQ resets all changes to the "q" field.
  2988. func (m *AgentBaseMutation) ResetQ() {
  2989. m.q = nil
  2990. delete(m.clearedFields, agentbase.FieldQ)
  2991. }
  2992. // SetA sets the "a" field.
  2993. func (m *AgentBaseMutation) SetA(s string) {
  2994. m.a = &s
  2995. }
  2996. // A returns the value of the "a" field in the mutation.
  2997. func (m *AgentBaseMutation) A() (r string, exists bool) {
  2998. v := m.a
  2999. if v == nil {
  3000. return
  3001. }
  3002. return *v, true
  3003. }
  3004. // OldA returns the old "a" field's value of the AgentBase entity.
  3005. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3007. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  3008. if !m.op.Is(OpUpdateOne) {
  3009. return v, errors.New("OldA is only allowed on UpdateOne operations")
  3010. }
  3011. if m.id == nil || m.oldValue == nil {
  3012. return v, errors.New("OldA requires an ID field in the mutation")
  3013. }
  3014. oldValue, err := m.oldValue(ctx)
  3015. if err != nil {
  3016. return v, fmt.Errorf("querying old value for OldA: %w", err)
  3017. }
  3018. return oldValue.A, nil
  3019. }
  3020. // ClearA clears the value of the "a" field.
  3021. func (m *AgentBaseMutation) ClearA() {
  3022. m.a = nil
  3023. m.clearedFields[agentbase.FieldA] = struct{}{}
  3024. }
  3025. // ACleared returns if the "a" field was cleared in this mutation.
  3026. func (m *AgentBaseMutation) ACleared() bool {
  3027. _, ok := m.clearedFields[agentbase.FieldA]
  3028. return ok
  3029. }
  3030. // ResetA resets all changes to the "a" field.
  3031. func (m *AgentBaseMutation) ResetA() {
  3032. m.a = nil
  3033. delete(m.clearedFields, agentbase.FieldA)
  3034. }
  3035. // SetChunkIndex sets the "chunk_index" field.
  3036. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  3037. m.chunk_index = &u
  3038. m.addchunk_index = nil
  3039. }
  3040. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  3041. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  3042. v := m.chunk_index
  3043. if v == nil {
  3044. return
  3045. }
  3046. return *v, true
  3047. }
  3048. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  3049. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3051. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  3052. if !m.op.Is(OpUpdateOne) {
  3053. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  3054. }
  3055. if m.id == nil || m.oldValue == nil {
  3056. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  3057. }
  3058. oldValue, err := m.oldValue(ctx)
  3059. if err != nil {
  3060. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  3061. }
  3062. return oldValue.ChunkIndex, nil
  3063. }
  3064. // AddChunkIndex adds u to the "chunk_index" field.
  3065. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  3066. if m.addchunk_index != nil {
  3067. *m.addchunk_index += u
  3068. } else {
  3069. m.addchunk_index = &u
  3070. }
  3071. }
  3072. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  3073. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  3074. v := m.addchunk_index
  3075. if v == nil {
  3076. return
  3077. }
  3078. return *v, true
  3079. }
  3080. // ResetChunkIndex resets all changes to the "chunk_index" field.
  3081. func (m *AgentBaseMutation) ResetChunkIndex() {
  3082. m.chunk_index = nil
  3083. m.addchunk_index = nil
  3084. }
  3085. // SetIndexes sets the "indexes" field.
  3086. func (m *AgentBaseMutation) SetIndexes(s []string) {
  3087. m.indexes = &s
  3088. m.appendindexes = nil
  3089. }
  3090. // Indexes returns the value of the "indexes" field in the mutation.
  3091. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  3092. v := m.indexes
  3093. if v == nil {
  3094. return
  3095. }
  3096. return *v, true
  3097. }
  3098. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  3099. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3101. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  3102. if !m.op.Is(OpUpdateOne) {
  3103. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  3104. }
  3105. if m.id == nil || m.oldValue == nil {
  3106. return v, errors.New("OldIndexes requires an ID field in the mutation")
  3107. }
  3108. oldValue, err := m.oldValue(ctx)
  3109. if err != nil {
  3110. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  3111. }
  3112. return oldValue.Indexes, nil
  3113. }
  3114. // AppendIndexes adds s to the "indexes" field.
  3115. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  3116. m.appendindexes = append(m.appendindexes, s...)
  3117. }
  3118. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  3119. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  3120. if len(m.appendindexes) == 0 {
  3121. return nil, false
  3122. }
  3123. return m.appendindexes, true
  3124. }
  3125. // ClearIndexes clears the value of the "indexes" field.
  3126. func (m *AgentBaseMutation) ClearIndexes() {
  3127. m.indexes = nil
  3128. m.appendindexes = nil
  3129. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  3130. }
  3131. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  3132. func (m *AgentBaseMutation) IndexesCleared() bool {
  3133. _, ok := m.clearedFields[agentbase.FieldIndexes]
  3134. return ok
  3135. }
  3136. // ResetIndexes resets all changes to the "indexes" field.
  3137. func (m *AgentBaseMutation) ResetIndexes() {
  3138. m.indexes = nil
  3139. m.appendindexes = nil
  3140. delete(m.clearedFields, agentbase.FieldIndexes)
  3141. }
  3142. // SetDatasetID sets the "dataset_id" field.
  3143. func (m *AgentBaseMutation) SetDatasetID(s string) {
  3144. m.dataset_id = &s
  3145. }
  3146. // DatasetID returns the value of the "dataset_id" field in the mutation.
  3147. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  3148. v := m.dataset_id
  3149. if v == nil {
  3150. return
  3151. }
  3152. return *v, true
  3153. }
  3154. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  3155. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3157. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  3158. if !m.op.Is(OpUpdateOne) {
  3159. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  3160. }
  3161. if m.id == nil || m.oldValue == nil {
  3162. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  3163. }
  3164. oldValue, err := m.oldValue(ctx)
  3165. if err != nil {
  3166. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  3167. }
  3168. return oldValue.DatasetID, nil
  3169. }
  3170. // ClearDatasetID clears the value of the "dataset_id" field.
  3171. func (m *AgentBaseMutation) ClearDatasetID() {
  3172. m.dataset_id = nil
  3173. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  3174. }
  3175. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  3176. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  3177. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  3178. return ok
  3179. }
  3180. // ResetDatasetID resets all changes to the "dataset_id" field.
  3181. func (m *AgentBaseMutation) ResetDatasetID() {
  3182. m.dataset_id = nil
  3183. delete(m.clearedFields, agentbase.FieldDatasetID)
  3184. }
  3185. // SetCollectionID sets the "collection_id" field.
  3186. func (m *AgentBaseMutation) SetCollectionID(s string) {
  3187. m.collection_id = &s
  3188. }
  3189. // CollectionID returns the value of the "collection_id" field in the mutation.
  3190. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  3191. v := m.collection_id
  3192. if v == nil {
  3193. return
  3194. }
  3195. return *v, true
  3196. }
  3197. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  3198. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3200. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  3201. if !m.op.Is(OpUpdateOne) {
  3202. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  3203. }
  3204. if m.id == nil || m.oldValue == nil {
  3205. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  3206. }
  3207. oldValue, err := m.oldValue(ctx)
  3208. if err != nil {
  3209. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  3210. }
  3211. return oldValue.CollectionID, nil
  3212. }
  3213. // ClearCollectionID clears the value of the "collection_id" field.
  3214. func (m *AgentBaseMutation) ClearCollectionID() {
  3215. m.collection_id = nil
  3216. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  3217. }
  3218. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  3219. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  3220. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  3221. return ok
  3222. }
  3223. // ResetCollectionID resets all changes to the "collection_id" field.
  3224. func (m *AgentBaseMutation) ResetCollectionID() {
  3225. m.collection_id = nil
  3226. delete(m.clearedFields, agentbase.FieldCollectionID)
  3227. }
  3228. // SetSourceName sets the "source_name" field.
  3229. func (m *AgentBaseMutation) SetSourceName(s string) {
  3230. m.source_name = &s
  3231. }
  3232. // SourceName returns the value of the "source_name" field in the mutation.
  3233. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  3234. v := m.source_name
  3235. if v == nil {
  3236. return
  3237. }
  3238. return *v, true
  3239. }
  3240. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  3241. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3243. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  3244. if !m.op.Is(OpUpdateOne) {
  3245. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  3246. }
  3247. if m.id == nil || m.oldValue == nil {
  3248. return v, errors.New("OldSourceName requires an ID field in the mutation")
  3249. }
  3250. oldValue, err := m.oldValue(ctx)
  3251. if err != nil {
  3252. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  3253. }
  3254. return oldValue.SourceName, nil
  3255. }
  3256. // ClearSourceName clears the value of the "source_name" field.
  3257. func (m *AgentBaseMutation) ClearSourceName() {
  3258. m.source_name = nil
  3259. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  3260. }
  3261. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  3262. func (m *AgentBaseMutation) SourceNameCleared() bool {
  3263. _, ok := m.clearedFields[agentbase.FieldSourceName]
  3264. return ok
  3265. }
  3266. // ResetSourceName resets all changes to the "source_name" field.
  3267. func (m *AgentBaseMutation) ResetSourceName() {
  3268. m.source_name = nil
  3269. delete(m.clearedFields, agentbase.FieldSourceName)
  3270. }
  3271. // SetCanWrite sets the "can_write" field.
  3272. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  3273. m.can_write = &b
  3274. m.appendcan_write = nil
  3275. }
  3276. // CanWrite returns the value of the "can_write" field in the mutation.
  3277. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  3278. v := m.can_write
  3279. if v == nil {
  3280. return
  3281. }
  3282. return *v, true
  3283. }
  3284. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  3285. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3287. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  3288. if !m.op.Is(OpUpdateOne) {
  3289. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  3290. }
  3291. if m.id == nil || m.oldValue == nil {
  3292. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  3293. }
  3294. oldValue, err := m.oldValue(ctx)
  3295. if err != nil {
  3296. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  3297. }
  3298. return oldValue.CanWrite, nil
  3299. }
  3300. // AppendCanWrite adds b to the "can_write" field.
  3301. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  3302. m.appendcan_write = append(m.appendcan_write, b...)
  3303. }
  3304. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  3305. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  3306. if len(m.appendcan_write) == 0 {
  3307. return nil, false
  3308. }
  3309. return m.appendcan_write, true
  3310. }
  3311. // ClearCanWrite clears the value of the "can_write" field.
  3312. func (m *AgentBaseMutation) ClearCanWrite() {
  3313. m.can_write = nil
  3314. m.appendcan_write = nil
  3315. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  3316. }
  3317. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  3318. func (m *AgentBaseMutation) CanWriteCleared() bool {
  3319. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  3320. return ok
  3321. }
  3322. // ResetCanWrite resets all changes to the "can_write" field.
  3323. func (m *AgentBaseMutation) ResetCanWrite() {
  3324. m.can_write = nil
  3325. m.appendcan_write = nil
  3326. delete(m.clearedFields, agentbase.FieldCanWrite)
  3327. }
  3328. // SetIsOwner sets the "is_owner" field.
  3329. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  3330. m.is_owner = &b
  3331. m.appendis_owner = nil
  3332. }
  3333. // IsOwner returns the value of the "is_owner" field in the mutation.
  3334. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  3335. v := m.is_owner
  3336. if v == nil {
  3337. return
  3338. }
  3339. return *v, true
  3340. }
  3341. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  3342. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3344. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  3345. if !m.op.Is(OpUpdateOne) {
  3346. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  3347. }
  3348. if m.id == nil || m.oldValue == nil {
  3349. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  3350. }
  3351. oldValue, err := m.oldValue(ctx)
  3352. if err != nil {
  3353. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  3354. }
  3355. return oldValue.IsOwner, nil
  3356. }
  3357. // AppendIsOwner adds b to the "is_owner" field.
  3358. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  3359. m.appendis_owner = append(m.appendis_owner, b...)
  3360. }
  3361. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  3362. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  3363. if len(m.appendis_owner) == 0 {
  3364. return nil, false
  3365. }
  3366. return m.appendis_owner, true
  3367. }
  3368. // ClearIsOwner clears the value of the "is_owner" field.
  3369. func (m *AgentBaseMutation) ClearIsOwner() {
  3370. m.is_owner = nil
  3371. m.appendis_owner = nil
  3372. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  3373. }
  3374. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  3375. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  3376. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  3377. return ok
  3378. }
  3379. // ResetIsOwner resets all changes to the "is_owner" field.
  3380. func (m *AgentBaseMutation) ResetIsOwner() {
  3381. m.is_owner = nil
  3382. m.appendis_owner = nil
  3383. delete(m.clearedFields, agentbase.FieldIsOwner)
  3384. }
  3385. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  3386. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  3387. if m.wx_agent == nil {
  3388. m.wx_agent = make(map[uint64]struct{})
  3389. }
  3390. for i := range ids {
  3391. m.wx_agent[ids[i]] = struct{}{}
  3392. }
  3393. }
  3394. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  3395. func (m *AgentBaseMutation) ClearWxAgent() {
  3396. m.clearedwx_agent = true
  3397. }
  3398. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  3399. func (m *AgentBaseMutation) WxAgentCleared() bool {
  3400. return m.clearedwx_agent
  3401. }
  3402. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  3403. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  3404. if m.removedwx_agent == nil {
  3405. m.removedwx_agent = make(map[uint64]struct{})
  3406. }
  3407. for i := range ids {
  3408. delete(m.wx_agent, ids[i])
  3409. m.removedwx_agent[ids[i]] = struct{}{}
  3410. }
  3411. }
  3412. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  3413. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  3414. for id := range m.removedwx_agent {
  3415. ids = append(ids, id)
  3416. }
  3417. return
  3418. }
  3419. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  3420. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  3421. for id := range m.wx_agent {
  3422. ids = append(ids, id)
  3423. }
  3424. return
  3425. }
  3426. // ResetWxAgent resets all changes to the "wx_agent" edge.
  3427. func (m *AgentBaseMutation) ResetWxAgent() {
  3428. m.wx_agent = nil
  3429. m.clearedwx_agent = false
  3430. m.removedwx_agent = nil
  3431. }
  3432. // Where appends a list predicates to the AgentBaseMutation builder.
  3433. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  3434. m.predicates = append(m.predicates, ps...)
  3435. }
  3436. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  3437. // users can use type-assertion to append predicates that do not depend on any generated package.
  3438. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  3439. p := make([]predicate.AgentBase, len(ps))
  3440. for i := range ps {
  3441. p[i] = ps[i]
  3442. }
  3443. m.Where(p...)
  3444. }
  3445. // Op returns the operation name.
  3446. func (m *AgentBaseMutation) Op() Op {
  3447. return m.op
  3448. }
  3449. // SetOp allows setting the mutation operation.
  3450. func (m *AgentBaseMutation) SetOp(op Op) {
  3451. m.op = op
  3452. }
  3453. // Type returns the node type of this mutation (AgentBase).
  3454. func (m *AgentBaseMutation) Type() string {
  3455. return m.typ
  3456. }
  3457. // Fields returns all fields that were changed during this mutation. Note that in
  3458. // order to get all numeric fields that were incremented/decremented, call
  3459. // AddedFields().
  3460. func (m *AgentBaseMutation) Fields() []string {
  3461. fields := make([]string, 0, 9)
  3462. if m.q != nil {
  3463. fields = append(fields, agentbase.FieldQ)
  3464. }
  3465. if m.a != nil {
  3466. fields = append(fields, agentbase.FieldA)
  3467. }
  3468. if m.chunk_index != nil {
  3469. fields = append(fields, agentbase.FieldChunkIndex)
  3470. }
  3471. if m.indexes != nil {
  3472. fields = append(fields, agentbase.FieldIndexes)
  3473. }
  3474. if m.dataset_id != nil {
  3475. fields = append(fields, agentbase.FieldDatasetID)
  3476. }
  3477. if m.collection_id != nil {
  3478. fields = append(fields, agentbase.FieldCollectionID)
  3479. }
  3480. if m.source_name != nil {
  3481. fields = append(fields, agentbase.FieldSourceName)
  3482. }
  3483. if m.can_write != nil {
  3484. fields = append(fields, agentbase.FieldCanWrite)
  3485. }
  3486. if m.is_owner != nil {
  3487. fields = append(fields, agentbase.FieldIsOwner)
  3488. }
  3489. return fields
  3490. }
  3491. // Field returns the value of a field with the given name. The second boolean
  3492. // return value indicates that this field was not set, or was not defined in the
  3493. // schema.
  3494. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  3495. switch name {
  3496. case agentbase.FieldQ:
  3497. return m.Q()
  3498. case agentbase.FieldA:
  3499. return m.A()
  3500. case agentbase.FieldChunkIndex:
  3501. return m.ChunkIndex()
  3502. case agentbase.FieldIndexes:
  3503. return m.Indexes()
  3504. case agentbase.FieldDatasetID:
  3505. return m.DatasetID()
  3506. case agentbase.FieldCollectionID:
  3507. return m.CollectionID()
  3508. case agentbase.FieldSourceName:
  3509. return m.SourceName()
  3510. case agentbase.FieldCanWrite:
  3511. return m.CanWrite()
  3512. case agentbase.FieldIsOwner:
  3513. return m.IsOwner()
  3514. }
  3515. return nil, false
  3516. }
  3517. // OldField returns the old value of the field from the database. An error is
  3518. // returned if the mutation operation is not UpdateOne, or the query to the
  3519. // database failed.
  3520. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3521. switch name {
  3522. case agentbase.FieldQ:
  3523. return m.OldQ(ctx)
  3524. case agentbase.FieldA:
  3525. return m.OldA(ctx)
  3526. case agentbase.FieldChunkIndex:
  3527. return m.OldChunkIndex(ctx)
  3528. case agentbase.FieldIndexes:
  3529. return m.OldIndexes(ctx)
  3530. case agentbase.FieldDatasetID:
  3531. return m.OldDatasetID(ctx)
  3532. case agentbase.FieldCollectionID:
  3533. return m.OldCollectionID(ctx)
  3534. case agentbase.FieldSourceName:
  3535. return m.OldSourceName(ctx)
  3536. case agentbase.FieldCanWrite:
  3537. return m.OldCanWrite(ctx)
  3538. case agentbase.FieldIsOwner:
  3539. return m.OldIsOwner(ctx)
  3540. }
  3541. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  3542. }
  3543. // SetField sets the value of a field with the given name. It returns an error if
  3544. // the field is not defined in the schema, or if the type mismatched the field
  3545. // type.
  3546. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  3547. switch name {
  3548. case agentbase.FieldQ:
  3549. v, ok := value.(string)
  3550. if !ok {
  3551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3552. }
  3553. m.SetQ(v)
  3554. return nil
  3555. case agentbase.FieldA:
  3556. v, ok := value.(string)
  3557. if !ok {
  3558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3559. }
  3560. m.SetA(v)
  3561. return nil
  3562. case agentbase.FieldChunkIndex:
  3563. v, ok := value.(uint64)
  3564. if !ok {
  3565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3566. }
  3567. m.SetChunkIndex(v)
  3568. return nil
  3569. case agentbase.FieldIndexes:
  3570. v, ok := value.([]string)
  3571. if !ok {
  3572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3573. }
  3574. m.SetIndexes(v)
  3575. return nil
  3576. case agentbase.FieldDatasetID:
  3577. v, ok := value.(string)
  3578. if !ok {
  3579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3580. }
  3581. m.SetDatasetID(v)
  3582. return nil
  3583. case agentbase.FieldCollectionID:
  3584. v, ok := value.(string)
  3585. if !ok {
  3586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3587. }
  3588. m.SetCollectionID(v)
  3589. return nil
  3590. case agentbase.FieldSourceName:
  3591. v, ok := value.(string)
  3592. if !ok {
  3593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3594. }
  3595. m.SetSourceName(v)
  3596. return nil
  3597. case agentbase.FieldCanWrite:
  3598. v, ok := value.([]bool)
  3599. if !ok {
  3600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3601. }
  3602. m.SetCanWrite(v)
  3603. return nil
  3604. case agentbase.FieldIsOwner:
  3605. v, ok := value.([]bool)
  3606. if !ok {
  3607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3608. }
  3609. m.SetIsOwner(v)
  3610. return nil
  3611. }
  3612. return fmt.Errorf("unknown AgentBase field %s", name)
  3613. }
  3614. // AddedFields returns all numeric fields that were incremented/decremented during
  3615. // this mutation.
  3616. func (m *AgentBaseMutation) AddedFields() []string {
  3617. var fields []string
  3618. if m.addchunk_index != nil {
  3619. fields = append(fields, agentbase.FieldChunkIndex)
  3620. }
  3621. return fields
  3622. }
  3623. // AddedField returns the numeric value that was incremented/decremented on a field
  3624. // with the given name. The second boolean return value indicates that this field
  3625. // was not set, or was not defined in the schema.
  3626. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  3627. switch name {
  3628. case agentbase.FieldChunkIndex:
  3629. return m.AddedChunkIndex()
  3630. }
  3631. return nil, false
  3632. }
  3633. // AddField adds the value to the field with the given name. It returns an error if
  3634. // the field is not defined in the schema, or if the type mismatched the field
  3635. // type.
  3636. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  3637. switch name {
  3638. case agentbase.FieldChunkIndex:
  3639. v, ok := value.(int64)
  3640. if !ok {
  3641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3642. }
  3643. m.AddChunkIndex(v)
  3644. return nil
  3645. }
  3646. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  3647. }
  3648. // ClearedFields returns all nullable fields that were cleared during this
  3649. // mutation.
  3650. func (m *AgentBaseMutation) ClearedFields() []string {
  3651. var fields []string
  3652. if m.FieldCleared(agentbase.FieldQ) {
  3653. fields = append(fields, agentbase.FieldQ)
  3654. }
  3655. if m.FieldCleared(agentbase.FieldA) {
  3656. fields = append(fields, agentbase.FieldA)
  3657. }
  3658. if m.FieldCleared(agentbase.FieldIndexes) {
  3659. fields = append(fields, agentbase.FieldIndexes)
  3660. }
  3661. if m.FieldCleared(agentbase.FieldDatasetID) {
  3662. fields = append(fields, agentbase.FieldDatasetID)
  3663. }
  3664. if m.FieldCleared(agentbase.FieldCollectionID) {
  3665. fields = append(fields, agentbase.FieldCollectionID)
  3666. }
  3667. if m.FieldCleared(agentbase.FieldSourceName) {
  3668. fields = append(fields, agentbase.FieldSourceName)
  3669. }
  3670. if m.FieldCleared(agentbase.FieldCanWrite) {
  3671. fields = append(fields, agentbase.FieldCanWrite)
  3672. }
  3673. if m.FieldCleared(agentbase.FieldIsOwner) {
  3674. fields = append(fields, agentbase.FieldIsOwner)
  3675. }
  3676. return fields
  3677. }
  3678. // FieldCleared returns a boolean indicating if a field with the given name was
  3679. // cleared in this mutation.
  3680. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  3681. _, ok := m.clearedFields[name]
  3682. return ok
  3683. }
  3684. // ClearField clears the value of the field with the given name. It returns an
  3685. // error if the field is not defined in the schema.
  3686. func (m *AgentBaseMutation) ClearField(name string) error {
  3687. switch name {
  3688. case agentbase.FieldQ:
  3689. m.ClearQ()
  3690. return nil
  3691. case agentbase.FieldA:
  3692. m.ClearA()
  3693. return nil
  3694. case agentbase.FieldIndexes:
  3695. m.ClearIndexes()
  3696. return nil
  3697. case agentbase.FieldDatasetID:
  3698. m.ClearDatasetID()
  3699. return nil
  3700. case agentbase.FieldCollectionID:
  3701. m.ClearCollectionID()
  3702. return nil
  3703. case agentbase.FieldSourceName:
  3704. m.ClearSourceName()
  3705. return nil
  3706. case agentbase.FieldCanWrite:
  3707. m.ClearCanWrite()
  3708. return nil
  3709. case agentbase.FieldIsOwner:
  3710. m.ClearIsOwner()
  3711. return nil
  3712. }
  3713. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  3714. }
  3715. // ResetField resets all changes in the mutation for the field with the given name.
  3716. // It returns an error if the field is not defined in the schema.
  3717. func (m *AgentBaseMutation) ResetField(name string) error {
  3718. switch name {
  3719. case agentbase.FieldQ:
  3720. m.ResetQ()
  3721. return nil
  3722. case agentbase.FieldA:
  3723. m.ResetA()
  3724. return nil
  3725. case agentbase.FieldChunkIndex:
  3726. m.ResetChunkIndex()
  3727. return nil
  3728. case agentbase.FieldIndexes:
  3729. m.ResetIndexes()
  3730. return nil
  3731. case agentbase.FieldDatasetID:
  3732. m.ResetDatasetID()
  3733. return nil
  3734. case agentbase.FieldCollectionID:
  3735. m.ResetCollectionID()
  3736. return nil
  3737. case agentbase.FieldSourceName:
  3738. m.ResetSourceName()
  3739. return nil
  3740. case agentbase.FieldCanWrite:
  3741. m.ResetCanWrite()
  3742. return nil
  3743. case agentbase.FieldIsOwner:
  3744. m.ResetIsOwner()
  3745. return nil
  3746. }
  3747. return fmt.Errorf("unknown AgentBase field %s", name)
  3748. }
  3749. // AddedEdges returns all edge names that were set/added in this mutation.
  3750. func (m *AgentBaseMutation) AddedEdges() []string {
  3751. edges := make([]string, 0, 1)
  3752. if m.wx_agent != nil {
  3753. edges = append(edges, agentbase.EdgeWxAgent)
  3754. }
  3755. return edges
  3756. }
  3757. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3758. // name in this mutation.
  3759. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  3760. switch name {
  3761. case agentbase.EdgeWxAgent:
  3762. ids := make([]ent.Value, 0, len(m.wx_agent))
  3763. for id := range m.wx_agent {
  3764. ids = append(ids, id)
  3765. }
  3766. return ids
  3767. }
  3768. return nil
  3769. }
  3770. // RemovedEdges returns all edge names that were removed in this mutation.
  3771. func (m *AgentBaseMutation) RemovedEdges() []string {
  3772. edges := make([]string, 0, 1)
  3773. if m.removedwx_agent != nil {
  3774. edges = append(edges, agentbase.EdgeWxAgent)
  3775. }
  3776. return edges
  3777. }
  3778. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3779. // the given name in this mutation.
  3780. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  3781. switch name {
  3782. case agentbase.EdgeWxAgent:
  3783. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  3784. for id := range m.removedwx_agent {
  3785. ids = append(ids, id)
  3786. }
  3787. return ids
  3788. }
  3789. return nil
  3790. }
  3791. // ClearedEdges returns all edge names that were cleared in this mutation.
  3792. func (m *AgentBaseMutation) ClearedEdges() []string {
  3793. edges := make([]string, 0, 1)
  3794. if m.clearedwx_agent {
  3795. edges = append(edges, agentbase.EdgeWxAgent)
  3796. }
  3797. return edges
  3798. }
  3799. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3800. // was cleared in this mutation.
  3801. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  3802. switch name {
  3803. case agentbase.EdgeWxAgent:
  3804. return m.clearedwx_agent
  3805. }
  3806. return false
  3807. }
  3808. // ClearEdge clears the value of the edge with the given name. It returns an error
  3809. // if that edge is not defined in the schema.
  3810. func (m *AgentBaseMutation) ClearEdge(name string) error {
  3811. switch name {
  3812. }
  3813. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  3814. }
  3815. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3816. // It returns an error if the edge is not defined in the schema.
  3817. func (m *AgentBaseMutation) ResetEdge(name string) error {
  3818. switch name {
  3819. case agentbase.EdgeWxAgent:
  3820. m.ResetWxAgent()
  3821. return nil
  3822. }
  3823. return fmt.Errorf("unknown AgentBase edge %s", name)
  3824. }
  3825. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  3826. type AliyunAvatarMutation struct {
  3827. config
  3828. op Op
  3829. typ string
  3830. id *uint64
  3831. created_at *time.Time
  3832. updated_at *time.Time
  3833. deleted_at *time.Time
  3834. user_id *uint64
  3835. adduser_id *int64
  3836. biz_id *string
  3837. access_key_id *string
  3838. access_key_secret *string
  3839. app_id *string
  3840. tenant_id *uint64
  3841. addtenant_id *int64
  3842. response *string
  3843. token *string
  3844. session_id *string
  3845. clearedFields map[string]struct{}
  3846. done bool
  3847. oldValue func(context.Context) (*AliyunAvatar, error)
  3848. predicates []predicate.AliyunAvatar
  3849. }
  3850. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  3851. // aliyunavatarOption allows management of the mutation configuration using functional options.
  3852. type aliyunavatarOption func(*AliyunAvatarMutation)
  3853. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  3854. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  3855. m := &AliyunAvatarMutation{
  3856. config: c,
  3857. op: op,
  3858. typ: TypeAliyunAvatar,
  3859. clearedFields: make(map[string]struct{}),
  3860. }
  3861. for _, opt := range opts {
  3862. opt(m)
  3863. }
  3864. return m
  3865. }
  3866. // withAliyunAvatarID sets the ID field of the mutation.
  3867. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  3868. return func(m *AliyunAvatarMutation) {
  3869. var (
  3870. err error
  3871. once sync.Once
  3872. value *AliyunAvatar
  3873. )
  3874. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  3875. once.Do(func() {
  3876. if m.done {
  3877. err = errors.New("querying old values post mutation is not allowed")
  3878. } else {
  3879. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  3880. }
  3881. })
  3882. return value, err
  3883. }
  3884. m.id = &id
  3885. }
  3886. }
  3887. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  3888. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  3889. return func(m *AliyunAvatarMutation) {
  3890. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  3891. return node, nil
  3892. }
  3893. m.id = &node.ID
  3894. }
  3895. }
  3896. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3897. // executed in a transaction (ent.Tx), a transactional client is returned.
  3898. func (m AliyunAvatarMutation) Client() *Client {
  3899. client := &Client{config: m.config}
  3900. client.init()
  3901. return client
  3902. }
  3903. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3904. // it returns an error otherwise.
  3905. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  3906. if _, ok := m.driver.(*txDriver); !ok {
  3907. return nil, errors.New("ent: mutation is not running in a transaction")
  3908. }
  3909. tx := &Tx{config: m.config}
  3910. tx.init()
  3911. return tx, nil
  3912. }
  3913. // SetID sets the value of the id field. Note that this
  3914. // operation is only accepted on creation of AliyunAvatar entities.
  3915. func (m *AliyunAvatarMutation) SetID(id uint64) {
  3916. m.id = &id
  3917. }
  3918. // ID returns the ID value in the mutation. Note that the ID is only available
  3919. // if it was provided to the builder or after it was returned from the database.
  3920. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  3921. if m.id == nil {
  3922. return
  3923. }
  3924. return *m.id, true
  3925. }
  3926. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3927. // That means, if the mutation is applied within a transaction with an isolation level such
  3928. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3929. // or updated by the mutation.
  3930. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  3931. switch {
  3932. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3933. id, exists := m.ID()
  3934. if exists {
  3935. return []uint64{id}, nil
  3936. }
  3937. fallthrough
  3938. case m.op.Is(OpUpdate | OpDelete):
  3939. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  3940. default:
  3941. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3942. }
  3943. }
  3944. // SetCreatedAt sets the "created_at" field.
  3945. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  3946. m.created_at = &t
  3947. }
  3948. // CreatedAt returns the value of the "created_at" field in the mutation.
  3949. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  3950. v := m.created_at
  3951. if v == nil {
  3952. return
  3953. }
  3954. return *v, true
  3955. }
  3956. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  3957. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3959. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3960. if !m.op.Is(OpUpdateOne) {
  3961. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3962. }
  3963. if m.id == nil || m.oldValue == nil {
  3964. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3965. }
  3966. oldValue, err := m.oldValue(ctx)
  3967. if err != nil {
  3968. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3969. }
  3970. return oldValue.CreatedAt, nil
  3971. }
  3972. // ResetCreatedAt resets all changes to the "created_at" field.
  3973. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  3974. m.created_at = nil
  3975. }
  3976. // SetUpdatedAt sets the "updated_at" field.
  3977. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  3978. m.updated_at = &t
  3979. }
  3980. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3981. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  3982. v := m.updated_at
  3983. if v == nil {
  3984. return
  3985. }
  3986. return *v, true
  3987. }
  3988. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  3989. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3991. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3992. if !m.op.Is(OpUpdateOne) {
  3993. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3994. }
  3995. if m.id == nil || m.oldValue == nil {
  3996. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3997. }
  3998. oldValue, err := m.oldValue(ctx)
  3999. if err != nil {
  4000. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4001. }
  4002. return oldValue.UpdatedAt, nil
  4003. }
  4004. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4005. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  4006. m.updated_at = nil
  4007. }
  4008. // SetDeletedAt sets the "deleted_at" field.
  4009. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  4010. m.deleted_at = &t
  4011. }
  4012. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4013. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  4014. v := m.deleted_at
  4015. if v == nil {
  4016. return
  4017. }
  4018. return *v, true
  4019. }
  4020. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  4021. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4023. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4024. if !m.op.Is(OpUpdateOne) {
  4025. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4026. }
  4027. if m.id == nil || m.oldValue == nil {
  4028. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4029. }
  4030. oldValue, err := m.oldValue(ctx)
  4031. if err != nil {
  4032. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4033. }
  4034. return oldValue.DeletedAt, nil
  4035. }
  4036. // ClearDeletedAt clears the value of the "deleted_at" field.
  4037. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  4038. m.deleted_at = nil
  4039. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  4040. }
  4041. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4042. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  4043. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  4044. return ok
  4045. }
  4046. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4047. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  4048. m.deleted_at = nil
  4049. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  4050. }
  4051. // SetUserID sets the "user_id" field.
  4052. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  4053. m.user_id = &u
  4054. m.adduser_id = nil
  4055. }
  4056. // UserID returns the value of the "user_id" field in the mutation.
  4057. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  4058. v := m.user_id
  4059. if v == nil {
  4060. return
  4061. }
  4062. return *v, true
  4063. }
  4064. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  4065. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4067. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  4068. if !m.op.Is(OpUpdateOne) {
  4069. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4070. }
  4071. if m.id == nil || m.oldValue == nil {
  4072. return v, errors.New("OldUserID requires an ID field in the mutation")
  4073. }
  4074. oldValue, err := m.oldValue(ctx)
  4075. if err != nil {
  4076. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4077. }
  4078. return oldValue.UserID, nil
  4079. }
  4080. // AddUserID adds u to the "user_id" field.
  4081. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  4082. if m.adduser_id != nil {
  4083. *m.adduser_id += u
  4084. } else {
  4085. m.adduser_id = &u
  4086. }
  4087. }
  4088. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  4089. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  4090. v := m.adduser_id
  4091. if v == nil {
  4092. return
  4093. }
  4094. return *v, true
  4095. }
  4096. // ResetUserID resets all changes to the "user_id" field.
  4097. func (m *AliyunAvatarMutation) ResetUserID() {
  4098. m.user_id = nil
  4099. m.adduser_id = nil
  4100. }
  4101. // SetBizID sets the "biz_id" field.
  4102. func (m *AliyunAvatarMutation) SetBizID(s string) {
  4103. m.biz_id = &s
  4104. }
  4105. // BizID returns the value of the "biz_id" field in the mutation.
  4106. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  4107. v := m.biz_id
  4108. if v == nil {
  4109. return
  4110. }
  4111. return *v, true
  4112. }
  4113. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  4114. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4116. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  4117. if !m.op.Is(OpUpdateOne) {
  4118. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  4119. }
  4120. if m.id == nil || m.oldValue == nil {
  4121. return v, errors.New("OldBizID requires an ID field in the mutation")
  4122. }
  4123. oldValue, err := m.oldValue(ctx)
  4124. if err != nil {
  4125. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  4126. }
  4127. return oldValue.BizID, nil
  4128. }
  4129. // ResetBizID resets all changes to the "biz_id" field.
  4130. func (m *AliyunAvatarMutation) ResetBizID() {
  4131. m.biz_id = nil
  4132. }
  4133. // SetAccessKeyID sets the "access_key_id" field.
  4134. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  4135. m.access_key_id = &s
  4136. }
  4137. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  4138. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  4139. v := m.access_key_id
  4140. if v == nil {
  4141. return
  4142. }
  4143. return *v, true
  4144. }
  4145. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  4146. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4148. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  4149. if !m.op.Is(OpUpdateOne) {
  4150. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  4151. }
  4152. if m.id == nil || m.oldValue == nil {
  4153. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  4154. }
  4155. oldValue, err := m.oldValue(ctx)
  4156. if err != nil {
  4157. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  4158. }
  4159. return oldValue.AccessKeyID, nil
  4160. }
  4161. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  4162. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  4163. m.access_key_id = nil
  4164. }
  4165. // SetAccessKeySecret sets the "access_key_secret" field.
  4166. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  4167. m.access_key_secret = &s
  4168. }
  4169. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  4170. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  4171. v := m.access_key_secret
  4172. if v == nil {
  4173. return
  4174. }
  4175. return *v, true
  4176. }
  4177. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  4178. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4180. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  4181. if !m.op.Is(OpUpdateOne) {
  4182. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  4183. }
  4184. if m.id == nil || m.oldValue == nil {
  4185. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  4186. }
  4187. oldValue, err := m.oldValue(ctx)
  4188. if err != nil {
  4189. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  4190. }
  4191. return oldValue.AccessKeySecret, nil
  4192. }
  4193. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  4194. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  4195. m.access_key_secret = nil
  4196. }
  4197. // SetAppID sets the "app_id" field.
  4198. func (m *AliyunAvatarMutation) SetAppID(s string) {
  4199. m.app_id = &s
  4200. }
  4201. // AppID returns the value of the "app_id" field in the mutation.
  4202. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  4203. v := m.app_id
  4204. if v == nil {
  4205. return
  4206. }
  4207. return *v, true
  4208. }
  4209. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  4210. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4212. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  4213. if !m.op.Is(OpUpdateOne) {
  4214. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  4215. }
  4216. if m.id == nil || m.oldValue == nil {
  4217. return v, errors.New("OldAppID requires an ID field in the mutation")
  4218. }
  4219. oldValue, err := m.oldValue(ctx)
  4220. if err != nil {
  4221. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  4222. }
  4223. return oldValue.AppID, nil
  4224. }
  4225. // ClearAppID clears the value of the "app_id" field.
  4226. func (m *AliyunAvatarMutation) ClearAppID() {
  4227. m.app_id = nil
  4228. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  4229. }
  4230. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  4231. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  4232. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  4233. return ok
  4234. }
  4235. // ResetAppID resets all changes to the "app_id" field.
  4236. func (m *AliyunAvatarMutation) ResetAppID() {
  4237. m.app_id = nil
  4238. delete(m.clearedFields, aliyunavatar.FieldAppID)
  4239. }
  4240. // SetTenantID sets the "tenant_id" field.
  4241. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  4242. m.tenant_id = &u
  4243. m.addtenant_id = nil
  4244. }
  4245. // TenantID returns the value of the "tenant_id" field in the mutation.
  4246. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  4247. v := m.tenant_id
  4248. if v == nil {
  4249. return
  4250. }
  4251. return *v, true
  4252. }
  4253. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  4254. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4256. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  4257. if !m.op.Is(OpUpdateOne) {
  4258. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  4259. }
  4260. if m.id == nil || m.oldValue == nil {
  4261. return v, errors.New("OldTenantID requires an ID field in the mutation")
  4262. }
  4263. oldValue, err := m.oldValue(ctx)
  4264. if err != nil {
  4265. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  4266. }
  4267. return oldValue.TenantID, nil
  4268. }
  4269. // AddTenantID adds u to the "tenant_id" field.
  4270. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  4271. if m.addtenant_id != nil {
  4272. *m.addtenant_id += u
  4273. } else {
  4274. m.addtenant_id = &u
  4275. }
  4276. }
  4277. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  4278. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  4279. v := m.addtenant_id
  4280. if v == nil {
  4281. return
  4282. }
  4283. return *v, true
  4284. }
  4285. // ResetTenantID resets all changes to the "tenant_id" field.
  4286. func (m *AliyunAvatarMutation) ResetTenantID() {
  4287. m.tenant_id = nil
  4288. m.addtenant_id = nil
  4289. }
  4290. // SetResponse sets the "response" field.
  4291. func (m *AliyunAvatarMutation) SetResponse(s string) {
  4292. m.response = &s
  4293. }
  4294. // Response returns the value of the "response" field in the mutation.
  4295. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  4296. v := m.response
  4297. if v == nil {
  4298. return
  4299. }
  4300. return *v, true
  4301. }
  4302. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  4303. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4305. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  4306. if !m.op.Is(OpUpdateOne) {
  4307. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  4308. }
  4309. if m.id == nil || m.oldValue == nil {
  4310. return v, errors.New("OldResponse requires an ID field in the mutation")
  4311. }
  4312. oldValue, err := m.oldValue(ctx)
  4313. if err != nil {
  4314. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  4315. }
  4316. return oldValue.Response, nil
  4317. }
  4318. // ResetResponse resets all changes to the "response" field.
  4319. func (m *AliyunAvatarMutation) ResetResponse() {
  4320. m.response = nil
  4321. }
  4322. // SetToken sets the "token" field.
  4323. func (m *AliyunAvatarMutation) SetToken(s string) {
  4324. m.token = &s
  4325. }
  4326. // Token returns the value of the "token" field in the mutation.
  4327. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  4328. v := m.token
  4329. if v == nil {
  4330. return
  4331. }
  4332. return *v, true
  4333. }
  4334. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  4335. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4337. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  4338. if !m.op.Is(OpUpdateOne) {
  4339. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  4340. }
  4341. if m.id == nil || m.oldValue == nil {
  4342. return v, errors.New("OldToken requires an ID field in the mutation")
  4343. }
  4344. oldValue, err := m.oldValue(ctx)
  4345. if err != nil {
  4346. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  4347. }
  4348. return oldValue.Token, nil
  4349. }
  4350. // ResetToken resets all changes to the "token" field.
  4351. func (m *AliyunAvatarMutation) ResetToken() {
  4352. m.token = nil
  4353. }
  4354. // SetSessionID sets the "session_id" field.
  4355. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  4356. m.session_id = &s
  4357. }
  4358. // SessionID returns the value of the "session_id" field in the mutation.
  4359. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  4360. v := m.session_id
  4361. if v == nil {
  4362. return
  4363. }
  4364. return *v, true
  4365. }
  4366. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  4367. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4369. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  4370. if !m.op.Is(OpUpdateOne) {
  4371. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  4372. }
  4373. if m.id == nil || m.oldValue == nil {
  4374. return v, errors.New("OldSessionID requires an ID field in the mutation")
  4375. }
  4376. oldValue, err := m.oldValue(ctx)
  4377. if err != nil {
  4378. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  4379. }
  4380. return oldValue.SessionID, nil
  4381. }
  4382. // ResetSessionID resets all changes to the "session_id" field.
  4383. func (m *AliyunAvatarMutation) ResetSessionID() {
  4384. m.session_id = nil
  4385. }
  4386. // Where appends a list predicates to the AliyunAvatarMutation builder.
  4387. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  4388. m.predicates = append(m.predicates, ps...)
  4389. }
  4390. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  4391. // users can use type-assertion to append predicates that do not depend on any generated package.
  4392. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  4393. p := make([]predicate.AliyunAvatar, len(ps))
  4394. for i := range ps {
  4395. p[i] = ps[i]
  4396. }
  4397. m.Where(p...)
  4398. }
  4399. // Op returns the operation name.
  4400. func (m *AliyunAvatarMutation) Op() Op {
  4401. return m.op
  4402. }
  4403. // SetOp allows setting the mutation operation.
  4404. func (m *AliyunAvatarMutation) SetOp(op Op) {
  4405. m.op = op
  4406. }
  4407. // Type returns the node type of this mutation (AliyunAvatar).
  4408. func (m *AliyunAvatarMutation) Type() string {
  4409. return m.typ
  4410. }
  4411. // Fields returns all fields that were changed during this mutation. Note that in
  4412. // order to get all numeric fields that were incremented/decremented, call
  4413. // AddedFields().
  4414. func (m *AliyunAvatarMutation) Fields() []string {
  4415. fields := make([]string, 0, 12)
  4416. if m.created_at != nil {
  4417. fields = append(fields, aliyunavatar.FieldCreatedAt)
  4418. }
  4419. if m.updated_at != nil {
  4420. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  4421. }
  4422. if m.deleted_at != nil {
  4423. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4424. }
  4425. if m.user_id != nil {
  4426. fields = append(fields, aliyunavatar.FieldUserID)
  4427. }
  4428. if m.biz_id != nil {
  4429. fields = append(fields, aliyunavatar.FieldBizID)
  4430. }
  4431. if m.access_key_id != nil {
  4432. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  4433. }
  4434. if m.access_key_secret != nil {
  4435. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  4436. }
  4437. if m.app_id != nil {
  4438. fields = append(fields, aliyunavatar.FieldAppID)
  4439. }
  4440. if m.tenant_id != nil {
  4441. fields = append(fields, aliyunavatar.FieldTenantID)
  4442. }
  4443. if m.response != nil {
  4444. fields = append(fields, aliyunavatar.FieldResponse)
  4445. }
  4446. if m.token != nil {
  4447. fields = append(fields, aliyunavatar.FieldToken)
  4448. }
  4449. if m.session_id != nil {
  4450. fields = append(fields, aliyunavatar.FieldSessionID)
  4451. }
  4452. return fields
  4453. }
  4454. // Field returns the value of a field with the given name. The second boolean
  4455. // return value indicates that this field was not set, or was not defined in the
  4456. // schema.
  4457. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  4458. switch name {
  4459. case aliyunavatar.FieldCreatedAt:
  4460. return m.CreatedAt()
  4461. case aliyunavatar.FieldUpdatedAt:
  4462. return m.UpdatedAt()
  4463. case aliyunavatar.FieldDeletedAt:
  4464. return m.DeletedAt()
  4465. case aliyunavatar.FieldUserID:
  4466. return m.UserID()
  4467. case aliyunavatar.FieldBizID:
  4468. return m.BizID()
  4469. case aliyunavatar.FieldAccessKeyID:
  4470. return m.AccessKeyID()
  4471. case aliyunavatar.FieldAccessKeySecret:
  4472. return m.AccessKeySecret()
  4473. case aliyunavatar.FieldAppID:
  4474. return m.AppID()
  4475. case aliyunavatar.FieldTenantID:
  4476. return m.TenantID()
  4477. case aliyunavatar.FieldResponse:
  4478. return m.Response()
  4479. case aliyunavatar.FieldToken:
  4480. return m.Token()
  4481. case aliyunavatar.FieldSessionID:
  4482. return m.SessionID()
  4483. }
  4484. return nil, false
  4485. }
  4486. // OldField returns the old value of the field from the database. An error is
  4487. // returned if the mutation operation is not UpdateOne, or the query to the
  4488. // database failed.
  4489. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4490. switch name {
  4491. case aliyunavatar.FieldCreatedAt:
  4492. return m.OldCreatedAt(ctx)
  4493. case aliyunavatar.FieldUpdatedAt:
  4494. return m.OldUpdatedAt(ctx)
  4495. case aliyunavatar.FieldDeletedAt:
  4496. return m.OldDeletedAt(ctx)
  4497. case aliyunavatar.FieldUserID:
  4498. return m.OldUserID(ctx)
  4499. case aliyunavatar.FieldBizID:
  4500. return m.OldBizID(ctx)
  4501. case aliyunavatar.FieldAccessKeyID:
  4502. return m.OldAccessKeyID(ctx)
  4503. case aliyunavatar.FieldAccessKeySecret:
  4504. return m.OldAccessKeySecret(ctx)
  4505. case aliyunavatar.FieldAppID:
  4506. return m.OldAppID(ctx)
  4507. case aliyunavatar.FieldTenantID:
  4508. return m.OldTenantID(ctx)
  4509. case aliyunavatar.FieldResponse:
  4510. return m.OldResponse(ctx)
  4511. case aliyunavatar.FieldToken:
  4512. return m.OldToken(ctx)
  4513. case aliyunavatar.FieldSessionID:
  4514. return m.OldSessionID(ctx)
  4515. }
  4516. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  4517. }
  4518. // SetField sets the value of a field with the given name. It returns an error if
  4519. // the field is not defined in the schema, or if the type mismatched the field
  4520. // type.
  4521. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  4522. switch name {
  4523. case aliyunavatar.FieldCreatedAt:
  4524. v, ok := value.(time.Time)
  4525. if !ok {
  4526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4527. }
  4528. m.SetCreatedAt(v)
  4529. return nil
  4530. case aliyunavatar.FieldUpdatedAt:
  4531. v, ok := value.(time.Time)
  4532. if !ok {
  4533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4534. }
  4535. m.SetUpdatedAt(v)
  4536. return nil
  4537. case aliyunavatar.FieldDeletedAt:
  4538. v, ok := value.(time.Time)
  4539. if !ok {
  4540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4541. }
  4542. m.SetDeletedAt(v)
  4543. return nil
  4544. case aliyunavatar.FieldUserID:
  4545. v, ok := value.(uint64)
  4546. if !ok {
  4547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4548. }
  4549. m.SetUserID(v)
  4550. return nil
  4551. case aliyunavatar.FieldBizID:
  4552. v, ok := value.(string)
  4553. if !ok {
  4554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4555. }
  4556. m.SetBizID(v)
  4557. return nil
  4558. case aliyunavatar.FieldAccessKeyID:
  4559. v, ok := value.(string)
  4560. if !ok {
  4561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4562. }
  4563. m.SetAccessKeyID(v)
  4564. return nil
  4565. case aliyunavatar.FieldAccessKeySecret:
  4566. v, ok := value.(string)
  4567. if !ok {
  4568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4569. }
  4570. m.SetAccessKeySecret(v)
  4571. return nil
  4572. case aliyunavatar.FieldAppID:
  4573. v, ok := value.(string)
  4574. if !ok {
  4575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4576. }
  4577. m.SetAppID(v)
  4578. return nil
  4579. case aliyunavatar.FieldTenantID:
  4580. v, ok := value.(uint64)
  4581. if !ok {
  4582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4583. }
  4584. m.SetTenantID(v)
  4585. return nil
  4586. case aliyunavatar.FieldResponse:
  4587. v, ok := value.(string)
  4588. if !ok {
  4589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4590. }
  4591. m.SetResponse(v)
  4592. return nil
  4593. case aliyunavatar.FieldToken:
  4594. v, ok := value.(string)
  4595. if !ok {
  4596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4597. }
  4598. m.SetToken(v)
  4599. return nil
  4600. case aliyunavatar.FieldSessionID:
  4601. v, ok := value.(string)
  4602. if !ok {
  4603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4604. }
  4605. m.SetSessionID(v)
  4606. return nil
  4607. }
  4608. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4609. }
  4610. // AddedFields returns all numeric fields that were incremented/decremented during
  4611. // this mutation.
  4612. func (m *AliyunAvatarMutation) AddedFields() []string {
  4613. var fields []string
  4614. if m.adduser_id != nil {
  4615. fields = append(fields, aliyunavatar.FieldUserID)
  4616. }
  4617. if m.addtenant_id != nil {
  4618. fields = append(fields, aliyunavatar.FieldTenantID)
  4619. }
  4620. return fields
  4621. }
  4622. // AddedField returns the numeric value that was incremented/decremented on a field
  4623. // with the given name. The second boolean return value indicates that this field
  4624. // was not set, or was not defined in the schema.
  4625. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  4626. switch name {
  4627. case aliyunavatar.FieldUserID:
  4628. return m.AddedUserID()
  4629. case aliyunavatar.FieldTenantID:
  4630. return m.AddedTenantID()
  4631. }
  4632. return nil, false
  4633. }
  4634. // AddField adds the value to the field with the given name. It returns an error if
  4635. // the field is not defined in the schema, or if the type mismatched the field
  4636. // type.
  4637. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  4638. switch name {
  4639. case aliyunavatar.FieldUserID:
  4640. v, ok := value.(int64)
  4641. if !ok {
  4642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4643. }
  4644. m.AddUserID(v)
  4645. return nil
  4646. case aliyunavatar.FieldTenantID:
  4647. v, ok := value.(int64)
  4648. if !ok {
  4649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4650. }
  4651. m.AddTenantID(v)
  4652. return nil
  4653. }
  4654. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  4655. }
  4656. // ClearedFields returns all nullable fields that were cleared during this
  4657. // mutation.
  4658. func (m *AliyunAvatarMutation) ClearedFields() []string {
  4659. var fields []string
  4660. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  4661. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4662. }
  4663. if m.FieldCleared(aliyunavatar.FieldAppID) {
  4664. fields = append(fields, aliyunavatar.FieldAppID)
  4665. }
  4666. return fields
  4667. }
  4668. // FieldCleared returns a boolean indicating if a field with the given name was
  4669. // cleared in this mutation.
  4670. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  4671. _, ok := m.clearedFields[name]
  4672. return ok
  4673. }
  4674. // ClearField clears the value of the field with the given name. It returns an
  4675. // error if the field is not defined in the schema.
  4676. func (m *AliyunAvatarMutation) ClearField(name string) error {
  4677. switch name {
  4678. case aliyunavatar.FieldDeletedAt:
  4679. m.ClearDeletedAt()
  4680. return nil
  4681. case aliyunavatar.FieldAppID:
  4682. m.ClearAppID()
  4683. return nil
  4684. }
  4685. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  4686. }
  4687. // ResetField resets all changes in the mutation for the field with the given name.
  4688. // It returns an error if the field is not defined in the schema.
  4689. func (m *AliyunAvatarMutation) ResetField(name string) error {
  4690. switch name {
  4691. case aliyunavatar.FieldCreatedAt:
  4692. m.ResetCreatedAt()
  4693. return nil
  4694. case aliyunavatar.FieldUpdatedAt:
  4695. m.ResetUpdatedAt()
  4696. return nil
  4697. case aliyunavatar.FieldDeletedAt:
  4698. m.ResetDeletedAt()
  4699. return nil
  4700. case aliyunavatar.FieldUserID:
  4701. m.ResetUserID()
  4702. return nil
  4703. case aliyunavatar.FieldBizID:
  4704. m.ResetBizID()
  4705. return nil
  4706. case aliyunavatar.FieldAccessKeyID:
  4707. m.ResetAccessKeyID()
  4708. return nil
  4709. case aliyunavatar.FieldAccessKeySecret:
  4710. m.ResetAccessKeySecret()
  4711. return nil
  4712. case aliyunavatar.FieldAppID:
  4713. m.ResetAppID()
  4714. return nil
  4715. case aliyunavatar.FieldTenantID:
  4716. m.ResetTenantID()
  4717. return nil
  4718. case aliyunavatar.FieldResponse:
  4719. m.ResetResponse()
  4720. return nil
  4721. case aliyunavatar.FieldToken:
  4722. m.ResetToken()
  4723. return nil
  4724. case aliyunavatar.FieldSessionID:
  4725. m.ResetSessionID()
  4726. return nil
  4727. }
  4728. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4729. }
  4730. // AddedEdges returns all edge names that were set/added in this mutation.
  4731. func (m *AliyunAvatarMutation) AddedEdges() []string {
  4732. edges := make([]string, 0, 0)
  4733. return edges
  4734. }
  4735. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4736. // name in this mutation.
  4737. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  4738. return nil
  4739. }
  4740. // RemovedEdges returns all edge names that were removed in this mutation.
  4741. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  4742. edges := make([]string, 0, 0)
  4743. return edges
  4744. }
  4745. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4746. // the given name in this mutation.
  4747. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  4748. return nil
  4749. }
  4750. // ClearedEdges returns all edge names that were cleared in this mutation.
  4751. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  4752. edges := make([]string, 0, 0)
  4753. return edges
  4754. }
  4755. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4756. // was cleared in this mutation.
  4757. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  4758. return false
  4759. }
  4760. // ClearEdge clears the value of the edge with the given name. It returns an error
  4761. // if that edge is not defined in the schema.
  4762. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  4763. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  4764. }
  4765. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4766. // It returns an error if the edge is not defined in the schema.
  4767. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  4768. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  4769. }
  4770. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  4771. type AllocAgentMutation struct {
  4772. config
  4773. op Op
  4774. typ string
  4775. id *uint64
  4776. created_at *time.Time
  4777. updated_at *time.Time
  4778. deleted_at *time.Time
  4779. user_id *string
  4780. organization_id *uint64
  4781. addorganization_id *int64
  4782. agents *[]uint64
  4783. appendagents []uint64
  4784. status *int
  4785. addstatus *int
  4786. clearedFields map[string]struct{}
  4787. done bool
  4788. oldValue func(context.Context) (*AllocAgent, error)
  4789. predicates []predicate.AllocAgent
  4790. }
  4791. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  4792. // allocagentOption allows management of the mutation configuration using functional options.
  4793. type allocagentOption func(*AllocAgentMutation)
  4794. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  4795. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  4796. m := &AllocAgentMutation{
  4797. config: c,
  4798. op: op,
  4799. typ: TypeAllocAgent,
  4800. clearedFields: make(map[string]struct{}),
  4801. }
  4802. for _, opt := range opts {
  4803. opt(m)
  4804. }
  4805. return m
  4806. }
  4807. // withAllocAgentID sets the ID field of the mutation.
  4808. func withAllocAgentID(id uint64) allocagentOption {
  4809. return func(m *AllocAgentMutation) {
  4810. var (
  4811. err error
  4812. once sync.Once
  4813. value *AllocAgent
  4814. )
  4815. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  4816. once.Do(func() {
  4817. if m.done {
  4818. err = errors.New("querying old values post mutation is not allowed")
  4819. } else {
  4820. value, err = m.Client().AllocAgent.Get(ctx, id)
  4821. }
  4822. })
  4823. return value, err
  4824. }
  4825. m.id = &id
  4826. }
  4827. }
  4828. // withAllocAgent sets the old AllocAgent of the mutation.
  4829. func withAllocAgent(node *AllocAgent) allocagentOption {
  4830. return func(m *AllocAgentMutation) {
  4831. m.oldValue = func(context.Context) (*AllocAgent, error) {
  4832. return node, nil
  4833. }
  4834. m.id = &node.ID
  4835. }
  4836. }
  4837. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4838. // executed in a transaction (ent.Tx), a transactional client is returned.
  4839. func (m AllocAgentMutation) Client() *Client {
  4840. client := &Client{config: m.config}
  4841. client.init()
  4842. return client
  4843. }
  4844. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4845. // it returns an error otherwise.
  4846. func (m AllocAgentMutation) Tx() (*Tx, error) {
  4847. if _, ok := m.driver.(*txDriver); !ok {
  4848. return nil, errors.New("ent: mutation is not running in a transaction")
  4849. }
  4850. tx := &Tx{config: m.config}
  4851. tx.init()
  4852. return tx, nil
  4853. }
  4854. // SetID sets the value of the id field. Note that this
  4855. // operation is only accepted on creation of AllocAgent entities.
  4856. func (m *AllocAgentMutation) SetID(id uint64) {
  4857. m.id = &id
  4858. }
  4859. // ID returns the ID value in the mutation. Note that the ID is only available
  4860. // if it was provided to the builder or after it was returned from the database.
  4861. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  4862. if m.id == nil {
  4863. return
  4864. }
  4865. return *m.id, true
  4866. }
  4867. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4868. // That means, if the mutation is applied within a transaction with an isolation level such
  4869. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4870. // or updated by the mutation.
  4871. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  4872. switch {
  4873. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4874. id, exists := m.ID()
  4875. if exists {
  4876. return []uint64{id}, nil
  4877. }
  4878. fallthrough
  4879. case m.op.Is(OpUpdate | OpDelete):
  4880. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  4881. default:
  4882. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4883. }
  4884. }
  4885. // SetCreatedAt sets the "created_at" field.
  4886. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  4887. m.created_at = &t
  4888. }
  4889. // CreatedAt returns the value of the "created_at" field in the mutation.
  4890. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  4891. v := m.created_at
  4892. if v == nil {
  4893. return
  4894. }
  4895. return *v, true
  4896. }
  4897. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  4898. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4900. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4901. if !m.op.Is(OpUpdateOne) {
  4902. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4903. }
  4904. if m.id == nil || m.oldValue == nil {
  4905. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4906. }
  4907. oldValue, err := m.oldValue(ctx)
  4908. if err != nil {
  4909. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4910. }
  4911. return oldValue.CreatedAt, nil
  4912. }
  4913. // ResetCreatedAt resets all changes to the "created_at" field.
  4914. func (m *AllocAgentMutation) ResetCreatedAt() {
  4915. m.created_at = nil
  4916. }
  4917. // SetUpdatedAt sets the "updated_at" field.
  4918. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  4919. m.updated_at = &t
  4920. }
  4921. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4922. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  4923. v := m.updated_at
  4924. if v == nil {
  4925. return
  4926. }
  4927. return *v, true
  4928. }
  4929. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  4930. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4932. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4933. if !m.op.Is(OpUpdateOne) {
  4934. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4935. }
  4936. if m.id == nil || m.oldValue == nil {
  4937. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4938. }
  4939. oldValue, err := m.oldValue(ctx)
  4940. if err != nil {
  4941. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4942. }
  4943. return oldValue.UpdatedAt, nil
  4944. }
  4945. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4946. func (m *AllocAgentMutation) ResetUpdatedAt() {
  4947. m.updated_at = nil
  4948. }
  4949. // SetDeletedAt sets the "deleted_at" field.
  4950. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  4951. m.deleted_at = &t
  4952. }
  4953. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4954. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  4955. v := m.deleted_at
  4956. if v == nil {
  4957. return
  4958. }
  4959. return *v, true
  4960. }
  4961. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  4962. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4964. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4965. if !m.op.Is(OpUpdateOne) {
  4966. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4967. }
  4968. if m.id == nil || m.oldValue == nil {
  4969. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4970. }
  4971. oldValue, err := m.oldValue(ctx)
  4972. if err != nil {
  4973. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4974. }
  4975. return oldValue.DeletedAt, nil
  4976. }
  4977. // ClearDeletedAt clears the value of the "deleted_at" field.
  4978. func (m *AllocAgentMutation) ClearDeletedAt() {
  4979. m.deleted_at = nil
  4980. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  4981. }
  4982. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4983. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  4984. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  4985. return ok
  4986. }
  4987. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4988. func (m *AllocAgentMutation) ResetDeletedAt() {
  4989. m.deleted_at = nil
  4990. delete(m.clearedFields, allocagent.FieldDeletedAt)
  4991. }
  4992. // SetUserID sets the "user_id" field.
  4993. func (m *AllocAgentMutation) SetUserID(s string) {
  4994. m.user_id = &s
  4995. }
  4996. // UserID returns the value of the "user_id" field in the mutation.
  4997. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  4998. v := m.user_id
  4999. if v == nil {
  5000. return
  5001. }
  5002. return *v, true
  5003. }
  5004. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  5005. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5007. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  5008. if !m.op.Is(OpUpdateOne) {
  5009. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5010. }
  5011. if m.id == nil || m.oldValue == nil {
  5012. return v, errors.New("OldUserID requires an ID field in the mutation")
  5013. }
  5014. oldValue, err := m.oldValue(ctx)
  5015. if err != nil {
  5016. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5017. }
  5018. return oldValue.UserID, nil
  5019. }
  5020. // ClearUserID clears the value of the "user_id" field.
  5021. func (m *AllocAgentMutation) ClearUserID() {
  5022. m.user_id = nil
  5023. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  5024. }
  5025. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  5026. func (m *AllocAgentMutation) UserIDCleared() bool {
  5027. _, ok := m.clearedFields[allocagent.FieldUserID]
  5028. return ok
  5029. }
  5030. // ResetUserID resets all changes to the "user_id" field.
  5031. func (m *AllocAgentMutation) ResetUserID() {
  5032. m.user_id = nil
  5033. delete(m.clearedFields, allocagent.FieldUserID)
  5034. }
  5035. // SetOrganizationID sets the "organization_id" field.
  5036. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  5037. m.organization_id = &u
  5038. m.addorganization_id = nil
  5039. }
  5040. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5041. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  5042. v := m.organization_id
  5043. if v == nil {
  5044. return
  5045. }
  5046. return *v, true
  5047. }
  5048. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  5049. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5051. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5052. if !m.op.Is(OpUpdateOne) {
  5053. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5054. }
  5055. if m.id == nil || m.oldValue == nil {
  5056. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5057. }
  5058. oldValue, err := m.oldValue(ctx)
  5059. if err != nil {
  5060. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5061. }
  5062. return oldValue.OrganizationID, nil
  5063. }
  5064. // AddOrganizationID adds u to the "organization_id" field.
  5065. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  5066. if m.addorganization_id != nil {
  5067. *m.addorganization_id += u
  5068. } else {
  5069. m.addorganization_id = &u
  5070. }
  5071. }
  5072. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5073. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  5074. v := m.addorganization_id
  5075. if v == nil {
  5076. return
  5077. }
  5078. return *v, true
  5079. }
  5080. // ClearOrganizationID clears the value of the "organization_id" field.
  5081. func (m *AllocAgentMutation) ClearOrganizationID() {
  5082. m.organization_id = nil
  5083. m.addorganization_id = nil
  5084. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  5085. }
  5086. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5087. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  5088. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  5089. return ok
  5090. }
  5091. // ResetOrganizationID resets all changes to the "organization_id" field.
  5092. func (m *AllocAgentMutation) ResetOrganizationID() {
  5093. m.organization_id = nil
  5094. m.addorganization_id = nil
  5095. delete(m.clearedFields, allocagent.FieldOrganizationID)
  5096. }
  5097. // SetAgents sets the "agents" field.
  5098. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  5099. m.agents = &u
  5100. m.appendagents = nil
  5101. }
  5102. // Agents returns the value of the "agents" field in the mutation.
  5103. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  5104. v := m.agents
  5105. if v == nil {
  5106. return
  5107. }
  5108. return *v, true
  5109. }
  5110. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  5111. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5113. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  5114. if !m.op.Is(OpUpdateOne) {
  5115. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  5116. }
  5117. if m.id == nil || m.oldValue == nil {
  5118. return v, errors.New("OldAgents requires an ID field in the mutation")
  5119. }
  5120. oldValue, err := m.oldValue(ctx)
  5121. if err != nil {
  5122. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  5123. }
  5124. return oldValue.Agents, nil
  5125. }
  5126. // AppendAgents adds u to the "agents" field.
  5127. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  5128. m.appendagents = append(m.appendagents, u...)
  5129. }
  5130. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  5131. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  5132. if len(m.appendagents) == 0 {
  5133. return nil, false
  5134. }
  5135. return m.appendagents, true
  5136. }
  5137. // ResetAgents resets all changes to the "agents" field.
  5138. func (m *AllocAgentMutation) ResetAgents() {
  5139. m.agents = nil
  5140. m.appendagents = nil
  5141. }
  5142. // SetStatus sets the "status" field.
  5143. func (m *AllocAgentMutation) SetStatus(i int) {
  5144. m.status = &i
  5145. m.addstatus = nil
  5146. }
  5147. // Status returns the value of the "status" field in the mutation.
  5148. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  5149. v := m.status
  5150. if v == nil {
  5151. return
  5152. }
  5153. return *v, true
  5154. }
  5155. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  5156. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5158. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  5159. if !m.op.Is(OpUpdateOne) {
  5160. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5161. }
  5162. if m.id == nil || m.oldValue == nil {
  5163. return v, errors.New("OldStatus requires an ID field in the mutation")
  5164. }
  5165. oldValue, err := m.oldValue(ctx)
  5166. if err != nil {
  5167. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5168. }
  5169. return oldValue.Status, nil
  5170. }
  5171. // AddStatus adds i to the "status" field.
  5172. func (m *AllocAgentMutation) AddStatus(i int) {
  5173. if m.addstatus != nil {
  5174. *m.addstatus += i
  5175. } else {
  5176. m.addstatus = &i
  5177. }
  5178. }
  5179. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5180. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  5181. v := m.addstatus
  5182. if v == nil {
  5183. return
  5184. }
  5185. return *v, true
  5186. }
  5187. // ClearStatus clears the value of the "status" field.
  5188. func (m *AllocAgentMutation) ClearStatus() {
  5189. m.status = nil
  5190. m.addstatus = nil
  5191. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  5192. }
  5193. // StatusCleared returns if the "status" field was cleared in this mutation.
  5194. func (m *AllocAgentMutation) StatusCleared() bool {
  5195. _, ok := m.clearedFields[allocagent.FieldStatus]
  5196. return ok
  5197. }
  5198. // ResetStatus resets all changes to the "status" field.
  5199. func (m *AllocAgentMutation) ResetStatus() {
  5200. m.status = nil
  5201. m.addstatus = nil
  5202. delete(m.clearedFields, allocagent.FieldStatus)
  5203. }
  5204. // Where appends a list predicates to the AllocAgentMutation builder.
  5205. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  5206. m.predicates = append(m.predicates, ps...)
  5207. }
  5208. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  5209. // users can use type-assertion to append predicates that do not depend on any generated package.
  5210. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  5211. p := make([]predicate.AllocAgent, len(ps))
  5212. for i := range ps {
  5213. p[i] = ps[i]
  5214. }
  5215. m.Where(p...)
  5216. }
  5217. // Op returns the operation name.
  5218. func (m *AllocAgentMutation) Op() Op {
  5219. return m.op
  5220. }
  5221. // SetOp allows setting the mutation operation.
  5222. func (m *AllocAgentMutation) SetOp(op Op) {
  5223. m.op = op
  5224. }
  5225. // Type returns the node type of this mutation (AllocAgent).
  5226. func (m *AllocAgentMutation) Type() string {
  5227. return m.typ
  5228. }
  5229. // Fields returns all fields that were changed during this mutation. Note that in
  5230. // order to get all numeric fields that were incremented/decremented, call
  5231. // AddedFields().
  5232. func (m *AllocAgentMutation) Fields() []string {
  5233. fields := make([]string, 0, 7)
  5234. if m.created_at != nil {
  5235. fields = append(fields, allocagent.FieldCreatedAt)
  5236. }
  5237. if m.updated_at != nil {
  5238. fields = append(fields, allocagent.FieldUpdatedAt)
  5239. }
  5240. if m.deleted_at != nil {
  5241. fields = append(fields, allocagent.FieldDeletedAt)
  5242. }
  5243. if m.user_id != nil {
  5244. fields = append(fields, allocagent.FieldUserID)
  5245. }
  5246. if m.organization_id != nil {
  5247. fields = append(fields, allocagent.FieldOrganizationID)
  5248. }
  5249. if m.agents != nil {
  5250. fields = append(fields, allocagent.FieldAgents)
  5251. }
  5252. if m.status != nil {
  5253. fields = append(fields, allocagent.FieldStatus)
  5254. }
  5255. return fields
  5256. }
  5257. // Field returns the value of a field with the given name. The second boolean
  5258. // return value indicates that this field was not set, or was not defined in the
  5259. // schema.
  5260. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  5261. switch name {
  5262. case allocagent.FieldCreatedAt:
  5263. return m.CreatedAt()
  5264. case allocagent.FieldUpdatedAt:
  5265. return m.UpdatedAt()
  5266. case allocagent.FieldDeletedAt:
  5267. return m.DeletedAt()
  5268. case allocagent.FieldUserID:
  5269. return m.UserID()
  5270. case allocagent.FieldOrganizationID:
  5271. return m.OrganizationID()
  5272. case allocagent.FieldAgents:
  5273. return m.Agents()
  5274. case allocagent.FieldStatus:
  5275. return m.Status()
  5276. }
  5277. return nil, false
  5278. }
  5279. // OldField returns the old value of the field from the database. An error is
  5280. // returned if the mutation operation is not UpdateOne, or the query to the
  5281. // database failed.
  5282. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5283. switch name {
  5284. case allocagent.FieldCreatedAt:
  5285. return m.OldCreatedAt(ctx)
  5286. case allocagent.FieldUpdatedAt:
  5287. return m.OldUpdatedAt(ctx)
  5288. case allocagent.FieldDeletedAt:
  5289. return m.OldDeletedAt(ctx)
  5290. case allocagent.FieldUserID:
  5291. return m.OldUserID(ctx)
  5292. case allocagent.FieldOrganizationID:
  5293. return m.OldOrganizationID(ctx)
  5294. case allocagent.FieldAgents:
  5295. return m.OldAgents(ctx)
  5296. case allocagent.FieldStatus:
  5297. return m.OldStatus(ctx)
  5298. }
  5299. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  5300. }
  5301. // SetField sets the value of a field with the given name. It returns an error if
  5302. // the field is not defined in the schema, or if the type mismatched the field
  5303. // type.
  5304. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  5305. switch name {
  5306. case allocagent.FieldCreatedAt:
  5307. v, ok := value.(time.Time)
  5308. if !ok {
  5309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5310. }
  5311. m.SetCreatedAt(v)
  5312. return nil
  5313. case allocagent.FieldUpdatedAt:
  5314. v, ok := value.(time.Time)
  5315. if !ok {
  5316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5317. }
  5318. m.SetUpdatedAt(v)
  5319. return nil
  5320. case allocagent.FieldDeletedAt:
  5321. v, ok := value.(time.Time)
  5322. if !ok {
  5323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5324. }
  5325. m.SetDeletedAt(v)
  5326. return nil
  5327. case allocagent.FieldUserID:
  5328. v, ok := value.(string)
  5329. if !ok {
  5330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5331. }
  5332. m.SetUserID(v)
  5333. return nil
  5334. case allocagent.FieldOrganizationID:
  5335. v, ok := value.(uint64)
  5336. if !ok {
  5337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5338. }
  5339. m.SetOrganizationID(v)
  5340. return nil
  5341. case allocagent.FieldAgents:
  5342. v, ok := value.([]uint64)
  5343. if !ok {
  5344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5345. }
  5346. m.SetAgents(v)
  5347. return nil
  5348. case allocagent.FieldStatus:
  5349. v, ok := value.(int)
  5350. if !ok {
  5351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5352. }
  5353. m.SetStatus(v)
  5354. return nil
  5355. }
  5356. return fmt.Errorf("unknown AllocAgent field %s", name)
  5357. }
  5358. // AddedFields returns all numeric fields that were incremented/decremented during
  5359. // this mutation.
  5360. func (m *AllocAgentMutation) AddedFields() []string {
  5361. var fields []string
  5362. if m.addorganization_id != nil {
  5363. fields = append(fields, allocagent.FieldOrganizationID)
  5364. }
  5365. if m.addstatus != nil {
  5366. fields = append(fields, allocagent.FieldStatus)
  5367. }
  5368. return fields
  5369. }
  5370. // AddedField returns the numeric value that was incremented/decremented on a field
  5371. // with the given name. The second boolean return value indicates that this field
  5372. // was not set, or was not defined in the schema.
  5373. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  5374. switch name {
  5375. case allocagent.FieldOrganizationID:
  5376. return m.AddedOrganizationID()
  5377. case allocagent.FieldStatus:
  5378. return m.AddedStatus()
  5379. }
  5380. return nil, false
  5381. }
  5382. // AddField adds the value to the field with the given name. It returns an error if
  5383. // the field is not defined in the schema, or if the type mismatched the field
  5384. // type.
  5385. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  5386. switch name {
  5387. case allocagent.FieldOrganizationID:
  5388. v, ok := value.(int64)
  5389. if !ok {
  5390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5391. }
  5392. m.AddOrganizationID(v)
  5393. return nil
  5394. case allocagent.FieldStatus:
  5395. v, ok := value.(int)
  5396. if !ok {
  5397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5398. }
  5399. m.AddStatus(v)
  5400. return nil
  5401. }
  5402. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  5403. }
  5404. // ClearedFields returns all nullable fields that were cleared during this
  5405. // mutation.
  5406. func (m *AllocAgentMutation) ClearedFields() []string {
  5407. var fields []string
  5408. if m.FieldCleared(allocagent.FieldDeletedAt) {
  5409. fields = append(fields, allocagent.FieldDeletedAt)
  5410. }
  5411. if m.FieldCleared(allocagent.FieldUserID) {
  5412. fields = append(fields, allocagent.FieldUserID)
  5413. }
  5414. if m.FieldCleared(allocagent.FieldOrganizationID) {
  5415. fields = append(fields, allocagent.FieldOrganizationID)
  5416. }
  5417. if m.FieldCleared(allocagent.FieldStatus) {
  5418. fields = append(fields, allocagent.FieldStatus)
  5419. }
  5420. return fields
  5421. }
  5422. // FieldCleared returns a boolean indicating if a field with the given name was
  5423. // cleared in this mutation.
  5424. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  5425. _, ok := m.clearedFields[name]
  5426. return ok
  5427. }
  5428. // ClearField clears the value of the field with the given name. It returns an
  5429. // error if the field is not defined in the schema.
  5430. func (m *AllocAgentMutation) ClearField(name string) error {
  5431. switch name {
  5432. case allocagent.FieldDeletedAt:
  5433. m.ClearDeletedAt()
  5434. return nil
  5435. case allocagent.FieldUserID:
  5436. m.ClearUserID()
  5437. return nil
  5438. case allocagent.FieldOrganizationID:
  5439. m.ClearOrganizationID()
  5440. return nil
  5441. case allocagent.FieldStatus:
  5442. m.ClearStatus()
  5443. return nil
  5444. }
  5445. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  5446. }
  5447. // ResetField resets all changes in the mutation for the field with the given name.
  5448. // It returns an error if the field is not defined in the schema.
  5449. func (m *AllocAgentMutation) ResetField(name string) error {
  5450. switch name {
  5451. case allocagent.FieldCreatedAt:
  5452. m.ResetCreatedAt()
  5453. return nil
  5454. case allocagent.FieldUpdatedAt:
  5455. m.ResetUpdatedAt()
  5456. return nil
  5457. case allocagent.FieldDeletedAt:
  5458. m.ResetDeletedAt()
  5459. return nil
  5460. case allocagent.FieldUserID:
  5461. m.ResetUserID()
  5462. return nil
  5463. case allocagent.FieldOrganizationID:
  5464. m.ResetOrganizationID()
  5465. return nil
  5466. case allocagent.FieldAgents:
  5467. m.ResetAgents()
  5468. return nil
  5469. case allocagent.FieldStatus:
  5470. m.ResetStatus()
  5471. return nil
  5472. }
  5473. return fmt.Errorf("unknown AllocAgent field %s", name)
  5474. }
  5475. // AddedEdges returns all edge names that were set/added in this mutation.
  5476. func (m *AllocAgentMutation) AddedEdges() []string {
  5477. edges := make([]string, 0, 0)
  5478. return edges
  5479. }
  5480. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5481. // name in this mutation.
  5482. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  5483. return nil
  5484. }
  5485. // RemovedEdges returns all edge names that were removed in this mutation.
  5486. func (m *AllocAgentMutation) RemovedEdges() []string {
  5487. edges := make([]string, 0, 0)
  5488. return edges
  5489. }
  5490. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5491. // the given name in this mutation.
  5492. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  5493. return nil
  5494. }
  5495. // ClearedEdges returns all edge names that were cleared in this mutation.
  5496. func (m *AllocAgentMutation) ClearedEdges() []string {
  5497. edges := make([]string, 0, 0)
  5498. return edges
  5499. }
  5500. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5501. // was cleared in this mutation.
  5502. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  5503. return false
  5504. }
  5505. // ClearEdge clears the value of the edge with the given name. It returns an error
  5506. // if that edge is not defined in the schema.
  5507. func (m *AllocAgentMutation) ClearEdge(name string) error {
  5508. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  5509. }
  5510. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5511. // It returns an error if the edge is not defined in the schema.
  5512. func (m *AllocAgentMutation) ResetEdge(name string) error {
  5513. return fmt.Errorf("unknown AllocAgent edge %s", name)
  5514. }
  5515. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  5516. type ApiKeyMutation struct {
  5517. config
  5518. op Op
  5519. typ string
  5520. id *uint64
  5521. created_at *time.Time
  5522. updated_at *time.Time
  5523. deleted_at *time.Time
  5524. title *string
  5525. key *string
  5526. organization_id *uint64
  5527. addorganization_id *int64
  5528. custom_agent_base *string
  5529. custom_agent_key *string
  5530. openai_base *string
  5531. openai_key *string
  5532. clearedFields map[string]struct{}
  5533. agent *uint64
  5534. clearedagent bool
  5535. done bool
  5536. oldValue func(context.Context) (*ApiKey, error)
  5537. predicates []predicate.ApiKey
  5538. }
  5539. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  5540. // apikeyOption allows management of the mutation configuration using functional options.
  5541. type apikeyOption func(*ApiKeyMutation)
  5542. // newApiKeyMutation creates new mutation for the ApiKey entity.
  5543. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  5544. m := &ApiKeyMutation{
  5545. config: c,
  5546. op: op,
  5547. typ: TypeApiKey,
  5548. clearedFields: make(map[string]struct{}),
  5549. }
  5550. for _, opt := range opts {
  5551. opt(m)
  5552. }
  5553. return m
  5554. }
  5555. // withApiKeyID sets the ID field of the mutation.
  5556. func withApiKeyID(id uint64) apikeyOption {
  5557. return func(m *ApiKeyMutation) {
  5558. var (
  5559. err error
  5560. once sync.Once
  5561. value *ApiKey
  5562. )
  5563. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  5564. once.Do(func() {
  5565. if m.done {
  5566. err = errors.New("querying old values post mutation is not allowed")
  5567. } else {
  5568. value, err = m.Client().ApiKey.Get(ctx, id)
  5569. }
  5570. })
  5571. return value, err
  5572. }
  5573. m.id = &id
  5574. }
  5575. }
  5576. // withApiKey sets the old ApiKey of the mutation.
  5577. func withApiKey(node *ApiKey) apikeyOption {
  5578. return func(m *ApiKeyMutation) {
  5579. m.oldValue = func(context.Context) (*ApiKey, error) {
  5580. return node, nil
  5581. }
  5582. m.id = &node.ID
  5583. }
  5584. }
  5585. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5586. // executed in a transaction (ent.Tx), a transactional client is returned.
  5587. func (m ApiKeyMutation) Client() *Client {
  5588. client := &Client{config: m.config}
  5589. client.init()
  5590. return client
  5591. }
  5592. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5593. // it returns an error otherwise.
  5594. func (m ApiKeyMutation) Tx() (*Tx, error) {
  5595. if _, ok := m.driver.(*txDriver); !ok {
  5596. return nil, errors.New("ent: mutation is not running in a transaction")
  5597. }
  5598. tx := &Tx{config: m.config}
  5599. tx.init()
  5600. return tx, nil
  5601. }
  5602. // SetID sets the value of the id field. Note that this
  5603. // operation is only accepted on creation of ApiKey entities.
  5604. func (m *ApiKeyMutation) SetID(id uint64) {
  5605. m.id = &id
  5606. }
  5607. // ID returns the ID value in the mutation. Note that the ID is only available
  5608. // if it was provided to the builder or after it was returned from the database.
  5609. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  5610. if m.id == nil {
  5611. return
  5612. }
  5613. return *m.id, true
  5614. }
  5615. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5616. // That means, if the mutation is applied within a transaction with an isolation level such
  5617. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5618. // or updated by the mutation.
  5619. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  5620. switch {
  5621. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5622. id, exists := m.ID()
  5623. if exists {
  5624. return []uint64{id}, nil
  5625. }
  5626. fallthrough
  5627. case m.op.Is(OpUpdate | OpDelete):
  5628. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  5629. default:
  5630. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5631. }
  5632. }
  5633. // SetCreatedAt sets the "created_at" field.
  5634. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  5635. m.created_at = &t
  5636. }
  5637. // CreatedAt returns the value of the "created_at" field in the mutation.
  5638. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  5639. v := m.created_at
  5640. if v == nil {
  5641. return
  5642. }
  5643. return *v, true
  5644. }
  5645. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  5646. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5648. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5649. if !m.op.Is(OpUpdateOne) {
  5650. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5651. }
  5652. if m.id == nil || m.oldValue == nil {
  5653. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5654. }
  5655. oldValue, err := m.oldValue(ctx)
  5656. if err != nil {
  5657. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5658. }
  5659. return oldValue.CreatedAt, nil
  5660. }
  5661. // ResetCreatedAt resets all changes to the "created_at" field.
  5662. func (m *ApiKeyMutation) ResetCreatedAt() {
  5663. m.created_at = nil
  5664. }
  5665. // SetUpdatedAt sets the "updated_at" field.
  5666. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  5667. m.updated_at = &t
  5668. }
  5669. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5670. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  5671. v := m.updated_at
  5672. if v == nil {
  5673. return
  5674. }
  5675. return *v, true
  5676. }
  5677. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  5678. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5680. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5681. if !m.op.Is(OpUpdateOne) {
  5682. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5683. }
  5684. if m.id == nil || m.oldValue == nil {
  5685. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5686. }
  5687. oldValue, err := m.oldValue(ctx)
  5688. if err != nil {
  5689. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5690. }
  5691. return oldValue.UpdatedAt, nil
  5692. }
  5693. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5694. func (m *ApiKeyMutation) ResetUpdatedAt() {
  5695. m.updated_at = nil
  5696. }
  5697. // SetDeletedAt sets the "deleted_at" field.
  5698. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  5699. m.deleted_at = &t
  5700. }
  5701. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5702. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  5703. v := m.deleted_at
  5704. if v == nil {
  5705. return
  5706. }
  5707. return *v, true
  5708. }
  5709. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  5710. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5712. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5713. if !m.op.Is(OpUpdateOne) {
  5714. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5715. }
  5716. if m.id == nil || m.oldValue == nil {
  5717. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5718. }
  5719. oldValue, err := m.oldValue(ctx)
  5720. if err != nil {
  5721. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5722. }
  5723. return oldValue.DeletedAt, nil
  5724. }
  5725. // ClearDeletedAt clears the value of the "deleted_at" field.
  5726. func (m *ApiKeyMutation) ClearDeletedAt() {
  5727. m.deleted_at = nil
  5728. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  5729. }
  5730. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5731. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  5732. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  5733. return ok
  5734. }
  5735. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5736. func (m *ApiKeyMutation) ResetDeletedAt() {
  5737. m.deleted_at = nil
  5738. delete(m.clearedFields, apikey.FieldDeletedAt)
  5739. }
  5740. // SetTitle sets the "title" field.
  5741. func (m *ApiKeyMutation) SetTitle(s string) {
  5742. m.title = &s
  5743. }
  5744. // Title returns the value of the "title" field in the mutation.
  5745. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  5746. v := m.title
  5747. if v == nil {
  5748. return
  5749. }
  5750. return *v, true
  5751. }
  5752. // OldTitle returns the old "title" field's value of the ApiKey entity.
  5753. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5755. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  5756. if !m.op.Is(OpUpdateOne) {
  5757. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5758. }
  5759. if m.id == nil || m.oldValue == nil {
  5760. return v, errors.New("OldTitle requires an ID field in the mutation")
  5761. }
  5762. oldValue, err := m.oldValue(ctx)
  5763. if err != nil {
  5764. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5765. }
  5766. return oldValue.Title, nil
  5767. }
  5768. // ClearTitle clears the value of the "title" field.
  5769. func (m *ApiKeyMutation) ClearTitle() {
  5770. m.title = nil
  5771. m.clearedFields[apikey.FieldTitle] = struct{}{}
  5772. }
  5773. // TitleCleared returns if the "title" field was cleared in this mutation.
  5774. func (m *ApiKeyMutation) TitleCleared() bool {
  5775. _, ok := m.clearedFields[apikey.FieldTitle]
  5776. return ok
  5777. }
  5778. // ResetTitle resets all changes to the "title" field.
  5779. func (m *ApiKeyMutation) ResetTitle() {
  5780. m.title = nil
  5781. delete(m.clearedFields, apikey.FieldTitle)
  5782. }
  5783. // SetKey sets the "key" field.
  5784. func (m *ApiKeyMutation) SetKey(s string) {
  5785. m.key = &s
  5786. }
  5787. // Key returns the value of the "key" field in the mutation.
  5788. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  5789. v := m.key
  5790. if v == nil {
  5791. return
  5792. }
  5793. return *v, true
  5794. }
  5795. // OldKey returns the old "key" field's value of the ApiKey entity.
  5796. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5798. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  5799. if !m.op.Is(OpUpdateOne) {
  5800. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  5801. }
  5802. if m.id == nil || m.oldValue == nil {
  5803. return v, errors.New("OldKey requires an ID field in the mutation")
  5804. }
  5805. oldValue, err := m.oldValue(ctx)
  5806. if err != nil {
  5807. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  5808. }
  5809. return oldValue.Key, nil
  5810. }
  5811. // ClearKey clears the value of the "key" field.
  5812. func (m *ApiKeyMutation) ClearKey() {
  5813. m.key = nil
  5814. m.clearedFields[apikey.FieldKey] = struct{}{}
  5815. }
  5816. // KeyCleared returns if the "key" field was cleared in this mutation.
  5817. func (m *ApiKeyMutation) KeyCleared() bool {
  5818. _, ok := m.clearedFields[apikey.FieldKey]
  5819. return ok
  5820. }
  5821. // ResetKey resets all changes to the "key" field.
  5822. func (m *ApiKeyMutation) ResetKey() {
  5823. m.key = nil
  5824. delete(m.clearedFields, apikey.FieldKey)
  5825. }
  5826. // SetOrganizationID sets the "organization_id" field.
  5827. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  5828. m.organization_id = &u
  5829. m.addorganization_id = nil
  5830. }
  5831. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5832. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  5833. v := m.organization_id
  5834. if v == nil {
  5835. return
  5836. }
  5837. return *v, true
  5838. }
  5839. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  5840. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5842. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5843. if !m.op.Is(OpUpdateOne) {
  5844. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5845. }
  5846. if m.id == nil || m.oldValue == nil {
  5847. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5848. }
  5849. oldValue, err := m.oldValue(ctx)
  5850. if err != nil {
  5851. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5852. }
  5853. return oldValue.OrganizationID, nil
  5854. }
  5855. // AddOrganizationID adds u to the "organization_id" field.
  5856. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  5857. if m.addorganization_id != nil {
  5858. *m.addorganization_id += u
  5859. } else {
  5860. m.addorganization_id = &u
  5861. }
  5862. }
  5863. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5864. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  5865. v := m.addorganization_id
  5866. if v == nil {
  5867. return
  5868. }
  5869. return *v, true
  5870. }
  5871. // ResetOrganizationID resets all changes to the "organization_id" field.
  5872. func (m *ApiKeyMutation) ResetOrganizationID() {
  5873. m.organization_id = nil
  5874. m.addorganization_id = nil
  5875. }
  5876. // SetAgentID sets the "agent_id" field.
  5877. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  5878. m.agent = &u
  5879. }
  5880. // AgentID returns the value of the "agent_id" field in the mutation.
  5881. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  5882. v := m.agent
  5883. if v == nil {
  5884. return
  5885. }
  5886. return *v, true
  5887. }
  5888. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  5889. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5891. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  5892. if !m.op.Is(OpUpdateOne) {
  5893. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  5894. }
  5895. if m.id == nil || m.oldValue == nil {
  5896. return v, errors.New("OldAgentID requires an ID field in the mutation")
  5897. }
  5898. oldValue, err := m.oldValue(ctx)
  5899. if err != nil {
  5900. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  5901. }
  5902. return oldValue.AgentID, nil
  5903. }
  5904. // ResetAgentID resets all changes to the "agent_id" field.
  5905. func (m *ApiKeyMutation) ResetAgentID() {
  5906. m.agent = nil
  5907. }
  5908. // SetCustomAgentBase sets the "custom_agent_base" field.
  5909. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  5910. m.custom_agent_base = &s
  5911. }
  5912. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  5913. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  5914. v := m.custom_agent_base
  5915. if v == nil {
  5916. return
  5917. }
  5918. return *v, true
  5919. }
  5920. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  5921. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5923. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  5924. if !m.op.Is(OpUpdateOne) {
  5925. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  5926. }
  5927. if m.id == nil || m.oldValue == nil {
  5928. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  5929. }
  5930. oldValue, err := m.oldValue(ctx)
  5931. if err != nil {
  5932. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  5933. }
  5934. return oldValue.CustomAgentBase, nil
  5935. }
  5936. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  5937. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  5938. m.custom_agent_base = nil
  5939. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  5940. }
  5941. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  5942. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  5943. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  5944. return ok
  5945. }
  5946. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  5947. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  5948. m.custom_agent_base = nil
  5949. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  5950. }
  5951. // SetCustomAgentKey sets the "custom_agent_key" field.
  5952. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  5953. m.custom_agent_key = &s
  5954. }
  5955. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  5956. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  5957. v := m.custom_agent_key
  5958. if v == nil {
  5959. return
  5960. }
  5961. return *v, true
  5962. }
  5963. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  5964. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5966. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  5967. if !m.op.Is(OpUpdateOne) {
  5968. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  5969. }
  5970. if m.id == nil || m.oldValue == nil {
  5971. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  5972. }
  5973. oldValue, err := m.oldValue(ctx)
  5974. if err != nil {
  5975. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  5976. }
  5977. return oldValue.CustomAgentKey, nil
  5978. }
  5979. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  5980. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  5981. m.custom_agent_key = nil
  5982. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  5983. }
  5984. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  5985. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  5986. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  5987. return ok
  5988. }
  5989. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  5990. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  5991. m.custom_agent_key = nil
  5992. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  5993. }
  5994. // SetOpenaiBase sets the "openai_base" field.
  5995. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  5996. m.openai_base = &s
  5997. }
  5998. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  5999. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  6000. v := m.openai_base
  6001. if v == nil {
  6002. return
  6003. }
  6004. return *v, true
  6005. }
  6006. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  6007. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6009. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  6010. if !m.op.Is(OpUpdateOne) {
  6011. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  6012. }
  6013. if m.id == nil || m.oldValue == nil {
  6014. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  6015. }
  6016. oldValue, err := m.oldValue(ctx)
  6017. if err != nil {
  6018. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  6019. }
  6020. return oldValue.OpenaiBase, nil
  6021. }
  6022. // ClearOpenaiBase clears the value of the "openai_base" field.
  6023. func (m *ApiKeyMutation) ClearOpenaiBase() {
  6024. m.openai_base = nil
  6025. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  6026. }
  6027. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  6028. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  6029. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  6030. return ok
  6031. }
  6032. // ResetOpenaiBase resets all changes to the "openai_base" field.
  6033. func (m *ApiKeyMutation) ResetOpenaiBase() {
  6034. m.openai_base = nil
  6035. delete(m.clearedFields, apikey.FieldOpenaiBase)
  6036. }
  6037. // SetOpenaiKey sets the "openai_key" field.
  6038. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  6039. m.openai_key = &s
  6040. }
  6041. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  6042. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  6043. v := m.openai_key
  6044. if v == nil {
  6045. return
  6046. }
  6047. return *v, true
  6048. }
  6049. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  6050. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6052. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  6053. if !m.op.Is(OpUpdateOne) {
  6054. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  6055. }
  6056. if m.id == nil || m.oldValue == nil {
  6057. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  6058. }
  6059. oldValue, err := m.oldValue(ctx)
  6060. if err != nil {
  6061. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  6062. }
  6063. return oldValue.OpenaiKey, nil
  6064. }
  6065. // ClearOpenaiKey clears the value of the "openai_key" field.
  6066. func (m *ApiKeyMutation) ClearOpenaiKey() {
  6067. m.openai_key = nil
  6068. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  6069. }
  6070. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  6071. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  6072. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  6073. return ok
  6074. }
  6075. // ResetOpenaiKey resets all changes to the "openai_key" field.
  6076. func (m *ApiKeyMutation) ResetOpenaiKey() {
  6077. m.openai_key = nil
  6078. delete(m.clearedFields, apikey.FieldOpenaiKey)
  6079. }
  6080. // ClearAgent clears the "agent" edge to the Agent entity.
  6081. func (m *ApiKeyMutation) ClearAgent() {
  6082. m.clearedagent = true
  6083. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  6084. }
  6085. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  6086. func (m *ApiKeyMutation) AgentCleared() bool {
  6087. return m.clearedagent
  6088. }
  6089. // AgentIDs returns the "agent" edge IDs in the mutation.
  6090. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6091. // AgentID instead. It exists only for internal usage by the builders.
  6092. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  6093. if id := m.agent; id != nil {
  6094. ids = append(ids, *id)
  6095. }
  6096. return
  6097. }
  6098. // ResetAgent resets all changes to the "agent" edge.
  6099. func (m *ApiKeyMutation) ResetAgent() {
  6100. m.agent = nil
  6101. m.clearedagent = false
  6102. }
  6103. // Where appends a list predicates to the ApiKeyMutation builder.
  6104. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  6105. m.predicates = append(m.predicates, ps...)
  6106. }
  6107. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  6108. // users can use type-assertion to append predicates that do not depend on any generated package.
  6109. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  6110. p := make([]predicate.ApiKey, len(ps))
  6111. for i := range ps {
  6112. p[i] = ps[i]
  6113. }
  6114. m.Where(p...)
  6115. }
  6116. // Op returns the operation name.
  6117. func (m *ApiKeyMutation) Op() Op {
  6118. return m.op
  6119. }
  6120. // SetOp allows setting the mutation operation.
  6121. func (m *ApiKeyMutation) SetOp(op Op) {
  6122. m.op = op
  6123. }
  6124. // Type returns the node type of this mutation (ApiKey).
  6125. func (m *ApiKeyMutation) Type() string {
  6126. return m.typ
  6127. }
  6128. // Fields returns all fields that were changed during this mutation. Note that in
  6129. // order to get all numeric fields that were incremented/decremented, call
  6130. // AddedFields().
  6131. func (m *ApiKeyMutation) Fields() []string {
  6132. fields := make([]string, 0, 11)
  6133. if m.created_at != nil {
  6134. fields = append(fields, apikey.FieldCreatedAt)
  6135. }
  6136. if m.updated_at != nil {
  6137. fields = append(fields, apikey.FieldUpdatedAt)
  6138. }
  6139. if m.deleted_at != nil {
  6140. fields = append(fields, apikey.FieldDeletedAt)
  6141. }
  6142. if m.title != nil {
  6143. fields = append(fields, apikey.FieldTitle)
  6144. }
  6145. if m.key != nil {
  6146. fields = append(fields, apikey.FieldKey)
  6147. }
  6148. if m.organization_id != nil {
  6149. fields = append(fields, apikey.FieldOrganizationID)
  6150. }
  6151. if m.agent != nil {
  6152. fields = append(fields, apikey.FieldAgentID)
  6153. }
  6154. if m.custom_agent_base != nil {
  6155. fields = append(fields, apikey.FieldCustomAgentBase)
  6156. }
  6157. if m.custom_agent_key != nil {
  6158. fields = append(fields, apikey.FieldCustomAgentKey)
  6159. }
  6160. if m.openai_base != nil {
  6161. fields = append(fields, apikey.FieldOpenaiBase)
  6162. }
  6163. if m.openai_key != nil {
  6164. fields = append(fields, apikey.FieldOpenaiKey)
  6165. }
  6166. return fields
  6167. }
  6168. // Field returns the value of a field with the given name. The second boolean
  6169. // return value indicates that this field was not set, or was not defined in the
  6170. // schema.
  6171. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  6172. switch name {
  6173. case apikey.FieldCreatedAt:
  6174. return m.CreatedAt()
  6175. case apikey.FieldUpdatedAt:
  6176. return m.UpdatedAt()
  6177. case apikey.FieldDeletedAt:
  6178. return m.DeletedAt()
  6179. case apikey.FieldTitle:
  6180. return m.Title()
  6181. case apikey.FieldKey:
  6182. return m.Key()
  6183. case apikey.FieldOrganizationID:
  6184. return m.OrganizationID()
  6185. case apikey.FieldAgentID:
  6186. return m.AgentID()
  6187. case apikey.FieldCustomAgentBase:
  6188. return m.CustomAgentBase()
  6189. case apikey.FieldCustomAgentKey:
  6190. return m.CustomAgentKey()
  6191. case apikey.FieldOpenaiBase:
  6192. return m.OpenaiBase()
  6193. case apikey.FieldOpenaiKey:
  6194. return m.OpenaiKey()
  6195. }
  6196. return nil, false
  6197. }
  6198. // OldField returns the old value of the field from the database. An error is
  6199. // returned if the mutation operation is not UpdateOne, or the query to the
  6200. // database failed.
  6201. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6202. switch name {
  6203. case apikey.FieldCreatedAt:
  6204. return m.OldCreatedAt(ctx)
  6205. case apikey.FieldUpdatedAt:
  6206. return m.OldUpdatedAt(ctx)
  6207. case apikey.FieldDeletedAt:
  6208. return m.OldDeletedAt(ctx)
  6209. case apikey.FieldTitle:
  6210. return m.OldTitle(ctx)
  6211. case apikey.FieldKey:
  6212. return m.OldKey(ctx)
  6213. case apikey.FieldOrganizationID:
  6214. return m.OldOrganizationID(ctx)
  6215. case apikey.FieldAgentID:
  6216. return m.OldAgentID(ctx)
  6217. case apikey.FieldCustomAgentBase:
  6218. return m.OldCustomAgentBase(ctx)
  6219. case apikey.FieldCustomAgentKey:
  6220. return m.OldCustomAgentKey(ctx)
  6221. case apikey.FieldOpenaiBase:
  6222. return m.OldOpenaiBase(ctx)
  6223. case apikey.FieldOpenaiKey:
  6224. return m.OldOpenaiKey(ctx)
  6225. }
  6226. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  6227. }
  6228. // SetField sets the value of a field with the given name. It returns an error if
  6229. // the field is not defined in the schema, or if the type mismatched the field
  6230. // type.
  6231. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  6232. switch name {
  6233. case apikey.FieldCreatedAt:
  6234. v, ok := value.(time.Time)
  6235. if !ok {
  6236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6237. }
  6238. m.SetCreatedAt(v)
  6239. return nil
  6240. case apikey.FieldUpdatedAt:
  6241. v, ok := value.(time.Time)
  6242. if !ok {
  6243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6244. }
  6245. m.SetUpdatedAt(v)
  6246. return nil
  6247. case apikey.FieldDeletedAt:
  6248. v, ok := value.(time.Time)
  6249. if !ok {
  6250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6251. }
  6252. m.SetDeletedAt(v)
  6253. return nil
  6254. case apikey.FieldTitle:
  6255. v, ok := value.(string)
  6256. if !ok {
  6257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6258. }
  6259. m.SetTitle(v)
  6260. return nil
  6261. case apikey.FieldKey:
  6262. v, ok := value.(string)
  6263. if !ok {
  6264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6265. }
  6266. m.SetKey(v)
  6267. return nil
  6268. case apikey.FieldOrganizationID:
  6269. v, ok := value.(uint64)
  6270. if !ok {
  6271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6272. }
  6273. m.SetOrganizationID(v)
  6274. return nil
  6275. case apikey.FieldAgentID:
  6276. v, ok := value.(uint64)
  6277. if !ok {
  6278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6279. }
  6280. m.SetAgentID(v)
  6281. return nil
  6282. case apikey.FieldCustomAgentBase:
  6283. v, ok := value.(string)
  6284. if !ok {
  6285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6286. }
  6287. m.SetCustomAgentBase(v)
  6288. return nil
  6289. case apikey.FieldCustomAgentKey:
  6290. v, ok := value.(string)
  6291. if !ok {
  6292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6293. }
  6294. m.SetCustomAgentKey(v)
  6295. return nil
  6296. case apikey.FieldOpenaiBase:
  6297. v, ok := value.(string)
  6298. if !ok {
  6299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6300. }
  6301. m.SetOpenaiBase(v)
  6302. return nil
  6303. case apikey.FieldOpenaiKey:
  6304. v, ok := value.(string)
  6305. if !ok {
  6306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6307. }
  6308. m.SetOpenaiKey(v)
  6309. return nil
  6310. }
  6311. return fmt.Errorf("unknown ApiKey field %s", name)
  6312. }
  6313. // AddedFields returns all numeric fields that were incremented/decremented during
  6314. // this mutation.
  6315. func (m *ApiKeyMutation) AddedFields() []string {
  6316. var fields []string
  6317. if m.addorganization_id != nil {
  6318. fields = append(fields, apikey.FieldOrganizationID)
  6319. }
  6320. return fields
  6321. }
  6322. // AddedField returns the numeric value that was incremented/decremented on a field
  6323. // with the given name. The second boolean return value indicates that this field
  6324. // was not set, or was not defined in the schema.
  6325. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  6326. switch name {
  6327. case apikey.FieldOrganizationID:
  6328. return m.AddedOrganizationID()
  6329. }
  6330. return nil, false
  6331. }
  6332. // AddField adds the value to the field with the given name. It returns an error if
  6333. // the field is not defined in the schema, or if the type mismatched the field
  6334. // type.
  6335. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  6336. switch name {
  6337. case apikey.FieldOrganizationID:
  6338. v, ok := value.(int64)
  6339. if !ok {
  6340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6341. }
  6342. m.AddOrganizationID(v)
  6343. return nil
  6344. }
  6345. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  6346. }
  6347. // ClearedFields returns all nullable fields that were cleared during this
  6348. // mutation.
  6349. func (m *ApiKeyMutation) ClearedFields() []string {
  6350. var fields []string
  6351. if m.FieldCleared(apikey.FieldDeletedAt) {
  6352. fields = append(fields, apikey.FieldDeletedAt)
  6353. }
  6354. if m.FieldCleared(apikey.FieldTitle) {
  6355. fields = append(fields, apikey.FieldTitle)
  6356. }
  6357. if m.FieldCleared(apikey.FieldKey) {
  6358. fields = append(fields, apikey.FieldKey)
  6359. }
  6360. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  6361. fields = append(fields, apikey.FieldCustomAgentBase)
  6362. }
  6363. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  6364. fields = append(fields, apikey.FieldCustomAgentKey)
  6365. }
  6366. if m.FieldCleared(apikey.FieldOpenaiBase) {
  6367. fields = append(fields, apikey.FieldOpenaiBase)
  6368. }
  6369. if m.FieldCleared(apikey.FieldOpenaiKey) {
  6370. fields = append(fields, apikey.FieldOpenaiKey)
  6371. }
  6372. return fields
  6373. }
  6374. // FieldCleared returns a boolean indicating if a field with the given name was
  6375. // cleared in this mutation.
  6376. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  6377. _, ok := m.clearedFields[name]
  6378. return ok
  6379. }
  6380. // ClearField clears the value of the field with the given name. It returns an
  6381. // error if the field is not defined in the schema.
  6382. func (m *ApiKeyMutation) ClearField(name string) error {
  6383. switch name {
  6384. case apikey.FieldDeletedAt:
  6385. m.ClearDeletedAt()
  6386. return nil
  6387. case apikey.FieldTitle:
  6388. m.ClearTitle()
  6389. return nil
  6390. case apikey.FieldKey:
  6391. m.ClearKey()
  6392. return nil
  6393. case apikey.FieldCustomAgentBase:
  6394. m.ClearCustomAgentBase()
  6395. return nil
  6396. case apikey.FieldCustomAgentKey:
  6397. m.ClearCustomAgentKey()
  6398. return nil
  6399. case apikey.FieldOpenaiBase:
  6400. m.ClearOpenaiBase()
  6401. return nil
  6402. case apikey.FieldOpenaiKey:
  6403. m.ClearOpenaiKey()
  6404. return nil
  6405. }
  6406. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  6407. }
  6408. // ResetField resets all changes in the mutation for the field with the given name.
  6409. // It returns an error if the field is not defined in the schema.
  6410. func (m *ApiKeyMutation) ResetField(name string) error {
  6411. switch name {
  6412. case apikey.FieldCreatedAt:
  6413. m.ResetCreatedAt()
  6414. return nil
  6415. case apikey.FieldUpdatedAt:
  6416. m.ResetUpdatedAt()
  6417. return nil
  6418. case apikey.FieldDeletedAt:
  6419. m.ResetDeletedAt()
  6420. return nil
  6421. case apikey.FieldTitle:
  6422. m.ResetTitle()
  6423. return nil
  6424. case apikey.FieldKey:
  6425. m.ResetKey()
  6426. return nil
  6427. case apikey.FieldOrganizationID:
  6428. m.ResetOrganizationID()
  6429. return nil
  6430. case apikey.FieldAgentID:
  6431. m.ResetAgentID()
  6432. return nil
  6433. case apikey.FieldCustomAgentBase:
  6434. m.ResetCustomAgentBase()
  6435. return nil
  6436. case apikey.FieldCustomAgentKey:
  6437. m.ResetCustomAgentKey()
  6438. return nil
  6439. case apikey.FieldOpenaiBase:
  6440. m.ResetOpenaiBase()
  6441. return nil
  6442. case apikey.FieldOpenaiKey:
  6443. m.ResetOpenaiKey()
  6444. return nil
  6445. }
  6446. return fmt.Errorf("unknown ApiKey field %s", name)
  6447. }
  6448. // AddedEdges returns all edge names that were set/added in this mutation.
  6449. func (m *ApiKeyMutation) AddedEdges() []string {
  6450. edges := make([]string, 0, 1)
  6451. if m.agent != nil {
  6452. edges = append(edges, apikey.EdgeAgent)
  6453. }
  6454. return edges
  6455. }
  6456. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6457. // name in this mutation.
  6458. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  6459. switch name {
  6460. case apikey.EdgeAgent:
  6461. if id := m.agent; id != nil {
  6462. return []ent.Value{*id}
  6463. }
  6464. }
  6465. return nil
  6466. }
  6467. // RemovedEdges returns all edge names that were removed in this mutation.
  6468. func (m *ApiKeyMutation) RemovedEdges() []string {
  6469. edges := make([]string, 0, 1)
  6470. return edges
  6471. }
  6472. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6473. // the given name in this mutation.
  6474. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  6475. return nil
  6476. }
  6477. // ClearedEdges returns all edge names that were cleared in this mutation.
  6478. func (m *ApiKeyMutation) ClearedEdges() []string {
  6479. edges := make([]string, 0, 1)
  6480. if m.clearedagent {
  6481. edges = append(edges, apikey.EdgeAgent)
  6482. }
  6483. return edges
  6484. }
  6485. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6486. // was cleared in this mutation.
  6487. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  6488. switch name {
  6489. case apikey.EdgeAgent:
  6490. return m.clearedagent
  6491. }
  6492. return false
  6493. }
  6494. // ClearEdge clears the value of the edge with the given name. It returns an error
  6495. // if that edge is not defined in the schema.
  6496. func (m *ApiKeyMutation) ClearEdge(name string) error {
  6497. switch name {
  6498. case apikey.EdgeAgent:
  6499. m.ClearAgent()
  6500. return nil
  6501. }
  6502. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  6503. }
  6504. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6505. // It returns an error if the edge is not defined in the schema.
  6506. func (m *ApiKeyMutation) ResetEdge(name string) error {
  6507. switch name {
  6508. case apikey.EdgeAgent:
  6509. m.ResetAgent()
  6510. return nil
  6511. }
  6512. return fmt.Errorf("unknown ApiKey edge %s", name)
  6513. }
  6514. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  6515. type BatchMsgMutation struct {
  6516. config
  6517. op Op
  6518. typ string
  6519. id *uint64
  6520. created_at *time.Time
  6521. updated_at *time.Time
  6522. deleted_at *time.Time
  6523. status *uint8
  6524. addstatus *int8
  6525. batch_no *string
  6526. task_name *string
  6527. fromwxid *string
  6528. msg *string
  6529. tag *string
  6530. tagids *string
  6531. total *int32
  6532. addtotal *int32
  6533. success *int32
  6534. addsuccess *int32
  6535. fail *int32
  6536. addfail *int32
  6537. start_time *time.Time
  6538. stop_time *time.Time
  6539. send_time *time.Time
  6540. _type *int32
  6541. add_type *int32
  6542. organization_id *uint64
  6543. addorganization_id *int64
  6544. ctype *uint64
  6545. addctype *int64
  6546. cc *string
  6547. phone *string
  6548. template_name *string
  6549. template_code *string
  6550. lang *string
  6551. clearedFields map[string]struct{}
  6552. done bool
  6553. oldValue func(context.Context) (*BatchMsg, error)
  6554. predicates []predicate.BatchMsg
  6555. }
  6556. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  6557. // batchmsgOption allows management of the mutation configuration using functional options.
  6558. type batchmsgOption func(*BatchMsgMutation)
  6559. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  6560. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  6561. m := &BatchMsgMutation{
  6562. config: c,
  6563. op: op,
  6564. typ: TypeBatchMsg,
  6565. clearedFields: make(map[string]struct{}),
  6566. }
  6567. for _, opt := range opts {
  6568. opt(m)
  6569. }
  6570. return m
  6571. }
  6572. // withBatchMsgID sets the ID field of the mutation.
  6573. func withBatchMsgID(id uint64) batchmsgOption {
  6574. return func(m *BatchMsgMutation) {
  6575. var (
  6576. err error
  6577. once sync.Once
  6578. value *BatchMsg
  6579. )
  6580. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  6581. once.Do(func() {
  6582. if m.done {
  6583. err = errors.New("querying old values post mutation is not allowed")
  6584. } else {
  6585. value, err = m.Client().BatchMsg.Get(ctx, id)
  6586. }
  6587. })
  6588. return value, err
  6589. }
  6590. m.id = &id
  6591. }
  6592. }
  6593. // withBatchMsg sets the old BatchMsg of the mutation.
  6594. func withBatchMsg(node *BatchMsg) batchmsgOption {
  6595. return func(m *BatchMsgMutation) {
  6596. m.oldValue = func(context.Context) (*BatchMsg, error) {
  6597. return node, nil
  6598. }
  6599. m.id = &node.ID
  6600. }
  6601. }
  6602. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6603. // executed in a transaction (ent.Tx), a transactional client is returned.
  6604. func (m BatchMsgMutation) Client() *Client {
  6605. client := &Client{config: m.config}
  6606. client.init()
  6607. return client
  6608. }
  6609. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6610. // it returns an error otherwise.
  6611. func (m BatchMsgMutation) Tx() (*Tx, error) {
  6612. if _, ok := m.driver.(*txDriver); !ok {
  6613. return nil, errors.New("ent: mutation is not running in a transaction")
  6614. }
  6615. tx := &Tx{config: m.config}
  6616. tx.init()
  6617. return tx, nil
  6618. }
  6619. // SetID sets the value of the id field. Note that this
  6620. // operation is only accepted on creation of BatchMsg entities.
  6621. func (m *BatchMsgMutation) SetID(id uint64) {
  6622. m.id = &id
  6623. }
  6624. // ID returns the ID value in the mutation. Note that the ID is only available
  6625. // if it was provided to the builder or after it was returned from the database.
  6626. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  6627. if m.id == nil {
  6628. return
  6629. }
  6630. return *m.id, true
  6631. }
  6632. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6633. // That means, if the mutation is applied within a transaction with an isolation level such
  6634. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6635. // or updated by the mutation.
  6636. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  6637. switch {
  6638. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6639. id, exists := m.ID()
  6640. if exists {
  6641. return []uint64{id}, nil
  6642. }
  6643. fallthrough
  6644. case m.op.Is(OpUpdate | OpDelete):
  6645. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  6646. default:
  6647. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6648. }
  6649. }
  6650. // SetCreatedAt sets the "created_at" field.
  6651. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  6652. m.created_at = &t
  6653. }
  6654. // CreatedAt returns the value of the "created_at" field in the mutation.
  6655. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  6656. v := m.created_at
  6657. if v == nil {
  6658. return
  6659. }
  6660. return *v, true
  6661. }
  6662. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  6663. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6665. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6666. if !m.op.Is(OpUpdateOne) {
  6667. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6668. }
  6669. if m.id == nil || m.oldValue == nil {
  6670. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6671. }
  6672. oldValue, err := m.oldValue(ctx)
  6673. if err != nil {
  6674. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6675. }
  6676. return oldValue.CreatedAt, nil
  6677. }
  6678. // ResetCreatedAt resets all changes to the "created_at" field.
  6679. func (m *BatchMsgMutation) ResetCreatedAt() {
  6680. m.created_at = nil
  6681. }
  6682. // SetUpdatedAt sets the "updated_at" field.
  6683. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  6684. m.updated_at = &t
  6685. }
  6686. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6687. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  6688. v := m.updated_at
  6689. if v == nil {
  6690. return
  6691. }
  6692. return *v, true
  6693. }
  6694. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  6695. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6697. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6698. if !m.op.Is(OpUpdateOne) {
  6699. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6700. }
  6701. if m.id == nil || m.oldValue == nil {
  6702. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6703. }
  6704. oldValue, err := m.oldValue(ctx)
  6705. if err != nil {
  6706. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6707. }
  6708. return oldValue.UpdatedAt, nil
  6709. }
  6710. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6711. func (m *BatchMsgMutation) ResetUpdatedAt() {
  6712. m.updated_at = nil
  6713. }
  6714. // SetDeletedAt sets the "deleted_at" field.
  6715. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  6716. m.deleted_at = &t
  6717. }
  6718. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6719. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  6720. v := m.deleted_at
  6721. if v == nil {
  6722. return
  6723. }
  6724. return *v, true
  6725. }
  6726. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  6727. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6729. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6730. if !m.op.Is(OpUpdateOne) {
  6731. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6732. }
  6733. if m.id == nil || m.oldValue == nil {
  6734. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6735. }
  6736. oldValue, err := m.oldValue(ctx)
  6737. if err != nil {
  6738. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6739. }
  6740. return oldValue.DeletedAt, nil
  6741. }
  6742. // ClearDeletedAt clears the value of the "deleted_at" field.
  6743. func (m *BatchMsgMutation) ClearDeletedAt() {
  6744. m.deleted_at = nil
  6745. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  6746. }
  6747. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6748. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  6749. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  6750. return ok
  6751. }
  6752. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6753. func (m *BatchMsgMutation) ResetDeletedAt() {
  6754. m.deleted_at = nil
  6755. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  6756. }
  6757. // SetStatus sets the "status" field.
  6758. func (m *BatchMsgMutation) SetStatus(u uint8) {
  6759. m.status = &u
  6760. m.addstatus = nil
  6761. }
  6762. // Status returns the value of the "status" field in the mutation.
  6763. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  6764. v := m.status
  6765. if v == nil {
  6766. return
  6767. }
  6768. return *v, true
  6769. }
  6770. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  6771. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6773. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6774. if !m.op.Is(OpUpdateOne) {
  6775. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6776. }
  6777. if m.id == nil || m.oldValue == nil {
  6778. return v, errors.New("OldStatus requires an ID field in the mutation")
  6779. }
  6780. oldValue, err := m.oldValue(ctx)
  6781. if err != nil {
  6782. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6783. }
  6784. return oldValue.Status, nil
  6785. }
  6786. // AddStatus adds u to the "status" field.
  6787. func (m *BatchMsgMutation) AddStatus(u int8) {
  6788. if m.addstatus != nil {
  6789. *m.addstatus += u
  6790. } else {
  6791. m.addstatus = &u
  6792. }
  6793. }
  6794. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6795. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  6796. v := m.addstatus
  6797. if v == nil {
  6798. return
  6799. }
  6800. return *v, true
  6801. }
  6802. // ClearStatus clears the value of the "status" field.
  6803. func (m *BatchMsgMutation) ClearStatus() {
  6804. m.status = nil
  6805. m.addstatus = nil
  6806. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  6807. }
  6808. // StatusCleared returns if the "status" field was cleared in this mutation.
  6809. func (m *BatchMsgMutation) StatusCleared() bool {
  6810. _, ok := m.clearedFields[batchmsg.FieldStatus]
  6811. return ok
  6812. }
  6813. // ResetStatus resets all changes to the "status" field.
  6814. func (m *BatchMsgMutation) ResetStatus() {
  6815. m.status = nil
  6816. m.addstatus = nil
  6817. delete(m.clearedFields, batchmsg.FieldStatus)
  6818. }
  6819. // SetBatchNo sets the "batch_no" field.
  6820. func (m *BatchMsgMutation) SetBatchNo(s string) {
  6821. m.batch_no = &s
  6822. }
  6823. // BatchNo returns the value of the "batch_no" field in the mutation.
  6824. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  6825. v := m.batch_no
  6826. if v == nil {
  6827. return
  6828. }
  6829. return *v, true
  6830. }
  6831. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  6832. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6834. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  6835. if !m.op.Is(OpUpdateOne) {
  6836. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  6837. }
  6838. if m.id == nil || m.oldValue == nil {
  6839. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  6840. }
  6841. oldValue, err := m.oldValue(ctx)
  6842. if err != nil {
  6843. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  6844. }
  6845. return oldValue.BatchNo, nil
  6846. }
  6847. // ClearBatchNo clears the value of the "batch_no" field.
  6848. func (m *BatchMsgMutation) ClearBatchNo() {
  6849. m.batch_no = nil
  6850. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  6851. }
  6852. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  6853. func (m *BatchMsgMutation) BatchNoCleared() bool {
  6854. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  6855. return ok
  6856. }
  6857. // ResetBatchNo resets all changes to the "batch_no" field.
  6858. func (m *BatchMsgMutation) ResetBatchNo() {
  6859. m.batch_no = nil
  6860. delete(m.clearedFields, batchmsg.FieldBatchNo)
  6861. }
  6862. // SetTaskName sets the "task_name" field.
  6863. func (m *BatchMsgMutation) SetTaskName(s string) {
  6864. m.task_name = &s
  6865. }
  6866. // TaskName returns the value of the "task_name" field in the mutation.
  6867. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  6868. v := m.task_name
  6869. if v == nil {
  6870. return
  6871. }
  6872. return *v, true
  6873. }
  6874. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  6875. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6877. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  6878. if !m.op.Is(OpUpdateOne) {
  6879. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  6880. }
  6881. if m.id == nil || m.oldValue == nil {
  6882. return v, errors.New("OldTaskName requires an ID field in the mutation")
  6883. }
  6884. oldValue, err := m.oldValue(ctx)
  6885. if err != nil {
  6886. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  6887. }
  6888. return oldValue.TaskName, nil
  6889. }
  6890. // ClearTaskName clears the value of the "task_name" field.
  6891. func (m *BatchMsgMutation) ClearTaskName() {
  6892. m.task_name = nil
  6893. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  6894. }
  6895. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  6896. func (m *BatchMsgMutation) TaskNameCleared() bool {
  6897. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  6898. return ok
  6899. }
  6900. // ResetTaskName resets all changes to the "task_name" field.
  6901. func (m *BatchMsgMutation) ResetTaskName() {
  6902. m.task_name = nil
  6903. delete(m.clearedFields, batchmsg.FieldTaskName)
  6904. }
  6905. // SetFromwxid sets the "fromwxid" field.
  6906. func (m *BatchMsgMutation) SetFromwxid(s string) {
  6907. m.fromwxid = &s
  6908. }
  6909. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  6910. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  6911. v := m.fromwxid
  6912. if v == nil {
  6913. return
  6914. }
  6915. return *v, true
  6916. }
  6917. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  6918. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6920. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  6921. if !m.op.Is(OpUpdateOne) {
  6922. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  6923. }
  6924. if m.id == nil || m.oldValue == nil {
  6925. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  6926. }
  6927. oldValue, err := m.oldValue(ctx)
  6928. if err != nil {
  6929. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  6930. }
  6931. return oldValue.Fromwxid, nil
  6932. }
  6933. // ClearFromwxid clears the value of the "fromwxid" field.
  6934. func (m *BatchMsgMutation) ClearFromwxid() {
  6935. m.fromwxid = nil
  6936. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  6937. }
  6938. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  6939. func (m *BatchMsgMutation) FromwxidCleared() bool {
  6940. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  6941. return ok
  6942. }
  6943. // ResetFromwxid resets all changes to the "fromwxid" field.
  6944. func (m *BatchMsgMutation) ResetFromwxid() {
  6945. m.fromwxid = nil
  6946. delete(m.clearedFields, batchmsg.FieldFromwxid)
  6947. }
  6948. // SetMsg sets the "msg" field.
  6949. func (m *BatchMsgMutation) SetMsg(s string) {
  6950. m.msg = &s
  6951. }
  6952. // Msg returns the value of the "msg" field in the mutation.
  6953. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  6954. v := m.msg
  6955. if v == nil {
  6956. return
  6957. }
  6958. return *v, true
  6959. }
  6960. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  6961. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6963. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  6964. if !m.op.Is(OpUpdateOne) {
  6965. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  6966. }
  6967. if m.id == nil || m.oldValue == nil {
  6968. return v, errors.New("OldMsg requires an ID field in the mutation")
  6969. }
  6970. oldValue, err := m.oldValue(ctx)
  6971. if err != nil {
  6972. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  6973. }
  6974. return oldValue.Msg, nil
  6975. }
  6976. // ClearMsg clears the value of the "msg" field.
  6977. func (m *BatchMsgMutation) ClearMsg() {
  6978. m.msg = nil
  6979. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  6980. }
  6981. // MsgCleared returns if the "msg" field was cleared in this mutation.
  6982. func (m *BatchMsgMutation) MsgCleared() bool {
  6983. _, ok := m.clearedFields[batchmsg.FieldMsg]
  6984. return ok
  6985. }
  6986. // ResetMsg resets all changes to the "msg" field.
  6987. func (m *BatchMsgMutation) ResetMsg() {
  6988. m.msg = nil
  6989. delete(m.clearedFields, batchmsg.FieldMsg)
  6990. }
  6991. // SetTag sets the "tag" field.
  6992. func (m *BatchMsgMutation) SetTag(s string) {
  6993. m.tag = &s
  6994. }
  6995. // Tag returns the value of the "tag" field in the mutation.
  6996. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  6997. v := m.tag
  6998. if v == nil {
  6999. return
  7000. }
  7001. return *v, true
  7002. }
  7003. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  7004. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7006. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  7007. if !m.op.Is(OpUpdateOne) {
  7008. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  7009. }
  7010. if m.id == nil || m.oldValue == nil {
  7011. return v, errors.New("OldTag requires an ID field in the mutation")
  7012. }
  7013. oldValue, err := m.oldValue(ctx)
  7014. if err != nil {
  7015. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  7016. }
  7017. return oldValue.Tag, nil
  7018. }
  7019. // ClearTag clears the value of the "tag" field.
  7020. func (m *BatchMsgMutation) ClearTag() {
  7021. m.tag = nil
  7022. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  7023. }
  7024. // TagCleared returns if the "tag" field was cleared in this mutation.
  7025. func (m *BatchMsgMutation) TagCleared() bool {
  7026. _, ok := m.clearedFields[batchmsg.FieldTag]
  7027. return ok
  7028. }
  7029. // ResetTag resets all changes to the "tag" field.
  7030. func (m *BatchMsgMutation) ResetTag() {
  7031. m.tag = nil
  7032. delete(m.clearedFields, batchmsg.FieldTag)
  7033. }
  7034. // SetTagids sets the "tagids" field.
  7035. func (m *BatchMsgMutation) SetTagids(s string) {
  7036. m.tagids = &s
  7037. }
  7038. // Tagids returns the value of the "tagids" field in the mutation.
  7039. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  7040. v := m.tagids
  7041. if v == nil {
  7042. return
  7043. }
  7044. return *v, true
  7045. }
  7046. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  7047. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7049. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  7050. if !m.op.Is(OpUpdateOne) {
  7051. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  7052. }
  7053. if m.id == nil || m.oldValue == nil {
  7054. return v, errors.New("OldTagids requires an ID field in the mutation")
  7055. }
  7056. oldValue, err := m.oldValue(ctx)
  7057. if err != nil {
  7058. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  7059. }
  7060. return oldValue.Tagids, nil
  7061. }
  7062. // ClearTagids clears the value of the "tagids" field.
  7063. func (m *BatchMsgMutation) ClearTagids() {
  7064. m.tagids = nil
  7065. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  7066. }
  7067. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  7068. func (m *BatchMsgMutation) TagidsCleared() bool {
  7069. _, ok := m.clearedFields[batchmsg.FieldTagids]
  7070. return ok
  7071. }
  7072. // ResetTagids resets all changes to the "tagids" field.
  7073. func (m *BatchMsgMutation) ResetTagids() {
  7074. m.tagids = nil
  7075. delete(m.clearedFields, batchmsg.FieldTagids)
  7076. }
  7077. // SetTotal sets the "total" field.
  7078. func (m *BatchMsgMutation) SetTotal(i int32) {
  7079. m.total = &i
  7080. m.addtotal = nil
  7081. }
  7082. // Total returns the value of the "total" field in the mutation.
  7083. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  7084. v := m.total
  7085. if v == nil {
  7086. return
  7087. }
  7088. return *v, true
  7089. }
  7090. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  7091. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7093. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  7094. if !m.op.Is(OpUpdateOne) {
  7095. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  7096. }
  7097. if m.id == nil || m.oldValue == nil {
  7098. return v, errors.New("OldTotal requires an ID field in the mutation")
  7099. }
  7100. oldValue, err := m.oldValue(ctx)
  7101. if err != nil {
  7102. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  7103. }
  7104. return oldValue.Total, nil
  7105. }
  7106. // AddTotal adds i to the "total" field.
  7107. func (m *BatchMsgMutation) AddTotal(i int32) {
  7108. if m.addtotal != nil {
  7109. *m.addtotal += i
  7110. } else {
  7111. m.addtotal = &i
  7112. }
  7113. }
  7114. // AddedTotal returns the value that was added to the "total" field in this mutation.
  7115. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  7116. v := m.addtotal
  7117. if v == nil {
  7118. return
  7119. }
  7120. return *v, true
  7121. }
  7122. // ClearTotal clears the value of the "total" field.
  7123. func (m *BatchMsgMutation) ClearTotal() {
  7124. m.total = nil
  7125. m.addtotal = nil
  7126. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  7127. }
  7128. // TotalCleared returns if the "total" field was cleared in this mutation.
  7129. func (m *BatchMsgMutation) TotalCleared() bool {
  7130. _, ok := m.clearedFields[batchmsg.FieldTotal]
  7131. return ok
  7132. }
  7133. // ResetTotal resets all changes to the "total" field.
  7134. func (m *BatchMsgMutation) ResetTotal() {
  7135. m.total = nil
  7136. m.addtotal = nil
  7137. delete(m.clearedFields, batchmsg.FieldTotal)
  7138. }
  7139. // SetSuccess sets the "success" field.
  7140. func (m *BatchMsgMutation) SetSuccess(i int32) {
  7141. m.success = &i
  7142. m.addsuccess = nil
  7143. }
  7144. // Success returns the value of the "success" field in the mutation.
  7145. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  7146. v := m.success
  7147. if v == nil {
  7148. return
  7149. }
  7150. return *v, true
  7151. }
  7152. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  7153. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7155. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  7156. if !m.op.Is(OpUpdateOne) {
  7157. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  7158. }
  7159. if m.id == nil || m.oldValue == nil {
  7160. return v, errors.New("OldSuccess requires an ID field in the mutation")
  7161. }
  7162. oldValue, err := m.oldValue(ctx)
  7163. if err != nil {
  7164. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  7165. }
  7166. return oldValue.Success, nil
  7167. }
  7168. // AddSuccess adds i to the "success" field.
  7169. func (m *BatchMsgMutation) AddSuccess(i int32) {
  7170. if m.addsuccess != nil {
  7171. *m.addsuccess += i
  7172. } else {
  7173. m.addsuccess = &i
  7174. }
  7175. }
  7176. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  7177. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  7178. v := m.addsuccess
  7179. if v == nil {
  7180. return
  7181. }
  7182. return *v, true
  7183. }
  7184. // ClearSuccess clears the value of the "success" field.
  7185. func (m *BatchMsgMutation) ClearSuccess() {
  7186. m.success = nil
  7187. m.addsuccess = nil
  7188. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  7189. }
  7190. // SuccessCleared returns if the "success" field was cleared in this mutation.
  7191. func (m *BatchMsgMutation) SuccessCleared() bool {
  7192. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  7193. return ok
  7194. }
  7195. // ResetSuccess resets all changes to the "success" field.
  7196. func (m *BatchMsgMutation) ResetSuccess() {
  7197. m.success = nil
  7198. m.addsuccess = nil
  7199. delete(m.clearedFields, batchmsg.FieldSuccess)
  7200. }
  7201. // SetFail sets the "fail" field.
  7202. func (m *BatchMsgMutation) SetFail(i int32) {
  7203. m.fail = &i
  7204. m.addfail = nil
  7205. }
  7206. // Fail returns the value of the "fail" field in the mutation.
  7207. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  7208. v := m.fail
  7209. if v == nil {
  7210. return
  7211. }
  7212. return *v, true
  7213. }
  7214. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  7215. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7217. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  7218. if !m.op.Is(OpUpdateOne) {
  7219. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  7220. }
  7221. if m.id == nil || m.oldValue == nil {
  7222. return v, errors.New("OldFail requires an ID field in the mutation")
  7223. }
  7224. oldValue, err := m.oldValue(ctx)
  7225. if err != nil {
  7226. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  7227. }
  7228. return oldValue.Fail, nil
  7229. }
  7230. // AddFail adds i to the "fail" field.
  7231. func (m *BatchMsgMutation) AddFail(i int32) {
  7232. if m.addfail != nil {
  7233. *m.addfail += i
  7234. } else {
  7235. m.addfail = &i
  7236. }
  7237. }
  7238. // AddedFail returns the value that was added to the "fail" field in this mutation.
  7239. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  7240. v := m.addfail
  7241. if v == nil {
  7242. return
  7243. }
  7244. return *v, true
  7245. }
  7246. // ClearFail clears the value of the "fail" field.
  7247. func (m *BatchMsgMutation) ClearFail() {
  7248. m.fail = nil
  7249. m.addfail = nil
  7250. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  7251. }
  7252. // FailCleared returns if the "fail" field was cleared in this mutation.
  7253. func (m *BatchMsgMutation) FailCleared() bool {
  7254. _, ok := m.clearedFields[batchmsg.FieldFail]
  7255. return ok
  7256. }
  7257. // ResetFail resets all changes to the "fail" field.
  7258. func (m *BatchMsgMutation) ResetFail() {
  7259. m.fail = nil
  7260. m.addfail = nil
  7261. delete(m.clearedFields, batchmsg.FieldFail)
  7262. }
  7263. // SetStartTime sets the "start_time" field.
  7264. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  7265. m.start_time = &t
  7266. }
  7267. // StartTime returns the value of the "start_time" field in the mutation.
  7268. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  7269. v := m.start_time
  7270. if v == nil {
  7271. return
  7272. }
  7273. return *v, true
  7274. }
  7275. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  7276. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7278. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  7279. if !m.op.Is(OpUpdateOne) {
  7280. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  7281. }
  7282. if m.id == nil || m.oldValue == nil {
  7283. return v, errors.New("OldStartTime requires an ID field in the mutation")
  7284. }
  7285. oldValue, err := m.oldValue(ctx)
  7286. if err != nil {
  7287. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  7288. }
  7289. return oldValue.StartTime, nil
  7290. }
  7291. // ClearStartTime clears the value of the "start_time" field.
  7292. func (m *BatchMsgMutation) ClearStartTime() {
  7293. m.start_time = nil
  7294. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  7295. }
  7296. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  7297. func (m *BatchMsgMutation) StartTimeCleared() bool {
  7298. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  7299. return ok
  7300. }
  7301. // ResetStartTime resets all changes to the "start_time" field.
  7302. func (m *BatchMsgMutation) ResetStartTime() {
  7303. m.start_time = nil
  7304. delete(m.clearedFields, batchmsg.FieldStartTime)
  7305. }
  7306. // SetStopTime sets the "stop_time" field.
  7307. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  7308. m.stop_time = &t
  7309. }
  7310. // StopTime returns the value of the "stop_time" field in the mutation.
  7311. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  7312. v := m.stop_time
  7313. if v == nil {
  7314. return
  7315. }
  7316. return *v, true
  7317. }
  7318. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  7319. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7321. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  7322. if !m.op.Is(OpUpdateOne) {
  7323. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  7324. }
  7325. if m.id == nil || m.oldValue == nil {
  7326. return v, errors.New("OldStopTime requires an ID field in the mutation")
  7327. }
  7328. oldValue, err := m.oldValue(ctx)
  7329. if err != nil {
  7330. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  7331. }
  7332. return oldValue.StopTime, nil
  7333. }
  7334. // ClearStopTime clears the value of the "stop_time" field.
  7335. func (m *BatchMsgMutation) ClearStopTime() {
  7336. m.stop_time = nil
  7337. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  7338. }
  7339. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  7340. func (m *BatchMsgMutation) StopTimeCleared() bool {
  7341. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  7342. return ok
  7343. }
  7344. // ResetStopTime resets all changes to the "stop_time" field.
  7345. func (m *BatchMsgMutation) ResetStopTime() {
  7346. m.stop_time = nil
  7347. delete(m.clearedFields, batchmsg.FieldStopTime)
  7348. }
  7349. // SetSendTime sets the "send_time" field.
  7350. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  7351. m.send_time = &t
  7352. }
  7353. // SendTime returns the value of the "send_time" field in the mutation.
  7354. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  7355. v := m.send_time
  7356. if v == nil {
  7357. return
  7358. }
  7359. return *v, true
  7360. }
  7361. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  7362. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7364. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  7365. if !m.op.Is(OpUpdateOne) {
  7366. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  7367. }
  7368. if m.id == nil || m.oldValue == nil {
  7369. return v, errors.New("OldSendTime requires an ID field in the mutation")
  7370. }
  7371. oldValue, err := m.oldValue(ctx)
  7372. if err != nil {
  7373. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  7374. }
  7375. return oldValue.SendTime, nil
  7376. }
  7377. // ClearSendTime clears the value of the "send_time" field.
  7378. func (m *BatchMsgMutation) ClearSendTime() {
  7379. m.send_time = nil
  7380. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  7381. }
  7382. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  7383. func (m *BatchMsgMutation) SendTimeCleared() bool {
  7384. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  7385. return ok
  7386. }
  7387. // ResetSendTime resets all changes to the "send_time" field.
  7388. func (m *BatchMsgMutation) ResetSendTime() {
  7389. m.send_time = nil
  7390. delete(m.clearedFields, batchmsg.FieldSendTime)
  7391. }
  7392. // SetType sets the "type" field.
  7393. func (m *BatchMsgMutation) SetType(i int32) {
  7394. m._type = &i
  7395. m.add_type = nil
  7396. }
  7397. // GetType returns the value of the "type" field in the mutation.
  7398. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  7399. v := m._type
  7400. if v == nil {
  7401. return
  7402. }
  7403. return *v, true
  7404. }
  7405. // OldType returns the old "type" field's value of the BatchMsg entity.
  7406. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7408. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  7409. if !m.op.Is(OpUpdateOne) {
  7410. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7411. }
  7412. if m.id == nil || m.oldValue == nil {
  7413. return v, errors.New("OldType requires an ID field in the mutation")
  7414. }
  7415. oldValue, err := m.oldValue(ctx)
  7416. if err != nil {
  7417. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7418. }
  7419. return oldValue.Type, nil
  7420. }
  7421. // AddType adds i to the "type" field.
  7422. func (m *BatchMsgMutation) AddType(i int32) {
  7423. if m.add_type != nil {
  7424. *m.add_type += i
  7425. } else {
  7426. m.add_type = &i
  7427. }
  7428. }
  7429. // AddedType returns the value that was added to the "type" field in this mutation.
  7430. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  7431. v := m.add_type
  7432. if v == nil {
  7433. return
  7434. }
  7435. return *v, true
  7436. }
  7437. // ClearType clears the value of the "type" field.
  7438. func (m *BatchMsgMutation) ClearType() {
  7439. m._type = nil
  7440. m.add_type = nil
  7441. m.clearedFields[batchmsg.FieldType] = struct{}{}
  7442. }
  7443. // TypeCleared returns if the "type" field was cleared in this mutation.
  7444. func (m *BatchMsgMutation) TypeCleared() bool {
  7445. _, ok := m.clearedFields[batchmsg.FieldType]
  7446. return ok
  7447. }
  7448. // ResetType resets all changes to the "type" field.
  7449. func (m *BatchMsgMutation) ResetType() {
  7450. m._type = nil
  7451. m.add_type = nil
  7452. delete(m.clearedFields, batchmsg.FieldType)
  7453. }
  7454. // SetOrganizationID sets the "organization_id" field.
  7455. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  7456. m.organization_id = &u
  7457. m.addorganization_id = nil
  7458. }
  7459. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7460. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  7461. v := m.organization_id
  7462. if v == nil {
  7463. return
  7464. }
  7465. return *v, true
  7466. }
  7467. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  7468. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7470. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7471. if !m.op.Is(OpUpdateOne) {
  7472. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7473. }
  7474. if m.id == nil || m.oldValue == nil {
  7475. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7476. }
  7477. oldValue, err := m.oldValue(ctx)
  7478. if err != nil {
  7479. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7480. }
  7481. return oldValue.OrganizationID, nil
  7482. }
  7483. // AddOrganizationID adds u to the "organization_id" field.
  7484. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  7485. if m.addorganization_id != nil {
  7486. *m.addorganization_id += u
  7487. } else {
  7488. m.addorganization_id = &u
  7489. }
  7490. }
  7491. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7492. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  7493. v := m.addorganization_id
  7494. if v == nil {
  7495. return
  7496. }
  7497. return *v, true
  7498. }
  7499. // ResetOrganizationID resets all changes to the "organization_id" field.
  7500. func (m *BatchMsgMutation) ResetOrganizationID() {
  7501. m.organization_id = nil
  7502. m.addorganization_id = nil
  7503. }
  7504. // SetCtype sets the "ctype" field.
  7505. func (m *BatchMsgMutation) SetCtype(u uint64) {
  7506. m.ctype = &u
  7507. m.addctype = nil
  7508. }
  7509. // Ctype returns the value of the "ctype" field in the mutation.
  7510. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  7511. v := m.ctype
  7512. if v == nil {
  7513. return
  7514. }
  7515. return *v, true
  7516. }
  7517. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  7518. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7520. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  7521. if !m.op.Is(OpUpdateOne) {
  7522. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  7523. }
  7524. if m.id == nil || m.oldValue == nil {
  7525. return v, errors.New("OldCtype requires an ID field in the mutation")
  7526. }
  7527. oldValue, err := m.oldValue(ctx)
  7528. if err != nil {
  7529. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  7530. }
  7531. return oldValue.Ctype, nil
  7532. }
  7533. // AddCtype adds u to the "ctype" field.
  7534. func (m *BatchMsgMutation) AddCtype(u int64) {
  7535. if m.addctype != nil {
  7536. *m.addctype += u
  7537. } else {
  7538. m.addctype = &u
  7539. }
  7540. }
  7541. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  7542. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  7543. v := m.addctype
  7544. if v == nil {
  7545. return
  7546. }
  7547. return *v, true
  7548. }
  7549. // ResetCtype resets all changes to the "ctype" field.
  7550. func (m *BatchMsgMutation) ResetCtype() {
  7551. m.ctype = nil
  7552. m.addctype = nil
  7553. }
  7554. // SetCc sets the "cc" field.
  7555. func (m *BatchMsgMutation) SetCc(s string) {
  7556. m.cc = &s
  7557. }
  7558. // Cc returns the value of the "cc" field in the mutation.
  7559. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  7560. v := m.cc
  7561. if v == nil {
  7562. return
  7563. }
  7564. return *v, true
  7565. }
  7566. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  7567. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7569. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  7570. if !m.op.Is(OpUpdateOne) {
  7571. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  7572. }
  7573. if m.id == nil || m.oldValue == nil {
  7574. return v, errors.New("OldCc requires an ID field in the mutation")
  7575. }
  7576. oldValue, err := m.oldValue(ctx)
  7577. if err != nil {
  7578. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  7579. }
  7580. return oldValue.Cc, nil
  7581. }
  7582. // ClearCc clears the value of the "cc" field.
  7583. func (m *BatchMsgMutation) ClearCc() {
  7584. m.cc = nil
  7585. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  7586. }
  7587. // CcCleared returns if the "cc" field was cleared in this mutation.
  7588. func (m *BatchMsgMutation) CcCleared() bool {
  7589. _, ok := m.clearedFields[batchmsg.FieldCc]
  7590. return ok
  7591. }
  7592. // ResetCc resets all changes to the "cc" field.
  7593. func (m *BatchMsgMutation) ResetCc() {
  7594. m.cc = nil
  7595. delete(m.clearedFields, batchmsg.FieldCc)
  7596. }
  7597. // SetPhone sets the "phone" field.
  7598. func (m *BatchMsgMutation) SetPhone(s string) {
  7599. m.phone = &s
  7600. }
  7601. // Phone returns the value of the "phone" field in the mutation.
  7602. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  7603. v := m.phone
  7604. if v == nil {
  7605. return
  7606. }
  7607. return *v, true
  7608. }
  7609. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  7610. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7612. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  7613. if !m.op.Is(OpUpdateOne) {
  7614. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  7615. }
  7616. if m.id == nil || m.oldValue == nil {
  7617. return v, errors.New("OldPhone requires an ID field in the mutation")
  7618. }
  7619. oldValue, err := m.oldValue(ctx)
  7620. if err != nil {
  7621. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  7622. }
  7623. return oldValue.Phone, nil
  7624. }
  7625. // ClearPhone clears the value of the "phone" field.
  7626. func (m *BatchMsgMutation) ClearPhone() {
  7627. m.phone = nil
  7628. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  7629. }
  7630. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  7631. func (m *BatchMsgMutation) PhoneCleared() bool {
  7632. _, ok := m.clearedFields[batchmsg.FieldPhone]
  7633. return ok
  7634. }
  7635. // ResetPhone resets all changes to the "phone" field.
  7636. func (m *BatchMsgMutation) ResetPhone() {
  7637. m.phone = nil
  7638. delete(m.clearedFields, batchmsg.FieldPhone)
  7639. }
  7640. // SetTemplateName sets the "template_name" field.
  7641. func (m *BatchMsgMutation) SetTemplateName(s string) {
  7642. m.template_name = &s
  7643. }
  7644. // TemplateName returns the value of the "template_name" field in the mutation.
  7645. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  7646. v := m.template_name
  7647. if v == nil {
  7648. return
  7649. }
  7650. return *v, true
  7651. }
  7652. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  7653. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7655. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  7656. if !m.op.Is(OpUpdateOne) {
  7657. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  7658. }
  7659. if m.id == nil || m.oldValue == nil {
  7660. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  7661. }
  7662. oldValue, err := m.oldValue(ctx)
  7663. if err != nil {
  7664. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  7665. }
  7666. return oldValue.TemplateName, nil
  7667. }
  7668. // ClearTemplateName clears the value of the "template_name" field.
  7669. func (m *BatchMsgMutation) ClearTemplateName() {
  7670. m.template_name = nil
  7671. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  7672. }
  7673. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  7674. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  7675. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  7676. return ok
  7677. }
  7678. // ResetTemplateName resets all changes to the "template_name" field.
  7679. func (m *BatchMsgMutation) ResetTemplateName() {
  7680. m.template_name = nil
  7681. delete(m.clearedFields, batchmsg.FieldTemplateName)
  7682. }
  7683. // SetTemplateCode sets the "template_code" field.
  7684. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  7685. m.template_code = &s
  7686. }
  7687. // TemplateCode returns the value of the "template_code" field in the mutation.
  7688. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  7689. v := m.template_code
  7690. if v == nil {
  7691. return
  7692. }
  7693. return *v, true
  7694. }
  7695. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  7696. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7698. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  7699. if !m.op.Is(OpUpdateOne) {
  7700. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  7701. }
  7702. if m.id == nil || m.oldValue == nil {
  7703. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  7704. }
  7705. oldValue, err := m.oldValue(ctx)
  7706. if err != nil {
  7707. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  7708. }
  7709. return oldValue.TemplateCode, nil
  7710. }
  7711. // ClearTemplateCode clears the value of the "template_code" field.
  7712. func (m *BatchMsgMutation) ClearTemplateCode() {
  7713. m.template_code = nil
  7714. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  7715. }
  7716. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  7717. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  7718. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  7719. return ok
  7720. }
  7721. // ResetTemplateCode resets all changes to the "template_code" field.
  7722. func (m *BatchMsgMutation) ResetTemplateCode() {
  7723. m.template_code = nil
  7724. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  7725. }
  7726. // SetLang sets the "lang" field.
  7727. func (m *BatchMsgMutation) SetLang(s string) {
  7728. m.lang = &s
  7729. }
  7730. // Lang returns the value of the "lang" field in the mutation.
  7731. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  7732. v := m.lang
  7733. if v == nil {
  7734. return
  7735. }
  7736. return *v, true
  7737. }
  7738. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  7739. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7741. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  7742. if !m.op.Is(OpUpdateOne) {
  7743. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  7744. }
  7745. if m.id == nil || m.oldValue == nil {
  7746. return v, errors.New("OldLang requires an ID field in the mutation")
  7747. }
  7748. oldValue, err := m.oldValue(ctx)
  7749. if err != nil {
  7750. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  7751. }
  7752. return oldValue.Lang, nil
  7753. }
  7754. // ClearLang clears the value of the "lang" field.
  7755. func (m *BatchMsgMutation) ClearLang() {
  7756. m.lang = nil
  7757. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  7758. }
  7759. // LangCleared returns if the "lang" field was cleared in this mutation.
  7760. func (m *BatchMsgMutation) LangCleared() bool {
  7761. _, ok := m.clearedFields[batchmsg.FieldLang]
  7762. return ok
  7763. }
  7764. // ResetLang resets all changes to the "lang" field.
  7765. func (m *BatchMsgMutation) ResetLang() {
  7766. m.lang = nil
  7767. delete(m.clearedFields, batchmsg.FieldLang)
  7768. }
  7769. // Where appends a list predicates to the BatchMsgMutation builder.
  7770. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  7771. m.predicates = append(m.predicates, ps...)
  7772. }
  7773. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  7774. // users can use type-assertion to append predicates that do not depend on any generated package.
  7775. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  7776. p := make([]predicate.BatchMsg, len(ps))
  7777. for i := range ps {
  7778. p[i] = ps[i]
  7779. }
  7780. m.Where(p...)
  7781. }
  7782. // Op returns the operation name.
  7783. func (m *BatchMsgMutation) Op() Op {
  7784. return m.op
  7785. }
  7786. // SetOp allows setting the mutation operation.
  7787. func (m *BatchMsgMutation) SetOp(op Op) {
  7788. m.op = op
  7789. }
  7790. // Type returns the node type of this mutation (BatchMsg).
  7791. func (m *BatchMsgMutation) Type() string {
  7792. return m.typ
  7793. }
  7794. // Fields returns all fields that were changed during this mutation. Note that in
  7795. // order to get all numeric fields that were incremented/decremented, call
  7796. // AddedFields().
  7797. func (m *BatchMsgMutation) Fields() []string {
  7798. fields := make([]string, 0, 24)
  7799. if m.created_at != nil {
  7800. fields = append(fields, batchmsg.FieldCreatedAt)
  7801. }
  7802. if m.updated_at != nil {
  7803. fields = append(fields, batchmsg.FieldUpdatedAt)
  7804. }
  7805. if m.deleted_at != nil {
  7806. fields = append(fields, batchmsg.FieldDeletedAt)
  7807. }
  7808. if m.status != nil {
  7809. fields = append(fields, batchmsg.FieldStatus)
  7810. }
  7811. if m.batch_no != nil {
  7812. fields = append(fields, batchmsg.FieldBatchNo)
  7813. }
  7814. if m.task_name != nil {
  7815. fields = append(fields, batchmsg.FieldTaskName)
  7816. }
  7817. if m.fromwxid != nil {
  7818. fields = append(fields, batchmsg.FieldFromwxid)
  7819. }
  7820. if m.msg != nil {
  7821. fields = append(fields, batchmsg.FieldMsg)
  7822. }
  7823. if m.tag != nil {
  7824. fields = append(fields, batchmsg.FieldTag)
  7825. }
  7826. if m.tagids != nil {
  7827. fields = append(fields, batchmsg.FieldTagids)
  7828. }
  7829. if m.total != nil {
  7830. fields = append(fields, batchmsg.FieldTotal)
  7831. }
  7832. if m.success != nil {
  7833. fields = append(fields, batchmsg.FieldSuccess)
  7834. }
  7835. if m.fail != nil {
  7836. fields = append(fields, batchmsg.FieldFail)
  7837. }
  7838. if m.start_time != nil {
  7839. fields = append(fields, batchmsg.FieldStartTime)
  7840. }
  7841. if m.stop_time != nil {
  7842. fields = append(fields, batchmsg.FieldStopTime)
  7843. }
  7844. if m.send_time != nil {
  7845. fields = append(fields, batchmsg.FieldSendTime)
  7846. }
  7847. if m._type != nil {
  7848. fields = append(fields, batchmsg.FieldType)
  7849. }
  7850. if m.organization_id != nil {
  7851. fields = append(fields, batchmsg.FieldOrganizationID)
  7852. }
  7853. if m.ctype != nil {
  7854. fields = append(fields, batchmsg.FieldCtype)
  7855. }
  7856. if m.cc != nil {
  7857. fields = append(fields, batchmsg.FieldCc)
  7858. }
  7859. if m.phone != nil {
  7860. fields = append(fields, batchmsg.FieldPhone)
  7861. }
  7862. if m.template_name != nil {
  7863. fields = append(fields, batchmsg.FieldTemplateName)
  7864. }
  7865. if m.template_code != nil {
  7866. fields = append(fields, batchmsg.FieldTemplateCode)
  7867. }
  7868. if m.lang != nil {
  7869. fields = append(fields, batchmsg.FieldLang)
  7870. }
  7871. return fields
  7872. }
  7873. // Field returns the value of a field with the given name. The second boolean
  7874. // return value indicates that this field was not set, or was not defined in the
  7875. // schema.
  7876. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  7877. switch name {
  7878. case batchmsg.FieldCreatedAt:
  7879. return m.CreatedAt()
  7880. case batchmsg.FieldUpdatedAt:
  7881. return m.UpdatedAt()
  7882. case batchmsg.FieldDeletedAt:
  7883. return m.DeletedAt()
  7884. case batchmsg.FieldStatus:
  7885. return m.Status()
  7886. case batchmsg.FieldBatchNo:
  7887. return m.BatchNo()
  7888. case batchmsg.FieldTaskName:
  7889. return m.TaskName()
  7890. case batchmsg.FieldFromwxid:
  7891. return m.Fromwxid()
  7892. case batchmsg.FieldMsg:
  7893. return m.Msg()
  7894. case batchmsg.FieldTag:
  7895. return m.Tag()
  7896. case batchmsg.FieldTagids:
  7897. return m.Tagids()
  7898. case batchmsg.FieldTotal:
  7899. return m.Total()
  7900. case batchmsg.FieldSuccess:
  7901. return m.Success()
  7902. case batchmsg.FieldFail:
  7903. return m.Fail()
  7904. case batchmsg.FieldStartTime:
  7905. return m.StartTime()
  7906. case batchmsg.FieldStopTime:
  7907. return m.StopTime()
  7908. case batchmsg.FieldSendTime:
  7909. return m.SendTime()
  7910. case batchmsg.FieldType:
  7911. return m.GetType()
  7912. case batchmsg.FieldOrganizationID:
  7913. return m.OrganizationID()
  7914. case batchmsg.FieldCtype:
  7915. return m.Ctype()
  7916. case batchmsg.FieldCc:
  7917. return m.Cc()
  7918. case batchmsg.FieldPhone:
  7919. return m.Phone()
  7920. case batchmsg.FieldTemplateName:
  7921. return m.TemplateName()
  7922. case batchmsg.FieldTemplateCode:
  7923. return m.TemplateCode()
  7924. case batchmsg.FieldLang:
  7925. return m.Lang()
  7926. }
  7927. return nil, false
  7928. }
  7929. // OldField returns the old value of the field from the database. An error is
  7930. // returned if the mutation operation is not UpdateOne, or the query to the
  7931. // database failed.
  7932. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7933. switch name {
  7934. case batchmsg.FieldCreatedAt:
  7935. return m.OldCreatedAt(ctx)
  7936. case batchmsg.FieldUpdatedAt:
  7937. return m.OldUpdatedAt(ctx)
  7938. case batchmsg.FieldDeletedAt:
  7939. return m.OldDeletedAt(ctx)
  7940. case batchmsg.FieldStatus:
  7941. return m.OldStatus(ctx)
  7942. case batchmsg.FieldBatchNo:
  7943. return m.OldBatchNo(ctx)
  7944. case batchmsg.FieldTaskName:
  7945. return m.OldTaskName(ctx)
  7946. case batchmsg.FieldFromwxid:
  7947. return m.OldFromwxid(ctx)
  7948. case batchmsg.FieldMsg:
  7949. return m.OldMsg(ctx)
  7950. case batchmsg.FieldTag:
  7951. return m.OldTag(ctx)
  7952. case batchmsg.FieldTagids:
  7953. return m.OldTagids(ctx)
  7954. case batchmsg.FieldTotal:
  7955. return m.OldTotal(ctx)
  7956. case batchmsg.FieldSuccess:
  7957. return m.OldSuccess(ctx)
  7958. case batchmsg.FieldFail:
  7959. return m.OldFail(ctx)
  7960. case batchmsg.FieldStartTime:
  7961. return m.OldStartTime(ctx)
  7962. case batchmsg.FieldStopTime:
  7963. return m.OldStopTime(ctx)
  7964. case batchmsg.FieldSendTime:
  7965. return m.OldSendTime(ctx)
  7966. case batchmsg.FieldType:
  7967. return m.OldType(ctx)
  7968. case batchmsg.FieldOrganizationID:
  7969. return m.OldOrganizationID(ctx)
  7970. case batchmsg.FieldCtype:
  7971. return m.OldCtype(ctx)
  7972. case batchmsg.FieldCc:
  7973. return m.OldCc(ctx)
  7974. case batchmsg.FieldPhone:
  7975. return m.OldPhone(ctx)
  7976. case batchmsg.FieldTemplateName:
  7977. return m.OldTemplateName(ctx)
  7978. case batchmsg.FieldTemplateCode:
  7979. return m.OldTemplateCode(ctx)
  7980. case batchmsg.FieldLang:
  7981. return m.OldLang(ctx)
  7982. }
  7983. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  7984. }
  7985. // SetField sets the value of a field with the given name. It returns an error if
  7986. // the field is not defined in the schema, or if the type mismatched the field
  7987. // type.
  7988. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  7989. switch name {
  7990. case batchmsg.FieldCreatedAt:
  7991. v, ok := value.(time.Time)
  7992. if !ok {
  7993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7994. }
  7995. m.SetCreatedAt(v)
  7996. return nil
  7997. case batchmsg.FieldUpdatedAt:
  7998. v, ok := value.(time.Time)
  7999. if !ok {
  8000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8001. }
  8002. m.SetUpdatedAt(v)
  8003. return nil
  8004. case batchmsg.FieldDeletedAt:
  8005. v, ok := value.(time.Time)
  8006. if !ok {
  8007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8008. }
  8009. m.SetDeletedAt(v)
  8010. return nil
  8011. case batchmsg.FieldStatus:
  8012. v, ok := value.(uint8)
  8013. if !ok {
  8014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8015. }
  8016. m.SetStatus(v)
  8017. return nil
  8018. case batchmsg.FieldBatchNo:
  8019. v, ok := value.(string)
  8020. if !ok {
  8021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8022. }
  8023. m.SetBatchNo(v)
  8024. return nil
  8025. case batchmsg.FieldTaskName:
  8026. v, ok := value.(string)
  8027. if !ok {
  8028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8029. }
  8030. m.SetTaskName(v)
  8031. return nil
  8032. case batchmsg.FieldFromwxid:
  8033. v, ok := value.(string)
  8034. if !ok {
  8035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8036. }
  8037. m.SetFromwxid(v)
  8038. return nil
  8039. case batchmsg.FieldMsg:
  8040. v, ok := value.(string)
  8041. if !ok {
  8042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8043. }
  8044. m.SetMsg(v)
  8045. return nil
  8046. case batchmsg.FieldTag:
  8047. v, ok := value.(string)
  8048. if !ok {
  8049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8050. }
  8051. m.SetTag(v)
  8052. return nil
  8053. case batchmsg.FieldTagids:
  8054. v, ok := value.(string)
  8055. if !ok {
  8056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8057. }
  8058. m.SetTagids(v)
  8059. return nil
  8060. case batchmsg.FieldTotal:
  8061. v, ok := value.(int32)
  8062. if !ok {
  8063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8064. }
  8065. m.SetTotal(v)
  8066. return nil
  8067. case batchmsg.FieldSuccess:
  8068. v, ok := value.(int32)
  8069. if !ok {
  8070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8071. }
  8072. m.SetSuccess(v)
  8073. return nil
  8074. case batchmsg.FieldFail:
  8075. v, ok := value.(int32)
  8076. if !ok {
  8077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8078. }
  8079. m.SetFail(v)
  8080. return nil
  8081. case batchmsg.FieldStartTime:
  8082. v, ok := value.(time.Time)
  8083. if !ok {
  8084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8085. }
  8086. m.SetStartTime(v)
  8087. return nil
  8088. case batchmsg.FieldStopTime:
  8089. v, ok := value.(time.Time)
  8090. if !ok {
  8091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8092. }
  8093. m.SetStopTime(v)
  8094. return nil
  8095. case batchmsg.FieldSendTime:
  8096. v, ok := value.(time.Time)
  8097. if !ok {
  8098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8099. }
  8100. m.SetSendTime(v)
  8101. return nil
  8102. case batchmsg.FieldType:
  8103. v, ok := value.(int32)
  8104. if !ok {
  8105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8106. }
  8107. m.SetType(v)
  8108. return nil
  8109. case batchmsg.FieldOrganizationID:
  8110. v, ok := value.(uint64)
  8111. if !ok {
  8112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8113. }
  8114. m.SetOrganizationID(v)
  8115. return nil
  8116. case batchmsg.FieldCtype:
  8117. v, ok := value.(uint64)
  8118. if !ok {
  8119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8120. }
  8121. m.SetCtype(v)
  8122. return nil
  8123. case batchmsg.FieldCc:
  8124. v, ok := value.(string)
  8125. if !ok {
  8126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8127. }
  8128. m.SetCc(v)
  8129. return nil
  8130. case batchmsg.FieldPhone:
  8131. v, ok := value.(string)
  8132. if !ok {
  8133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8134. }
  8135. m.SetPhone(v)
  8136. return nil
  8137. case batchmsg.FieldTemplateName:
  8138. v, ok := value.(string)
  8139. if !ok {
  8140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8141. }
  8142. m.SetTemplateName(v)
  8143. return nil
  8144. case batchmsg.FieldTemplateCode:
  8145. v, ok := value.(string)
  8146. if !ok {
  8147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8148. }
  8149. m.SetTemplateCode(v)
  8150. return nil
  8151. case batchmsg.FieldLang:
  8152. v, ok := value.(string)
  8153. if !ok {
  8154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8155. }
  8156. m.SetLang(v)
  8157. return nil
  8158. }
  8159. return fmt.Errorf("unknown BatchMsg field %s", name)
  8160. }
  8161. // AddedFields returns all numeric fields that were incremented/decremented during
  8162. // this mutation.
  8163. func (m *BatchMsgMutation) AddedFields() []string {
  8164. var fields []string
  8165. if m.addstatus != nil {
  8166. fields = append(fields, batchmsg.FieldStatus)
  8167. }
  8168. if m.addtotal != nil {
  8169. fields = append(fields, batchmsg.FieldTotal)
  8170. }
  8171. if m.addsuccess != nil {
  8172. fields = append(fields, batchmsg.FieldSuccess)
  8173. }
  8174. if m.addfail != nil {
  8175. fields = append(fields, batchmsg.FieldFail)
  8176. }
  8177. if m.add_type != nil {
  8178. fields = append(fields, batchmsg.FieldType)
  8179. }
  8180. if m.addorganization_id != nil {
  8181. fields = append(fields, batchmsg.FieldOrganizationID)
  8182. }
  8183. if m.addctype != nil {
  8184. fields = append(fields, batchmsg.FieldCtype)
  8185. }
  8186. return fields
  8187. }
  8188. // AddedField returns the numeric value that was incremented/decremented on a field
  8189. // with the given name. The second boolean return value indicates that this field
  8190. // was not set, or was not defined in the schema.
  8191. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  8192. switch name {
  8193. case batchmsg.FieldStatus:
  8194. return m.AddedStatus()
  8195. case batchmsg.FieldTotal:
  8196. return m.AddedTotal()
  8197. case batchmsg.FieldSuccess:
  8198. return m.AddedSuccess()
  8199. case batchmsg.FieldFail:
  8200. return m.AddedFail()
  8201. case batchmsg.FieldType:
  8202. return m.AddedType()
  8203. case batchmsg.FieldOrganizationID:
  8204. return m.AddedOrganizationID()
  8205. case batchmsg.FieldCtype:
  8206. return m.AddedCtype()
  8207. }
  8208. return nil, false
  8209. }
  8210. // AddField adds the value to the field with the given name. It returns an error if
  8211. // the field is not defined in the schema, or if the type mismatched the field
  8212. // type.
  8213. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  8214. switch name {
  8215. case batchmsg.FieldStatus:
  8216. v, ok := value.(int8)
  8217. if !ok {
  8218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8219. }
  8220. m.AddStatus(v)
  8221. return nil
  8222. case batchmsg.FieldTotal:
  8223. v, ok := value.(int32)
  8224. if !ok {
  8225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8226. }
  8227. m.AddTotal(v)
  8228. return nil
  8229. case batchmsg.FieldSuccess:
  8230. v, ok := value.(int32)
  8231. if !ok {
  8232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8233. }
  8234. m.AddSuccess(v)
  8235. return nil
  8236. case batchmsg.FieldFail:
  8237. v, ok := value.(int32)
  8238. if !ok {
  8239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8240. }
  8241. m.AddFail(v)
  8242. return nil
  8243. case batchmsg.FieldType:
  8244. v, ok := value.(int32)
  8245. if !ok {
  8246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8247. }
  8248. m.AddType(v)
  8249. return nil
  8250. case batchmsg.FieldOrganizationID:
  8251. v, ok := value.(int64)
  8252. if !ok {
  8253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8254. }
  8255. m.AddOrganizationID(v)
  8256. return nil
  8257. case batchmsg.FieldCtype:
  8258. v, ok := value.(int64)
  8259. if !ok {
  8260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8261. }
  8262. m.AddCtype(v)
  8263. return nil
  8264. }
  8265. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  8266. }
  8267. // ClearedFields returns all nullable fields that were cleared during this
  8268. // mutation.
  8269. func (m *BatchMsgMutation) ClearedFields() []string {
  8270. var fields []string
  8271. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  8272. fields = append(fields, batchmsg.FieldDeletedAt)
  8273. }
  8274. if m.FieldCleared(batchmsg.FieldStatus) {
  8275. fields = append(fields, batchmsg.FieldStatus)
  8276. }
  8277. if m.FieldCleared(batchmsg.FieldBatchNo) {
  8278. fields = append(fields, batchmsg.FieldBatchNo)
  8279. }
  8280. if m.FieldCleared(batchmsg.FieldTaskName) {
  8281. fields = append(fields, batchmsg.FieldTaskName)
  8282. }
  8283. if m.FieldCleared(batchmsg.FieldFromwxid) {
  8284. fields = append(fields, batchmsg.FieldFromwxid)
  8285. }
  8286. if m.FieldCleared(batchmsg.FieldMsg) {
  8287. fields = append(fields, batchmsg.FieldMsg)
  8288. }
  8289. if m.FieldCleared(batchmsg.FieldTag) {
  8290. fields = append(fields, batchmsg.FieldTag)
  8291. }
  8292. if m.FieldCleared(batchmsg.FieldTagids) {
  8293. fields = append(fields, batchmsg.FieldTagids)
  8294. }
  8295. if m.FieldCleared(batchmsg.FieldTotal) {
  8296. fields = append(fields, batchmsg.FieldTotal)
  8297. }
  8298. if m.FieldCleared(batchmsg.FieldSuccess) {
  8299. fields = append(fields, batchmsg.FieldSuccess)
  8300. }
  8301. if m.FieldCleared(batchmsg.FieldFail) {
  8302. fields = append(fields, batchmsg.FieldFail)
  8303. }
  8304. if m.FieldCleared(batchmsg.FieldStartTime) {
  8305. fields = append(fields, batchmsg.FieldStartTime)
  8306. }
  8307. if m.FieldCleared(batchmsg.FieldStopTime) {
  8308. fields = append(fields, batchmsg.FieldStopTime)
  8309. }
  8310. if m.FieldCleared(batchmsg.FieldSendTime) {
  8311. fields = append(fields, batchmsg.FieldSendTime)
  8312. }
  8313. if m.FieldCleared(batchmsg.FieldType) {
  8314. fields = append(fields, batchmsg.FieldType)
  8315. }
  8316. if m.FieldCleared(batchmsg.FieldCc) {
  8317. fields = append(fields, batchmsg.FieldCc)
  8318. }
  8319. if m.FieldCleared(batchmsg.FieldPhone) {
  8320. fields = append(fields, batchmsg.FieldPhone)
  8321. }
  8322. if m.FieldCleared(batchmsg.FieldTemplateName) {
  8323. fields = append(fields, batchmsg.FieldTemplateName)
  8324. }
  8325. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  8326. fields = append(fields, batchmsg.FieldTemplateCode)
  8327. }
  8328. if m.FieldCleared(batchmsg.FieldLang) {
  8329. fields = append(fields, batchmsg.FieldLang)
  8330. }
  8331. return fields
  8332. }
  8333. // FieldCleared returns a boolean indicating if a field with the given name was
  8334. // cleared in this mutation.
  8335. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  8336. _, ok := m.clearedFields[name]
  8337. return ok
  8338. }
  8339. // ClearField clears the value of the field with the given name. It returns an
  8340. // error if the field is not defined in the schema.
  8341. func (m *BatchMsgMutation) ClearField(name string) error {
  8342. switch name {
  8343. case batchmsg.FieldDeletedAt:
  8344. m.ClearDeletedAt()
  8345. return nil
  8346. case batchmsg.FieldStatus:
  8347. m.ClearStatus()
  8348. return nil
  8349. case batchmsg.FieldBatchNo:
  8350. m.ClearBatchNo()
  8351. return nil
  8352. case batchmsg.FieldTaskName:
  8353. m.ClearTaskName()
  8354. return nil
  8355. case batchmsg.FieldFromwxid:
  8356. m.ClearFromwxid()
  8357. return nil
  8358. case batchmsg.FieldMsg:
  8359. m.ClearMsg()
  8360. return nil
  8361. case batchmsg.FieldTag:
  8362. m.ClearTag()
  8363. return nil
  8364. case batchmsg.FieldTagids:
  8365. m.ClearTagids()
  8366. return nil
  8367. case batchmsg.FieldTotal:
  8368. m.ClearTotal()
  8369. return nil
  8370. case batchmsg.FieldSuccess:
  8371. m.ClearSuccess()
  8372. return nil
  8373. case batchmsg.FieldFail:
  8374. m.ClearFail()
  8375. return nil
  8376. case batchmsg.FieldStartTime:
  8377. m.ClearStartTime()
  8378. return nil
  8379. case batchmsg.FieldStopTime:
  8380. m.ClearStopTime()
  8381. return nil
  8382. case batchmsg.FieldSendTime:
  8383. m.ClearSendTime()
  8384. return nil
  8385. case batchmsg.FieldType:
  8386. m.ClearType()
  8387. return nil
  8388. case batchmsg.FieldCc:
  8389. m.ClearCc()
  8390. return nil
  8391. case batchmsg.FieldPhone:
  8392. m.ClearPhone()
  8393. return nil
  8394. case batchmsg.FieldTemplateName:
  8395. m.ClearTemplateName()
  8396. return nil
  8397. case batchmsg.FieldTemplateCode:
  8398. m.ClearTemplateCode()
  8399. return nil
  8400. case batchmsg.FieldLang:
  8401. m.ClearLang()
  8402. return nil
  8403. }
  8404. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  8405. }
  8406. // ResetField resets all changes in the mutation for the field with the given name.
  8407. // It returns an error if the field is not defined in the schema.
  8408. func (m *BatchMsgMutation) ResetField(name string) error {
  8409. switch name {
  8410. case batchmsg.FieldCreatedAt:
  8411. m.ResetCreatedAt()
  8412. return nil
  8413. case batchmsg.FieldUpdatedAt:
  8414. m.ResetUpdatedAt()
  8415. return nil
  8416. case batchmsg.FieldDeletedAt:
  8417. m.ResetDeletedAt()
  8418. return nil
  8419. case batchmsg.FieldStatus:
  8420. m.ResetStatus()
  8421. return nil
  8422. case batchmsg.FieldBatchNo:
  8423. m.ResetBatchNo()
  8424. return nil
  8425. case batchmsg.FieldTaskName:
  8426. m.ResetTaskName()
  8427. return nil
  8428. case batchmsg.FieldFromwxid:
  8429. m.ResetFromwxid()
  8430. return nil
  8431. case batchmsg.FieldMsg:
  8432. m.ResetMsg()
  8433. return nil
  8434. case batchmsg.FieldTag:
  8435. m.ResetTag()
  8436. return nil
  8437. case batchmsg.FieldTagids:
  8438. m.ResetTagids()
  8439. return nil
  8440. case batchmsg.FieldTotal:
  8441. m.ResetTotal()
  8442. return nil
  8443. case batchmsg.FieldSuccess:
  8444. m.ResetSuccess()
  8445. return nil
  8446. case batchmsg.FieldFail:
  8447. m.ResetFail()
  8448. return nil
  8449. case batchmsg.FieldStartTime:
  8450. m.ResetStartTime()
  8451. return nil
  8452. case batchmsg.FieldStopTime:
  8453. m.ResetStopTime()
  8454. return nil
  8455. case batchmsg.FieldSendTime:
  8456. m.ResetSendTime()
  8457. return nil
  8458. case batchmsg.FieldType:
  8459. m.ResetType()
  8460. return nil
  8461. case batchmsg.FieldOrganizationID:
  8462. m.ResetOrganizationID()
  8463. return nil
  8464. case batchmsg.FieldCtype:
  8465. m.ResetCtype()
  8466. return nil
  8467. case batchmsg.FieldCc:
  8468. m.ResetCc()
  8469. return nil
  8470. case batchmsg.FieldPhone:
  8471. m.ResetPhone()
  8472. return nil
  8473. case batchmsg.FieldTemplateName:
  8474. m.ResetTemplateName()
  8475. return nil
  8476. case batchmsg.FieldTemplateCode:
  8477. m.ResetTemplateCode()
  8478. return nil
  8479. case batchmsg.FieldLang:
  8480. m.ResetLang()
  8481. return nil
  8482. }
  8483. return fmt.Errorf("unknown BatchMsg field %s", name)
  8484. }
  8485. // AddedEdges returns all edge names that were set/added in this mutation.
  8486. func (m *BatchMsgMutation) AddedEdges() []string {
  8487. edges := make([]string, 0, 0)
  8488. return edges
  8489. }
  8490. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8491. // name in this mutation.
  8492. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  8493. return nil
  8494. }
  8495. // RemovedEdges returns all edge names that were removed in this mutation.
  8496. func (m *BatchMsgMutation) RemovedEdges() []string {
  8497. edges := make([]string, 0, 0)
  8498. return edges
  8499. }
  8500. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8501. // the given name in this mutation.
  8502. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  8503. return nil
  8504. }
  8505. // ClearedEdges returns all edge names that were cleared in this mutation.
  8506. func (m *BatchMsgMutation) ClearedEdges() []string {
  8507. edges := make([]string, 0, 0)
  8508. return edges
  8509. }
  8510. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8511. // was cleared in this mutation.
  8512. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  8513. return false
  8514. }
  8515. // ClearEdge clears the value of the edge with the given name. It returns an error
  8516. // if that edge is not defined in the schema.
  8517. func (m *BatchMsgMutation) ClearEdge(name string) error {
  8518. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  8519. }
  8520. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8521. // It returns an error if the edge is not defined in the schema.
  8522. func (m *BatchMsgMutation) ResetEdge(name string) error {
  8523. return fmt.Errorf("unknown BatchMsg edge %s", name)
  8524. }
  8525. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  8526. type CategoryMutation struct {
  8527. config
  8528. op Op
  8529. typ string
  8530. id *uint64
  8531. created_at *time.Time
  8532. updated_at *time.Time
  8533. deleted_at *time.Time
  8534. name *string
  8535. organization_id *uint64
  8536. addorganization_id *int64
  8537. clearedFields map[string]struct{}
  8538. done bool
  8539. oldValue func(context.Context) (*Category, error)
  8540. predicates []predicate.Category
  8541. }
  8542. var _ ent.Mutation = (*CategoryMutation)(nil)
  8543. // categoryOption allows management of the mutation configuration using functional options.
  8544. type categoryOption func(*CategoryMutation)
  8545. // newCategoryMutation creates new mutation for the Category entity.
  8546. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  8547. m := &CategoryMutation{
  8548. config: c,
  8549. op: op,
  8550. typ: TypeCategory,
  8551. clearedFields: make(map[string]struct{}),
  8552. }
  8553. for _, opt := range opts {
  8554. opt(m)
  8555. }
  8556. return m
  8557. }
  8558. // withCategoryID sets the ID field of the mutation.
  8559. func withCategoryID(id uint64) categoryOption {
  8560. return func(m *CategoryMutation) {
  8561. var (
  8562. err error
  8563. once sync.Once
  8564. value *Category
  8565. )
  8566. m.oldValue = func(ctx context.Context) (*Category, error) {
  8567. once.Do(func() {
  8568. if m.done {
  8569. err = errors.New("querying old values post mutation is not allowed")
  8570. } else {
  8571. value, err = m.Client().Category.Get(ctx, id)
  8572. }
  8573. })
  8574. return value, err
  8575. }
  8576. m.id = &id
  8577. }
  8578. }
  8579. // withCategory sets the old Category of the mutation.
  8580. func withCategory(node *Category) categoryOption {
  8581. return func(m *CategoryMutation) {
  8582. m.oldValue = func(context.Context) (*Category, error) {
  8583. return node, nil
  8584. }
  8585. m.id = &node.ID
  8586. }
  8587. }
  8588. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8589. // executed in a transaction (ent.Tx), a transactional client is returned.
  8590. func (m CategoryMutation) Client() *Client {
  8591. client := &Client{config: m.config}
  8592. client.init()
  8593. return client
  8594. }
  8595. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8596. // it returns an error otherwise.
  8597. func (m CategoryMutation) Tx() (*Tx, error) {
  8598. if _, ok := m.driver.(*txDriver); !ok {
  8599. return nil, errors.New("ent: mutation is not running in a transaction")
  8600. }
  8601. tx := &Tx{config: m.config}
  8602. tx.init()
  8603. return tx, nil
  8604. }
  8605. // SetID sets the value of the id field. Note that this
  8606. // operation is only accepted on creation of Category entities.
  8607. func (m *CategoryMutation) SetID(id uint64) {
  8608. m.id = &id
  8609. }
  8610. // ID returns the ID value in the mutation. Note that the ID is only available
  8611. // if it was provided to the builder or after it was returned from the database.
  8612. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  8613. if m.id == nil {
  8614. return
  8615. }
  8616. return *m.id, true
  8617. }
  8618. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8619. // That means, if the mutation is applied within a transaction with an isolation level such
  8620. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8621. // or updated by the mutation.
  8622. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  8623. switch {
  8624. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8625. id, exists := m.ID()
  8626. if exists {
  8627. return []uint64{id}, nil
  8628. }
  8629. fallthrough
  8630. case m.op.Is(OpUpdate | OpDelete):
  8631. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  8632. default:
  8633. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8634. }
  8635. }
  8636. // SetCreatedAt sets the "created_at" field.
  8637. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  8638. m.created_at = &t
  8639. }
  8640. // CreatedAt returns the value of the "created_at" field in the mutation.
  8641. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  8642. v := m.created_at
  8643. if v == nil {
  8644. return
  8645. }
  8646. return *v, true
  8647. }
  8648. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  8649. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8651. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8652. if !m.op.Is(OpUpdateOne) {
  8653. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8654. }
  8655. if m.id == nil || m.oldValue == nil {
  8656. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8657. }
  8658. oldValue, err := m.oldValue(ctx)
  8659. if err != nil {
  8660. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8661. }
  8662. return oldValue.CreatedAt, nil
  8663. }
  8664. // ResetCreatedAt resets all changes to the "created_at" field.
  8665. func (m *CategoryMutation) ResetCreatedAt() {
  8666. m.created_at = nil
  8667. }
  8668. // SetUpdatedAt sets the "updated_at" field.
  8669. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  8670. m.updated_at = &t
  8671. }
  8672. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8673. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  8674. v := m.updated_at
  8675. if v == nil {
  8676. return
  8677. }
  8678. return *v, true
  8679. }
  8680. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  8681. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8683. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8684. if !m.op.Is(OpUpdateOne) {
  8685. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8686. }
  8687. if m.id == nil || m.oldValue == nil {
  8688. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8689. }
  8690. oldValue, err := m.oldValue(ctx)
  8691. if err != nil {
  8692. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8693. }
  8694. return oldValue.UpdatedAt, nil
  8695. }
  8696. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8697. func (m *CategoryMutation) ResetUpdatedAt() {
  8698. m.updated_at = nil
  8699. }
  8700. // SetDeletedAt sets the "deleted_at" field.
  8701. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  8702. m.deleted_at = &t
  8703. }
  8704. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8705. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  8706. v := m.deleted_at
  8707. if v == nil {
  8708. return
  8709. }
  8710. return *v, true
  8711. }
  8712. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  8713. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8715. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8716. if !m.op.Is(OpUpdateOne) {
  8717. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8718. }
  8719. if m.id == nil || m.oldValue == nil {
  8720. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8721. }
  8722. oldValue, err := m.oldValue(ctx)
  8723. if err != nil {
  8724. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8725. }
  8726. return oldValue.DeletedAt, nil
  8727. }
  8728. // ClearDeletedAt clears the value of the "deleted_at" field.
  8729. func (m *CategoryMutation) ClearDeletedAt() {
  8730. m.deleted_at = nil
  8731. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  8732. }
  8733. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8734. func (m *CategoryMutation) DeletedAtCleared() bool {
  8735. _, ok := m.clearedFields[category.FieldDeletedAt]
  8736. return ok
  8737. }
  8738. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8739. func (m *CategoryMutation) ResetDeletedAt() {
  8740. m.deleted_at = nil
  8741. delete(m.clearedFields, category.FieldDeletedAt)
  8742. }
  8743. // SetName sets the "name" field.
  8744. func (m *CategoryMutation) SetName(s string) {
  8745. m.name = &s
  8746. }
  8747. // Name returns the value of the "name" field in the mutation.
  8748. func (m *CategoryMutation) Name() (r string, exists bool) {
  8749. v := m.name
  8750. if v == nil {
  8751. return
  8752. }
  8753. return *v, true
  8754. }
  8755. // OldName returns the old "name" field's value of the Category entity.
  8756. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8758. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  8759. if !m.op.Is(OpUpdateOne) {
  8760. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8761. }
  8762. if m.id == nil || m.oldValue == nil {
  8763. return v, errors.New("OldName requires an ID field in the mutation")
  8764. }
  8765. oldValue, err := m.oldValue(ctx)
  8766. if err != nil {
  8767. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8768. }
  8769. return oldValue.Name, nil
  8770. }
  8771. // ResetName resets all changes to the "name" field.
  8772. func (m *CategoryMutation) ResetName() {
  8773. m.name = nil
  8774. }
  8775. // SetOrganizationID sets the "organization_id" field.
  8776. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  8777. m.organization_id = &u
  8778. m.addorganization_id = nil
  8779. }
  8780. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8781. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  8782. v := m.organization_id
  8783. if v == nil {
  8784. return
  8785. }
  8786. return *v, true
  8787. }
  8788. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  8789. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8791. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8792. if !m.op.Is(OpUpdateOne) {
  8793. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8794. }
  8795. if m.id == nil || m.oldValue == nil {
  8796. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8797. }
  8798. oldValue, err := m.oldValue(ctx)
  8799. if err != nil {
  8800. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8801. }
  8802. return oldValue.OrganizationID, nil
  8803. }
  8804. // AddOrganizationID adds u to the "organization_id" field.
  8805. func (m *CategoryMutation) AddOrganizationID(u int64) {
  8806. if m.addorganization_id != nil {
  8807. *m.addorganization_id += u
  8808. } else {
  8809. m.addorganization_id = &u
  8810. }
  8811. }
  8812. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8813. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  8814. v := m.addorganization_id
  8815. if v == nil {
  8816. return
  8817. }
  8818. return *v, true
  8819. }
  8820. // ResetOrganizationID resets all changes to the "organization_id" field.
  8821. func (m *CategoryMutation) ResetOrganizationID() {
  8822. m.organization_id = nil
  8823. m.addorganization_id = nil
  8824. }
  8825. // Where appends a list predicates to the CategoryMutation builder.
  8826. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  8827. m.predicates = append(m.predicates, ps...)
  8828. }
  8829. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  8830. // users can use type-assertion to append predicates that do not depend on any generated package.
  8831. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  8832. p := make([]predicate.Category, len(ps))
  8833. for i := range ps {
  8834. p[i] = ps[i]
  8835. }
  8836. m.Where(p...)
  8837. }
  8838. // Op returns the operation name.
  8839. func (m *CategoryMutation) Op() Op {
  8840. return m.op
  8841. }
  8842. // SetOp allows setting the mutation operation.
  8843. func (m *CategoryMutation) SetOp(op Op) {
  8844. m.op = op
  8845. }
  8846. // Type returns the node type of this mutation (Category).
  8847. func (m *CategoryMutation) Type() string {
  8848. return m.typ
  8849. }
  8850. // Fields returns all fields that were changed during this mutation. Note that in
  8851. // order to get all numeric fields that were incremented/decremented, call
  8852. // AddedFields().
  8853. func (m *CategoryMutation) Fields() []string {
  8854. fields := make([]string, 0, 5)
  8855. if m.created_at != nil {
  8856. fields = append(fields, category.FieldCreatedAt)
  8857. }
  8858. if m.updated_at != nil {
  8859. fields = append(fields, category.FieldUpdatedAt)
  8860. }
  8861. if m.deleted_at != nil {
  8862. fields = append(fields, category.FieldDeletedAt)
  8863. }
  8864. if m.name != nil {
  8865. fields = append(fields, category.FieldName)
  8866. }
  8867. if m.organization_id != nil {
  8868. fields = append(fields, category.FieldOrganizationID)
  8869. }
  8870. return fields
  8871. }
  8872. // Field returns the value of a field with the given name. The second boolean
  8873. // return value indicates that this field was not set, or was not defined in the
  8874. // schema.
  8875. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  8876. switch name {
  8877. case category.FieldCreatedAt:
  8878. return m.CreatedAt()
  8879. case category.FieldUpdatedAt:
  8880. return m.UpdatedAt()
  8881. case category.FieldDeletedAt:
  8882. return m.DeletedAt()
  8883. case category.FieldName:
  8884. return m.Name()
  8885. case category.FieldOrganizationID:
  8886. return m.OrganizationID()
  8887. }
  8888. return nil, false
  8889. }
  8890. // OldField returns the old value of the field from the database. An error is
  8891. // returned if the mutation operation is not UpdateOne, or the query to the
  8892. // database failed.
  8893. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8894. switch name {
  8895. case category.FieldCreatedAt:
  8896. return m.OldCreatedAt(ctx)
  8897. case category.FieldUpdatedAt:
  8898. return m.OldUpdatedAt(ctx)
  8899. case category.FieldDeletedAt:
  8900. return m.OldDeletedAt(ctx)
  8901. case category.FieldName:
  8902. return m.OldName(ctx)
  8903. case category.FieldOrganizationID:
  8904. return m.OldOrganizationID(ctx)
  8905. }
  8906. return nil, fmt.Errorf("unknown Category field %s", name)
  8907. }
  8908. // SetField sets the value of a field with the given name. It returns an error if
  8909. // the field is not defined in the schema, or if the type mismatched the field
  8910. // type.
  8911. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  8912. switch name {
  8913. case category.FieldCreatedAt:
  8914. v, ok := value.(time.Time)
  8915. if !ok {
  8916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8917. }
  8918. m.SetCreatedAt(v)
  8919. return nil
  8920. case category.FieldUpdatedAt:
  8921. v, ok := value.(time.Time)
  8922. if !ok {
  8923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8924. }
  8925. m.SetUpdatedAt(v)
  8926. return nil
  8927. case category.FieldDeletedAt:
  8928. v, ok := value.(time.Time)
  8929. if !ok {
  8930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8931. }
  8932. m.SetDeletedAt(v)
  8933. return nil
  8934. case category.FieldName:
  8935. v, ok := value.(string)
  8936. if !ok {
  8937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8938. }
  8939. m.SetName(v)
  8940. return nil
  8941. case category.FieldOrganizationID:
  8942. v, ok := value.(uint64)
  8943. if !ok {
  8944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8945. }
  8946. m.SetOrganizationID(v)
  8947. return nil
  8948. }
  8949. return fmt.Errorf("unknown Category field %s", name)
  8950. }
  8951. // AddedFields returns all numeric fields that were incremented/decremented during
  8952. // this mutation.
  8953. func (m *CategoryMutation) AddedFields() []string {
  8954. var fields []string
  8955. if m.addorganization_id != nil {
  8956. fields = append(fields, category.FieldOrganizationID)
  8957. }
  8958. return fields
  8959. }
  8960. // AddedField returns the numeric value that was incremented/decremented on a field
  8961. // with the given name. The second boolean return value indicates that this field
  8962. // was not set, or was not defined in the schema.
  8963. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  8964. switch name {
  8965. case category.FieldOrganizationID:
  8966. return m.AddedOrganizationID()
  8967. }
  8968. return nil, false
  8969. }
  8970. // AddField adds the value to the field with the given name. It returns an error if
  8971. // the field is not defined in the schema, or if the type mismatched the field
  8972. // type.
  8973. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  8974. switch name {
  8975. case category.FieldOrganizationID:
  8976. v, ok := value.(int64)
  8977. if !ok {
  8978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8979. }
  8980. m.AddOrganizationID(v)
  8981. return nil
  8982. }
  8983. return fmt.Errorf("unknown Category numeric field %s", name)
  8984. }
  8985. // ClearedFields returns all nullable fields that were cleared during this
  8986. // mutation.
  8987. func (m *CategoryMutation) ClearedFields() []string {
  8988. var fields []string
  8989. if m.FieldCleared(category.FieldDeletedAt) {
  8990. fields = append(fields, category.FieldDeletedAt)
  8991. }
  8992. return fields
  8993. }
  8994. // FieldCleared returns a boolean indicating if a field with the given name was
  8995. // cleared in this mutation.
  8996. func (m *CategoryMutation) FieldCleared(name string) bool {
  8997. _, ok := m.clearedFields[name]
  8998. return ok
  8999. }
  9000. // ClearField clears the value of the field with the given name. It returns an
  9001. // error if the field is not defined in the schema.
  9002. func (m *CategoryMutation) ClearField(name string) error {
  9003. switch name {
  9004. case category.FieldDeletedAt:
  9005. m.ClearDeletedAt()
  9006. return nil
  9007. }
  9008. return fmt.Errorf("unknown Category nullable field %s", name)
  9009. }
  9010. // ResetField resets all changes in the mutation for the field with the given name.
  9011. // It returns an error if the field is not defined in the schema.
  9012. func (m *CategoryMutation) ResetField(name string) error {
  9013. switch name {
  9014. case category.FieldCreatedAt:
  9015. m.ResetCreatedAt()
  9016. return nil
  9017. case category.FieldUpdatedAt:
  9018. m.ResetUpdatedAt()
  9019. return nil
  9020. case category.FieldDeletedAt:
  9021. m.ResetDeletedAt()
  9022. return nil
  9023. case category.FieldName:
  9024. m.ResetName()
  9025. return nil
  9026. case category.FieldOrganizationID:
  9027. m.ResetOrganizationID()
  9028. return nil
  9029. }
  9030. return fmt.Errorf("unknown Category field %s", name)
  9031. }
  9032. // AddedEdges returns all edge names that were set/added in this mutation.
  9033. func (m *CategoryMutation) AddedEdges() []string {
  9034. edges := make([]string, 0, 0)
  9035. return edges
  9036. }
  9037. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9038. // name in this mutation.
  9039. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  9040. return nil
  9041. }
  9042. // RemovedEdges returns all edge names that were removed in this mutation.
  9043. func (m *CategoryMutation) RemovedEdges() []string {
  9044. edges := make([]string, 0, 0)
  9045. return edges
  9046. }
  9047. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9048. // the given name in this mutation.
  9049. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  9050. return nil
  9051. }
  9052. // ClearedEdges returns all edge names that were cleared in this mutation.
  9053. func (m *CategoryMutation) ClearedEdges() []string {
  9054. edges := make([]string, 0, 0)
  9055. return edges
  9056. }
  9057. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9058. // was cleared in this mutation.
  9059. func (m *CategoryMutation) EdgeCleared(name string) bool {
  9060. return false
  9061. }
  9062. // ClearEdge clears the value of the edge with the given name. It returns an error
  9063. // if that edge is not defined in the schema.
  9064. func (m *CategoryMutation) ClearEdge(name string) error {
  9065. return fmt.Errorf("unknown Category unique edge %s", name)
  9066. }
  9067. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9068. // It returns an error if the edge is not defined in the schema.
  9069. func (m *CategoryMutation) ResetEdge(name string) error {
  9070. return fmt.Errorf("unknown Category edge %s", name)
  9071. }
  9072. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  9073. type ChatRecordsMutation struct {
  9074. config
  9075. op Op
  9076. typ string
  9077. id *uint64
  9078. created_at *time.Time
  9079. updated_at *time.Time
  9080. deleted_at *time.Time
  9081. content *string
  9082. content_type *uint8
  9083. addcontent_type *int8
  9084. session_id *uint64
  9085. addsession_id *int64
  9086. user_id *uint64
  9087. adduser_id *int64
  9088. bot_id *uint64
  9089. addbot_id *int64
  9090. bot_type *uint8
  9091. addbot_type *int8
  9092. clearedFields map[string]struct{}
  9093. done bool
  9094. oldValue func(context.Context) (*ChatRecords, error)
  9095. predicates []predicate.ChatRecords
  9096. }
  9097. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  9098. // chatrecordsOption allows management of the mutation configuration using functional options.
  9099. type chatrecordsOption func(*ChatRecordsMutation)
  9100. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  9101. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  9102. m := &ChatRecordsMutation{
  9103. config: c,
  9104. op: op,
  9105. typ: TypeChatRecords,
  9106. clearedFields: make(map[string]struct{}),
  9107. }
  9108. for _, opt := range opts {
  9109. opt(m)
  9110. }
  9111. return m
  9112. }
  9113. // withChatRecordsID sets the ID field of the mutation.
  9114. func withChatRecordsID(id uint64) chatrecordsOption {
  9115. return func(m *ChatRecordsMutation) {
  9116. var (
  9117. err error
  9118. once sync.Once
  9119. value *ChatRecords
  9120. )
  9121. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  9122. once.Do(func() {
  9123. if m.done {
  9124. err = errors.New("querying old values post mutation is not allowed")
  9125. } else {
  9126. value, err = m.Client().ChatRecords.Get(ctx, id)
  9127. }
  9128. })
  9129. return value, err
  9130. }
  9131. m.id = &id
  9132. }
  9133. }
  9134. // withChatRecords sets the old ChatRecords of the mutation.
  9135. func withChatRecords(node *ChatRecords) chatrecordsOption {
  9136. return func(m *ChatRecordsMutation) {
  9137. m.oldValue = func(context.Context) (*ChatRecords, error) {
  9138. return node, nil
  9139. }
  9140. m.id = &node.ID
  9141. }
  9142. }
  9143. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9144. // executed in a transaction (ent.Tx), a transactional client is returned.
  9145. func (m ChatRecordsMutation) Client() *Client {
  9146. client := &Client{config: m.config}
  9147. client.init()
  9148. return client
  9149. }
  9150. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9151. // it returns an error otherwise.
  9152. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  9153. if _, ok := m.driver.(*txDriver); !ok {
  9154. return nil, errors.New("ent: mutation is not running in a transaction")
  9155. }
  9156. tx := &Tx{config: m.config}
  9157. tx.init()
  9158. return tx, nil
  9159. }
  9160. // SetID sets the value of the id field. Note that this
  9161. // operation is only accepted on creation of ChatRecords entities.
  9162. func (m *ChatRecordsMutation) SetID(id uint64) {
  9163. m.id = &id
  9164. }
  9165. // ID returns the ID value in the mutation. Note that the ID is only available
  9166. // if it was provided to the builder or after it was returned from the database.
  9167. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  9168. if m.id == nil {
  9169. return
  9170. }
  9171. return *m.id, true
  9172. }
  9173. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9174. // That means, if the mutation is applied within a transaction with an isolation level such
  9175. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9176. // or updated by the mutation.
  9177. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9178. switch {
  9179. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9180. id, exists := m.ID()
  9181. if exists {
  9182. return []uint64{id}, nil
  9183. }
  9184. fallthrough
  9185. case m.op.Is(OpUpdate | OpDelete):
  9186. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  9187. default:
  9188. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9189. }
  9190. }
  9191. // SetCreatedAt sets the "created_at" field.
  9192. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  9193. m.created_at = &t
  9194. }
  9195. // CreatedAt returns the value of the "created_at" field in the mutation.
  9196. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9197. v := m.created_at
  9198. if v == nil {
  9199. return
  9200. }
  9201. return *v, true
  9202. }
  9203. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  9204. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9206. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9207. if !m.op.Is(OpUpdateOne) {
  9208. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9209. }
  9210. if m.id == nil || m.oldValue == nil {
  9211. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9212. }
  9213. oldValue, err := m.oldValue(ctx)
  9214. if err != nil {
  9215. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9216. }
  9217. return oldValue.CreatedAt, nil
  9218. }
  9219. // ResetCreatedAt resets all changes to the "created_at" field.
  9220. func (m *ChatRecordsMutation) ResetCreatedAt() {
  9221. m.created_at = nil
  9222. }
  9223. // SetUpdatedAt sets the "updated_at" field.
  9224. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  9225. m.updated_at = &t
  9226. }
  9227. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9228. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9229. v := m.updated_at
  9230. if v == nil {
  9231. return
  9232. }
  9233. return *v, true
  9234. }
  9235. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  9236. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9238. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9239. if !m.op.Is(OpUpdateOne) {
  9240. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9241. }
  9242. if m.id == nil || m.oldValue == nil {
  9243. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9244. }
  9245. oldValue, err := m.oldValue(ctx)
  9246. if err != nil {
  9247. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9248. }
  9249. return oldValue.UpdatedAt, nil
  9250. }
  9251. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9252. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  9253. m.updated_at = nil
  9254. }
  9255. // SetDeletedAt sets the "deleted_at" field.
  9256. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  9257. m.deleted_at = &t
  9258. }
  9259. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9260. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9261. v := m.deleted_at
  9262. if v == nil {
  9263. return
  9264. }
  9265. return *v, true
  9266. }
  9267. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  9268. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9270. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9271. if !m.op.Is(OpUpdateOne) {
  9272. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9273. }
  9274. if m.id == nil || m.oldValue == nil {
  9275. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9276. }
  9277. oldValue, err := m.oldValue(ctx)
  9278. if err != nil {
  9279. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9280. }
  9281. return oldValue.DeletedAt, nil
  9282. }
  9283. // ClearDeletedAt clears the value of the "deleted_at" field.
  9284. func (m *ChatRecordsMutation) ClearDeletedAt() {
  9285. m.deleted_at = nil
  9286. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  9287. }
  9288. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9289. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  9290. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  9291. return ok
  9292. }
  9293. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9294. func (m *ChatRecordsMutation) ResetDeletedAt() {
  9295. m.deleted_at = nil
  9296. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  9297. }
  9298. // SetContent sets the "content" field.
  9299. func (m *ChatRecordsMutation) SetContent(s string) {
  9300. m.content = &s
  9301. }
  9302. // Content returns the value of the "content" field in the mutation.
  9303. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  9304. v := m.content
  9305. if v == nil {
  9306. return
  9307. }
  9308. return *v, true
  9309. }
  9310. // OldContent returns the old "content" field's value of the ChatRecords entity.
  9311. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9313. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9314. if !m.op.Is(OpUpdateOne) {
  9315. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9316. }
  9317. if m.id == nil || m.oldValue == nil {
  9318. return v, errors.New("OldContent requires an ID field in the mutation")
  9319. }
  9320. oldValue, err := m.oldValue(ctx)
  9321. if err != nil {
  9322. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9323. }
  9324. return oldValue.Content, nil
  9325. }
  9326. // ResetContent resets all changes to the "content" field.
  9327. func (m *ChatRecordsMutation) ResetContent() {
  9328. m.content = nil
  9329. }
  9330. // SetContentType sets the "content_type" field.
  9331. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  9332. m.content_type = &u
  9333. m.addcontent_type = nil
  9334. }
  9335. // ContentType returns the value of the "content_type" field in the mutation.
  9336. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  9337. v := m.content_type
  9338. if v == nil {
  9339. return
  9340. }
  9341. return *v, true
  9342. }
  9343. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  9344. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9346. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  9347. if !m.op.Is(OpUpdateOne) {
  9348. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9349. }
  9350. if m.id == nil || m.oldValue == nil {
  9351. return v, errors.New("OldContentType requires an ID field in the mutation")
  9352. }
  9353. oldValue, err := m.oldValue(ctx)
  9354. if err != nil {
  9355. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9356. }
  9357. return oldValue.ContentType, nil
  9358. }
  9359. // AddContentType adds u to the "content_type" field.
  9360. func (m *ChatRecordsMutation) AddContentType(u int8) {
  9361. if m.addcontent_type != nil {
  9362. *m.addcontent_type += u
  9363. } else {
  9364. m.addcontent_type = &u
  9365. }
  9366. }
  9367. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9368. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  9369. v := m.addcontent_type
  9370. if v == nil {
  9371. return
  9372. }
  9373. return *v, true
  9374. }
  9375. // ResetContentType resets all changes to the "content_type" field.
  9376. func (m *ChatRecordsMutation) ResetContentType() {
  9377. m.content_type = nil
  9378. m.addcontent_type = nil
  9379. }
  9380. // SetSessionID sets the "session_id" field.
  9381. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  9382. m.session_id = &u
  9383. m.addsession_id = nil
  9384. }
  9385. // SessionID returns the value of the "session_id" field in the mutation.
  9386. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  9387. v := m.session_id
  9388. if v == nil {
  9389. return
  9390. }
  9391. return *v, true
  9392. }
  9393. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  9394. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9396. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  9397. if !m.op.Is(OpUpdateOne) {
  9398. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  9399. }
  9400. if m.id == nil || m.oldValue == nil {
  9401. return v, errors.New("OldSessionID requires an ID field in the mutation")
  9402. }
  9403. oldValue, err := m.oldValue(ctx)
  9404. if err != nil {
  9405. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  9406. }
  9407. return oldValue.SessionID, nil
  9408. }
  9409. // AddSessionID adds u to the "session_id" field.
  9410. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  9411. if m.addsession_id != nil {
  9412. *m.addsession_id += u
  9413. } else {
  9414. m.addsession_id = &u
  9415. }
  9416. }
  9417. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  9418. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  9419. v := m.addsession_id
  9420. if v == nil {
  9421. return
  9422. }
  9423. return *v, true
  9424. }
  9425. // ResetSessionID resets all changes to the "session_id" field.
  9426. func (m *ChatRecordsMutation) ResetSessionID() {
  9427. m.session_id = nil
  9428. m.addsession_id = nil
  9429. }
  9430. // SetUserID sets the "user_id" field.
  9431. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  9432. m.user_id = &u
  9433. m.adduser_id = nil
  9434. }
  9435. // UserID returns the value of the "user_id" field in the mutation.
  9436. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  9437. v := m.user_id
  9438. if v == nil {
  9439. return
  9440. }
  9441. return *v, true
  9442. }
  9443. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  9444. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9446. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9447. if !m.op.Is(OpUpdateOne) {
  9448. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9449. }
  9450. if m.id == nil || m.oldValue == nil {
  9451. return v, errors.New("OldUserID requires an ID field in the mutation")
  9452. }
  9453. oldValue, err := m.oldValue(ctx)
  9454. if err != nil {
  9455. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9456. }
  9457. return oldValue.UserID, nil
  9458. }
  9459. // AddUserID adds u to the "user_id" field.
  9460. func (m *ChatRecordsMutation) AddUserID(u int64) {
  9461. if m.adduser_id != nil {
  9462. *m.adduser_id += u
  9463. } else {
  9464. m.adduser_id = &u
  9465. }
  9466. }
  9467. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9468. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  9469. v := m.adduser_id
  9470. if v == nil {
  9471. return
  9472. }
  9473. return *v, true
  9474. }
  9475. // ResetUserID resets all changes to the "user_id" field.
  9476. func (m *ChatRecordsMutation) ResetUserID() {
  9477. m.user_id = nil
  9478. m.adduser_id = nil
  9479. }
  9480. // SetBotID sets the "bot_id" field.
  9481. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  9482. m.bot_id = &u
  9483. m.addbot_id = nil
  9484. }
  9485. // BotID returns the value of the "bot_id" field in the mutation.
  9486. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  9487. v := m.bot_id
  9488. if v == nil {
  9489. return
  9490. }
  9491. return *v, true
  9492. }
  9493. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  9494. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9496. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9497. if !m.op.Is(OpUpdateOne) {
  9498. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9499. }
  9500. if m.id == nil || m.oldValue == nil {
  9501. return v, errors.New("OldBotID requires an ID field in the mutation")
  9502. }
  9503. oldValue, err := m.oldValue(ctx)
  9504. if err != nil {
  9505. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9506. }
  9507. return oldValue.BotID, nil
  9508. }
  9509. // AddBotID adds u to the "bot_id" field.
  9510. func (m *ChatRecordsMutation) AddBotID(u int64) {
  9511. if m.addbot_id != nil {
  9512. *m.addbot_id += u
  9513. } else {
  9514. m.addbot_id = &u
  9515. }
  9516. }
  9517. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9518. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  9519. v := m.addbot_id
  9520. if v == nil {
  9521. return
  9522. }
  9523. return *v, true
  9524. }
  9525. // ResetBotID resets all changes to the "bot_id" field.
  9526. func (m *ChatRecordsMutation) ResetBotID() {
  9527. m.bot_id = nil
  9528. m.addbot_id = nil
  9529. }
  9530. // SetBotType sets the "bot_type" field.
  9531. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  9532. m.bot_type = &u
  9533. m.addbot_type = nil
  9534. }
  9535. // BotType returns the value of the "bot_type" field in the mutation.
  9536. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  9537. v := m.bot_type
  9538. if v == nil {
  9539. return
  9540. }
  9541. return *v, true
  9542. }
  9543. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  9544. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9546. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9547. if !m.op.Is(OpUpdateOne) {
  9548. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9549. }
  9550. if m.id == nil || m.oldValue == nil {
  9551. return v, errors.New("OldBotType requires an ID field in the mutation")
  9552. }
  9553. oldValue, err := m.oldValue(ctx)
  9554. if err != nil {
  9555. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9556. }
  9557. return oldValue.BotType, nil
  9558. }
  9559. // AddBotType adds u to the "bot_type" field.
  9560. func (m *ChatRecordsMutation) AddBotType(u int8) {
  9561. if m.addbot_type != nil {
  9562. *m.addbot_type += u
  9563. } else {
  9564. m.addbot_type = &u
  9565. }
  9566. }
  9567. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9568. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  9569. v := m.addbot_type
  9570. if v == nil {
  9571. return
  9572. }
  9573. return *v, true
  9574. }
  9575. // ResetBotType resets all changes to the "bot_type" field.
  9576. func (m *ChatRecordsMutation) ResetBotType() {
  9577. m.bot_type = nil
  9578. m.addbot_type = nil
  9579. }
  9580. // Where appends a list predicates to the ChatRecordsMutation builder.
  9581. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  9582. m.predicates = append(m.predicates, ps...)
  9583. }
  9584. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  9585. // users can use type-assertion to append predicates that do not depend on any generated package.
  9586. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  9587. p := make([]predicate.ChatRecords, len(ps))
  9588. for i := range ps {
  9589. p[i] = ps[i]
  9590. }
  9591. m.Where(p...)
  9592. }
  9593. // Op returns the operation name.
  9594. func (m *ChatRecordsMutation) Op() Op {
  9595. return m.op
  9596. }
  9597. // SetOp allows setting the mutation operation.
  9598. func (m *ChatRecordsMutation) SetOp(op Op) {
  9599. m.op = op
  9600. }
  9601. // Type returns the node type of this mutation (ChatRecords).
  9602. func (m *ChatRecordsMutation) Type() string {
  9603. return m.typ
  9604. }
  9605. // Fields returns all fields that were changed during this mutation. Note that in
  9606. // order to get all numeric fields that were incremented/decremented, call
  9607. // AddedFields().
  9608. func (m *ChatRecordsMutation) Fields() []string {
  9609. fields := make([]string, 0, 9)
  9610. if m.created_at != nil {
  9611. fields = append(fields, chatrecords.FieldCreatedAt)
  9612. }
  9613. if m.updated_at != nil {
  9614. fields = append(fields, chatrecords.FieldUpdatedAt)
  9615. }
  9616. if m.deleted_at != nil {
  9617. fields = append(fields, chatrecords.FieldDeletedAt)
  9618. }
  9619. if m.content != nil {
  9620. fields = append(fields, chatrecords.FieldContent)
  9621. }
  9622. if m.content_type != nil {
  9623. fields = append(fields, chatrecords.FieldContentType)
  9624. }
  9625. if m.session_id != nil {
  9626. fields = append(fields, chatrecords.FieldSessionID)
  9627. }
  9628. if m.user_id != nil {
  9629. fields = append(fields, chatrecords.FieldUserID)
  9630. }
  9631. if m.bot_id != nil {
  9632. fields = append(fields, chatrecords.FieldBotID)
  9633. }
  9634. if m.bot_type != nil {
  9635. fields = append(fields, chatrecords.FieldBotType)
  9636. }
  9637. return fields
  9638. }
  9639. // Field returns the value of a field with the given name. The second boolean
  9640. // return value indicates that this field was not set, or was not defined in the
  9641. // schema.
  9642. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  9643. switch name {
  9644. case chatrecords.FieldCreatedAt:
  9645. return m.CreatedAt()
  9646. case chatrecords.FieldUpdatedAt:
  9647. return m.UpdatedAt()
  9648. case chatrecords.FieldDeletedAt:
  9649. return m.DeletedAt()
  9650. case chatrecords.FieldContent:
  9651. return m.Content()
  9652. case chatrecords.FieldContentType:
  9653. return m.ContentType()
  9654. case chatrecords.FieldSessionID:
  9655. return m.SessionID()
  9656. case chatrecords.FieldUserID:
  9657. return m.UserID()
  9658. case chatrecords.FieldBotID:
  9659. return m.BotID()
  9660. case chatrecords.FieldBotType:
  9661. return m.BotType()
  9662. }
  9663. return nil, false
  9664. }
  9665. // OldField returns the old value of the field from the database. An error is
  9666. // returned if the mutation operation is not UpdateOne, or the query to the
  9667. // database failed.
  9668. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9669. switch name {
  9670. case chatrecords.FieldCreatedAt:
  9671. return m.OldCreatedAt(ctx)
  9672. case chatrecords.FieldUpdatedAt:
  9673. return m.OldUpdatedAt(ctx)
  9674. case chatrecords.FieldDeletedAt:
  9675. return m.OldDeletedAt(ctx)
  9676. case chatrecords.FieldContent:
  9677. return m.OldContent(ctx)
  9678. case chatrecords.FieldContentType:
  9679. return m.OldContentType(ctx)
  9680. case chatrecords.FieldSessionID:
  9681. return m.OldSessionID(ctx)
  9682. case chatrecords.FieldUserID:
  9683. return m.OldUserID(ctx)
  9684. case chatrecords.FieldBotID:
  9685. return m.OldBotID(ctx)
  9686. case chatrecords.FieldBotType:
  9687. return m.OldBotType(ctx)
  9688. }
  9689. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  9690. }
  9691. // SetField sets the value of a field with the given name. It returns an error if
  9692. // the field is not defined in the schema, or if the type mismatched the field
  9693. // type.
  9694. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  9695. switch name {
  9696. case chatrecords.FieldCreatedAt:
  9697. v, ok := value.(time.Time)
  9698. if !ok {
  9699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9700. }
  9701. m.SetCreatedAt(v)
  9702. return nil
  9703. case chatrecords.FieldUpdatedAt:
  9704. v, ok := value.(time.Time)
  9705. if !ok {
  9706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9707. }
  9708. m.SetUpdatedAt(v)
  9709. return nil
  9710. case chatrecords.FieldDeletedAt:
  9711. v, ok := value.(time.Time)
  9712. if !ok {
  9713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9714. }
  9715. m.SetDeletedAt(v)
  9716. return nil
  9717. case chatrecords.FieldContent:
  9718. v, ok := value.(string)
  9719. if !ok {
  9720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9721. }
  9722. m.SetContent(v)
  9723. return nil
  9724. case chatrecords.FieldContentType:
  9725. v, ok := value.(uint8)
  9726. if !ok {
  9727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9728. }
  9729. m.SetContentType(v)
  9730. return nil
  9731. case chatrecords.FieldSessionID:
  9732. v, ok := value.(uint64)
  9733. if !ok {
  9734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9735. }
  9736. m.SetSessionID(v)
  9737. return nil
  9738. case chatrecords.FieldUserID:
  9739. v, ok := value.(uint64)
  9740. if !ok {
  9741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9742. }
  9743. m.SetUserID(v)
  9744. return nil
  9745. case chatrecords.FieldBotID:
  9746. v, ok := value.(uint64)
  9747. if !ok {
  9748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9749. }
  9750. m.SetBotID(v)
  9751. return nil
  9752. case chatrecords.FieldBotType:
  9753. v, ok := value.(uint8)
  9754. if !ok {
  9755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9756. }
  9757. m.SetBotType(v)
  9758. return nil
  9759. }
  9760. return fmt.Errorf("unknown ChatRecords field %s", name)
  9761. }
  9762. // AddedFields returns all numeric fields that were incremented/decremented during
  9763. // this mutation.
  9764. func (m *ChatRecordsMutation) AddedFields() []string {
  9765. var fields []string
  9766. if m.addcontent_type != nil {
  9767. fields = append(fields, chatrecords.FieldContentType)
  9768. }
  9769. if m.addsession_id != nil {
  9770. fields = append(fields, chatrecords.FieldSessionID)
  9771. }
  9772. if m.adduser_id != nil {
  9773. fields = append(fields, chatrecords.FieldUserID)
  9774. }
  9775. if m.addbot_id != nil {
  9776. fields = append(fields, chatrecords.FieldBotID)
  9777. }
  9778. if m.addbot_type != nil {
  9779. fields = append(fields, chatrecords.FieldBotType)
  9780. }
  9781. return fields
  9782. }
  9783. // AddedField returns the numeric value that was incremented/decremented on a field
  9784. // with the given name. The second boolean return value indicates that this field
  9785. // was not set, or was not defined in the schema.
  9786. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9787. switch name {
  9788. case chatrecords.FieldContentType:
  9789. return m.AddedContentType()
  9790. case chatrecords.FieldSessionID:
  9791. return m.AddedSessionID()
  9792. case chatrecords.FieldUserID:
  9793. return m.AddedUserID()
  9794. case chatrecords.FieldBotID:
  9795. return m.AddedBotID()
  9796. case chatrecords.FieldBotType:
  9797. return m.AddedBotType()
  9798. }
  9799. return nil, false
  9800. }
  9801. // AddField adds the value to the field with the given name. It returns an error if
  9802. // the field is not defined in the schema, or if the type mismatched the field
  9803. // type.
  9804. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  9805. switch name {
  9806. case chatrecords.FieldContentType:
  9807. v, ok := value.(int8)
  9808. if !ok {
  9809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9810. }
  9811. m.AddContentType(v)
  9812. return nil
  9813. case chatrecords.FieldSessionID:
  9814. v, ok := value.(int64)
  9815. if !ok {
  9816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9817. }
  9818. m.AddSessionID(v)
  9819. return nil
  9820. case chatrecords.FieldUserID:
  9821. v, ok := value.(int64)
  9822. if !ok {
  9823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9824. }
  9825. m.AddUserID(v)
  9826. return nil
  9827. case chatrecords.FieldBotID:
  9828. v, ok := value.(int64)
  9829. if !ok {
  9830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9831. }
  9832. m.AddBotID(v)
  9833. return nil
  9834. case chatrecords.FieldBotType:
  9835. v, ok := value.(int8)
  9836. if !ok {
  9837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9838. }
  9839. m.AddBotType(v)
  9840. return nil
  9841. }
  9842. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  9843. }
  9844. // ClearedFields returns all nullable fields that were cleared during this
  9845. // mutation.
  9846. func (m *ChatRecordsMutation) ClearedFields() []string {
  9847. var fields []string
  9848. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  9849. fields = append(fields, chatrecords.FieldDeletedAt)
  9850. }
  9851. return fields
  9852. }
  9853. // FieldCleared returns a boolean indicating if a field with the given name was
  9854. // cleared in this mutation.
  9855. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  9856. _, ok := m.clearedFields[name]
  9857. return ok
  9858. }
  9859. // ClearField clears the value of the field with the given name. It returns an
  9860. // error if the field is not defined in the schema.
  9861. func (m *ChatRecordsMutation) ClearField(name string) error {
  9862. switch name {
  9863. case chatrecords.FieldDeletedAt:
  9864. m.ClearDeletedAt()
  9865. return nil
  9866. }
  9867. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  9868. }
  9869. // ResetField resets all changes in the mutation for the field with the given name.
  9870. // It returns an error if the field is not defined in the schema.
  9871. func (m *ChatRecordsMutation) ResetField(name string) error {
  9872. switch name {
  9873. case chatrecords.FieldCreatedAt:
  9874. m.ResetCreatedAt()
  9875. return nil
  9876. case chatrecords.FieldUpdatedAt:
  9877. m.ResetUpdatedAt()
  9878. return nil
  9879. case chatrecords.FieldDeletedAt:
  9880. m.ResetDeletedAt()
  9881. return nil
  9882. case chatrecords.FieldContent:
  9883. m.ResetContent()
  9884. return nil
  9885. case chatrecords.FieldContentType:
  9886. m.ResetContentType()
  9887. return nil
  9888. case chatrecords.FieldSessionID:
  9889. m.ResetSessionID()
  9890. return nil
  9891. case chatrecords.FieldUserID:
  9892. m.ResetUserID()
  9893. return nil
  9894. case chatrecords.FieldBotID:
  9895. m.ResetBotID()
  9896. return nil
  9897. case chatrecords.FieldBotType:
  9898. m.ResetBotType()
  9899. return nil
  9900. }
  9901. return fmt.Errorf("unknown ChatRecords field %s", name)
  9902. }
  9903. // AddedEdges returns all edge names that were set/added in this mutation.
  9904. func (m *ChatRecordsMutation) AddedEdges() []string {
  9905. edges := make([]string, 0, 0)
  9906. return edges
  9907. }
  9908. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9909. // name in this mutation.
  9910. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  9911. return nil
  9912. }
  9913. // RemovedEdges returns all edge names that were removed in this mutation.
  9914. func (m *ChatRecordsMutation) RemovedEdges() []string {
  9915. edges := make([]string, 0, 0)
  9916. return edges
  9917. }
  9918. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9919. // the given name in this mutation.
  9920. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  9921. return nil
  9922. }
  9923. // ClearedEdges returns all edge names that were cleared in this mutation.
  9924. func (m *ChatRecordsMutation) ClearedEdges() []string {
  9925. edges := make([]string, 0, 0)
  9926. return edges
  9927. }
  9928. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9929. // was cleared in this mutation.
  9930. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  9931. return false
  9932. }
  9933. // ClearEdge clears the value of the edge with the given name. It returns an error
  9934. // if that edge is not defined in the schema.
  9935. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  9936. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  9937. }
  9938. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9939. // It returns an error if the edge is not defined in the schema.
  9940. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  9941. return fmt.Errorf("unknown ChatRecords edge %s", name)
  9942. }
  9943. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  9944. type ChatSessionMutation struct {
  9945. config
  9946. op Op
  9947. typ string
  9948. id *uint64
  9949. created_at *time.Time
  9950. updated_at *time.Time
  9951. deleted_at *time.Time
  9952. name *string
  9953. user_id *uint64
  9954. adduser_id *int64
  9955. bot_id *uint64
  9956. addbot_id *int64
  9957. bot_type *uint8
  9958. addbot_type *int8
  9959. clearedFields map[string]struct{}
  9960. done bool
  9961. oldValue func(context.Context) (*ChatSession, error)
  9962. predicates []predicate.ChatSession
  9963. }
  9964. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  9965. // chatsessionOption allows management of the mutation configuration using functional options.
  9966. type chatsessionOption func(*ChatSessionMutation)
  9967. // newChatSessionMutation creates new mutation for the ChatSession entity.
  9968. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  9969. m := &ChatSessionMutation{
  9970. config: c,
  9971. op: op,
  9972. typ: TypeChatSession,
  9973. clearedFields: make(map[string]struct{}),
  9974. }
  9975. for _, opt := range opts {
  9976. opt(m)
  9977. }
  9978. return m
  9979. }
  9980. // withChatSessionID sets the ID field of the mutation.
  9981. func withChatSessionID(id uint64) chatsessionOption {
  9982. return func(m *ChatSessionMutation) {
  9983. var (
  9984. err error
  9985. once sync.Once
  9986. value *ChatSession
  9987. )
  9988. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  9989. once.Do(func() {
  9990. if m.done {
  9991. err = errors.New("querying old values post mutation is not allowed")
  9992. } else {
  9993. value, err = m.Client().ChatSession.Get(ctx, id)
  9994. }
  9995. })
  9996. return value, err
  9997. }
  9998. m.id = &id
  9999. }
  10000. }
  10001. // withChatSession sets the old ChatSession of the mutation.
  10002. func withChatSession(node *ChatSession) chatsessionOption {
  10003. return func(m *ChatSessionMutation) {
  10004. m.oldValue = func(context.Context) (*ChatSession, error) {
  10005. return node, nil
  10006. }
  10007. m.id = &node.ID
  10008. }
  10009. }
  10010. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10011. // executed in a transaction (ent.Tx), a transactional client is returned.
  10012. func (m ChatSessionMutation) Client() *Client {
  10013. client := &Client{config: m.config}
  10014. client.init()
  10015. return client
  10016. }
  10017. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10018. // it returns an error otherwise.
  10019. func (m ChatSessionMutation) Tx() (*Tx, error) {
  10020. if _, ok := m.driver.(*txDriver); !ok {
  10021. return nil, errors.New("ent: mutation is not running in a transaction")
  10022. }
  10023. tx := &Tx{config: m.config}
  10024. tx.init()
  10025. return tx, nil
  10026. }
  10027. // SetID sets the value of the id field. Note that this
  10028. // operation is only accepted on creation of ChatSession entities.
  10029. func (m *ChatSessionMutation) SetID(id uint64) {
  10030. m.id = &id
  10031. }
  10032. // ID returns the ID value in the mutation. Note that the ID is only available
  10033. // if it was provided to the builder or after it was returned from the database.
  10034. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  10035. if m.id == nil {
  10036. return
  10037. }
  10038. return *m.id, true
  10039. }
  10040. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10041. // That means, if the mutation is applied within a transaction with an isolation level such
  10042. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10043. // or updated by the mutation.
  10044. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  10045. switch {
  10046. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10047. id, exists := m.ID()
  10048. if exists {
  10049. return []uint64{id}, nil
  10050. }
  10051. fallthrough
  10052. case m.op.Is(OpUpdate | OpDelete):
  10053. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  10054. default:
  10055. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10056. }
  10057. }
  10058. // SetCreatedAt sets the "created_at" field.
  10059. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  10060. m.created_at = &t
  10061. }
  10062. // CreatedAt returns the value of the "created_at" field in the mutation.
  10063. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  10064. v := m.created_at
  10065. if v == nil {
  10066. return
  10067. }
  10068. return *v, true
  10069. }
  10070. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  10071. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10073. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10074. if !m.op.Is(OpUpdateOne) {
  10075. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10076. }
  10077. if m.id == nil || m.oldValue == nil {
  10078. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10079. }
  10080. oldValue, err := m.oldValue(ctx)
  10081. if err != nil {
  10082. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10083. }
  10084. return oldValue.CreatedAt, nil
  10085. }
  10086. // ResetCreatedAt resets all changes to the "created_at" field.
  10087. func (m *ChatSessionMutation) ResetCreatedAt() {
  10088. m.created_at = nil
  10089. }
  10090. // SetUpdatedAt sets the "updated_at" field.
  10091. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  10092. m.updated_at = &t
  10093. }
  10094. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10095. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  10096. v := m.updated_at
  10097. if v == nil {
  10098. return
  10099. }
  10100. return *v, true
  10101. }
  10102. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  10103. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10105. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10106. if !m.op.Is(OpUpdateOne) {
  10107. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10108. }
  10109. if m.id == nil || m.oldValue == nil {
  10110. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10111. }
  10112. oldValue, err := m.oldValue(ctx)
  10113. if err != nil {
  10114. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10115. }
  10116. return oldValue.UpdatedAt, nil
  10117. }
  10118. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10119. func (m *ChatSessionMutation) ResetUpdatedAt() {
  10120. m.updated_at = nil
  10121. }
  10122. // SetDeletedAt sets the "deleted_at" field.
  10123. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  10124. m.deleted_at = &t
  10125. }
  10126. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10127. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  10128. v := m.deleted_at
  10129. if v == nil {
  10130. return
  10131. }
  10132. return *v, true
  10133. }
  10134. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  10135. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10137. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10138. if !m.op.Is(OpUpdateOne) {
  10139. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10140. }
  10141. if m.id == nil || m.oldValue == nil {
  10142. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10143. }
  10144. oldValue, err := m.oldValue(ctx)
  10145. if err != nil {
  10146. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10147. }
  10148. return oldValue.DeletedAt, nil
  10149. }
  10150. // ClearDeletedAt clears the value of the "deleted_at" field.
  10151. func (m *ChatSessionMutation) ClearDeletedAt() {
  10152. m.deleted_at = nil
  10153. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  10154. }
  10155. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10156. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  10157. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  10158. return ok
  10159. }
  10160. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10161. func (m *ChatSessionMutation) ResetDeletedAt() {
  10162. m.deleted_at = nil
  10163. delete(m.clearedFields, chatsession.FieldDeletedAt)
  10164. }
  10165. // SetName sets the "name" field.
  10166. func (m *ChatSessionMutation) SetName(s string) {
  10167. m.name = &s
  10168. }
  10169. // Name returns the value of the "name" field in the mutation.
  10170. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  10171. v := m.name
  10172. if v == nil {
  10173. return
  10174. }
  10175. return *v, true
  10176. }
  10177. // OldName returns the old "name" field's value of the ChatSession entity.
  10178. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10180. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  10181. if !m.op.Is(OpUpdateOne) {
  10182. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10183. }
  10184. if m.id == nil || m.oldValue == nil {
  10185. return v, errors.New("OldName requires an ID field in the mutation")
  10186. }
  10187. oldValue, err := m.oldValue(ctx)
  10188. if err != nil {
  10189. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10190. }
  10191. return oldValue.Name, nil
  10192. }
  10193. // ResetName resets all changes to the "name" field.
  10194. func (m *ChatSessionMutation) ResetName() {
  10195. m.name = nil
  10196. }
  10197. // SetUserID sets the "user_id" field.
  10198. func (m *ChatSessionMutation) SetUserID(u uint64) {
  10199. m.user_id = &u
  10200. m.adduser_id = nil
  10201. }
  10202. // UserID returns the value of the "user_id" field in the mutation.
  10203. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  10204. v := m.user_id
  10205. if v == nil {
  10206. return
  10207. }
  10208. return *v, true
  10209. }
  10210. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  10211. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10213. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  10214. if !m.op.Is(OpUpdateOne) {
  10215. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10216. }
  10217. if m.id == nil || m.oldValue == nil {
  10218. return v, errors.New("OldUserID requires an ID field in the mutation")
  10219. }
  10220. oldValue, err := m.oldValue(ctx)
  10221. if err != nil {
  10222. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10223. }
  10224. return oldValue.UserID, nil
  10225. }
  10226. // AddUserID adds u to the "user_id" field.
  10227. func (m *ChatSessionMutation) AddUserID(u int64) {
  10228. if m.adduser_id != nil {
  10229. *m.adduser_id += u
  10230. } else {
  10231. m.adduser_id = &u
  10232. }
  10233. }
  10234. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  10235. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  10236. v := m.adduser_id
  10237. if v == nil {
  10238. return
  10239. }
  10240. return *v, true
  10241. }
  10242. // ResetUserID resets all changes to the "user_id" field.
  10243. func (m *ChatSessionMutation) ResetUserID() {
  10244. m.user_id = nil
  10245. m.adduser_id = nil
  10246. }
  10247. // SetBotID sets the "bot_id" field.
  10248. func (m *ChatSessionMutation) SetBotID(u uint64) {
  10249. m.bot_id = &u
  10250. m.addbot_id = nil
  10251. }
  10252. // BotID returns the value of the "bot_id" field in the mutation.
  10253. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  10254. v := m.bot_id
  10255. if v == nil {
  10256. return
  10257. }
  10258. return *v, true
  10259. }
  10260. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  10261. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10263. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  10264. if !m.op.Is(OpUpdateOne) {
  10265. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  10266. }
  10267. if m.id == nil || m.oldValue == nil {
  10268. return v, errors.New("OldBotID requires an ID field in the mutation")
  10269. }
  10270. oldValue, err := m.oldValue(ctx)
  10271. if err != nil {
  10272. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  10273. }
  10274. return oldValue.BotID, nil
  10275. }
  10276. // AddBotID adds u to the "bot_id" field.
  10277. func (m *ChatSessionMutation) AddBotID(u int64) {
  10278. if m.addbot_id != nil {
  10279. *m.addbot_id += u
  10280. } else {
  10281. m.addbot_id = &u
  10282. }
  10283. }
  10284. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  10285. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  10286. v := m.addbot_id
  10287. if v == nil {
  10288. return
  10289. }
  10290. return *v, true
  10291. }
  10292. // ResetBotID resets all changes to the "bot_id" field.
  10293. func (m *ChatSessionMutation) ResetBotID() {
  10294. m.bot_id = nil
  10295. m.addbot_id = nil
  10296. }
  10297. // SetBotType sets the "bot_type" field.
  10298. func (m *ChatSessionMutation) SetBotType(u uint8) {
  10299. m.bot_type = &u
  10300. m.addbot_type = nil
  10301. }
  10302. // BotType returns the value of the "bot_type" field in the mutation.
  10303. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  10304. v := m.bot_type
  10305. if v == nil {
  10306. return
  10307. }
  10308. return *v, true
  10309. }
  10310. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  10311. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10313. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  10314. if !m.op.Is(OpUpdateOne) {
  10315. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  10316. }
  10317. if m.id == nil || m.oldValue == nil {
  10318. return v, errors.New("OldBotType requires an ID field in the mutation")
  10319. }
  10320. oldValue, err := m.oldValue(ctx)
  10321. if err != nil {
  10322. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  10323. }
  10324. return oldValue.BotType, nil
  10325. }
  10326. // AddBotType adds u to the "bot_type" field.
  10327. func (m *ChatSessionMutation) AddBotType(u int8) {
  10328. if m.addbot_type != nil {
  10329. *m.addbot_type += u
  10330. } else {
  10331. m.addbot_type = &u
  10332. }
  10333. }
  10334. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  10335. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  10336. v := m.addbot_type
  10337. if v == nil {
  10338. return
  10339. }
  10340. return *v, true
  10341. }
  10342. // ResetBotType resets all changes to the "bot_type" field.
  10343. func (m *ChatSessionMutation) ResetBotType() {
  10344. m.bot_type = nil
  10345. m.addbot_type = nil
  10346. }
  10347. // Where appends a list predicates to the ChatSessionMutation builder.
  10348. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  10349. m.predicates = append(m.predicates, ps...)
  10350. }
  10351. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  10352. // users can use type-assertion to append predicates that do not depend on any generated package.
  10353. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  10354. p := make([]predicate.ChatSession, len(ps))
  10355. for i := range ps {
  10356. p[i] = ps[i]
  10357. }
  10358. m.Where(p...)
  10359. }
  10360. // Op returns the operation name.
  10361. func (m *ChatSessionMutation) Op() Op {
  10362. return m.op
  10363. }
  10364. // SetOp allows setting the mutation operation.
  10365. func (m *ChatSessionMutation) SetOp(op Op) {
  10366. m.op = op
  10367. }
  10368. // Type returns the node type of this mutation (ChatSession).
  10369. func (m *ChatSessionMutation) Type() string {
  10370. return m.typ
  10371. }
  10372. // Fields returns all fields that were changed during this mutation. Note that in
  10373. // order to get all numeric fields that were incremented/decremented, call
  10374. // AddedFields().
  10375. func (m *ChatSessionMutation) Fields() []string {
  10376. fields := make([]string, 0, 7)
  10377. if m.created_at != nil {
  10378. fields = append(fields, chatsession.FieldCreatedAt)
  10379. }
  10380. if m.updated_at != nil {
  10381. fields = append(fields, chatsession.FieldUpdatedAt)
  10382. }
  10383. if m.deleted_at != nil {
  10384. fields = append(fields, chatsession.FieldDeletedAt)
  10385. }
  10386. if m.name != nil {
  10387. fields = append(fields, chatsession.FieldName)
  10388. }
  10389. if m.user_id != nil {
  10390. fields = append(fields, chatsession.FieldUserID)
  10391. }
  10392. if m.bot_id != nil {
  10393. fields = append(fields, chatsession.FieldBotID)
  10394. }
  10395. if m.bot_type != nil {
  10396. fields = append(fields, chatsession.FieldBotType)
  10397. }
  10398. return fields
  10399. }
  10400. // Field returns the value of a field with the given name. The second boolean
  10401. // return value indicates that this field was not set, or was not defined in the
  10402. // schema.
  10403. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  10404. switch name {
  10405. case chatsession.FieldCreatedAt:
  10406. return m.CreatedAt()
  10407. case chatsession.FieldUpdatedAt:
  10408. return m.UpdatedAt()
  10409. case chatsession.FieldDeletedAt:
  10410. return m.DeletedAt()
  10411. case chatsession.FieldName:
  10412. return m.Name()
  10413. case chatsession.FieldUserID:
  10414. return m.UserID()
  10415. case chatsession.FieldBotID:
  10416. return m.BotID()
  10417. case chatsession.FieldBotType:
  10418. return m.BotType()
  10419. }
  10420. return nil, false
  10421. }
  10422. // OldField returns the old value of the field from the database. An error is
  10423. // returned if the mutation operation is not UpdateOne, or the query to the
  10424. // database failed.
  10425. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10426. switch name {
  10427. case chatsession.FieldCreatedAt:
  10428. return m.OldCreatedAt(ctx)
  10429. case chatsession.FieldUpdatedAt:
  10430. return m.OldUpdatedAt(ctx)
  10431. case chatsession.FieldDeletedAt:
  10432. return m.OldDeletedAt(ctx)
  10433. case chatsession.FieldName:
  10434. return m.OldName(ctx)
  10435. case chatsession.FieldUserID:
  10436. return m.OldUserID(ctx)
  10437. case chatsession.FieldBotID:
  10438. return m.OldBotID(ctx)
  10439. case chatsession.FieldBotType:
  10440. return m.OldBotType(ctx)
  10441. }
  10442. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  10443. }
  10444. // SetField sets the value of a field with the given name. It returns an error if
  10445. // the field is not defined in the schema, or if the type mismatched the field
  10446. // type.
  10447. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  10448. switch name {
  10449. case chatsession.FieldCreatedAt:
  10450. v, ok := value.(time.Time)
  10451. if !ok {
  10452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10453. }
  10454. m.SetCreatedAt(v)
  10455. return nil
  10456. case chatsession.FieldUpdatedAt:
  10457. v, ok := value.(time.Time)
  10458. if !ok {
  10459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10460. }
  10461. m.SetUpdatedAt(v)
  10462. return nil
  10463. case chatsession.FieldDeletedAt:
  10464. v, ok := value.(time.Time)
  10465. if !ok {
  10466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10467. }
  10468. m.SetDeletedAt(v)
  10469. return nil
  10470. case chatsession.FieldName:
  10471. v, ok := value.(string)
  10472. if !ok {
  10473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10474. }
  10475. m.SetName(v)
  10476. return nil
  10477. case chatsession.FieldUserID:
  10478. v, ok := value.(uint64)
  10479. if !ok {
  10480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10481. }
  10482. m.SetUserID(v)
  10483. return nil
  10484. case chatsession.FieldBotID:
  10485. v, ok := value.(uint64)
  10486. if !ok {
  10487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10488. }
  10489. m.SetBotID(v)
  10490. return nil
  10491. case chatsession.FieldBotType:
  10492. v, ok := value.(uint8)
  10493. if !ok {
  10494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10495. }
  10496. m.SetBotType(v)
  10497. return nil
  10498. }
  10499. return fmt.Errorf("unknown ChatSession field %s", name)
  10500. }
  10501. // AddedFields returns all numeric fields that were incremented/decremented during
  10502. // this mutation.
  10503. func (m *ChatSessionMutation) AddedFields() []string {
  10504. var fields []string
  10505. if m.adduser_id != nil {
  10506. fields = append(fields, chatsession.FieldUserID)
  10507. }
  10508. if m.addbot_id != nil {
  10509. fields = append(fields, chatsession.FieldBotID)
  10510. }
  10511. if m.addbot_type != nil {
  10512. fields = append(fields, chatsession.FieldBotType)
  10513. }
  10514. return fields
  10515. }
  10516. // AddedField returns the numeric value that was incremented/decremented on a field
  10517. // with the given name. The second boolean return value indicates that this field
  10518. // was not set, or was not defined in the schema.
  10519. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  10520. switch name {
  10521. case chatsession.FieldUserID:
  10522. return m.AddedUserID()
  10523. case chatsession.FieldBotID:
  10524. return m.AddedBotID()
  10525. case chatsession.FieldBotType:
  10526. return m.AddedBotType()
  10527. }
  10528. return nil, false
  10529. }
  10530. // AddField adds the value to the field with the given name. It returns an error if
  10531. // the field is not defined in the schema, or if the type mismatched the field
  10532. // type.
  10533. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  10534. switch name {
  10535. case chatsession.FieldUserID:
  10536. v, ok := value.(int64)
  10537. if !ok {
  10538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10539. }
  10540. m.AddUserID(v)
  10541. return nil
  10542. case chatsession.FieldBotID:
  10543. v, ok := value.(int64)
  10544. if !ok {
  10545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10546. }
  10547. m.AddBotID(v)
  10548. return nil
  10549. case chatsession.FieldBotType:
  10550. v, ok := value.(int8)
  10551. if !ok {
  10552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10553. }
  10554. m.AddBotType(v)
  10555. return nil
  10556. }
  10557. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  10558. }
  10559. // ClearedFields returns all nullable fields that were cleared during this
  10560. // mutation.
  10561. func (m *ChatSessionMutation) ClearedFields() []string {
  10562. var fields []string
  10563. if m.FieldCleared(chatsession.FieldDeletedAt) {
  10564. fields = append(fields, chatsession.FieldDeletedAt)
  10565. }
  10566. return fields
  10567. }
  10568. // FieldCleared returns a boolean indicating if a field with the given name was
  10569. // cleared in this mutation.
  10570. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  10571. _, ok := m.clearedFields[name]
  10572. return ok
  10573. }
  10574. // ClearField clears the value of the field with the given name. It returns an
  10575. // error if the field is not defined in the schema.
  10576. func (m *ChatSessionMutation) ClearField(name string) error {
  10577. switch name {
  10578. case chatsession.FieldDeletedAt:
  10579. m.ClearDeletedAt()
  10580. return nil
  10581. }
  10582. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  10583. }
  10584. // ResetField resets all changes in the mutation for the field with the given name.
  10585. // It returns an error if the field is not defined in the schema.
  10586. func (m *ChatSessionMutation) ResetField(name string) error {
  10587. switch name {
  10588. case chatsession.FieldCreatedAt:
  10589. m.ResetCreatedAt()
  10590. return nil
  10591. case chatsession.FieldUpdatedAt:
  10592. m.ResetUpdatedAt()
  10593. return nil
  10594. case chatsession.FieldDeletedAt:
  10595. m.ResetDeletedAt()
  10596. return nil
  10597. case chatsession.FieldName:
  10598. m.ResetName()
  10599. return nil
  10600. case chatsession.FieldUserID:
  10601. m.ResetUserID()
  10602. return nil
  10603. case chatsession.FieldBotID:
  10604. m.ResetBotID()
  10605. return nil
  10606. case chatsession.FieldBotType:
  10607. m.ResetBotType()
  10608. return nil
  10609. }
  10610. return fmt.Errorf("unknown ChatSession field %s", name)
  10611. }
  10612. // AddedEdges returns all edge names that were set/added in this mutation.
  10613. func (m *ChatSessionMutation) AddedEdges() []string {
  10614. edges := make([]string, 0, 0)
  10615. return edges
  10616. }
  10617. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10618. // name in this mutation.
  10619. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  10620. return nil
  10621. }
  10622. // RemovedEdges returns all edge names that were removed in this mutation.
  10623. func (m *ChatSessionMutation) RemovedEdges() []string {
  10624. edges := make([]string, 0, 0)
  10625. return edges
  10626. }
  10627. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10628. // the given name in this mutation.
  10629. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  10630. return nil
  10631. }
  10632. // ClearedEdges returns all edge names that were cleared in this mutation.
  10633. func (m *ChatSessionMutation) ClearedEdges() []string {
  10634. edges := make([]string, 0, 0)
  10635. return edges
  10636. }
  10637. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10638. // was cleared in this mutation.
  10639. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  10640. return false
  10641. }
  10642. // ClearEdge clears the value of the edge with the given name. It returns an error
  10643. // if that edge is not defined in the schema.
  10644. func (m *ChatSessionMutation) ClearEdge(name string) error {
  10645. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  10646. }
  10647. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10648. // It returns an error if the edge is not defined in the schema.
  10649. func (m *ChatSessionMutation) ResetEdge(name string) error {
  10650. return fmt.Errorf("unknown ChatSession edge %s", name)
  10651. }
  10652. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  10653. type CompapiAsynctaskMutation struct {
  10654. config
  10655. op Op
  10656. typ string
  10657. id *uint64
  10658. created_at *time.Time
  10659. updated_at *time.Time
  10660. auth_token *string
  10661. event_type *string
  10662. chat_id *string
  10663. response_chat_item_id *string
  10664. organization_id *uint64
  10665. addorganization_id *int64
  10666. openai_base *string
  10667. openai_key *string
  10668. request_raw *string
  10669. response_raw *string
  10670. callback_url *string
  10671. callback_response_raw *string
  10672. model *string
  10673. task_status *int8
  10674. addtask_status *int8
  10675. retry_count *int8
  10676. addretry_count *int8
  10677. last_error *string
  10678. clearedFields map[string]struct{}
  10679. done bool
  10680. oldValue func(context.Context) (*CompapiAsynctask, error)
  10681. predicates []predicate.CompapiAsynctask
  10682. }
  10683. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  10684. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  10685. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  10686. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  10687. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  10688. m := &CompapiAsynctaskMutation{
  10689. config: c,
  10690. op: op,
  10691. typ: TypeCompapiAsynctask,
  10692. clearedFields: make(map[string]struct{}),
  10693. }
  10694. for _, opt := range opts {
  10695. opt(m)
  10696. }
  10697. return m
  10698. }
  10699. // withCompapiAsynctaskID sets the ID field of the mutation.
  10700. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  10701. return func(m *CompapiAsynctaskMutation) {
  10702. var (
  10703. err error
  10704. once sync.Once
  10705. value *CompapiAsynctask
  10706. )
  10707. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  10708. once.Do(func() {
  10709. if m.done {
  10710. err = errors.New("querying old values post mutation is not allowed")
  10711. } else {
  10712. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  10713. }
  10714. })
  10715. return value, err
  10716. }
  10717. m.id = &id
  10718. }
  10719. }
  10720. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  10721. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  10722. return func(m *CompapiAsynctaskMutation) {
  10723. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  10724. return node, nil
  10725. }
  10726. m.id = &node.ID
  10727. }
  10728. }
  10729. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10730. // executed in a transaction (ent.Tx), a transactional client is returned.
  10731. func (m CompapiAsynctaskMutation) Client() *Client {
  10732. client := &Client{config: m.config}
  10733. client.init()
  10734. return client
  10735. }
  10736. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10737. // it returns an error otherwise.
  10738. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  10739. if _, ok := m.driver.(*txDriver); !ok {
  10740. return nil, errors.New("ent: mutation is not running in a transaction")
  10741. }
  10742. tx := &Tx{config: m.config}
  10743. tx.init()
  10744. return tx, nil
  10745. }
  10746. // SetID sets the value of the id field. Note that this
  10747. // operation is only accepted on creation of CompapiAsynctask entities.
  10748. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  10749. m.id = &id
  10750. }
  10751. // ID returns the ID value in the mutation. Note that the ID is only available
  10752. // if it was provided to the builder or after it was returned from the database.
  10753. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  10754. if m.id == nil {
  10755. return
  10756. }
  10757. return *m.id, true
  10758. }
  10759. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10760. // That means, if the mutation is applied within a transaction with an isolation level such
  10761. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10762. // or updated by the mutation.
  10763. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  10764. switch {
  10765. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10766. id, exists := m.ID()
  10767. if exists {
  10768. return []uint64{id}, nil
  10769. }
  10770. fallthrough
  10771. case m.op.Is(OpUpdate | OpDelete):
  10772. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  10773. default:
  10774. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10775. }
  10776. }
  10777. // SetCreatedAt sets the "created_at" field.
  10778. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  10779. m.created_at = &t
  10780. }
  10781. // CreatedAt returns the value of the "created_at" field in the mutation.
  10782. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  10783. v := m.created_at
  10784. if v == nil {
  10785. return
  10786. }
  10787. return *v, true
  10788. }
  10789. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  10790. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10792. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10793. if !m.op.Is(OpUpdateOne) {
  10794. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10795. }
  10796. if m.id == nil || m.oldValue == nil {
  10797. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10798. }
  10799. oldValue, err := m.oldValue(ctx)
  10800. if err != nil {
  10801. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10802. }
  10803. return oldValue.CreatedAt, nil
  10804. }
  10805. // ResetCreatedAt resets all changes to the "created_at" field.
  10806. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  10807. m.created_at = nil
  10808. }
  10809. // SetUpdatedAt sets the "updated_at" field.
  10810. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  10811. m.updated_at = &t
  10812. }
  10813. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10814. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  10815. v := m.updated_at
  10816. if v == nil {
  10817. return
  10818. }
  10819. return *v, true
  10820. }
  10821. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  10822. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10824. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10825. if !m.op.Is(OpUpdateOne) {
  10826. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10827. }
  10828. if m.id == nil || m.oldValue == nil {
  10829. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10830. }
  10831. oldValue, err := m.oldValue(ctx)
  10832. if err != nil {
  10833. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10834. }
  10835. return oldValue.UpdatedAt, nil
  10836. }
  10837. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10838. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  10839. m.updated_at = nil
  10840. }
  10841. // SetAuthToken sets the "auth_token" field.
  10842. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  10843. m.auth_token = &s
  10844. }
  10845. // AuthToken returns the value of the "auth_token" field in the mutation.
  10846. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  10847. v := m.auth_token
  10848. if v == nil {
  10849. return
  10850. }
  10851. return *v, true
  10852. }
  10853. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  10854. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10856. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  10857. if !m.op.Is(OpUpdateOne) {
  10858. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  10859. }
  10860. if m.id == nil || m.oldValue == nil {
  10861. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  10862. }
  10863. oldValue, err := m.oldValue(ctx)
  10864. if err != nil {
  10865. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  10866. }
  10867. return oldValue.AuthToken, nil
  10868. }
  10869. // ResetAuthToken resets all changes to the "auth_token" field.
  10870. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  10871. m.auth_token = nil
  10872. }
  10873. // SetEventType sets the "event_type" field.
  10874. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  10875. m.event_type = &s
  10876. }
  10877. // EventType returns the value of the "event_type" field in the mutation.
  10878. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  10879. v := m.event_type
  10880. if v == nil {
  10881. return
  10882. }
  10883. return *v, true
  10884. }
  10885. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  10886. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10888. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  10889. if !m.op.Is(OpUpdateOne) {
  10890. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  10891. }
  10892. if m.id == nil || m.oldValue == nil {
  10893. return v, errors.New("OldEventType requires an ID field in the mutation")
  10894. }
  10895. oldValue, err := m.oldValue(ctx)
  10896. if err != nil {
  10897. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  10898. }
  10899. return oldValue.EventType, nil
  10900. }
  10901. // ResetEventType resets all changes to the "event_type" field.
  10902. func (m *CompapiAsynctaskMutation) ResetEventType() {
  10903. m.event_type = nil
  10904. }
  10905. // SetChatID sets the "chat_id" field.
  10906. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  10907. m.chat_id = &s
  10908. }
  10909. // ChatID returns the value of the "chat_id" field in the mutation.
  10910. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  10911. v := m.chat_id
  10912. if v == nil {
  10913. return
  10914. }
  10915. return *v, true
  10916. }
  10917. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  10918. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10920. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  10921. if !m.op.Is(OpUpdateOne) {
  10922. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  10923. }
  10924. if m.id == nil || m.oldValue == nil {
  10925. return v, errors.New("OldChatID requires an ID field in the mutation")
  10926. }
  10927. oldValue, err := m.oldValue(ctx)
  10928. if err != nil {
  10929. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  10930. }
  10931. return oldValue.ChatID, nil
  10932. }
  10933. // ClearChatID clears the value of the "chat_id" field.
  10934. func (m *CompapiAsynctaskMutation) ClearChatID() {
  10935. m.chat_id = nil
  10936. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  10937. }
  10938. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  10939. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  10940. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  10941. return ok
  10942. }
  10943. // ResetChatID resets all changes to the "chat_id" field.
  10944. func (m *CompapiAsynctaskMutation) ResetChatID() {
  10945. m.chat_id = nil
  10946. delete(m.clearedFields, compapiasynctask.FieldChatID)
  10947. }
  10948. // SetResponseChatItemID sets the "response_chat_item_id" field.
  10949. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  10950. m.response_chat_item_id = &s
  10951. }
  10952. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  10953. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  10954. v := m.response_chat_item_id
  10955. if v == nil {
  10956. return
  10957. }
  10958. return *v, true
  10959. }
  10960. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  10961. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10963. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  10964. if !m.op.Is(OpUpdateOne) {
  10965. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  10966. }
  10967. if m.id == nil || m.oldValue == nil {
  10968. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  10969. }
  10970. oldValue, err := m.oldValue(ctx)
  10971. if err != nil {
  10972. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  10973. }
  10974. return oldValue.ResponseChatItemID, nil
  10975. }
  10976. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  10977. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  10978. m.response_chat_item_id = nil
  10979. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  10980. }
  10981. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  10982. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  10983. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  10984. return ok
  10985. }
  10986. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  10987. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  10988. m.response_chat_item_id = nil
  10989. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  10990. }
  10991. // SetOrganizationID sets the "organization_id" field.
  10992. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  10993. m.organization_id = &u
  10994. m.addorganization_id = nil
  10995. }
  10996. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10997. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  10998. v := m.organization_id
  10999. if v == nil {
  11000. return
  11001. }
  11002. return *v, true
  11003. }
  11004. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  11005. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11007. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11008. if !m.op.Is(OpUpdateOne) {
  11009. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11010. }
  11011. if m.id == nil || m.oldValue == nil {
  11012. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11013. }
  11014. oldValue, err := m.oldValue(ctx)
  11015. if err != nil {
  11016. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11017. }
  11018. return oldValue.OrganizationID, nil
  11019. }
  11020. // AddOrganizationID adds u to the "organization_id" field.
  11021. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  11022. if m.addorganization_id != nil {
  11023. *m.addorganization_id += u
  11024. } else {
  11025. m.addorganization_id = &u
  11026. }
  11027. }
  11028. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11029. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  11030. v := m.addorganization_id
  11031. if v == nil {
  11032. return
  11033. }
  11034. return *v, true
  11035. }
  11036. // ResetOrganizationID resets all changes to the "organization_id" field.
  11037. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  11038. m.organization_id = nil
  11039. m.addorganization_id = nil
  11040. }
  11041. // SetOpenaiBase sets the "openai_base" field.
  11042. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  11043. m.openai_base = &s
  11044. }
  11045. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  11046. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  11047. v := m.openai_base
  11048. if v == nil {
  11049. return
  11050. }
  11051. return *v, true
  11052. }
  11053. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  11054. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11056. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  11057. if !m.op.Is(OpUpdateOne) {
  11058. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  11059. }
  11060. if m.id == nil || m.oldValue == nil {
  11061. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  11062. }
  11063. oldValue, err := m.oldValue(ctx)
  11064. if err != nil {
  11065. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  11066. }
  11067. return oldValue.OpenaiBase, nil
  11068. }
  11069. // ResetOpenaiBase resets all changes to the "openai_base" field.
  11070. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  11071. m.openai_base = nil
  11072. }
  11073. // SetOpenaiKey sets the "openai_key" field.
  11074. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  11075. m.openai_key = &s
  11076. }
  11077. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  11078. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  11079. v := m.openai_key
  11080. if v == nil {
  11081. return
  11082. }
  11083. return *v, true
  11084. }
  11085. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  11086. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11088. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  11089. if !m.op.Is(OpUpdateOne) {
  11090. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  11091. }
  11092. if m.id == nil || m.oldValue == nil {
  11093. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  11094. }
  11095. oldValue, err := m.oldValue(ctx)
  11096. if err != nil {
  11097. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  11098. }
  11099. return oldValue.OpenaiKey, nil
  11100. }
  11101. // ResetOpenaiKey resets all changes to the "openai_key" field.
  11102. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  11103. m.openai_key = nil
  11104. }
  11105. // SetRequestRaw sets the "request_raw" field.
  11106. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  11107. m.request_raw = &s
  11108. }
  11109. // RequestRaw returns the value of the "request_raw" field in the mutation.
  11110. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  11111. v := m.request_raw
  11112. if v == nil {
  11113. return
  11114. }
  11115. return *v, true
  11116. }
  11117. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  11118. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11120. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  11121. if !m.op.Is(OpUpdateOne) {
  11122. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  11123. }
  11124. if m.id == nil || m.oldValue == nil {
  11125. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  11126. }
  11127. oldValue, err := m.oldValue(ctx)
  11128. if err != nil {
  11129. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  11130. }
  11131. return oldValue.RequestRaw, nil
  11132. }
  11133. // ResetRequestRaw resets all changes to the "request_raw" field.
  11134. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  11135. m.request_raw = nil
  11136. }
  11137. // SetResponseRaw sets the "response_raw" field.
  11138. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  11139. m.response_raw = &s
  11140. }
  11141. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  11142. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  11143. v := m.response_raw
  11144. if v == nil {
  11145. return
  11146. }
  11147. return *v, true
  11148. }
  11149. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  11150. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11152. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  11153. if !m.op.Is(OpUpdateOne) {
  11154. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  11155. }
  11156. if m.id == nil || m.oldValue == nil {
  11157. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  11158. }
  11159. oldValue, err := m.oldValue(ctx)
  11160. if err != nil {
  11161. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  11162. }
  11163. return oldValue.ResponseRaw, nil
  11164. }
  11165. // ClearResponseRaw clears the value of the "response_raw" field.
  11166. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  11167. m.response_raw = nil
  11168. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  11169. }
  11170. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  11171. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  11172. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  11173. return ok
  11174. }
  11175. // ResetResponseRaw resets all changes to the "response_raw" field.
  11176. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  11177. m.response_raw = nil
  11178. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  11179. }
  11180. // SetCallbackURL sets the "callback_url" field.
  11181. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  11182. m.callback_url = &s
  11183. }
  11184. // CallbackURL returns the value of the "callback_url" field in the mutation.
  11185. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  11186. v := m.callback_url
  11187. if v == nil {
  11188. return
  11189. }
  11190. return *v, true
  11191. }
  11192. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  11193. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11195. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  11196. if !m.op.Is(OpUpdateOne) {
  11197. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  11198. }
  11199. if m.id == nil || m.oldValue == nil {
  11200. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  11201. }
  11202. oldValue, err := m.oldValue(ctx)
  11203. if err != nil {
  11204. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  11205. }
  11206. return oldValue.CallbackURL, nil
  11207. }
  11208. // ResetCallbackURL resets all changes to the "callback_url" field.
  11209. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  11210. m.callback_url = nil
  11211. }
  11212. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  11213. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  11214. m.callback_response_raw = &s
  11215. }
  11216. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  11217. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  11218. v := m.callback_response_raw
  11219. if v == nil {
  11220. return
  11221. }
  11222. return *v, true
  11223. }
  11224. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  11225. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11227. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  11228. if !m.op.Is(OpUpdateOne) {
  11229. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  11230. }
  11231. if m.id == nil || m.oldValue == nil {
  11232. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  11233. }
  11234. oldValue, err := m.oldValue(ctx)
  11235. if err != nil {
  11236. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  11237. }
  11238. return oldValue.CallbackResponseRaw, nil
  11239. }
  11240. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  11241. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  11242. m.callback_response_raw = nil
  11243. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  11244. }
  11245. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  11246. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  11247. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  11248. return ok
  11249. }
  11250. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  11251. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  11252. m.callback_response_raw = nil
  11253. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  11254. }
  11255. // SetModel sets the "model" field.
  11256. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  11257. m.model = &s
  11258. }
  11259. // Model returns the value of the "model" field in the mutation.
  11260. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  11261. v := m.model
  11262. if v == nil {
  11263. return
  11264. }
  11265. return *v, true
  11266. }
  11267. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  11268. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11270. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  11271. if !m.op.Is(OpUpdateOne) {
  11272. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  11273. }
  11274. if m.id == nil || m.oldValue == nil {
  11275. return v, errors.New("OldModel requires an ID field in the mutation")
  11276. }
  11277. oldValue, err := m.oldValue(ctx)
  11278. if err != nil {
  11279. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  11280. }
  11281. return oldValue.Model, nil
  11282. }
  11283. // ClearModel clears the value of the "model" field.
  11284. func (m *CompapiAsynctaskMutation) ClearModel() {
  11285. m.model = nil
  11286. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  11287. }
  11288. // ModelCleared returns if the "model" field was cleared in this mutation.
  11289. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  11290. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  11291. return ok
  11292. }
  11293. // ResetModel resets all changes to the "model" field.
  11294. func (m *CompapiAsynctaskMutation) ResetModel() {
  11295. m.model = nil
  11296. delete(m.clearedFields, compapiasynctask.FieldModel)
  11297. }
  11298. // SetTaskStatus sets the "task_status" field.
  11299. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  11300. m.task_status = &i
  11301. m.addtask_status = nil
  11302. }
  11303. // TaskStatus returns the value of the "task_status" field in the mutation.
  11304. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  11305. v := m.task_status
  11306. if v == nil {
  11307. return
  11308. }
  11309. return *v, true
  11310. }
  11311. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  11312. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11314. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  11315. if !m.op.Is(OpUpdateOne) {
  11316. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  11317. }
  11318. if m.id == nil || m.oldValue == nil {
  11319. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  11320. }
  11321. oldValue, err := m.oldValue(ctx)
  11322. if err != nil {
  11323. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  11324. }
  11325. return oldValue.TaskStatus, nil
  11326. }
  11327. // AddTaskStatus adds i to the "task_status" field.
  11328. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  11329. if m.addtask_status != nil {
  11330. *m.addtask_status += i
  11331. } else {
  11332. m.addtask_status = &i
  11333. }
  11334. }
  11335. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  11336. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  11337. v := m.addtask_status
  11338. if v == nil {
  11339. return
  11340. }
  11341. return *v, true
  11342. }
  11343. // ClearTaskStatus clears the value of the "task_status" field.
  11344. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  11345. m.task_status = nil
  11346. m.addtask_status = nil
  11347. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  11348. }
  11349. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  11350. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  11351. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  11352. return ok
  11353. }
  11354. // ResetTaskStatus resets all changes to the "task_status" field.
  11355. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  11356. m.task_status = nil
  11357. m.addtask_status = nil
  11358. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  11359. }
  11360. // SetRetryCount sets the "retry_count" field.
  11361. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  11362. m.retry_count = &i
  11363. m.addretry_count = nil
  11364. }
  11365. // RetryCount returns the value of the "retry_count" field in the mutation.
  11366. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  11367. v := m.retry_count
  11368. if v == nil {
  11369. return
  11370. }
  11371. return *v, true
  11372. }
  11373. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  11374. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11376. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  11377. if !m.op.Is(OpUpdateOne) {
  11378. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  11379. }
  11380. if m.id == nil || m.oldValue == nil {
  11381. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  11382. }
  11383. oldValue, err := m.oldValue(ctx)
  11384. if err != nil {
  11385. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  11386. }
  11387. return oldValue.RetryCount, nil
  11388. }
  11389. // AddRetryCount adds i to the "retry_count" field.
  11390. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  11391. if m.addretry_count != nil {
  11392. *m.addretry_count += i
  11393. } else {
  11394. m.addretry_count = &i
  11395. }
  11396. }
  11397. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  11398. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  11399. v := m.addretry_count
  11400. if v == nil {
  11401. return
  11402. }
  11403. return *v, true
  11404. }
  11405. // ClearRetryCount clears the value of the "retry_count" field.
  11406. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  11407. m.retry_count = nil
  11408. m.addretry_count = nil
  11409. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  11410. }
  11411. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  11412. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  11413. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  11414. return ok
  11415. }
  11416. // ResetRetryCount resets all changes to the "retry_count" field.
  11417. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  11418. m.retry_count = nil
  11419. m.addretry_count = nil
  11420. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  11421. }
  11422. // SetLastError sets the "last_error" field.
  11423. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  11424. m.last_error = &s
  11425. }
  11426. // LastError returns the value of the "last_error" field in the mutation.
  11427. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  11428. v := m.last_error
  11429. if v == nil {
  11430. return
  11431. }
  11432. return *v, true
  11433. }
  11434. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  11435. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11437. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  11438. if !m.op.Is(OpUpdateOne) {
  11439. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  11440. }
  11441. if m.id == nil || m.oldValue == nil {
  11442. return v, errors.New("OldLastError requires an ID field in the mutation")
  11443. }
  11444. oldValue, err := m.oldValue(ctx)
  11445. if err != nil {
  11446. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  11447. }
  11448. return oldValue.LastError, nil
  11449. }
  11450. // ClearLastError clears the value of the "last_error" field.
  11451. func (m *CompapiAsynctaskMutation) ClearLastError() {
  11452. m.last_error = nil
  11453. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  11454. }
  11455. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  11456. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  11457. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  11458. return ok
  11459. }
  11460. // ResetLastError resets all changes to the "last_error" field.
  11461. func (m *CompapiAsynctaskMutation) ResetLastError() {
  11462. m.last_error = nil
  11463. delete(m.clearedFields, compapiasynctask.FieldLastError)
  11464. }
  11465. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  11466. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  11467. m.predicates = append(m.predicates, ps...)
  11468. }
  11469. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  11470. // users can use type-assertion to append predicates that do not depend on any generated package.
  11471. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  11472. p := make([]predicate.CompapiAsynctask, len(ps))
  11473. for i := range ps {
  11474. p[i] = ps[i]
  11475. }
  11476. m.Where(p...)
  11477. }
  11478. // Op returns the operation name.
  11479. func (m *CompapiAsynctaskMutation) Op() Op {
  11480. return m.op
  11481. }
  11482. // SetOp allows setting the mutation operation.
  11483. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  11484. m.op = op
  11485. }
  11486. // Type returns the node type of this mutation (CompapiAsynctask).
  11487. func (m *CompapiAsynctaskMutation) Type() string {
  11488. return m.typ
  11489. }
  11490. // Fields returns all fields that were changed during this mutation. Note that in
  11491. // order to get all numeric fields that were incremented/decremented, call
  11492. // AddedFields().
  11493. func (m *CompapiAsynctaskMutation) Fields() []string {
  11494. fields := make([]string, 0, 17)
  11495. if m.created_at != nil {
  11496. fields = append(fields, compapiasynctask.FieldCreatedAt)
  11497. }
  11498. if m.updated_at != nil {
  11499. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  11500. }
  11501. if m.auth_token != nil {
  11502. fields = append(fields, compapiasynctask.FieldAuthToken)
  11503. }
  11504. if m.event_type != nil {
  11505. fields = append(fields, compapiasynctask.FieldEventType)
  11506. }
  11507. if m.chat_id != nil {
  11508. fields = append(fields, compapiasynctask.FieldChatID)
  11509. }
  11510. if m.response_chat_item_id != nil {
  11511. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11512. }
  11513. if m.organization_id != nil {
  11514. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11515. }
  11516. if m.openai_base != nil {
  11517. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  11518. }
  11519. if m.openai_key != nil {
  11520. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  11521. }
  11522. if m.request_raw != nil {
  11523. fields = append(fields, compapiasynctask.FieldRequestRaw)
  11524. }
  11525. if m.response_raw != nil {
  11526. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11527. }
  11528. if m.callback_url != nil {
  11529. fields = append(fields, compapiasynctask.FieldCallbackURL)
  11530. }
  11531. if m.callback_response_raw != nil {
  11532. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11533. }
  11534. if m.model != nil {
  11535. fields = append(fields, compapiasynctask.FieldModel)
  11536. }
  11537. if m.task_status != nil {
  11538. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11539. }
  11540. if m.retry_count != nil {
  11541. fields = append(fields, compapiasynctask.FieldRetryCount)
  11542. }
  11543. if m.last_error != nil {
  11544. fields = append(fields, compapiasynctask.FieldLastError)
  11545. }
  11546. return fields
  11547. }
  11548. // Field returns the value of a field with the given name. The second boolean
  11549. // return value indicates that this field was not set, or was not defined in the
  11550. // schema.
  11551. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  11552. switch name {
  11553. case compapiasynctask.FieldCreatedAt:
  11554. return m.CreatedAt()
  11555. case compapiasynctask.FieldUpdatedAt:
  11556. return m.UpdatedAt()
  11557. case compapiasynctask.FieldAuthToken:
  11558. return m.AuthToken()
  11559. case compapiasynctask.FieldEventType:
  11560. return m.EventType()
  11561. case compapiasynctask.FieldChatID:
  11562. return m.ChatID()
  11563. case compapiasynctask.FieldResponseChatItemID:
  11564. return m.ResponseChatItemID()
  11565. case compapiasynctask.FieldOrganizationID:
  11566. return m.OrganizationID()
  11567. case compapiasynctask.FieldOpenaiBase:
  11568. return m.OpenaiBase()
  11569. case compapiasynctask.FieldOpenaiKey:
  11570. return m.OpenaiKey()
  11571. case compapiasynctask.FieldRequestRaw:
  11572. return m.RequestRaw()
  11573. case compapiasynctask.FieldResponseRaw:
  11574. return m.ResponseRaw()
  11575. case compapiasynctask.FieldCallbackURL:
  11576. return m.CallbackURL()
  11577. case compapiasynctask.FieldCallbackResponseRaw:
  11578. return m.CallbackResponseRaw()
  11579. case compapiasynctask.FieldModel:
  11580. return m.Model()
  11581. case compapiasynctask.FieldTaskStatus:
  11582. return m.TaskStatus()
  11583. case compapiasynctask.FieldRetryCount:
  11584. return m.RetryCount()
  11585. case compapiasynctask.FieldLastError:
  11586. return m.LastError()
  11587. }
  11588. return nil, false
  11589. }
  11590. // OldField returns the old value of the field from the database. An error is
  11591. // returned if the mutation operation is not UpdateOne, or the query to the
  11592. // database failed.
  11593. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11594. switch name {
  11595. case compapiasynctask.FieldCreatedAt:
  11596. return m.OldCreatedAt(ctx)
  11597. case compapiasynctask.FieldUpdatedAt:
  11598. return m.OldUpdatedAt(ctx)
  11599. case compapiasynctask.FieldAuthToken:
  11600. return m.OldAuthToken(ctx)
  11601. case compapiasynctask.FieldEventType:
  11602. return m.OldEventType(ctx)
  11603. case compapiasynctask.FieldChatID:
  11604. return m.OldChatID(ctx)
  11605. case compapiasynctask.FieldResponseChatItemID:
  11606. return m.OldResponseChatItemID(ctx)
  11607. case compapiasynctask.FieldOrganizationID:
  11608. return m.OldOrganizationID(ctx)
  11609. case compapiasynctask.FieldOpenaiBase:
  11610. return m.OldOpenaiBase(ctx)
  11611. case compapiasynctask.FieldOpenaiKey:
  11612. return m.OldOpenaiKey(ctx)
  11613. case compapiasynctask.FieldRequestRaw:
  11614. return m.OldRequestRaw(ctx)
  11615. case compapiasynctask.FieldResponseRaw:
  11616. return m.OldResponseRaw(ctx)
  11617. case compapiasynctask.FieldCallbackURL:
  11618. return m.OldCallbackURL(ctx)
  11619. case compapiasynctask.FieldCallbackResponseRaw:
  11620. return m.OldCallbackResponseRaw(ctx)
  11621. case compapiasynctask.FieldModel:
  11622. return m.OldModel(ctx)
  11623. case compapiasynctask.FieldTaskStatus:
  11624. return m.OldTaskStatus(ctx)
  11625. case compapiasynctask.FieldRetryCount:
  11626. return m.OldRetryCount(ctx)
  11627. case compapiasynctask.FieldLastError:
  11628. return m.OldLastError(ctx)
  11629. }
  11630. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11631. }
  11632. // SetField sets the value of a field with the given name. It returns an error if
  11633. // the field is not defined in the schema, or if the type mismatched the field
  11634. // type.
  11635. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  11636. switch name {
  11637. case compapiasynctask.FieldCreatedAt:
  11638. v, ok := value.(time.Time)
  11639. if !ok {
  11640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11641. }
  11642. m.SetCreatedAt(v)
  11643. return nil
  11644. case compapiasynctask.FieldUpdatedAt:
  11645. v, ok := value.(time.Time)
  11646. if !ok {
  11647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11648. }
  11649. m.SetUpdatedAt(v)
  11650. return nil
  11651. case compapiasynctask.FieldAuthToken:
  11652. v, ok := value.(string)
  11653. if !ok {
  11654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11655. }
  11656. m.SetAuthToken(v)
  11657. return nil
  11658. case compapiasynctask.FieldEventType:
  11659. v, ok := value.(string)
  11660. if !ok {
  11661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11662. }
  11663. m.SetEventType(v)
  11664. return nil
  11665. case compapiasynctask.FieldChatID:
  11666. v, ok := value.(string)
  11667. if !ok {
  11668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11669. }
  11670. m.SetChatID(v)
  11671. return nil
  11672. case compapiasynctask.FieldResponseChatItemID:
  11673. v, ok := value.(string)
  11674. if !ok {
  11675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11676. }
  11677. m.SetResponseChatItemID(v)
  11678. return nil
  11679. case compapiasynctask.FieldOrganizationID:
  11680. v, ok := value.(uint64)
  11681. if !ok {
  11682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11683. }
  11684. m.SetOrganizationID(v)
  11685. return nil
  11686. case compapiasynctask.FieldOpenaiBase:
  11687. v, ok := value.(string)
  11688. if !ok {
  11689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11690. }
  11691. m.SetOpenaiBase(v)
  11692. return nil
  11693. case compapiasynctask.FieldOpenaiKey:
  11694. v, ok := value.(string)
  11695. if !ok {
  11696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11697. }
  11698. m.SetOpenaiKey(v)
  11699. return nil
  11700. case compapiasynctask.FieldRequestRaw:
  11701. v, ok := value.(string)
  11702. if !ok {
  11703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11704. }
  11705. m.SetRequestRaw(v)
  11706. return nil
  11707. case compapiasynctask.FieldResponseRaw:
  11708. v, ok := value.(string)
  11709. if !ok {
  11710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11711. }
  11712. m.SetResponseRaw(v)
  11713. return nil
  11714. case compapiasynctask.FieldCallbackURL:
  11715. v, ok := value.(string)
  11716. if !ok {
  11717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11718. }
  11719. m.SetCallbackURL(v)
  11720. return nil
  11721. case compapiasynctask.FieldCallbackResponseRaw:
  11722. v, ok := value.(string)
  11723. if !ok {
  11724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11725. }
  11726. m.SetCallbackResponseRaw(v)
  11727. return nil
  11728. case compapiasynctask.FieldModel:
  11729. v, ok := value.(string)
  11730. if !ok {
  11731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11732. }
  11733. m.SetModel(v)
  11734. return nil
  11735. case compapiasynctask.FieldTaskStatus:
  11736. v, ok := value.(int8)
  11737. if !ok {
  11738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11739. }
  11740. m.SetTaskStatus(v)
  11741. return nil
  11742. case compapiasynctask.FieldRetryCount:
  11743. v, ok := value.(int8)
  11744. if !ok {
  11745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11746. }
  11747. m.SetRetryCount(v)
  11748. return nil
  11749. case compapiasynctask.FieldLastError:
  11750. v, ok := value.(string)
  11751. if !ok {
  11752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11753. }
  11754. m.SetLastError(v)
  11755. return nil
  11756. }
  11757. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11758. }
  11759. // AddedFields returns all numeric fields that were incremented/decremented during
  11760. // this mutation.
  11761. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  11762. var fields []string
  11763. if m.addorganization_id != nil {
  11764. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11765. }
  11766. if m.addtask_status != nil {
  11767. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11768. }
  11769. if m.addretry_count != nil {
  11770. fields = append(fields, compapiasynctask.FieldRetryCount)
  11771. }
  11772. return fields
  11773. }
  11774. // AddedField returns the numeric value that was incremented/decremented on a field
  11775. // with the given name. The second boolean return value indicates that this field
  11776. // was not set, or was not defined in the schema.
  11777. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  11778. switch name {
  11779. case compapiasynctask.FieldOrganizationID:
  11780. return m.AddedOrganizationID()
  11781. case compapiasynctask.FieldTaskStatus:
  11782. return m.AddedTaskStatus()
  11783. case compapiasynctask.FieldRetryCount:
  11784. return m.AddedRetryCount()
  11785. }
  11786. return nil, false
  11787. }
  11788. // AddField adds the value to the field with the given name. It returns an error if
  11789. // the field is not defined in the schema, or if the type mismatched the field
  11790. // type.
  11791. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  11792. switch name {
  11793. case compapiasynctask.FieldOrganizationID:
  11794. v, ok := value.(int64)
  11795. if !ok {
  11796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11797. }
  11798. m.AddOrganizationID(v)
  11799. return nil
  11800. case compapiasynctask.FieldTaskStatus:
  11801. v, ok := value.(int8)
  11802. if !ok {
  11803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11804. }
  11805. m.AddTaskStatus(v)
  11806. return nil
  11807. case compapiasynctask.FieldRetryCount:
  11808. v, ok := value.(int8)
  11809. if !ok {
  11810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11811. }
  11812. m.AddRetryCount(v)
  11813. return nil
  11814. }
  11815. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  11816. }
  11817. // ClearedFields returns all nullable fields that were cleared during this
  11818. // mutation.
  11819. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  11820. var fields []string
  11821. if m.FieldCleared(compapiasynctask.FieldChatID) {
  11822. fields = append(fields, compapiasynctask.FieldChatID)
  11823. }
  11824. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  11825. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11826. }
  11827. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  11828. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11829. }
  11830. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  11831. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11832. }
  11833. if m.FieldCleared(compapiasynctask.FieldModel) {
  11834. fields = append(fields, compapiasynctask.FieldModel)
  11835. }
  11836. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  11837. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11838. }
  11839. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  11840. fields = append(fields, compapiasynctask.FieldRetryCount)
  11841. }
  11842. if m.FieldCleared(compapiasynctask.FieldLastError) {
  11843. fields = append(fields, compapiasynctask.FieldLastError)
  11844. }
  11845. return fields
  11846. }
  11847. // FieldCleared returns a boolean indicating if a field with the given name was
  11848. // cleared in this mutation.
  11849. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  11850. _, ok := m.clearedFields[name]
  11851. return ok
  11852. }
  11853. // ClearField clears the value of the field with the given name. It returns an
  11854. // error if the field is not defined in the schema.
  11855. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  11856. switch name {
  11857. case compapiasynctask.FieldChatID:
  11858. m.ClearChatID()
  11859. return nil
  11860. case compapiasynctask.FieldResponseChatItemID:
  11861. m.ClearResponseChatItemID()
  11862. return nil
  11863. case compapiasynctask.FieldResponseRaw:
  11864. m.ClearResponseRaw()
  11865. return nil
  11866. case compapiasynctask.FieldCallbackResponseRaw:
  11867. m.ClearCallbackResponseRaw()
  11868. return nil
  11869. case compapiasynctask.FieldModel:
  11870. m.ClearModel()
  11871. return nil
  11872. case compapiasynctask.FieldTaskStatus:
  11873. m.ClearTaskStatus()
  11874. return nil
  11875. case compapiasynctask.FieldRetryCount:
  11876. m.ClearRetryCount()
  11877. return nil
  11878. case compapiasynctask.FieldLastError:
  11879. m.ClearLastError()
  11880. return nil
  11881. }
  11882. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  11883. }
  11884. // ResetField resets all changes in the mutation for the field with the given name.
  11885. // It returns an error if the field is not defined in the schema.
  11886. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  11887. switch name {
  11888. case compapiasynctask.FieldCreatedAt:
  11889. m.ResetCreatedAt()
  11890. return nil
  11891. case compapiasynctask.FieldUpdatedAt:
  11892. m.ResetUpdatedAt()
  11893. return nil
  11894. case compapiasynctask.FieldAuthToken:
  11895. m.ResetAuthToken()
  11896. return nil
  11897. case compapiasynctask.FieldEventType:
  11898. m.ResetEventType()
  11899. return nil
  11900. case compapiasynctask.FieldChatID:
  11901. m.ResetChatID()
  11902. return nil
  11903. case compapiasynctask.FieldResponseChatItemID:
  11904. m.ResetResponseChatItemID()
  11905. return nil
  11906. case compapiasynctask.FieldOrganizationID:
  11907. m.ResetOrganizationID()
  11908. return nil
  11909. case compapiasynctask.FieldOpenaiBase:
  11910. m.ResetOpenaiBase()
  11911. return nil
  11912. case compapiasynctask.FieldOpenaiKey:
  11913. m.ResetOpenaiKey()
  11914. return nil
  11915. case compapiasynctask.FieldRequestRaw:
  11916. m.ResetRequestRaw()
  11917. return nil
  11918. case compapiasynctask.FieldResponseRaw:
  11919. m.ResetResponseRaw()
  11920. return nil
  11921. case compapiasynctask.FieldCallbackURL:
  11922. m.ResetCallbackURL()
  11923. return nil
  11924. case compapiasynctask.FieldCallbackResponseRaw:
  11925. m.ResetCallbackResponseRaw()
  11926. return nil
  11927. case compapiasynctask.FieldModel:
  11928. m.ResetModel()
  11929. return nil
  11930. case compapiasynctask.FieldTaskStatus:
  11931. m.ResetTaskStatus()
  11932. return nil
  11933. case compapiasynctask.FieldRetryCount:
  11934. m.ResetRetryCount()
  11935. return nil
  11936. case compapiasynctask.FieldLastError:
  11937. m.ResetLastError()
  11938. return nil
  11939. }
  11940. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11941. }
  11942. // AddedEdges returns all edge names that were set/added in this mutation.
  11943. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  11944. edges := make([]string, 0, 0)
  11945. return edges
  11946. }
  11947. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11948. // name in this mutation.
  11949. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  11950. return nil
  11951. }
  11952. // RemovedEdges returns all edge names that were removed in this mutation.
  11953. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  11954. edges := make([]string, 0, 0)
  11955. return edges
  11956. }
  11957. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11958. // the given name in this mutation.
  11959. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  11960. return nil
  11961. }
  11962. // ClearedEdges returns all edge names that were cleared in this mutation.
  11963. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  11964. edges := make([]string, 0, 0)
  11965. return edges
  11966. }
  11967. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11968. // was cleared in this mutation.
  11969. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  11970. return false
  11971. }
  11972. // ClearEdge clears the value of the edge with the given name. It returns an error
  11973. // if that edge is not defined in the schema.
  11974. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  11975. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  11976. }
  11977. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11978. // It returns an error if the edge is not defined in the schema.
  11979. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  11980. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  11981. }
  11982. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  11983. type ContactMutation struct {
  11984. config
  11985. op Op
  11986. typ string
  11987. id *uint64
  11988. created_at *time.Time
  11989. updated_at *time.Time
  11990. status *uint8
  11991. addstatus *int8
  11992. deleted_at *time.Time
  11993. wx_wxid *string
  11994. _type *int
  11995. add_type *int
  11996. wxid *string
  11997. account *string
  11998. nickname *string
  11999. markname *string
  12000. headimg *string
  12001. sex *int
  12002. addsex *int
  12003. starrole *string
  12004. dontseeit *int
  12005. adddontseeit *int
  12006. dontseeme *int
  12007. adddontseeme *int
  12008. lag *string
  12009. gid *string
  12010. gname *string
  12011. v3 *string
  12012. organization_id *uint64
  12013. addorganization_id *int64
  12014. ctype *uint64
  12015. addctype *int64
  12016. cage *int
  12017. addcage *int
  12018. cname *string
  12019. carea *string
  12020. cbirthday *string
  12021. cbirtharea *string
  12022. cidcard_no *string
  12023. ctitle *string
  12024. cc *string
  12025. phone *string
  12026. clearedFields map[string]struct{}
  12027. contact_relationships map[uint64]struct{}
  12028. removedcontact_relationships map[uint64]struct{}
  12029. clearedcontact_relationships bool
  12030. contact_fields map[uint64]struct{}
  12031. removedcontact_fields map[uint64]struct{}
  12032. clearedcontact_fields bool
  12033. contact_messages map[uint64]struct{}
  12034. removedcontact_messages map[uint64]struct{}
  12035. clearedcontact_messages bool
  12036. done bool
  12037. oldValue func(context.Context) (*Contact, error)
  12038. predicates []predicate.Contact
  12039. }
  12040. var _ ent.Mutation = (*ContactMutation)(nil)
  12041. // contactOption allows management of the mutation configuration using functional options.
  12042. type contactOption func(*ContactMutation)
  12043. // newContactMutation creates new mutation for the Contact entity.
  12044. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  12045. m := &ContactMutation{
  12046. config: c,
  12047. op: op,
  12048. typ: TypeContact,
  12049. clearedFields: make(map[string]struct{}),
  12050. }
  12051. for _, opt := range opts {
  12052. opt(m)
  12053. }
  12054. return m
  12055. }
  12056. // withContactID sets the ID field of the mutation.
  12057. func withContactID(id uint64) contactOption {
  12058. return func(m *ContactMutation) {
  12059. var (
  12060. err error
  12061. once sync.Once
  12062. value *Contact
  12063. )
  12064. m.oldValue = func(ctx context.Context) (*Contact, error) {
  12065. once.Do(func() {
  12066. if m.done {
  12067. err = errors.New("querying old values post mutation is not allowed")
  12068. } else {
  12069. value, err = m.Client().Contact.Get(ctx, id)
  12070. }
  12071. })
  12072. return value, err
  12073. }
  12074. m.id = &id
  12075. }
  12076. }
  12077. // withContact sets the old Contact of the mutation.
  12078. func withContact(node *Contact) contactOption {
  12079. return func(m *ContactMutation) {
  12080. m.oldValue = func(context.Context) (*Contact, error) {
  12081. return node, nil
  12082. }
  12083. m.id = &node.ID
  12084. }
  12085. }
  12086. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12087. // executed in a transaction (ent.Tx), a transactional client is returned.
  12088. func (m ContactMutation) Client() *Client {
  12089. client := &Client{config: m.config}
  12090. client.init()
  12091. return client
  12092. }
  12093. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12094. // it returns an error otherwise.
  12095. func (m ContactMutation) Tx() (*Tx, error) {
  12096. if _, ok := m.driver.(*txDriver); !ok {
  12097. return nil, errors.New("ent: mutation is not running in a transaction")
  12098. }
  12099. tx := &Tx{config: m.config}
  12100. tx.init()
  12101. return tx, nil
  12102. }
  12103. // SetID sets the value of the id field. Note that this
  12104. // operation is only accepted on creation of Contact entities.
  12105. func (m *ContactMutation) SetID(id uint64) {
  12106. m.id = &id
  12107. }
  12108. // ID returns the ID value in the mutation. Note that the ID is only available
  12109. // if it was provided to the builder or after it was returned from the database.
  12110. func (m *ContactMutation) ID() (id uint64, exists bool) {
  12111. if m.id == nil {
  12112. return
  12113. }
  12114. return *m.id, true
  12115. }
  12116. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12117. // That means, if the mutation is applied within a transaction with an isolation level such
  12118. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12119. // or updated by the mutation.
  12120. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  12121. switch {
  12122. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12123. id, exists := m.ID()
  12124. if exists {
  12125. return []uint64{id}, nil
  12126. }
  12127. fallthrough
  12128. case m.op.Is(OpUpdate | OpDelete):
  12129. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  12130. default:
  12131. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12132. }
  12133. }
  12134. // SetCreatedAt sets the "created_at" field.
  12135. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  12136. m.created_at = &t
  12137. }
  12138. // CreatedAt returns the value of the "created_at" field in the mutation.
  12139. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  12140. v := m.created_at
  12141. if v == nil {
  12142. return
  12143. }
  12144. return *v, true
  12145. }
  12146. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  12147. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12149. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12150. if !m.op.Is(OpUpdateOne) {
  12151. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12152. }
  12153. if m.id == nil || m.oldValue == nil {
  12154. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12155. }
  12156. oldValue, err := m.oldValue(ctx)
  12157. if err != nil {
  12158. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12159. }
  12160. return oldValue.CreatedAt, nil
  12161. }
  12162. // ResetCreatedAt resets all changes to the "created_at" field.
  12163. func (m *ContactMutation) ResetCreatedAt() {
  12164. m.created_at = nil
  12165. }
  12166. // SetUpdatedAt sets the "updated_at" field.
  12167. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  12168. m.updated_at = &t
  12169. }
  12170. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12171. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  12172. v := m.updated_at
  12173. if v == nil {
  12174. return
  12175. }
  12176. return *v, true
  12177. }
  12178. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  12179. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12181. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12182. if !m.op.Is(OpUpdateOne) {
  12183. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12184. }
  12185. if m.id == nil || m.oldValue == nil {
  12186. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12187. }
  12188. oldValue, err := m.oldValue(ctx)
  12189. if err != nil {
  12190. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12191. }
  12192. return oldValue.UpdatedAt, nil
  12193. }
  12194. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12195. func (m *ContactMutation) ResetUpdatedAt() {
  12196. m.updated_at = nil
  12197. }
  12198. // SetStatus sets the "status" field.
  12199. func (m *ContactMutation) SetStatus(u uint8) {
  12200. m.status = &u
  12201. m.addstatus = nil
  12202. }
  12203. // Status returns the value of the "status" field in the mutation.
  12204. func (m *ContactMutation) Status() (r uint8, exists bool) {
  12205. v := m.status
  12206. if v == nil {
  12207. return
  12208. }
  12209. return *v, true
  12210. }
  12211. // OldStatus returns the old "status" field's value of the Contact entity.
  12212. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12214. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12215. if !m.op.Is(OpUpdateOne) {
  12216. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12217. }
  12218. if m.id == nil || m.oldValue == nil {
  12219. return v, errors.New("OldStatus requires an ID field in the mutation")
  12220. }
  12221. oldValue, err := m.oldValue(ctx)
  12222. if err != nil {
  12223. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12224. }
  12225. return oldValue.Status, nil
  12226. }
  12227. // AddStatus adds u to the "status" field.
  12228. func (m *ContactMutation) AddStatus(u int8) {
  12229. if m.addstatus != nil {
  12230. *m.addstatus += u
  12231. } else {
  12232. m.addstatus = &u
  12233. }
  12234. }
  12235. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12236. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  12237. v := m.addstatus
  12238. if v == nil {
  12239. return
  12240. }
  12241. return *v, true
  12242. }
  12243. // ClearStatus clears the value of the "status" field.
  12244. func (m *ContactMutation) ClearStatus() {
  12245. m.status = nil
  12246. m.addstatus = nil
  12247. m.clearedFields[contact.FieldStatus] = struct{}{}
  12248. }
  12249. // StatusCleared returns if the "status" field was cleared in this mutation.
  12250. func (m *ContactMutation) StatusCleared() bool {
  12251. _, ok := m.clearedFields[contact.FieldStatus]
  12252. return ok
  12253. }
  12254. // ResetStatus resets all changes to the "status" field.
  12255. func (m *ContactMutation) ResetStatus() {
  12256. m.status = nil
  12257. m.addstatus = nil
  12258. delete(m.clearedFields, contact.FieldStatus)
  12259. }
  12260. // SetDeletedAt sets the "deleted_at" field.
  12261. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  12262. m.deleted_at = &t
  12263. }
  12264. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12265. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  12266. v := m.deleted_at
  12267. if v == nil {
  12268. return
  12269. }
  12270. return *v, true
  12271. }
  12272. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  12273. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12275. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12276. if !m.op.Is(OpUpdateOne) {
  12277. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12278. }
  12279. if m.id == nil || m.oldValue == nil {
  12280. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12281. }
  12282. oldValue, err := m.oldValue(ctx)
  12283. if err != nil {
  12284. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12285. }
  12286. return oldValue.DeletedAt, nil
  12287. }
  12288. // ClearDeletedAt clears the value of the "deleted_at" field.
  12289. func (m *ContactMutation) ClearDeletedAt() {
  12290. m.deleted_at = nil
  12291. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  12292. }
  12293. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12294. func (m *ContactMutation) DeletedAtCleared() bool {
  12295. _, ok := m.clearedFields[contact.FieldDeletedAt]
  12296. return ok
  12297. }
  12298. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12299. func (m *ContactMutation) ResetDeletedAt() {
  12300. m.deleted_at = nil
  12301. delete(m.clearedFields, contact.FieldDeletedAt)
  12302. }
  12303. // SetWxWxid sets the "wx_wxid" field.
  12304. func (m *ContactMutation) SetWxWxid(s string) {
  12305. m.wx_wxid = &s
  12306. }
  12307. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12308. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  12309. v := m.wx_wxid
  12310. if v == nil {
  12311. return
  12312. }
  12313. return *v, true
  12314. }
  12315. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  12316. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12318. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12319. if !m.op.Is(OpUpdateOne) {
  12320. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12321. }
  12322. if m.id == nil || m.oldValue == nil {
  12323. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12324. }
  12325. oldValue, err := m.oldValue(ctx)
  12326. if err != nil {
  12327. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12328. }
  12329. return oldValue.WxWxid, nil
  12330. }
  12331. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12332. func (m *ContactMutation) ResetWxWxid() {
  12333. m.wx_wxid = nil
  12334. }
  12335. // SetType sets the "type" field.
  12336. func (m *ContactMutation) SetType(i int) {
  12337. m._type = &i
  12338. m.add_type = nil
  12339. }
  12340. // GetType returns the value of the "type" field in the mutation.
  12341. func (m *ContactMutation) GetType() (r int, exists bool) {
  12342. v := m._type
  12343. if v == nil {
  12344. return
  12345. }
  12346. return *v, true
  12347. }
  12348. // OldType returns the old "type" field's value of the Contact entity.
  12349. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12351. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  12352. if !m.op.Is(OpUpdateOne) {
  12353. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12354. }
  12355. if m.id == nil || m.oldValue == nil {
  12356. return v, errors.New("OldType requires an ID field in the mutation")
  12357. }
  12358. oldValue, err := m.oldValue(ctx)
  12359. if err != nil {
  12360. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12361. }
  12362. return oldValue.Type, nil
  12363. }
  12364. // AddType adds i to the "type" field.
  12365. func (m *ContactMutation) AddType(i int) {
  12366. if m.add_type != nil {
  12367. *m.add_type += i
  12368. } else {
  12369. m.add_type = &i
  12370. }
  12371. }
  12372. // AddedType returns the value that was added to the "type" field in this mutation.
  12373. func (m *ContactMutation) AddedType() (r int, exists bool) {
  12374. v := m.add_type
  12375. if v == nil {
  12376. return
  12377. }
  12378. return *v, true
  12379. }
  12380. // ClearType clears the value of the "type" field.
  12381. func (m *ContactMutation) ClearType() {
  12382. m._type = nil
  12383. m.add_type = nil
  12384. m.clearedFields[contact.FieldType] = struct{}{}
  12385. }
  12386. // TypeCleared returns if the "type" field was cleared in this mutation.
  12387. func (m *ContactMutation) TypeCleared() bool {
  12388. _, ok := m.clearedFields[contact.FieldType]
  12389. return ok
  12390. }
  12391. // ResetType resets all changes to the "type" field.
  12392. func (m *ContactMutation) ResetType() {
  12393. m._type = nil
  12394. m.add_type = nil
  12395. delete(m.clearedFields, contact.FieldType)
  12396. }
  12397. // SetWxid sets the "wxid" field.
  12398. func (m *ContactMutation) SetWxid(s string) {
  12399. m.wxid = &s
  12400. }
  12401. // Wxid returns the value of the "wxid" field in the mutation.
  12402. func (m *ContactMutation) Wxid() (r string, exists bool) {
  12403. v := m.wxid
  12404. if v == nil {
  12405. return
  12406. }
  12407. return *v, true
  12408. }
  12409. // OldWxid returns the old "wxid" field's value of the Contact entity.
  12410. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12412. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  12413. if !m.op.Is(OpUpdateOne) {
  12414. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12415. }
  12416. if m.id == nil || m.oldValue == nil {
  12417. return v, errors.New("OldWxid requires an ID field in the mutation")
  12418. }
  12419. oldValue, err := m.oldValue(ctx)
  12420. if err != nil {
  12421. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12422. }
  12423. return oldValue.Wxid, nil
  12424. }
  12425. // ResetWxid resets all changes to the "wxid" field.
  12426. func (m *ContactMutation) ResetWxid() {
  12427. m.wxid = nil
  12428. }
  12429. // SetAccount sets the "account" field.
  12430. func (m *ContactMutation) SetAccount(s string) {
  12431. m.account = &s
  12432. }
  12433. // Account returns the value of the "account" field in the mutation.
  12434. func (m *ContactMutation) Account() (r string, exists bool) {
  12435. v := m.account
  12436. if v == nil {
  12437. return
  12438. }
  12439. return *v, true
  12440. }
  12441. // OldAccount returns the old "account" field's value of the Contact entity.
  12442. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12444. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  12445. if !m.op.Is(OpUpdateOne) {
  12446. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  12447. }
  12448. if m.id == nil || m.oldValue == nil {
  12449. return v, errors.New("OldAccount requires an ID field in the mutation")
  12450. }
  12451. oldValue, err := m.oldValue(ctx)
  12452. if err != nil {
  12453. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  12454. }
  12455. return oldValue.Account, nil
  12456. }
  12457. // ResetAccount resets all changes to the "account" field.
  12458. func (m *ContactMutation) ResetAccount() {
  12459. m.account = nil
  12460. }
  12461. // SetNickname sets the "nickname" field.
  12462. func (m *ContactMutation) SetNickname(s string) {
  12463. m.nickname = &s
  12464. }
  12465. // Nickname returns the value of the "nickname" field in the mutation.
  12466. func (m *ContactMutation) Nickname() (r string, exists bool) {
  12467. v := m.nickname
  12468. if v == nil {
  12469. return
  12470. }
  12471. return *v, true
  12472. }
  12473. // OldNickname returns the old "nickname" field's value of the Contact entity.
  12474. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12476. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  12477. if !m.op.Is(OpUpdateOne) {
  12478. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  12479. }
  12480. if m.id == nil || m.oldValue == nil {
  12481. return v, errors.New("OldNickname requires an ID field in the mutation")
  12482. }
  12483. oldValue, err := m.oldValue(ctx)
  12484. if err != nil {
  12485. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  12486. }
  12487. return oldValue.Nickname, nil
  12488. }
  12489. // ResetNickname resets all changes to the "nickname" field.
  12490. func (m *ContactMutation) ResetNickname() {
  12491. m.nickname = nil
  12492. }
  12493. // SetMarkname sets the "markname" field.
  12494. func (m *ContactMutation) SetMarkname(s string) {
  12495. m.markname = &s
  12496. }
  12497. // Markname returns the value of the "markname" field in the mutation.
  12498. func (m *ContactMutation) Markname() (r string, exists bool) {
  12499. v := m.markname
  12500. if v == nil {
  12501. return
  12502. }
  12503. return *v, true
  12504. }
  12505. // OldMarkname returns the old "markname" field's value of the Contact entity.
  12506. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12508. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  12509. if !m.op.Is(OpUpdateOne) {
  12510. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  12511. }
  12512. if m.id == nil || m.oldValue == nil {
  12513. return v, errors.New("OldMarkname requires an ID field in the mutation")
  12514. }
  12515. oldValue, err := m.oldValue(ctx)
  12516. if err != nil {
  12517. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  12518. }
  12519. return oldValue.Markname, nil
  12520. }
  12521. // ResetMarkname resets all changes to the "markname" field.
  12522. func (m *ContactMutation) ResetMarkname() {
  12523. m.markname = nil
  12524. }
  12525. // SetHeadimg sets the "headimg" field.
  12526. func (m *ContactMutation) SetHeadimg(s string) {
  12527. m.headimg = &s
  12528. }
  12529. // Headimg returns the value of the "headimg" field in the mutation.
  12530. func (m *ContactMutation) Headimg() (r string, exists bool) {
  12531. v := m.headimg
  12532. if v == nil {
  12533. return
  12534. }
  12535. return *v, true
  12536. }
  12537. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  12538. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12540. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  12541. if !m.op.Is(OpUpdateOne) {
  12542. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  12543. }
  12544. if m.id == nil || m.oldValue == nil {
  12545. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  12546. }
  12547. oldValue, err := m.oldValue(ctx)
  12548. if err != nil {
  12549. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  12550. }
  12551. return oldValue.Headimg, nil
  12552. }
  12553. // ResetHeadimg resets all changes to the "headimg" field.
  12554. func (m *ContactMutation) ResetHeadimg() {
  12555. m.headimg = nil
  12556. }
  12557. // SetSex sets the "sex" field.
  12558. func (m *ContactMutation) SetSex(i int) {
  12559. m.sex = &i
  12560. m.addsex = nil
  12561. }
  12562. // Sex returns the value of the "sex" field in the mutation.
  12563. func (m *ContactMutation) Sex() (r int, exists bool) {
  12564. v := m.sex
  12565. if v == nil {
  12566. return
  12567. }
  12568. return *v, true
  12569. }
  12570. // OldSex returns the old "sex" field's value of the Contact entity.
  12571. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12573. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  12574. if !m.op.Is(OpUpdateOne) {
  12575. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  12576. }
  12577. if m.id == nil || m.oldValue == nil {
  12578. return v, errors.New("OldSex requires an ID field in the mutation")
  12579. }
  12580. oldValue, err := m.oldValue(ctx)
  12581. if err != nil {
  12582. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  12583. }
  12584. return oldValue.Sex, nil
  12585. }
  12586. // AddSex adds i to the "sex" field.
  12587. func (m *ContactMutation) AddSex(i int) {
  12588. if m.addsex != nil {
  12589. *m.addsex += i
  12590. } else {
  12591. m.addsex = &i
  12592. }
  12593. }
  12594. // AddedSex returns the value that was added to the "sex" field in this mutation.
  12595. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  12596. v := m.addsex
  12597. if v == nil {
  12598. return
  12599. }
  12600. return *v, true
  12601. }
  12602. // ResetSex resets all changes to the "sex" field.
  12603. func (m *ContactMutation) ResetSex() {
  12604. m.sex = nil
  12605. m.addsex = nil
  12606. }
  12607. // SetStarrole sets the "starrole" field.
  12608. func (m *ContactMutation) SetStarrole(s string) {
  12609. m.starrole = &s
  12610. }
  12611. // Starrole returns the value of the "starrole" field in the mutation.
  12612. func (m *ContactMutation) Starrole() (r string, exists bool) {
  12613. v := m.starrole
  12614. if v == nil {
  12615. return
  12616. }
  12617. return *v, true
  12618. }
  12619. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  12620. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12622. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  12623. if !m.op.Is(OpUpdateOne) {
  12624. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  12625. }
  12626. if m.id == nil || m.oldValue == nil {
  12627. return v, errors.New("OldStarrole requires an ID field in the mutation")
  12628. }
  12629. oldValue, err := m.oldValue(ctx)
  12630. if err != nil {
  12631. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  12632. }
  12633. return oldValue.Starrole, nil
  12634. }
  12635. // ResetStarrole resets all changes to the "starrole" field.
  12636. func (m *ContactMutation) ResetStarrole() {
  12637. m.starrole = nil
  12638. }
  12639. // SetDontseeit sets the "dontseeit" field.
  12640. func (m *ContactMutation) SetDontseeit(i int) {
  12641. m.dontseeit = &i
  12642. m.adddontseeit = nil
  12643. }
  12644. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  12645. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  12646. v := m.dontseeit
  12647. if v == nil {
  12648. return
  12649. }
  12650. return *v, true
  12651. }
  12652. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  12653. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12655. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  12656. if !m.op.Is(OpUpdateOne) {
  12657. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  12658. }
  12659. if m.id == nil || m.oldValue == nil {
  12660. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  12661. }
  12662. oldValue, err := m.oldValue(ctx)
  12663. if err != nil {
  12664. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  12665. }
  12666. return oldValue.Dontseeit, nil
  12667. }
  12668. // AddDontseeit adds i to the "dontseeit" field.
  12669. func (m *ContactMutation) AddDontseeit(i int) {
  12670. if m.adddontseeit != nil {
  12671. *m.adddontseeit += i
  12672. } else {
  12673. m.adddontseeit = &i
  12674. }
  12675. }
  12676. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  12677. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  12678. v := m.adddontseeit
  12679. if v == nil {
  12680. return
  12681. }
  12682. return *v, true
  12683. }
  12684. // ResetDontseeit resets all changes to the "dontseeit" field.
  12685. func (m *ContactMutation) ResetDontseeit() {
  12686. m.dontseeit = nil
  12687. m.adddontseeit = nil
  12688. }
  12689. // SetDontseeme sets the "dontseeme" field.
  12690. func (m *ContactMutation) SetDontseeme(i int) {
  12691. m.dontseeme = &i
  12692. m.adddontseeme = nil
  12693. }
  12694. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  12695. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  12696. v := m.dontseeme
  12697. if v == nil {
  12698. return
  12699. }
  12700. return *v, true
  12701. }
  12702. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  12703. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12705. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  12706. if !m.op.Is(OpUpdateOne) {
  12707. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  12708. }
  12709. if m.id == nil || m.oldValue == nil {
  12710. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  12711. }
  12712. oldValue, err := m.oldValue(ctx)
  12713. if err != nil {
  12714. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  12715. }
  12716. return oldValue.Dontseeme, nil
  12717. }
  12718. // AddDontseeme adds i to the "dontseeme" field.
  12719. func (m *ContactMutation) AddDontseeme(i int) {
  12720. if m.adddontseeme != nil {
  12721. *m.adddontseeme += i
  12722. } else {
  12723. m.adddontseeme = &i
  12724. }
  12725. }
  12726. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  12727. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  12728. v := m.adddontseeme
  12729. if v == nil {
  12730. return
  12731. }
  12732. return *v, true
  12733. }
  12734. // ResetDontseeme resets all changes to the "dontseeme" field.
  12735. func (m *ContactMutation) ResetDontseeme() {
  12736. m.dontseeme = nil
  12737. m.adddontseeme = nil
  12738. }
  12739. // SetLag sets the "lag" field.
  12740. func (m *ContactMutation) SetLag(s string) {
  12741. m.lag = &s
  12742. }
  12743. // Lag returns the value of the "lag" field in the mutation.
  12744. func (m *ContactMutation) Lag() (r string, exists bool) {
  12745. v := m.lag
  12746. if v == nil {
  12747. return
  12748. }
  12749. return *v, true
  12750. }
  12751. // OldLag returns the old "lag" field's value of the Contact entity.
  12752. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12754. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  12755. if !m.op.Is(OpUpdateOne) {
  12756. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  12757. }
  12758. if m.id == nil || m.oldValue == nil {
  12759. return v, errors.New("OldLag requires an ID field in the mutation")
  12760. }
  12761. oldValue, err := m.oldValue(ctx)
  12762. if err != nil {
  12763. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  12764. }
  12765. return oldValue.Lag, nil
  12766. }
  12767. // ResetLag resets all changes to the "lag" field.
  12768. func (m *ContactMutation) ResetLag() {
  12769. m.lag = nil
  12770. }
  12771. // SetGid sets the "gid" field.
  12772. func (m *ContactMutation) SetGid(s string) {
  12773. m.gid = &s
  12774. }
  12775. // Gid returns the value of the "gid" field in the mutation.
  12776. func (m *ContactMutation) Gid() (r string, exists bool) {
  12777. v := m.gid
  12778. if v == nil {
  12779. return
  12780. }
  12781. return *v, true
  12782. }
  12783. // OldGid returns the old "gid" field's value of the Contact entity.
  12784. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12786. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  12787. if !m.op.Is(OpUpdateOne) {
  12788. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  12789. }
  12790. if m.id == nil || m.oldValue == nil {
  12791. return v, errors.New("OldGid requires an ID field in the mutation")
  12792. }
  12793. oldValue, err := m.oldValue(ctx)
  12794. if err != nil {
  12795. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  12796. }
  12797. return oldValue.Gid, nil
  12798. }
  12799. // ResetGid resets all changes to the "gid" field.
  12800. func (m *ContactMutation) ResetGid() {
  12801. m.gid = nil
  12802. }
  12803. // SetGname sets the "gname" field.
  12804. func (m *ContactMutation) SetGname(s string) {
  12805. m.gname = &s
  12806. }
  12807. // Gname returns the value of the "gname" field in the mutation.
  12808. func (m *ContactMutation) Gname() (r string, exists bool) {
  12809. v := m.gname
  12810. if v == nil {
  12811. return
  12812. }
  12813. return *v, true
  12814. }
  12815. // OldGname returns the old "gname" field's value of the Contact entity.
  12816. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12818. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  12819. if !m.op.Is(OpUpdateOne) {
  12820. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  12821. }
  12822. if m.id == nil || m.oldValue == nil {
  12823. return v, errors.New("OldGname requires an ID field in the mutation")
  12824. }
  12825. oldValue, err := m.oldValue(ctx)
  12826. if err != nil {
  12827. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  12828. }
  12829. return oldValue.Gname, nil
  12830. }
  12831. // ResetGname resets all changes to the "gname" field.
  12832. func (m *ContactMutation) ResetGname() {
  12833. m.gname = nil
  12834. }
  12835. // SetV3 sets the "v3" field.
  12836. func (m *ContactMutation) SetV3(s string) {
  12837. m.v3 = &s
  12838. }
  12839. // V3 returns the value of the "v3" field in the mutation.
  12840. func (m *ContactMutation) V3() (r string, exists bool) {
  12841. v := m.v3
  12842. if v == nil {
  12843. return
  12844. }
  12845. return *v, true
  12846. }
  12847. // OldV3 returns the old "v3" field's value of the Contact entity.
  12848. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12850. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  12851. if !m.op.Is(OpUpdateOne) {
  12852. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  12853. }
  12854. if m.id == nil || m.oldValue == nil {
  12855. return v, errors.New("OldV3 requires an ID field in the mutation")
  12856. }
  12857. oldValue, err := m.oldValue(ctx)
  12858. if err != nil {
  12859. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  12860. }
  12861. return oldValue.V3, nil
  12862. }
  12863. // ResetV3 resets all changes to the "v3" field.
  12864. func (m *ContactMutation) ResetV3() {
  12865. m.v3 = nil
  12866. }
  12867. // SetOrganizationID sets the "organization_id" field.
  12868. func (m *ContactMutation) SetOrganizationID(u uint64) {
  12869. m.organization_id = &u
  12870. m.addorganization_id = nil
  12871. }
  12872. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12873. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  12874. v := m.organization_id
  12875. if v == nil {
  12876. return
  12877. }
  12878. return *v, true
  12879. }
  12880. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  12881. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12883. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12884. if !m.op.Is(OpUpdateOne) {
  12885. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12886. }
  12887. if m.id == nil || m.oldValue == nil {
  12888. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12889. }
  12890. oldValue, err := m.oldValue(ctx)
  12891. if err != nil {
  12892. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12893. }
  12894. return oldValue.OrganizationID, nil
  12895. }
  12896. // AddOrganizationID adds u to the "organization_id" field.
  12897. func (m *ContactMutation) AddOrganizationID(u int64) {
  12898. if m.addorganization_id != nil {
  12899. *m.addorganization_id += u
  12900. } else {
  12901. m.addorganization_id = &u
  12902. }
  12903. }
  12904. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12905. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  12906. v := m.addorganization_id
  12907. if v == nil {
  12908. return
  12909. }
  12910. return *v, true
  12911. }
  12912. // ClearOrganizationID clears the value of the "organization_id" field.
  12913. func (m *ContactMutation) ClearOrganizationID() {
  12914. m.organization_id = nil
  12915. m.addorganization_id = nil
  12916. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  12917. }
  12918. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12919. func (m *ContactMutation) OrganizationIDCleared() bool {
  12920. _, ok := m.clearedFields[contact.FieldOrganizationID]
  12921. return ok
  12922. }
  12923. // ResetOrganizationID resets all changes to the "organization_id" field.
  12924. func (m *ContactMutation) ResetOrganizationID() {
  12925. m.organization_id = nil
  12926. m.addorganization_id = nil
  12927. delete(m.clearedFields, contact.FieldOrganizationID)
  12928. }
  12929. // SetCtype sets the "ctype" field.
  12930. func (m *ContactMutation) SetCtype(u uint64) {
  12931. m.ctype = &u
  12932. m.addctype = nil
  12933. }
  12934. // Ctype returns the value of the "ctype" field in the mutation.
  12935. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  12936. v := m.ctype
  12937. if v == nil {
  12938. return
  12939. }
  12940. return *v, true
  12941. }
  12942. // OldCtype returns the old "ctype" field's value of the Contact entity.
  12943. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12945. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  12946. if !m.op.Is(OpUpdateOne) {
  12947. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  12948. }
  12949. if m.id == nil || m.oldValue == nil {
  12950. return v, errors.New("OldCtype requires an ID field in the mutation")
  12951. }
  12952. oldValue, err := m.oldValue(ctx)
  12953. if err != nil {
  12954. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  12955. }
  12956. return oldValue.Ctype, nil
  12957. }
  12958. // AddCtype adds u to the "ctype" field.
  12959. func (m *ContactMutation) AddCtype(u int64) {
  12960. if m.addctype != nil {
  12961. *m.addctype += u
  12962. } else {
  12963. m.addctype = &u
  12964. }
  12965. }
  12966. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  12967. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  12968. v := m.addctype
  12969. if v == nil {
  12970. return
  12971. }
  12972. return *v, true
  12973. }
  12974. // ResetCtype resets all changes to the "ctype" field.
  12975. func (m *ContactMutation) ResetCtype() {
  12976. m.ctype = nil
  12977. m.addctype = nil
  12978. }
  12979. // SetCage sets the "cage" field.
  12980. func (m *ContactMutation) SetCage(i int) {
  12981. m.cage = &i
  12982. m.addcage = nil
  12983. }
  12984. // Cage returns the value of the "cage" field in the mutation.
  12985. func (m *ContactMutation) Cage() (r int, exists bool) {
  12986. v := m.cage
  12987. if v == nil {
  12988. return
  12989. }
  12990. return *v, true
  12991. }
  12992. // OldCage returns the old "cage" field's value of the Contact entity.
  12993. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12995. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  12996. if !m.op.Is(OpUpdateOne) {
  12997. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  12998. }
  12999. if m.id == nil || m.oldValue == nil {
  13000. return v, errors.New("OldCage requires an ID field in the mutation")
  13001. }
  13002. oldValue, err := m.oldValue(ctx)
  13003. if err != nil {
  13004. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  13005. }
  13006. return oldValue.Cage, nil
  13007. }
  13008. // AddCage adds i to the "cage" field.
  13009. func (m *ContactMutation) AddCage(i int) {
  13010. if m.addcage != nil {
  13011. *m.addcage += i
  13012. } else {
  13013. m.addcage = &i
  13014. }
  13015. }
  13016. // AddedCage returns the value that was added to the "cage" field in this mutation.
  13017. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  13018. v := m.addcage
  13019. if v == nil {
  13020. return
  13021. }
  13022. return *v, true
  13023. }
  13024. // ResetCage resets all changes to the "cage" field.
  13025. func (m *ContactMutation) ResetCage() {
  13026. m.cage = nil
  13027. m.addcage = nil
  13028. }
  13029. // SetCname sets the "cname" field.
  13030. func (m *ContactMutation) SetCname(s string) {
  13031. m.cname = &s
  13032. }
  13033. // Cname returns the value of the "cname" field in the mutation.
  13034. func (m *ContactMutation) Cname() (r string, exists bool) {
  13035. v := m.cname
  13036. if v == nil {
  13037. return
  13038. }
  13039. return *v, true
  13040. }
  13041. // OldCname returns the old "cname" field's value of the Contact entity.
  13042. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13044. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  13045. if !m.op.Is(OpUpdateOne) {
  13046. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  13047. }
  13048. if m.id == nil || m.oldValue == nil {
  13049. return v, errors.New("OldCname requires an ID field in the mutation")
  13050. }
  13051. oldValue, err := m.oldValue(ctx)
  13052. if err != nil {
  13053. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  13054. }
  13055. return oldValue.Cname, nil
  13056. }
  13057. // ResetCname resets all changes to the "cname" field.
  13058. func (m *ContactMutation) ResetCname() {
  13059. m.cname = nil
  13060. }
  13061. // SetCarea sets the "carea" field.
  13062. func (m *ContactMutation) SetCarea(s string) {
  13063. m.carea = &s
  13064. }
  13065. // Carea returns the value of the "carea" field in the mutation.
  13066. func (m *ContactMutation) Carea() (r string, exists bool) {
  13067. v := m.carea
  13068. if v == nil {
  13069. return
  13070. }
  13071. return *v, true
  13072. }
  13073. // OldCarea returns the old "carea" field's value of the Contact entity.
  13074. // If the Contact 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 *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  13077. if !m.op.Is(OpUpdateOne) {
  13078. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  13079. }
  13080. if m.id == nil || m.oldValue == nil {
  13081. return v, errors.New("OldCarea 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 OldCarea: %w", err)
  13086. }
  13087. return oldValue.Carea, nil
  13088. }
  13089. // ResetCarea resets all changes to the "carea" field.
  13090. func (m *ContactMutation) ResetCarea() {
  13091. m.carea = nil
  13092. }
  13093. // SetCbirthday sets the "cbirthday" field.
  13094. func (m *ContactMutation) SetCbirthday(s string) {
  13095. m.cbirthday = &s
  13096. }
  13097. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  13098. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  13099. v := m.cbirthday
  13100. if v == nil {
  13101. return
  13102. }
  13103. return *v, true
  13104. }
  13105. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  13106. // If the Contact 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 *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  13109. if !m.op.Is(OpUpdateOne) {
  13110. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  13111. }
  13112. if m.id == nil || m.oldValue == nil {
  13113. return v, errors.New("OldCbirthday 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 OldCbirthday: %w", err)
  13118. }
  13119. return oldValue.Cbirthday, nil
  13120. }
  13121. // ResetCbirthday resets all changes to the "cbirthday" field.
  13122. func (m *ContactMutation) ResetCbirthday() {
  13123. m.cbirthday = nil
  13124. }
  13125. // SetCbirtharea sets the "cbirtharea" field.
  13126. func (m *ContactMutation) SetCbirtharea(s string) {
  13127. m.cbirtharea = &s
  13128. }
  13129. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  13130. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  13131. v := m.cbirtharea
  13132. if v == nil {
  13133. return
  13134. }
  13135. return *v, true
  13136. }
  13137. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  13138. // If the Contact 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 *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  13141. if !m.op.Is(OpUpdateOne) {
  13142. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  13143. }
  13144. if m.id == nil || m.oldValue == nil {
  13145. return v, errors.New("OldCbirtharea 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 OldCbirtharea: %w", err)
  13150. }
  13151. return oldValue.Cbirtharea, nil
  13152. }
  13153. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  13154. func (m *ContactMutation) ResetCbirtharea() {
  13155. m.cbirtharea = nil
  13156. }
  13157. // SetCidcardNo sets the "cidcard_no" field.
  13158. func (m *ContactMutation) SetCidcardNo(s string) {
  13159. m.cidcard_no = &s
  13160. }
  13161. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  13162. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  13163. v := m.cidcard_no
  13164. if v == nil {
  13165. return
  13166. }
  13167. return *v, true
  13168. }
  13169. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  13170. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13172. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  13173. if !m.op.Is(OpUpdateOne) {
  13174. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  13175. }
  13176. if m.id == nil || m.oldValue == nil {
  13177. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  13178. }
  13179. oldValue, err := m.oldValue(ctx)
  13180. if err != nil {
  13181. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  13182. }
  13183. return oldValue.CidcardNo, nil
  13184. }
  13185. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  13186. func (m *ContactMutation) ResetCidcardNo() {
  13187. m.cidcard_no = nil
  13188. }
  13189. // SetCtitle sets the "ctitle" field.
  13190. func (m *ContactMutation) SetCtitle(s string) {
  13191. m.ctitle = &s
  13192. }
  13193. // Ctitle returns the value of the "ctitle" field in the mutation.
  13194. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  13195. v := m.ctitle
  13196. if v == nil {
  13197. return
  13198. }
  13199. return *v, true
  13200. }
  13201. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  13202. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13204. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  13205. if !m.op.Is(OpUpdateOne) {
  13206. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  13207. }
  13208. if m.id == nil || m.oldValue == nil {
  13209. return v, errors.New("OldCtitle requires an ID field in the mutation")
  13210. }
  13211. oldValue, err := m.oldValue(ctx)
  13212. if err != nil {
  13213. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  13214. }
  13215. return oldValue.Ctitle, nil
  13216. }
  13217. // ResetCtitle resets all changes to the "ctitle" field.
  13218. func (m *ContactMutation) ResetCtitle() {
  13219. m.ctitle = nil
  13220. }
  13221. // SetCc sets the "cc" field.
  13222. func (m *ContactMutation) SetCc(s string) {
  13223. m.cc = &s
  13224. }
  13225. // Cc returns the value of the "cc" field in the mutation.
  13226. func (m *ContactMutation) Cc() (r string, exists bool) {
  13227. v := m.cc
  13228. if v == nil {
  13229. return
  13230. }
  13231. return *v, true
  13232. }
  13233. // OldCc returns the old "cc" field's value of the Contact entity.
  13234. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13236. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  13237. if !m.op.Is(OpUpdateOne) {
  13238. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  13239. }
  13240. if m.id == nil || m.oldValue == nil {
  13241. return v, errors.New("OldCc requires an ID field in the mutation")
  13242. }
  13243. oldValue, err := m.oldValue(ctx)
  13244. if err != nil {
  13245. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  13246. }
  13247. return oldValue.Cc, nil
  13248. }
  13249. // ResetCc resets all changes to the "cc" field.
  13250. func (m *ContactMutation) ResetCc() {
  13251. m.cc = nil
  13252. }
  13253. // SetPhone sets the "phone" field.
  13254. func (m *ContactMutation) SetPhone(s string) {
  13255. m.phone = &s
  13256. }
  13257. // Phone returns the value of the "phone" field in the mutation.
  13258. func (m *ContactMutation) Phone() (r string, exists bool) {
  13259. v := m.phone
  13260. if v == nil {
  13261. return
  13262. }
  13263. return *v, true
  13264. }
  13265. // OldPhone returns the old "phone" field's value of the Contact entity.
  13266. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13268. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  13269. if !m.op.Is(OpUpdateOne) {
  13270. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  13271. }
  13272. if m.id == nil || m.oldValue == nil {
  13273. return v, errors.New("OldPhone requires an ID field in the mutation")
  13274. }
  13275. oldValue, err := m.oldValue(ctx)
  13276. if err != nil {
  13277. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  13278. }
  13279. return oldValue.Phone, nil
  13280. }
  13281. // ResetPhone resets all changes to the "phone" field.
  13282. func (m *ContactMutation) ResetPhone() {
  13283. m.phone = nil
  13284. }
  13285. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  13286. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  13287. if m.contact_relationships == nil {
  13288. m.contact_relationships = make(map[uint64]struct{})
  13289. }
  13290. for i := range ids {
  13291. m.contact_relationships[ids[i]] = struct{}{}
  13292. }
  13293. }
  13294. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  13295. func (m *ContactMutation) ClearContactRelationships() {
  13296. m.clearedcontact_relationships = true
  13297. }
  13298. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  13299. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  13300. return m.clearedcontact_relationships
  13301. }
  13302. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  13303. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  13304. if m.removedcontact_relationships == nil {
  13305. m.removedcontact_relationships = make(map[uint64]struct{})
  13306. }
  13307. for i := range ids {
  13308. delete(m.contact_relationships, ids[i])
  13309. m.removedcontact_relationships[ids[i]] = struct{}{}
  13310. }
  13311. }
  13312. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  13313. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  13314. for id := range m.removedcontact_relationships {
  13315. ids = append(ids, id)
  13316. }
  13317. return
  13318. }
  13319. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  13320. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  13321. for id := range m.contact_relationships {
  13322. ids = append(ids, id)
  13323. }
  13324. return
  13325. }
  13326. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  13327. func (m *ContactMutation) ResetContactRelationships() {
  13328. m.contact_relationships = nil
  13329. m.clearedcontact_relationships = false
  13330. m.removedcontact_relationships = nil
  13331. }
  13332. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  13333. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  13334. if m.contact_fields == nil {
  13335. m.contact_fields = make(map[uint64]struct{})
  13336. }
  13337. for i := range ids {
  13338. m.contact_fields[ids[i]] = struct{}{}
  13339. }
  13340. }
  13341. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  13342. func (m *ContactMutation) ClearContactFields() {
  13343. m.clearedcontact_fields = true
  13344. }
  13345. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  13346. func (m *ContactMutation) ContactFieldsCleared() bool {
  13347. return m.clearedcontact_fields
  13348. }
  13349. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  13350. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  13351. if m.removedcontact_fields == nil {
  13352. m.removedcontact_fields = make(map[uint64]struct{})
  13353. }
  13354. for i := range ids {
  13355. delete(m.contact_fields, ids[i])
  13356. m.removedcontact_fields[ids[i]] = struct{}{}
  13357. }
  13358. }
  13359. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  13360. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  13361. for id := range m.removedcontact_fields {
  13362. ids = append(ids, id)
  13363. }
  13364. return
  13365. }
  13366. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  13367. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  13368. for id := range m.contact_fields {
  13369. ids = append(ids, id)
  13370. }
  13371. return
  13372. }
  13373. // ResetContactFields resets all changes to the "contact_fields" edge.
  13374. func (m *ContactMutation) ResetContactFields() {
  13375. m.contact_fields = nil
  13376. m.clearedcontact_fields = false
  13377. m.removedcontact_fields = nil
  13378. }
  13379. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  13380. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  13381. if m.contact_messages == nil {
  13382. m.contact_messages = make(map[uint64]struct{})
  13383. }
  13384. for i := range ids {
  13385. m.contact_messages[ids[i]] = struct{}{}
  13386. }
  13387. }
  13388. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  13389. func (m *ContactMutation) ClearContactMessages() {
  13390. m.clearedcontact_messages = true
  13391. }
  13392. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  13393. func (m *ContactMutation) ContactMessagesCleared() bool {
  13394. return m.clearedcontact_messages
  13395. }
  13396. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  13397. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  13398. if m.removedcontact_messages == nil {
  13399. m.removedcontact_messages = make(map[uint64]struct{})
  13400. }
  13401. for i := range ids {
  13402. delete(m.contact_messages, ids[i])
  13403. m.removedcontact_messages[ids[i]] = struct{}{}
  13404. }
  13405. }
  13406. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  13407. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  13408. for id := range m.removedcontact_messages {
  13409. ids = append(ids, id)
  13410. }
  13411. return
  13412. }
  13413. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  13414. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  13415. for id := range m.contact_messages {
  13416. ids = append(ids, id)
  13417. }
  13418. return
  13419. }
  13420. // ResetContactMessages resets all changes to the "contact_messages" edge.
  13421. func (m *ContactMutation) ResetContactMessages() {
  13422. m.contact_messages = nil
  13423. m.clearedcontact_messages = false
  13424. m.removedcontact_messages = nil
  13425. }
  13426. // Where appends a list predicates to the ContactMutation builder.
  13427. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  13428. m.predicates = append(m.predicates, ps...)
  13429. }
  13430. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  13431. // users can use type-assertion to append predicates that do not depend on any generated package.
  13432. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  13433. p := make([]predicate.Contact, len(ps))
  13434. for i := range ps {
  13435. p[i] = ps[i]
  13436. }
  13437. m.Where(p...)
  13438. }
  13439. // Op returns the operation name.
  13440. func (m *ContactMutation) Op() Op {
  13441. return m.op
  13442. }
  13443. // SetOp allows setting the mutation operation.
  13444. func (m *ContactMutation) SetOp(op Op) {
  13445. m.op = op
  13446. }
  13447. // Type returns the node type of this mutation (Contact).
  13448. func (m *ContactMutation) Type() string {
  13449. return m.typ
  13450. }
  13451. // Fields returns all fields that were changed during this mutation. Note that in
  13452. // order to get all numeric fields that were incremented/decremented, call
  13453. // AddedFields().
  13454. func (m *ContactMutation) Fields() []string {
  13455. fields := make([]string, 0, 30)
  13456. if m.created_at != nil {
  13457. fields = append(fields, contact.FieldCreatedAt)
  13458. }
  13459. if m.updated_at != nil {
  13460. fields = append(fields, contact.FieldUpdatedAt)
  13461. }
  13462. if m.status != nil {
  13463. fields = append(fields, contact.FieldStatus)
  13464. }
  13465. if m.deleted_at != nil {
  13466. fields = append(fields, contact.FieldDeletedAt)
  13467. }
  13468. if m.wx_wxid != nil {
  13469. fields = append(fields, contact.FieldWxWxid)
  13470. }
  13471. if m._type != nil {
  13472. fields = append(fields, contact.FieldType)
  13473. }
  13474. if m.wxid != nil {
  13475. fields = append(fields, contact.FieldWxid)
  13476. }
  13477. if m.account != nil {
  13478. fields = append(fields, contact.FieldAccount)
  13479. }
  13480. if m.nickname != nil {
  13481. fields = append(fields, contact.FieldNickname)
  13482. }
  13483. if m.markname != nil {
  13484. fields = append(fields, contact.FieldMarkname)
  13485. }
  13486. if m.headimg != nil {
  13487. fields = append(fields, contact.FieldHeadimg)
  13488. }
  13489. if m.sex != nil {
  13490. fields = append(fields, contact.FieldSex)
  13491. }
  13492. if m.starrole != nil {
  13493. fields = append(fields, contact.FieldStarrole)
  13494. }
  13495. if m.dontseeit != nil {
  13496. fields = append(fields, contact.FieldDontseeit)
  13497. }
  13498. if m.dontseeme != nil {
  13499. fields = append(fields, contact.FieldDontseeme)
  13500. }
  13501. if m.lag != nil {
  13502. fields = append(fields, contact.FieldLag)
  13503. }
  13504. if m.gid != nil {
  13505. fields = append(fields, contact.FieldGid)
  13506. }
  13507. if m.gname != nil {
  13508. fields = append(fields, contact.FieldGname)
  13509. }
  13510. if m.v3 != nil {
  13511. fields = append(fields, contact.FieldV3)
  13512. }
  13513. if m.organization_id != nil {
  13514. fields = append(fields, contact.FieldOrganizationID)
  13515. }
  13516. if m.ctype != nil {
  13517. fields = append(fields, contact.FieldCtype)
  13518. }
  13519. if m.cage != nil {
  13520. fields = append(fields, contact.FieldCage)
  13521. }
  13522. if m.cname != nil {
  13523. fields = append(fields, contact.FieldCname)
  13524. }
  13525. if m.carea != nil {
  13526. fields = append(fields, contact.FieldCarea)
  13527. }
  13528. if m.cbirthday != nil {
  13529. fields = append(fields, contact.FieldCbirthday)
  13530. }
  13531. if m.cbirtharea != nil {
  13532. fields = append(fields, contact.FieldCbirtharea)
  13533. }
  13534. if m.cidcard_no != nil {
  13535. fields = append(fields, contact.FieldCidcardNo)
  13536. }
  13537. if m.ctitle != nil {
  13538. fields = append(fields, contact.FieldCtitle)
  13539. }
  13540. if m.cc != nil {
  13541. fields = append(fields, contact.FieldCc)
  13542. }
  13543. if m.phone != nil {
  13544. fields = append(fields, contact.FieldPhone)
  13545. }
  13546. return fields
  13547. }
  13548. // Field returns the value of a field with the given name. The second boolean
  13549. // return value indicates that this field was not set, or was not defined in the
  13550. // schema.
  13551. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  13552. switch name {
  13553. case contact.FieldCreatedAt:
  13554. return m.CreatedAt()
  13555. case contact.FieldUpdatedAt:
  13556. return m.UpdatedAt()
  13557. case contact.FieldStatus:
  13558. return m.Status()
  13559. case contact.FieldDeletedAt:
  13560. return m.DeletedAt()
  13561. case contact.FieldWxWxid:
  13562. return m.WxWxid()
  13563. case contact.FieldType:
  13564. return m.GetType()
  13565. case contact.FieldWxid:
  13566. return m.Wxid()
  13567. case contact.FieldAccount:
  13568. return m.Account()
  13569. case contact.FieldNickname:
  13570. return m.Nickname()
  13571. case contact.FieldMarkname:
  13572. return m.Markname()
  13573. case contact.FieldHeadimg:
  13574. return m.Headimg()
  13575. case contact.FieldSex:
  13576. return m.Sex()
  13577. case contact.FieldStarrole:
  13578. return m.Starrole()
  13579. case contact.FieldDontseeit:
  13580. return m.Dontseeit()
  13581. case contact.FieldDontseeme:
  13582. return m.Dontseeme()
  13583. case contact.FieldLag:
  13584. return m.Lag()
  13585. case contact.FieldGid:
  13586. return m.Gid()
  13587. case contact.FieldGname:
  13588. return m.Gname()
  13589. case contact.FieldV3:
  13590. return m.V3()
  13591. case contact.FieldOrganizationID:
  13592. return m.OrganizationID()
  13593. case contact.FieldCtype:
  13594. return m.Ctype()
  13595. case contact.FieldCage:
  13596. return m.Cage()
  13597. case contact.FieldCname:
  13598. return m.Cname()
  13599. case contact.FieldCarea:
  13600. return m.Carea()
  13601. case contact.FieldCbirthday:
  13602. return m.Cbirthday()
  13603. case contact.FieldCbirtharea:
  13604. return m.Cbirtharea()
  13605. case contact.FieldCidcardNo:
  13606. return m.CidcardNo()
  13607. case contact.FieldCtitle:
  13608. return m.Ctitle()
  13609. case contact.FieldCc:
  13610. return m.Cc()
  13611. case contact.FieldPhone:
  13612. return m.Phone()
  13613. }
  13614. return nil, false
  13615. }
  13616. // OldField returns the old value of the field from the database. An error is
  13617. // returned if the mutation operation is not UpdateOne, or the query to the
  13618. // database failed.
  13619. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13620. switch name {
  13621. case contact.FieldCreatedAt:
  13622. return m.OldCreatedAt(ctx)
  13623. case contact.FieldUpdatedAt:
  13624. return m.OldUpdatedAt(ctx)
  13625. case contact.FieldStatus:
  13626. return m.OldStatus(ctx)
  13627. case contact.FieldDeletedAt:
  13628. return m.OldDeletedAt(ctx)
  13629. case contact.FieldWxWxid:
  13630. return m.OldWxWxid(ctx)
  13631. case contact.FieldType:
  13632. return m.OldType(ctx)
  13633. case contact.FieldWxid:
  13634. return m.OldWxid(ctx)
  13635. case contact.FieldAccount:
  13636. return m.OldAccount(ctx)
  13637. case contact.FieldNickname:
  13638. return m.OldNickname(ctx)
  13639. case contact.FieldMarkname:
  13640. return m.OldMarkname(ctx)
  13641. case contact.FieldHeadimg:
  13642. return m.OldHeadimg(ctx)
  13643. case contact.FieldSex:
  13644. return m.OldSex(ctx)
  13645. case contact.FieldStarrole:
  13646. return m.OldStarrole(ctx)
  13647. case contact.FieldDontseeit:
  13648. return m.OldDontseeit(ctx)
  13649. case contact.FieldDontseeme:
  13650. return m.OldDontseeme(ctx)
  13651. case contact.FieldLag:
  13652. return m.OldLag(ctx)
  13653. case contact.FieldGid:
  13654. return m.OldGid(ctx)
  13655. case contact.FieldGname:
  13656. return m.OldGname(ctx)
  13657. case contact.FieldV3:
  13658. return m.OldV3(ctx)
  13659. case contact.FieldOrganizationID:
  13660. return m.OldOrganizationID(ctx)
  13661. case contact.FieldCtype:
  13662. return m.OldCtype(ctx)
  13663. case contact.FieldCage:
  13664. return m.OldCage(ctx)
  13665. case contact.FieldCname:
  13666. return m.OldCname(ctx)
  13667. case contact.FieldCarea:
  13668. return m.OldCarea(ctx)
  13669. case contact.FieldCbirthday:
  13670. return m.OldCbirthday(ctx)
  13671. case contact.FieldCbirtharea:
  13672. return m.OldCbirtharea(ctx)
  13673. case contact.FieldCidcardNo:
  13674. return m.OldCidcardNo(ctx)
  13675. case contact.FieldCtitle:
  13676. return m.OldCtitle(ctx)
  13677. case contact.FieldCc:
  13678. return m.OldCc(ctx)
  13679. case contact.FieldPhone:
  13680. return m.OldPhone(ctx)
  13681. }
  13682. return nil, fmt.Errorf("unknown Contact field %s", name)
  13683. }
  13684. // SetField sets the value of a field with the given name. It returns an error if
  13685. // the field is not defined in the schema, or if the type mismatched the field
  13686. // type.
  13687. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  13688. switch name {
  13689. case contact.FieldCreatedAt:
  13690. v, ok := value.(time.Time)
  13691. if !ok {
  13692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13693. }
  13694. m.SetCreatedAt(v)
  13695. return nil
  13696. case contact.FieldUpdatedAt:
  13697. v, ok := value.(time.Time)
  13698. if !ok {
  13699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13700. }
  13701. m.SetUpdatedAt(v)
  13702. return nil
  13703. case contact.FieldStatus:
  13704. v, ok := value.(uint8)
  13705. if !ok {
  13706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13707. }
  13708. m.SetStatus(v)
  13709. return nil
  13710. case contact.FieldDeletedAt:
  13711. v, ok := value.(time.Time)
  13712. if !ok {
  13713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13714. }
  13715. m.SetDeletedAt(v)
  13716. return nil
  13717. case contact.FieldWxWxid:
  13718. v, ok := value.(string)
  13719. if !ok {
  13720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13721. }
  13722. m.SetWxWxid(v)
  13723. return nil
  13724. case contact.FieldType:
  13725. v, ok := value.(int)
  13726. if !ok {
  13727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13728. }
  13729. m.SetType(v)
  13730. return nil
  13731. case contact.FieldWxid:
  13732. v, ok := value.(string)
  13733. if !ok {
  13734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13735. }
  13736. m.SetWxid(v)
  13737. return nil
  13738. case contact.FieldAccount:
  13739. v, ok := value.(string)
  13740. if !ok {
  13741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13742. }
  13743. m.SetAccount(v)
  13744. return nil
  13745. case contact.FieldNickname:
  13746. v, ok := value.(string)
  13747. if !ok {
  13748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13749. }
  13750. m.SetNickname(v)
  13751. return nil
  13752. case contact.FieldMarkname:
  13753. v, ok := value.(string)
  13754. if !ok {
  13755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13756. }
  13757. m.SetMarkname(v)
  13758. return nil
  13759. case contact.FieldHeadimg:
  13760. v, ok := value.(string)
  13761. if !ok {
  13762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13763. }
  13764. m.SetHeadimg(v)
  13765. return nil
  13766. case contact.FieldSex:
  13767. v, ok := value.(int)
  13768. if !ok {
  13769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13770. }
  13771. m.SetSex(v)
  13772. return nil
  13773. case contact.FieldStarrole:
  13774. v, ok := value.(string)
  13775. if !ok {
  13776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13777. }
  13778. m.SetStarrole(v)
  13779. return nil
  13780. case contact.FieldDontseeit:
  13781. v, ok := value.(int)
  13782. if !ok {
  13783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13784. }
  13785. m.SetDontseeit(v)
  13786. return nil
  13787. case contact.FieldDontseeme:
  13788. v, ok := value.(int)
  13789. if !ok {
  13790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13791. }
  13792. m.SetDontseeme(v)
  13793. return nil
  13794. case contact.FieldLag:
  13795. v, ok := value.(string)
  13796. if !ok {
  13797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13798. }
  13799. m.SetLag(v)
  13800. return nil
  13801. case contact.FieldGid:
  13802. v, ok := value.(string)
  13803. if !ok {
  13804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13805. }
  13806. m.SetGid(v)
  13807. return nil
  13808. case contact.FieldGname:
  13809. v, ok := value.(string)
  13810. if !ok {
  13811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13812. }
  13813. m.SetGname(v)
  13814. return nil
  13815. case contact.FieldV3:
  13816. v, ok := value.(string)
  13817. if !ok {
  13818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13819. }
  13820. m.SetV3(v)
  13821. return nil
  13822. case contact.FieldOrganizationID:
  13823. v, ok := value.(uint64)
  13824. if !ok {
  13825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13826. }
  13827. m.SetOrganizationID(v)
  13828. return nil
  13829. case contact.FieldCtype:
  13830. v, ok := value.(uint64)
  13831. if !ok {
  13832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13833. }
  13834. m.SetCtype(v)
  13835. return nil
  13836. case contact.FieldCage:
  13837. v, ok := value.(int)
  13838. if !ok {
  13839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13840. }
  13841. m.SetCage(v)
  13842. return nil
  13843. case contact.FieldCname:
  13844. v, ok := value.(string)
  13845. if !ok {
  13846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13847. }
  13848. m.SetCname(v)
  13849. return nil
  13850. case contact.FieldCarea:
  13851. v, ok := value.(string)
  13852. if !ok {
  13853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13854. }
  13855. m.SetCarea(v)
  13856. return nil
  13857. case contact.FieldCbirthday:
  13858. v, ok := value.(string)
  13859. if !ok {
  13860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13861. }
  13862. m.SetCbirthday(v)
  13863. return nil
  13864. case contact.FieldCbirtharea:
  13865. v, ok := value.(string)
  13866. if !ok {
  13867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13868. }
  13869. m.SetCbirtharea(v)
  13870. return nil
  13871. case contact.FieldCidcardNo:
  13872. v, ok := value.(string)
  13873. if !ok {
  13874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13875. }
  13876. m.SetCidcardNo(v)
  13877. return nil
  13878. case contact.FieldCtitle:
  13879. v, ok := value.(string)
  13880. if !ok {
  13881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13882. }
  13883. m.SetCtitle(v)
  13884. return nil
  13885. case contact.FieldCc:
  13886. v, ok := value.(string)
  13887. if !ok {
  13888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13889. }
  13890. m.SetCc(v)
  13891. return nil
  13892. case contact.FieldPhone:
  13893. v, ok := value.(string)
  13894. if !ok {
  13895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13896. }
  13897. m.SetPhone(v)
  13898. return nil
  13899. }
  13900. return fmt.Errorf("unknown Contact field %s", name)
  13901. }
  13902. // AddedFields returns all numeric fields that were incremented/decremented during
  13903. // this mutation.
  13904. func (m *ContactMutation) AddedFields() []string {
  13905. var fields []string
  13906. if m.addstatus != nil {
  13907. fields = append(fields, contact.FieldStatus)
  13908. }
  13909. if m.add_type != nil {
  13910. fields = append(fields, contact.FieldType)
  13911. }
  13912. if m.addsex != nil {
  13913. fields = append(fields, contact.FieldSex)
  13914. }
  13915. if m.adddontseeit != nil {
  13916. fields = append(fields, contact.FieldDontseeit)
  13917. }
  13918. if m.adddontseeme != nil {
  13919. fields = append(fields, contact.FieldDontseeme)
  13920. }
  13921. if m.addorganization_id != nil {
  13922. fields = append(fields, contact.FieldOrganizationID)
  13923. }
  13924. if m.addctype != nil {
  13925. fields = append(fields, contact.FieldCtype)
  13926. }
  13927. if m.addcage != nil {
  13928. fields = append(fields, contact.FieldCage)
  13929. }
  13930. return fields
  13931. }
  13932. // AddedField returns the numeric value that was incremented/decremented on a field
  13933. // with the given name. The second boolean return value indicates that this field
  13934. // was not set, or was not defined in the schema.
  13935. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  13936. switch name {
  13937. case contact.FieldStatus:
  13938. return m.AddedStatus()
  13939. case contact.FieldType:
  13940. return m.AddedType()
  13941. case contact.FieldSex:
  13942. return m.AddedSex()
  13943. case contact.FieldDontseeit:
  13944. return m.AddedDontseeit()
  13945. case contact.FieldDontseeme:
  13946. return m.AddedDontseeme()
  13947. case contact.FieldOrganizationID:
  13948. return m.AddedOrganizationID()
  13949. case contact.FieldCtype:
  13950. return m.AddedCtype()
  13951. case contact.FieldCage:
  13952. return m.AddedCage()
  13953. }
  13954. return nil, false
  13955. }
  13956. // AddField adds the value to the field with the given name. It returns an error if
  13957. // the field is not defined in the schema, or if the type mismatched the field
  13958. // type.
  13959. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  13960. switch name {
  13961. case contact.FieldStatus:
  13962. v, ok := value.(int8)
  13963. if !ok {
  13964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13965. }
  13966. m.AddStatus(v)
  13967. return nil
  13968. case contact.FieldType:
  13969. v, ok := value.(int)
  13970. if !ok {
  13971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13972. }
  13973. m.AddType(v)
  13974. return nil
  13975. case contact.FieldSex:
  13976. v, ok := value.(int)
  13977. if !ok {
  13978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13979. }
  13980. m.AddSex(v)
  13981. return nil
  13982. case contact.FieldDontseeit:
  13983. v, ok := value.(int)
  13984. if !ok {
  13985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13986. }
  13987. m.AddDontseeit(v)
  13988. return nil
  13989. case contact.FieldDontseeme:
  13990. v, ok := value.(int)
  13991. if !ok {
  13992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13993. }
  13994. m.AddDontseeme(v)
  13995. return nil
  13996. case contact.FieldOrganizationID:
  13997. v, ok := value.(int64)
  13998. if !ok {
  13999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14000. }
  14001. m.AddOrganizationID(v)
  14002. return nil
  14003. case contact.FieldCtype:
  14004. v, ok := value.(int64)
  14005. if !ok {
  14006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14007. }
  14008. m.AddCtype(v)
  14009. return nil
  14010. case contact.FieldCage:
  14011. v, ok := value.(int)
  14012. if !ok {
  14013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14014. }
  14015. m.AddCage(v)
  14016. return nil
  14017. }
  14018. return fmt.Errorf("unknown Contact numeric field %s", name)
  14019. }
  14020. // ClearedFields returns all nullable fields that were cleared during this
  14021. // mutation.
  14022. func (m *ContactMutation) ClearedFields() []string {
  14023. var fields []string
  14024. if m.FieldCleared(contact.FieldStatus) {
  14025. fields = append(fields, contact.FieldStatus)
  14026. }
  14027. if m.FieldCleared(contact.FieldDeletedAt) {
  14028. fields = append(fields, contact.FieldDeletedAt)
  14029. }
  14030. if m.FieldCleared(contact.FieldType) {
  14031. fields = append(fields, contact.FieldType)
  14032. }
  14033. if m.FieldCleared(contact.FieldOrganizationID) {
  14034. fields = append(fields, contact.FieldOrganizationID)
  14035. }
  14036. return fields
  14037. }
  14038. // FieldCleared returns a boolean indicating if a field with the given name was
  14039. // cleared in this mutation.
  14040. func (m *ContactMutation) FieldCleared(name string) bool {
  14041. _, ok := m.clearedFields[name]
  14042. return ok
  14043. }
  14044. // ClearField clears the value of the field with the given name. It returns an
  14045. // error if the field is not defined in the schema.
  14046. func (m *ContactMutation) ClearField(name string) error {
  14047. switch name {
  14048. case contact.FieldStatus:
  14049. m.ClearStatus()
  14050. return nil
  14051. case contact.FieldDeletedAt:
  14052. m.ClearDeletedAt()
  14053. return nil
  14054. case contact.FieldType:
  14055. m.ClearType()
  14056. return nil
  14057. case contact.FieldOrganizationID:
  14058. m.ClearOrganizationID()
  14059. return nil
  14060. }
  14061. return fmt.Errorf("unknown Contact nullable field %s", name)
  14062. }
  14063. // ResetField resets all changes in the mutation for the field with the given name.
  14064. // It returns an error if the field is not defined in the schema.
  14065. func (m *ContactMutation) ResetField(name string) error {
  14066. switch name {
  14067. case contact.FieldCreatedAt:
  14068. m.ResetCreatedAt()
  14069. return nil
  14070. case contact.FieldUpdatedAt:
  14071. m.ResetUpdatedAt()
  14072. return nil
  14073. case contact.FieldStatus:
  14074. m.ResetStatus()
  14075. return nil
  14076. case contact.FieldDeletedAt:
  14077. m.ResetDeletedAt()
  14078. return nil
  14079. case contact.FieldWxWxid:
  14080. m.ResetWxWxid()
  14081. return nil
  14082. case contact.FieldType:
  14083. m.ResetType()
  14084. return nil
  14085. case contact.FieldWxid:
  14086. m.ResetWxid()
  14087. return nil
  14088. case contact.FieldAccount:
  14089. m.ResetAccount()
  14090. return nil
  14091. case contact.FieldNickname:
  14092. m.ResetNickname()
  14093. return nil
  14094. case contact.FieldMarkname:
  14095. m.ResetMarkname()
  14096. return nil
  14097. case contact.FieldHeadimg:
  14098. m.ResetHeadimg()
  14099. return nil
  14100. case contact.FieldSex:
  14101. m.ResetSex()
  14102. return nil
  14103. case contact.FieldStarrole:
  14104. m.ResetStarrole()
  14105. return nil
  14106. case contact.FieldDontseeit:
  14107. m.ResetDontseeit()
  14108. return nil
  14109. case contact.FieldDontseeme:
  14110. m.ResetDontseeme()
  14111. return nil
  14112. case contact.FieldLag:
  14113. m.ResetLag()
  14114. return nil
  14115. case contact.FieldGid:
  14116. m.ResetGid()
  14117. return nil
  14118. case contact.FieldGname:
  14119. m.ResetGname()
  14120. return nil
  14121. case contact.FieldV3:
  14122. m.ResetV3()
  14123. return nil
  14124. case contact.FieldOrganizationID:
  14125. m.ResetOrganizationID()
  14126. return nil
  14127. case contact.FieldCtype:
  14128. m.ResetCtype()
  14129. return nil
  14130. case contact.FieldCage:
  14131. m.ResetCage()
  14132. return nil
  14133. case contact.FieldCname:
  14134. m.ResetCname()
  14135. return nil
  14136. case contact.FieldCarea:
  14137. m.ResetCarea()
  14138. return nil
  14139. case contact.FieldCbirthday:
  14140. m.ResetCbirthday()
  14141. return nil
  14142. case contact.FieldCbirtharea:
  14143. m.ResetCbirtharea()
  14144. return nil
  14145. case contact.FieldCidcardNo:
  14146. m.ResetCidcardNo()
  14147. return nil
  14148. case contact.FieldCtitle:
  14149. m.ResetCtitle()
  14150. return nil
  14151. case contact.FieldCc:
  14152. m.ResetCc()
  14153. return nil
  14154. case contact.FieldPhone:
  14155. m.ResetPhone()
  14156. return nil
  14157. }
  14158. return fmt.Errorf("unknown Contact field %s", name)
  14159. }
  14160. // AddedEdges returns all edge names that were set/added in this mutation.
  14161. func (m *ContactMutation) AddedEdges() []string {
  14162. edges := make([]string, 0, 3)
  14163. if m.contact_relationships != nil {
  14164. edges = append(edges, contact.EdgeContactRelationships)
  14165. }
  14166. if m.contact_fields != nil {
  14167. edges = append(edges, contact.EdgeContactFields)
  14168. }
  14169. if m.contact_messages != nil {
  14170. edges = append(edges, contact.EdgeContactMessages)
  14171. }
  14172. return edges
  14173. }
  14174. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14175. // name in this mutation.
  14176. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  14177. switch name {
  14178. case contact.EdgeContactRelationships:
  14179. ids := make([]ent.Value, 0, len(m.contact_relationships))
  14180. for id := range m.contact_relationships {
  14181. ids = append(ids, id)
  14182. }
  14183. return ids
  14184. case contact.EdgeContactFields:
  14185. ids := make([]ent.Value, 0, len(m.contact_fields))
  14186. for id := range m.contact_fields {
  14187. ids = append(ids, id)
  14188. }
  14189. return ids
  14190. case contact.EdgeContactMessages:
  14191. ids := make([]ent.Value, 0, len(m.contact_messages))
  14192. for id := range m.contact_messages {
  14193. ids = append(ids, id)
  14194. }
  14195. return ids
  14196. }
  14197. return nil
  14198. }
  14199. // RemovedEdges returns all edge names that were removed in this mutation.
  14200. func (m *ContactMutation) RemovedEdges() []string {
  14201. edges := make([]string, 0, 3)
  14202. if m.removedcontact_relationships != nil {
  14203. edges = append(edges, contact.EdgeContactRelationships)
  14204. }
  14205. if m.removedcontact_fields != nil {
  14206. edges = append(edges, contact.EdgeContactFields)
  14207. }
  14208. if m.removedcontact_messages != nil {
  14209. edges = append(edges, contact.EdgeContactMessages)
  14210. }
  14211. return edges
  14212. }
  14213. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14214. // the given name in this mutation.
  14215. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  14216. switch name {
  14217. case contact.EdgeContactRelationships:
  14218. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  14219. for id := range m.removedcontact_relationships {
  14220. ids = append(ids, id)
  14221. }
  14222. return ids
  14223. case contact.EdgeContactFields:
  14224. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  14225. for id := range m.removedcontact_fields {
  14226. ids = append(ids, id)
  14227. }
  14228. return ids
  14229. case contact.EdgeContactMessages:
  14230. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  14231. for id := range m.removedcontact_messages {
  14232. ids = append(ids, id)
  14233. }
  14234. return ids
  14235. }
  14236. return nil
  14237. }
  14238. // ClearedEdges returns all edge names that were cleared in this mutation.
  14239. func (m *ContactMutation) ClearedEdges() []string {
  14240. edges := make([]string, 0, 3)
  14241. if m.clearedcontact_relationships {
  14242. edges = append(edges, contact.EdgeContactRelationships)
  14243. }
  14244. if m.clearedcontact_fields {
  14245. edges = append(edges, contact.EdgeContactFields)
  14246. }
  14247. if m.clearedcontact_messages {
  14248. edges = append(edges, contact.EdgeContactMessages)
  14249. }
  14250. return edges
  14251. }
  14252. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14253. // was cleared in this mutation.
  14254. func (m *ContactMutation) EdgeCleared(name string) bool {
  14255. switch name {
  14256. case contact.EdgeContactRelationships:
  14257. return m.clearedcontact_relationships
  14258. case contact.EdgeContactFields:
  14259. return m.clearedcontact_fields
  14260. case contact.EdgeContactMessages:
  14261. return m.clearedcontact_messages
  14262. }
  14263. return false
  14264. }
  14265. // ClearEdge clears the value of the edge with the given name. It returns an error
  14266. // if that edge is not defined in the schema.
  14267. func (m *ContactMutation) ClearEdge(name string) error {
  14268. switch name {
  14269. }
  14270. return fmt.Errorf("unknown Contact unique edge %s", name)
  14271. }
  14272. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14273. // It returns an error if the edge is not defined in the schema.
  14274. func (m *ContactMutation) ResetEdge(name string) error {
  14275. switch name {
  14276. case contact.EdgeContactRelationships:
  14277. m.ResetContactRelationships()
  14278. return nil
  14279. case contact.EdgeContactFields:
  14280. m.ResetContactFields()
  14281. return nil
  14282. case contact.EdgeContactMessages:
  14283. m.ResetContactMessages()
  14284. return nil
  14285. }
  14286. return fmt.Errorf("unknown Contact edge %s", name)
  14287. }
  14288. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  14289. type ContactFieldMutation struct {
  14290. config
  14291. op Op
  14292. typ string
  14293. id *uint64
  14294. created_at *time.Time
  14295. updated_at *time.Time
  14296. status *uint8
  14297. addstatus *int8
  14298. deleted_at *time.Time
  14299. form_id *string
  14300. value *[]string
  14301. appendvalue []string
  14302. clearedFields map[string]struct{}
  14303. field_contact *uint64
  14304. clearedfield_contact bool
  14305. done bool
  14306. oldValue func(context.Context) (*ContactField, error)
  14307. predicates []predicate.ContactField
  14308. }
  14309. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  14310. // contactfieldOption allows management of the mutation configuration using functional options.
  14311. type contactfieldOption func(*ContactFieldMutation)
  14312. // newContactFieldMutation creates new mutation for the ContactField entity.
  14313. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  14314. m := &ContactFieldMutation{
  14315. config: c,
  14316. op: op,
  14317. typ: TypeContactField,
  14318. clearedFields: make(map[string]struct{}),
  14319. }
  14320. for _, opt := range opts {
  14321. opt(m)
  14322. }
  14323. return m
  14324. }
  14325. // withContactFieldID sets the ID field of the mutation.
  14326. func withContactFieldID(id uint64) contactfieldOption {
  14327. return func(m *ContactFieldMutation) {
  14328. var (
  14329. err error
  14330. once sync.Once
  14331. value *ContactField
  14332. )
  14333. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  14334. once.Do(func() {
  14335. if m.done {
  14336. err = errors.New("querying old values post mutation is not allowed")
  14337. } else {
  14338. value, err = m.Client().ContactField.Get(ctx, id)
  14339. }
  14340. })
  14341. return value, err
  14342. }
  14343. m.id = &id
  14344. }
  14345. }
  14346. // withContactField sets the old ContactField of the mutation.
  14347. func withContactField(node *ContactField) contactfieldOption {
  14348. return func(m *ContactFieldMutation) {
  14349. m.oldValue = func(context.Context) (*ContactField, error) {
  14350. return node, nil
  14351. }
  14352. m.id = &node.ID
  14353. }
  14354. }
  14355. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14356. // executed in a transaction (ent.Tx), a transactional client is returned.
  14357. func (m ContactFieldMutation) Client() *Client {
  14358. client := &Client{config: m.config}
  14359. client.init()
  14360. return client
  14361. }
  14362. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14363. // it returns an error otherwise.
  14364. func (m ContactFieldMutation) Tx() (*Tx, error) {
  14365. if _, ok := m.driver.(*txDriver); !ok {
  14366. return nil, errors.New("ent: mutation is not running in a transaction")
  14367. }
  14368. tx := &Tx{config: m.config}
  14369. tx.init()
  14370. return tx, nil
  14371. }
  14372. // SetID sets the value of the id field. Note that this
  14373. // operation is only accepted on creation of ContactField entities.
  14374. func (m *ContactFieldMutation) SetID(id uint64) {
  14375. m.id = &id
  14376. }
  14377. // ID returns the ID value in the mutation. Note that the ID is only available
  14378. // if it was provided to the builder or after it was returned from the database.
  14379. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  14380. if m.id == nil {
  14381. return
  14382. }
  14383. return *m.id, true
  14384. }
  14385. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14386. // That means, if the mutation is applied within a transaction with an isolation level such
  14387. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14388. // or updated by the mutation.
  14389. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  14390. switch {
  14391. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14392. id, exists := m.ID()
  14393. if exists {
  14394. return []uint64{id}, nil
  14395. }
  14396. fallthrough
  14397. case m.op.Is(OpUpdate | OpDelete):
  14398. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  14399. default:
  14400. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14401. }
  14402. }
  14403. // SetCreatedAt sets the "created_at" field.
  14404. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  14405. m.created_at = &t
  14406. }
  14407. // CreatedAt returns the value of the "created_at" field in the mutation.
  14408. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  14409. v := m.created_at
  14410. if v == nil {
  14411. return
  14412. }
  14413. return *v, true
  14414. }
  14415. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  14416. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14418. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14419. if !m.op.Is(OpUpdateOne) {
  14420. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14421. }
  14422. if m.id == nil || m.oldValue == nil {
  14423. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14424. }
  14425. oldValue, err := m.oldValue(ctx)
  14426. if err != nil {
  14427. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14428. }
  14429. return oldValue.CreatedAt, nil
  14430. }
  14431. // ResetCreatedAt resets all changes to the "created_at" field.
  14432. func (m *ContactFieldMutation) ResetCreatedAt() {
  14433. m.created_at = nil
  14434. }
  14435. // SetUpdatedAt sets the "updated_at" field.
  14436. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  14437. m.updated_at = &t
  14438. }
  14439. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14440. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  14441. v := m.updated_at
  14442. if v == nil {
  14443. return
  14444. }
  14445. return *v, true
  14446. }
  14447. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  14448. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14450. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14451. if !m.op.Is(OpUpdateOne) {
  14452. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14453. }
  14454. if m.id == nil || m.oldValue == nil {
  14455. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14456. }
  14457. oldValue, err := m.oldValue(ctx)
  14458. if err != nil {
  14459. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14460. }
  14461. return oldValue.UpdatedAt, nil
  14462. }
  14463. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14464. func (m *ContactFieldMutation) ResetUpdatedAt() {
  14465. m.updated_at = nil
  14466. }
  14467. // SetStatus sets the "status" field.
  14468. func (m *ContactFieldMutation) SetStatus(u uint8) {
  14469. m.status = &u
  14470. m.addstatus = nil
  14471. }
  14472. // Status returns the value of the "status" field in the mutation.
  14473. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  14474. v := m.status
  14475. if v == nil {
  14476. return
  14477. }
  14478. return *v, true
  14479. }
  14480. // OldStatus returns the old "status" field's value of the ContactField entity.
  14481. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14483. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14484. if !m.op.Is(OpUpdateOne) {
  14485. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14486. }
  14487. if m.id == nil || m.oldValue == nil {
  14488. return v, errors.New("OldStatus requires an ID field in the mutation")
  14489. }
  14490. oldValue, err := m.oldValue(ctx)
  14491. if err != nil {
  14492. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14493. }
  14494. return oldValue.Status, nil
  14495. }
  14496. // AddStatus adds u to the "status" field.
  14497. func (m *ContactFieldMutation) AddStatus(u int8) {
  14498. if m.addstatus != nil {
  14499. *m.addstatus += u
  14500. } else {
  14501. m.addstatus = &u
  14502. }
  14503. }
  14504. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14505. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  14506. v := m.addstatus
  14507. if v == nil {
  14508. return
  14509. }
  14510. return *v, true
  14511. }
  14512. // ClearStatus clears the value of the "status" field.
  14513. func (m *ContactFieldMutation) ClearStatus() {
  14514. m.status = nil
  14515. m.addstatus = nil
  14516. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  14517. }
  14518. // StatusCleared returns if the "status" field was cleared in this mutation.
  14519. func (m *ContactFieldMutation) StatusCleared() bool {
  14520. _, ok := m.clearedFields[contactfield.FieldStatus]
  14521. return ok
  14522. }
  14523. // ResetStatus resets all changes to the "status" field.
  14524. func (m *ContactFieldMutation) ResetStatus() {
  14525. m.status = nil
  14526. m.addstatus = nil
  14527. delete(m.clearedFields, contactfield.FieldStatus)
  14528. }
  14529. // SetDeletedAt sets the "deleted_at" field.
  14530. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  14531. m.deleted_at = &t
  14532. }
  14533. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14534. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  14535. v := m.deleted_at
  14536. if v == nil {
  14537. return
  14538. }
  14539. return *v, true
  14540. }
  14541. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  14542. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14544. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14545. if !m.op.Is(OpUpdateOne) {
  14546. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14547. }
  14548. if m.id == nil || m.oldValue == nil {
  14549. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14550. }
  14551. oldValue, err := m.oldValue(ctx)
  14552. if err != nil {
  14553. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14554. }
  14555. return oldValue.DeletedAt, nil
  14556. }
  14557. // ClearDeletedAt clears the value of the "deleted_at" field.
  14558. func (m *ContactFieldMutation) ClearDeletedAt() {
  14559. m.deleted_at = nil
  14560. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  14561. }
  14562. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14563. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  14564. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  14565. return ok
  14566. }
  14567. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14568. func (m *ContactFieldMutation) ResetDeletedAt() {
  14569. m.deleted_at = nil
  14570. delete(m.clearedFields, contactfield.FieldDeletedAt)
  14571. }
  14572. // SetContactID sets the "contact_id" field.
  14573. func (m *ContactFieldMutation) SetContactID(u uint64) {
  14574. m.field_contact = &u
  14575. }
  14576. // ContactID returns the value of the "contact_id" field in the mutation.
  14577. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  14578. v := m.field_contact
  14579. if v == nil {
  14580. return
  14581. }
  14582. return *v, true
  14583. }
  14584. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  14585. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14587. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14588. if !m.op.Is(OpUpdateOne) {
  14589. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14590. }
  14591. if m.id == nil || m.oldValue == nil {
  14592. return v, errors.New("OldContactID requires an ID field in the mutation")
  14593. }
  14594. oldValue, err := m.oldValue(ctx)
  14595. if err != nil {
  14596. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14597. }
  14598. return oldValue.ContactID, nil
  14599. }
  14600. // ResetContactID resets all changes to the "contact_id" field.
  14601. func (m *ContactFieldMutation) ResetContactID() {
  14602. m.field_contact = nil
  14603. }
  14604. // SetFormID sets the "form_id" field.
  14605. func (m *ContactFieldMutation) SetFormID(s string) {
  14606. m.form_id = &s
  14607. }
  14608. // FormID returns the value of the "form_id" field in the mutation.
  14609. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  14610. v := m.form_id
  14611. if v == nil {
  14612. return
  14613. }
  14614. return *v, true
  14615. }
  14616. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  14617. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14619. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  14620. if !m.op.Is(OpUpdateOne) {
  14621. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  14622. }
  14623. if m.id == nil || m.oldValue == nil {
  14624. return v, errors.New("OldFormID requires an ID field in the mutation")
  14625. }
  14626. oldValue, err := m.oldValue(ctx)
  14627. if err != nil {
  14628. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  14629. }
  14630. return oldValue.FormID, nil
  14631. }
  14632. // ResetFormID resets all changes to the "form_id" field.
  14633. func (m *ContactFieldMutation) ResetFormID() {
  14634. m.form_id = nil
  14635. }
  14636. // SetValue sets the "value" field.
  14637. func (m *ContactFieldMutation) SetValue(s []string) {
  14638. m.value = &s
  14639. m.appendvalue = nil
  14640. }
  14641. // Value returns the value of the "value" field in the mutation.
  14642. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  14643. v := m.value
  14644. if v == nil {
  14645. return
  14646. }
  14647. return *v, true
  14648. }
  14649. // OldValue returns the old "value" field's value of the ContactField entity.
  14650. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14652. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  14653. if !m.op.Is(OpUpdateOne) {
  14654. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  14655. }
  14656. if m.id == nil || m.oldValue == nil {
  14657. return v, errors.New("OldValue requires an ID field in the mutation")
  14658. }
  14659. oldValue, err := m.oldValue(ctx)
  14660. if err != nil {
  14661. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  14662. }
  14663. return oldValue.Value, nil
  14664. }
  14665. // AppendValue adds s to the "value" field.
  14666. func (m *ContactFieldMutation) AppendValue(s []string) {
  14667. m.appendvalue = append(m.appendvalue, s...)
  14668. }
  14669. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  14670. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  14671. if len(m.appendvalue) == 0 {
  14672. return nil, false
  14673. }
  14674. return m.appendvalue, true
  14675. }
  14676. // ResetValue resets all changes to the "value" field.
  14677. func (m *ContactFieldMutation) ResetValue() {
  14678. m.value = nil
  14679. m.appendvalue = nil
  14680. }
  14681. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  14682. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  14683. m.field_contact = &id
  14684. }
  14685. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  14686. func (m *ContactFieldMutation) ClearFieldContact() {
  14687. m.clearedfield_contact = true
  14688. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  14689. }
  14690. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  14691. func (m *ContactFieldMutation) FieldContactCleared() bool {
  14692. return m.clearedfield_contact
  14693. }
  14694. // FieldContactID returns the "field_contact" edge ID in the mutation.
  14695. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  14696. if m.field_contact != nil {
  14697. return *m.field_contact, true
  14698. }
  14699. return
  14700. }
  14701. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  14702. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14703. // FieldContactID instead. It exists only for internal usage by the builders.
  14704. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  14705. if id := m.field_contact; id != nil {
  14706. ids = append(ids, *id)
  14707. }
  14708. return
  14709. }
  14710. // ResetFieldContact resets all changes to the "field_contact" edge.
  14711. func (m *ContactFieldMutation) ResetFieldContact() {
  14712. m.field_contact = nil
  14713. m.clearedfield_contact = false
  14714. }
  14715. // Where appends a list predicates to the ContactFieldMutation builder.
  14716. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  14717. m.predicates = append(m.predicates, ps...)
  14718. }
  14719. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  14720. // users can use type-assertion to append predicates that do not depend on any generated package.
  14721. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  14722. p := make([]predicate.ContactField, len(ps))
  14723. for i := range ps {
  14724. p[i] = ps[i]
  14725. }
  14726. m.Where(p...)
  14727. }
  14728. // Op returns the operation name.
  14729. func (m *ContactFieldMutation) Op() Op {
  14730. return m.op
  14731. }
  14732. // SetOp allows setting the mutation operation.
  14733. func (m *ContactFieldMutation) SetOp(op Op) {
  14734. m.op = op
  14735. }
  14736. // Type returns the node type of this mutation (ContactField).
  14737. func (m *ContactFieldMutation) Type() string {
  14738. return m.typ
  14739. }
  14740. // Fields returns all fields that were changed during this mutation. Note that in
  14741. // order to get all numeric fields that were incremented/decremented, call
  14742. // AddedFields().
  14743. func (m *ContactFieldMutation) Fields() []string {
  14744. fields := make([]string, 0, 7)
  14745. if m.created_at != nil {
  14746. fields = append(fields, contactfield.FieldCreatedAt)
  14747. }
  14748. if m.updated_at != nil {
  14749. fields = append(fields, contactfield.FieldUpdatedAt)
  14750. }
  14751. if m.status != nil {
  14752. fields = append(fields, contactfield.FieldStatus)
  14753. }
  14754. if m.deleted_at != nil {
  14755. fields = append(fields, contactfield.FieldDeletedAt)
  14756. }
  14757. if m.field_contact != nil {
  14758. fields = append(fields, contactfield.FieldContactID)
  14759. }
  14760. if m.form_id != nil {
  14761. fields = append(fields, contactfield.FieldFormID)
  14762. }
  14763. if m.value != nil {
  14764. fields = append(fields, contactfield.FieldValue)
  14765. }
  14766. return fields
  14767. }
  14768. // Field returns the value of a field with the given name. The second boolean
  14769. // return value indicates that this field was not set, or was not defined in the
  14770. // schema.
  14771. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  14772. switch name {
  14773. case contactfield.FieldCreatedAt:
  14774. return m.CreatedAt()
  14775. case contactfield.FieldUpdatedAt:
  14776. return m.UpdatedAt()
  14777. case contactfield.FieldStatus:
  14778. return m.Status()
  14779. case contactfield.FieldDeletedAt:
  14780. return m.DeletedAt()
  14781. case contactfield.FieldContactID:
  14782. return m.ContactID()
  14783. case contactfield.FieldFormID:
  14784. return m.FormID()
  14785. case contactfield.FieldValue:
  14786. return m.Value()
  14787. }
  14788. return nil, false
  14789. }
  14790. // OldField returns the old value of the field from the database. An error is
  14791. // returned if the mutation operation is not UpdateOne, or the query to the
  14792. // database failed.
  14793. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14794. switch name {
  14795. case contactfield.FieldCreatedAt:
  14796. return m.OldCreatedAt(ctx)
  14797. case contactfield.FieldUpdatedAt:
  14798. return m.OldUpdatedAt(ctx)
  14799. case contactfield.FieldStatus:
  14800. return m.OldStatus(ctx)
  14801. case contactfield.FieldDeletedAt:
  14802. return m.OldDeletedAt(ctx)
  14803. case contactfield.FieldContactID:
  14804. return m.OldContactID(ctx)
  14805. case contactfield.FieldFormID:
  14806. return m.OldFormID(ctx)
  14807. case contactfield.FieldValue:
  14808. return m.OldValue(ctx)
  14809. }
  14810. return nil, fmt.Errorf("unknown ContactField field %s", name)
  14811. }
  14812. // SetField sets the value of a field with the given name. It returns an error if
  14813. // the field is not defined in the schema, or if the type mismatched the field
  14814. // type.
  14815. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  14816. switch name {
  14817. case contactfield.FieldCreatedAt:
  14818. v, ok := value.(time.Time)
  14819. if !ok {
  14820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14821. }
  14822. m.SetCreatedAt(v)
  14823. return nil
  14824. case contactfield.FieldUpdatedAt:
  14825. v, ok := value.(time.Time)
  14826. if !ok {
  14827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14828. }
  14829. m.SetUpdatedAt(v)
  14830. return nil
  14831. case contactfield.FieldStatus:
  14832. v, ok := value.(uint8)
  14833. if !ok {
  14834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14835. }
  14836. m.SetStatus(v)
  14837. return nil
  14838. case contactfield.FieldDeletedAt:
  14839. v, ok := value.(time.Time)
  14840. if !ok {
  14841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14842. }
  14843. m.SetDeletedAt(v)
  14844. return nil
  14845. case contactfield.FieldContactID:
  14846. v, ok := value.(uint64)
  14847. if !ok {
  14848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14849. }
  14850. m.SetContactID(v)
  14851. return nil
  14852. case contactfield.FieldFormID:
  14853. v, ok := value.(string)
  14854. if !ok {
  14855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14856. }
  14857. m.SetFormID(v)
  14858. return nil
  14859. case contactfield.FieldValue:
  14860. v, ok := value.([]string)
  14861. if !ok {
  14862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14863. }
  14864. m.SetValue(v)
  14865. return nil
  14866. }
  14867. return fmt.Errorf("unknown ContactField field %s", name)
  14868. }
  14869. // AddedFields returns all numeric fields that were incremented/decremented during
  14870. // this mutation.
  14871. func (m *ContactFieldMutation) AddedFields() []string {
  14872. var fields []string
  14873. if m.addstatus != nil {
  14874. fields = append(fields, contactfield.FieldStatus)
  14875. }
  14876. return fields
  14877. }
  14878. // AddedField returns the numeric value that was incremented/decremented on a field
  14879. // with the given name. The second boolean return value indicates that this field
  14880. // was not set, or was not defined in the schema.
  14881. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  14882. switch name {
  14883. case contactfield.FieldStatus:
  14884. return m.AddedStatus()
  14885. }
  14886. return nil, false
  14887. }
  14888. // AddField adds the value to the field with the given name. It returns an error if
  14889. // the field is not defined in the schema, or if the type mismatched the field
  14890. // type.
  14891. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  14892. switch name {
  14893. case contactfield.FieldStatus:
  14894. v, ok := value.(int8)
  14895. if !ok {
  14896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14897. }
  14898. m.AddStatus(v)
  14899. return nil
  14900. }
  14901. return fmt.Errorf("unknown ContactField numeric field %s", name)
  14902. }
  14903. // ClearedFields returns all nullable fields that were cleared during this
  14904. // mutation.
  14905. func (m *ContactFieldMutation) ClearedFields() []string {
  14906. var fields []string
  14907. if m.FieldCleared(contactfield.FieldStatus) {
  14908. fields = append(fields, contactfield.FieldStatus)
  14909. }
  14910. if m.FieldCleared(contactfield.FieldDeletedAt) {
  14911. fields = append(fields, contactfield.FieldDeletedAt)
  14912. }
  14913. return fields
  14914. }
  14915. // FieldCleared returns a boolean indicating if a field with the given name was
  14916. // cleared in this mutation.
  14917. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  14918. _, ok := m.clearedFields[name]
  14919. return ok
  14920. }
  14921. // ClearField clears the value of the field with the given name. It returns an
  14922. // error if the field is not defined in the schema.
  14923. func (m *ContactFieldMutation) ClearField(name string) error {
  14924. switch name {
  14925. case contactfield.FieldStatus:
  14926. m.ClearStatus()
  14927. return nil
  14928. case contactfield.FieldDeletedAt:
  14929. m.ClearDeletedAt()
  14930. return nil
  14931. }
  14932. return fmt.Errorf("unknown ContactField nullable field %s", name)
  14933. }
  14934. // ResetField resets all changes in the mutation for the field with the given name.
  14935. // It returns an error if the field is not defined in the schema.
  14936. func (m *ContactFieldMutation) ResetField(name string) error {
  14937. switch name {
  14938. case contactfield.FieldCreatedAt:
  14939. m.ResetCreatedAt()
  14940. return nil
  14941. case contactfield.FieldUpdatedAt:
  14942. m.ResetUpdatedAt()
  14943. return nil
  14944. case contactfield.FieldStatus:
  14945. m.ResetStatus()
  14946. return nil
  14947. case contactfield.FieldDeletedAt:
  14948. m.ResetDeletedAt()
  14949. return nil
  14950. case contactfield.FieldContactID:
  14951. m.ResetContactID()
  14952. return nil
  14953. case contactfield.FieldFormID:
  14954. m.ResetFormID()
  14955. return nil
  14956. case contactfield.FieldValue:
  14957. m.ResetValue()
  14958. return nil
  14959. }
  14960. return fmt.Errorf("unknown ContactField field %s", name)
  14961. }
  14962. // AddedEdges returns all edge names that were set/added in this mutation.
  14963. func (m *ContactFieldMutation) AddedEdges() []string {
  14964. edges := make([]string, 0, 1)
  14965. if m.field_contact != nil {
  14966. edges = append(edges, contactfield.EdgeFieldContact)
  14967. }
  14968. return edges
  14969. }
  14970. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14971. // name in this mutation.
  14972. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  14973. switch name {
  14974. case contactfield.EdgeFieldContact:
  14975. if id := m.field_contact; id != nil {
  14976. return []ent.Value{*id}
  14977. }
  14978. }
  14979. return nil
  14980. }
  14981. // RemovedEdges returns all edge names that were removed in this mutation.
  14982. func (m *ContactFieldMutation) RemovedEdges() []string {
  14983. edges := make([]string, 0, 1)
  14984. return edges
  14985. }
  14986. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14987. // the given name in this mutation.
  14988. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  14989. return nil
  14990. }
  14991. // ClearedEdges returns all edge names that were cleared in this mutation.
  14992. func (m *ContactFieldMutation) ClearedEdges() []string {
  14993. edges := make([]string, 0, 1)
  14994. if m.clearedfield_contact {
  14995. edges = append(edges, contactfield.EdgeFieldContact)
  14996. }
  14997. return edges
  14998. }
  14999. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15000. // was cleared in this mutation.
  15001. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  15002. switch name {
  15003. case contactfield.EdgeFieldContact:
  15004. return m.clearedfield_contact
  15005. }
  15006. return false
  15007. }
  15008. // ClearEdge clears the value of the edge with the given name. It returns an error
  15009. // if that edge is not defined in the schema.
  15010. func (m *ContactFieldMutation) ClearEdge(name string) error {
  15011. switch name {
  15012. case contactfield.EdgeFieldContact:
  15013. m.ClearFieldContact()
  15014. return nil
  15015. }
  15016. return fmt.Errorf("unknown ContactField unique edge %s", name)
  15017. }
  15018. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15019. // It returns an error if the edge is not defined in the schema.
  15020. func (m *ContactFieldMutation) ResetEdge(name string) error {
  15021. switch name {
  15022. case contactfield.EdgeFieldContact:
  15023. m.ResetFieldContact()
  15024. return nil
  15025. }
  15026. return fmt.Errorf("unknown ContactField edge %s", name)
  15027. }
  15028. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  15029. type ContactFieldTemplateMutation struct {
  15030. config
  15031. op Op
  15032. typ string
  15033. id *uint64
  15034. created_at *time.Time
  15035. updated_at *time.Time
  15036. status *uint8
  15037. addstatus *int8
  15038. deleted_at *time.Time
  15039. organization_id *uint64
  15040. addorganization_id *int64
  15041. template *[]custom_types.ContactFieldTemplate
  15042. appendtemplate []custom_types.ContactFieldTemplate
  15043. clearedFields map[string]struct{}
  15044. done bool
  15045. oldValue func(context.Context) (*ContactFieldTemplate, error)
  15046. predicates []predicate.ContactFieldTemplate
  15047. }
  15048. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  15049. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  15050. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  15051. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  15052. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  15053. m := &ContactFieldTemplateMutation{
  15054. config: c,
  15055. op: op,
  15056. typ: TypeContactFieldTemplate,
  15057. clearedFields: make(map[string]struct{}),
  15058. }
  15059. for _, opt := range opts {
  15060. opt(m)
  15061. }
  15062. return m
  15063. }
  15064. // withContactFieldTemplateID sets the ID field of the mutation.
  15065. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  15066. return func(m *ContactFieldTemplateMutation) {
  15067. var (
  15068. err error
  15069. once sync.Once
  15070. value *ContactFieldTemplate
  15071. )
  15072. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  15073. once.Do(func() {
  15074. if m.done {
  15075. err = errors.New("querying old values post mutation is not allowed")
  15076. } else {
  15077. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  15078. }
  15079. })
  15080. return value, err
  15081. }
  15082. m.id = &id
  15083. }
  15084. }
  15085. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  15086. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  15087. return func(m *ContactFieldTemplateMutation) {
  15088. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  15089. return node, nil
  15090. }
  15091. m.id = &node.ID
  15092. }
  15093. }
  15094. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15095. // executed in a transaction (ent.Tx), a transactional client is returned.
  15096. func (m ContactFieldTemplateMutation) Client() *Client {
  15097. client := &Client{config: m.config}
  15098. client.init()
  15099. return client
  15100. }
  15101. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15102. // it returns an error otherwise.
  15103. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  15104. if _, ok := m.driver.(*txDriver); !ok {
  15105. return nil, errors.New("ent: mutation is not running in a transaction")
  15106. }
  15107. tx := &Tx{config: m.config}
  15108. tx.init()
  15109. return tx, nil
  15110. }
  15111. // SetID sets the value of the id field. Note that this
  15112. // operation is only accepted on creation of ContactFieldTemplate entities.
  15113. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  15114. m.id = &id
  15115. }
  15116. // ID returns the ID value in the mutation. Note that the ID is only available
  15117. // if it was provided to the builder or after it was returned from the database.
  15118. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  15119. if m.id == nil {
  15120. return
  15121. }
  15122. return *m.id, true
  15123. }
  15124. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15125. // That means, if the mutation is applied within a transaction with an isolation level such
  15126. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15127. // or updated by the mutation.
  15128. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  15129. switch {
  15130. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15131. id, exists := m.ID()
  15132. if exists {
  15133. return []uint64{id}, nil
  15134. }
  15135. fallthrough
  15136. case m.op.Is(OpUpdate | OpDelete):
  15137. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  15138. default:
  15139. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15140. }
  15141. }
  15142. // SetCreatedAt sets the "created_at" field.
  15143. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  15144. m.created_at = &t
  15145. }
  15146. // CreatedAt returns the value of the "created_at" field in the mutation.
  15147. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  15148. v := m.created_at
  15149. if v == nil {
  15150. return
  15151. }
  15152. return *v, true
  15153. }
  15154. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  15155. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15157. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15158. if !m.op.Is(OpUpdateOne) {
  15159. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15160. }
  15161. if m.id == nil || m.oldValue == nil {
  15162. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15163. }
  15164. oldValue, err := m.oldValue(ctx)
  15165. if err != nil {
  15166. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15167. }
  15168. return oldValue.CreatedAt, nil
  15169. }
  15170. // ResetCreatedAt resets all changes to the "created_at" field.
  15171. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  15172. m.created_at = nil
  15173. }
  15174. // SetUpdatedAt sets the "updated_at" field.
  15175. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  15176. m.updated_at = &t
  15177. }
  15178. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15179. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  15180. v := m.updated_at
  15181. if v == nil {
  15182. return
  15183. }
  15184. return *v, true
  15185. }
  15186. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  15187. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15189. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15190. if !m.op.Is(OpUpdateOne) {
  15191. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15192. }
  15193. if m.id == nil || m.oldValue == nil {
  15194. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15195. }
  15196. oldValue, err := m.oldValue(ctx)
  15197. if err != nil {
  15198. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15199. }
  15200. return oldValue.UpdatedAt, nil
  15201. }
  15202. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15203. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  15204. m.updated_at = nil
  15205. }
  15206. // SetStatus sets the "status" field.
  15207. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  15208. m.status = &u
  15209. m.addstatus = nil
  15210. }
  15211. // Status returns the value of the "status" field in the mutation.
  15212. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  15213. v := m.status
  15214. if v == nil {
  15215. return
  15216. }
  15217. return *v, true
  15218. }
  15219. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  15220. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15222. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15223. if !m.op.Is(OpUpdateOne) {
  15224. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15225. }
  15226. if m.id == nil || m.oldValue == nil {
  15227. return v, errors.New("OldStatus requires an ID field in the mutation")
  15228. }
  15229. oldValue, err := m.oldValue(ctx)
  15230. if err != nil {
  15231. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15232. }
  15233. return oldValue.Status, nil
  15234. }
  15235. // AddStatus adds u to the "status" field.
  15236. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  15237. if m.addstatus != nil {
  15238. *m.addstatus += u
  15239. } else {
  15240. m.addstatus = &u
  15241. }
  15242. }
  15243. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15244. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  15245. v := m.addstatus
  15246. if v == nil {
  15247. return
  15248. }
  15249. return *v, true
  15250. }
  15251. // ClearStatus clears the value of the "status" field.
  15252. func (m *ContactFieldTemplateMutation) ClearStatus() {
  15253. m.status = nil
  15254. m.addstatus = nil
  15255. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  15256. }
  15257. // StatusCleared returns if the "status" field was cleared in this mutation.
  15258. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  15259. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  15260. return ok
  15261. }
  15262. // ResetStatus resets all changes to the "status" field.
  15263. func (m *ContactFieldTemplateMutation) ResetStatus() {
  15264. m.status = nil
  15265. m.addstatus = nil
  15266. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  15267. }
  15268. // SetDeletedAt sets the "deleted_at" field.
  15269. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  15270. m.deleted_at = &t
  15271. }
  15272. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15273. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  15274. v := m.deleted_at
  15275. if v == nil {
  15276. return
  15277. }
  15278. return *v, true
  15279. }
  15280. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  15281. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15283. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15284. if !m.op.Is(OpUpdateOne) {
  15285. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15286. }
  15287. if m.id == nil || m.oldValue == nil {
  15288. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15289. }
  15290. oldValue, err := m.oldValue(ctx)
  15291. if err != nil {
  15292. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15293. }
  15294. return oldValue.DeletedAt, nil
  15295. }
  15296. // ClearDeletedAt clears the value of the "deleted_at" field.
  15297. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  15298. m.deleted_at = nil
  15299. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  15300. }
  15301. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15302. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  15303. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  15304. return ok
  15305. }
  15306. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15307. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  15308. m.deleted_at = nil
  15309. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  15310. }
  15311. // SetOrganizationID sets the "organization_id" field.
  15312. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  15313. m.organization_id = &u
  15314. m.addorganization_id = nil
  15315. }
  15316. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15317. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  15318. v := m.organization_id
  15319. if v == nil {
  15320. return
  15321. }
  15322. return *v, true
  15323. }
  15324. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  15325. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15327. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15328. if !m.op.Is(OpUpdateOne) {
  15329. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15330. }
  15331. if m.id == nil || m.oldValue == nil {
  15332. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15333. }
  15334. oldValue, err := m.oldValue(ctx)
  15335. if err != nil {
  15336. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15337. }
  15338. return oldValue.OrganizationID, nil
  15339. }
  15340. // AddOrganizationID adds u to the "organization_id" field.
  15341. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  15342. if m.addorganization_id != nil {
  15343. *m.addorganization_id += u
  15344. } else {
  15345. m.addorganization_id = &u
  15346. }
  15347. }
  15348. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15349. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  15350. v := m.addorganization_id
  15351. if v == nil {
  15352. return
  15353. }
  15354. return *v, true
  15355. }
  15356. // ResetOrganizationID resets all changes to the "organization_id" field.
  15357. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  15358. m.organization_id = nil
  15359. m.addorganization_id = nil
  15360. }
  15361. // SetTemplate sets the "template" field.
  15362. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  15363. m.template = &ctft
  15364. m.appendtemplate = nil
  15365. }
  15366. // Template returns the value of the "template" field in the mutation.
  15367. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  15368. v := m.template
  15369. if v == nil {
  15370. return
  15371. }
  15372. return *v, true
  15373. }
  15374. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  15375. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15377. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  15378. if !m.op.Is(OpUpdateOne) {
  15379. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  15380. }
  15381. if m.id == nil || m.oldValue == nil {
  15382. return v, errors.New("OldTemplate requires an ID field in the mutation")
  15383. }
  15384. oldValue, err := m.oldValue(ctx)
  15385. if err != nil {
  15386. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  15387. }
  15388. return oldValue.Template, nil
  15389. }
  15390. // AppendTemplate adds ctft to the "template" field.
  15391. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  15392. m.appendtemplate = append(m.appendtemplate, ctft...)
  15393. }
  15394. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  15395. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  15396. if len(m.appendtemplate) == 0 {
  15397. return nil, false
  15398. }
  15399. return m.appendtemplate, true
  15400. }
  15401. // ResetTemplate resets all changes to the "template" field.
  15402. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  15403. m.template = nil
  15404. m.appendtemplate = nil
  15405. }
  15406. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  15407. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  15408. m.predicates = append(m.predicates, ps...)
  15409. }
  15410. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  15411. // users can use type-assertion to append predicates that do not depend on any generated package.
  15412. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  15413. p := make([]predicate.ContactFieldTemplate, len(ps))
  15414. for i := range ps {
  15415. p[i] = ps[i]
  15416. }
  15417. m.Where(p...)
  15418. }
  15419. // Op returns the operation name.
  15420. func (m *ContactFieldTemplateMutation) Op() Op {
  15421. return m.op
  15422. }
  15423. // SetOp allows setting the mutation operation.
  15424. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  15425. m.op = op
  15426. }
  15427. // Type returns the node type of this mutation (ContactFieldTemplate).
  15428. func (m *ContactFieldTemplateMutation) Type() string {
  15429. return m.typ
  15430. }
  15431. // Fields returns all fields that were changed during this mutation. Note that in
  15432. // order to get all numeric fields that were incremented/decremented, call
  15433. // AddedFields().
  15434. func (m *ContactFieldTemplateMutation) Fields() []string {
  15435. fields := make([]string, 0, 6)
  15436. if m.created_at != nil {
  15437. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  15438. }
  15439. if m.updated_at != nil {
  15440. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  15441. }
  15442. if m.status != nil {
  15443. fields = append(fields, contactfieldtemplate.FieldStatus)
  15444. }
  15445. if m.deleted_at != nil {
  15446. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15447. }
  15448. if m.organization_id != nil {
  15449. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15450. }
  15451. if m.template != nil {
  15452. fields = append(fields, contactfieldtemplate.FieldTemplate)
  15453. }
  15454. return fields
  15455. }
  15456. // Field returns the value of a field with the given name. The second boolean
  15457. // return value indicates that this field was not set, or was not defined in the
  15458. // schema.
  15459. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  15460. switch name {
  15461. case contactfieldtemplate.FieldCreatedAt:
  15462. return m.CreatedAt()
  15463. case contactfieldtemplate.FieldUpdatedAt:
  15464. return m.UpdatedAt()
  15465. case contactfieldtemplate.FieldStatus:
  15466. return m.Status()
  15467. case contactfieldtemplate.FieldDeletedAt:
  15468. return m.DeletedAt()
  15469. case contactfieldtemplate.FieldOrganizationID:
  15470. return m.OrganizationID()
  15471. case contactfieldtemplate.FieldTemplate:
  15472. return m.Template()
  15473. }
  15474. return nil, false
  15475. }
  15476. // OldField returns the old value of the field from the database. An error is
  15477. // returned if the mutation operation is not UpdateOne, or the query to the
  15478. // database failed.
  15479. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15480. switch name {
  15481. case contactfieldtemplate.FieldCreatedAt:
  15482. return m.OldCreatedAt(ctx)
  15483. case contactfieldtemplate.FieldUpdatedAt:
  15484. return m.OldUpdatedAt(ctx)
  15485. case contactfieldtemplate.FieldStatus:
  15486. return m.OldStatus(ctx)
  15487. case contactfieldtemplate.FieldDeletedAt:
  15488. return m.OldDeletedAt(ctx)
  15489. case contactfieldtemplate.FieldOrganizationID:
  15490. return m.OldOrganizationID(ctx)
  15491. case contactfieldtemplate.FieldTemplate:
  15492. return m.OldTemplate(ctx)
  15493. }
  15494. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15495. }
  15496. // SetField sets the value of a field with the given name. It returns an error if
  15497. // the field is not defined in the schema, or if the type mismatched the field
  15498. // type.
  15499. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  15500. switch name {
  15501. case contactfieldtemplate.FieldCreatedAt:
  15502. v, ok := value.(time.Time)
  15503. if !ok {
  15504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15505. }
  15506. m.SetCreatedAt(v)
  15507. return nil
  15508. case contactfieldtemplate.FieldUpdatedAt:
  15509. v, ok := value.(time.Time)
  15510. if !ok {
  15511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15512. }
  15513. m.SetUpdatedAt(v)
  15514. return nil
  15515. case contactfieldtemplate.FieldStatus:
  15516. v, ok := value.(uint8)
  15517. if !ok {
  15518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15519. }
  15520. m.SetStatus(v)
  15521. return nil
  15522. case contactfieldtemplate.FieldDeletedAt:
  15523. v, ok := value.(time.Time)
  15524. if !ok {
  15525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15526. }
  15527. m.SetDeletedAt(v)
  15528. return nil
  15529. case contactfieldtemplate.FieldOrganizationID:
  15530. v, ok := value.(uint64)
  15531. if !ok {
  15532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15533. }
  15534. m.SetOrganizationID(v)
  15535. return nil
  15536. case contactfieldtemplate.FieldTemplate:
  15537. v, ok := value.([]custom_types.ContactFieldTemplate)
  15538. if !ok {
  15539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15540. }
  15541. m.SetTemplate(v)
  15542. return nil
  15543. }
  15544. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15545. }
  15546. // AddedFields returns all numeric fields that were incremented/decremented during
  15547. // this mutation.
  15548. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  15549. var fields []string
  15550. if m.addstatus != nil {
  15551. fields = append(fields, contactfieldtemplate.FieldStatus)
  15552. }
  15553. if m.addorganization_id != nil {
  15554. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15555. }
  15556. return fields
  15557. }
  15558. // AddedField returns the numeric value that was incremented/decremented on a field
  15559. // with the given name. The second boolean return value indicates that this field
  15560. // was not set, or was not defined in the schema.
  15561. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  15562. switch name {
  15563. case contactfieldtemplate.FieldStatus:
  15564. return m.AddedStatus()
  15565. case contactfieldtemplate.FieldOrganizationID:
  15566. return m.AddedOrganizationID()
  15567. }
  15568. return nil, false
  15569. }
  15570. // AddField adds the value to the field with the given name. It returns an error if
  15571. // the field is not defined in the schema, or if the type mismatched the field
  15572. // type.
  15573. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  15574. switch name {
  15575. case contactfieldtemplate.FieldStatus:
  15576. v, ok := value.(int8)
  15577. if !ok {
  15578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15579. }
  15580. m.AddStatus(v)
  15581. return nil
  15582. case contactfieldtemplate.FieldOrganizationID:
  15583. v, ok := value.(int64)
  15584. if !ok {
  15585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15586. }
  15587. m.AddOrganizationID(v)
  15588. return nil
  15589. }
  15590. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  15591. }
  15592. // ClearedFields returns all nullable fields that were cleared during this
  15593. // mutation.
  15594. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  15595. var fields []string
  15596. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  15597. fields = append(fields, contactfieldtemplate.FieldStatus)
  15598. }
  15599. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  15600. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15601. }
  15602. return fields
  15603. }
  15604. // FieldCleared returns a boolean indicating if a field with the given name was
  15605. // cleared in this mutation.
  15606. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  15607. _, ok := m.clearedFields[name]
  15608. return ok
  15609. }
  15610. // ClearField clears the value of the field with the given name. It returns an
  15611. // error if the field is not defined in the schema.
  15612. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  15613. switch name {
  15614. case contactfieldtemplate.FieldStatus:
  15615. m.ClearStatus()
  15616. return nil
  15617. case contactfieldtemplate.FieldDeletedAt:
  15618. m.ClearDeletedAt()
  15619. return nil
  15620. }
  15621. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  15622. }
  15623. // ResetField resets all changes in the mutation for the field with the given name.
  15624. // It returns an error if the field is not defined in the schema.
  15625. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  15626. switch name {
  15627. case contactfieldtemplate.FieldCreatedAt:
  15628. m.ResetCreatedAt()
  15629. return nil
  15630. case contactfieldtemplate.FieldUpdatedAt:
  15631. m.ResetUpdatedAt()
  15632. return nil
  15633. case contactfieldtemplate.FieldStatus:
  15634. m.ResetStatus()
  15635. return nil
  15636. case contactfieldtemplate.FieldDeletedAt:
  15637. m.ResetDeletedAt()
  15638. return nil
  15639. case contactfieldtemplate.FieldOrganizationID:
  15640. m.ResetOrganizationID()
  15641. return nil
  15642. case contactfieldtemplate.FieldTemplate:
  15643. m.ResetTemplate()
  15644. return nil
  15645. }
  15646. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15647. }
  15648. // AddedEdges returns all edge names that were set/added in this mutation.
  15649. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  15650. edges := make([]string, 0, 0)
  15651. return edges
  15652. }
  15653. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15654. // name in this mutation.
  15655. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  15656. return nil
  15657. }
  15658. // RemovedEdges returns all edge names that were removed in this mutation.
  15659. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  15660. edges := make([]string, 0, 0)
  15661. return edges
  15662. }
  15663. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15664. // the given name in this mutation.
  15665. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  15666. return nil
  15667. }
  15668. // ClearedEdges returns all edge names that were cleared in this mutation.
  15669. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  15670. edges := make([]string, 0, 0)
  15671. return edges
  15672. }
  15673. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15674. // was cleared in this mutation.
  15675. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  15676. return false
  15677. }
  15678. // ClearEdge clears the value of the edge with the given name. It returns an error
  15679. // if that edge is not defined in the schema.
  15680. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  15681. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  15682. }
  15683. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15684. // It returns an error if the edge is not defined in the schema.
  15685. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  15686. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  15687. }
  15688. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  15689. type CreditBalanceMutation struct {
  15690. config
  15691. op Op
  15692. typ string
  15693. id *uint64
  15694. created_at *time.Time
  15695. updated_at *time.Time
  15696. deleted_at *time.Time
  15697. user_id *string
  15698. balance *float64
  15699. addbalance *float64
  15700. status *int
  15701. addstatus *int
  15702. organization_id *uint64
  15703. addorganization_id *int64
  15704. clearedFields map[string]struct{}
  15705. done bool
  15706. oldValue func(context.Context) (*CreditBalance, error)
  15707. predicates []predicate.CreditBalance
  15708. }
  15709. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  15710. // creditbalanceOption allows management of the mutation configuration using functional options.
  15711. type creditbalanceOption func(*CreditBalanceMutation)
  15712. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  15713. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  15714. m := &CreditBalanceMutation{
  15715. config: c,
  15716. op: op,
  15717. typ: TypeCreditBalance,
  15718. clearedFields: make(map[string]struct{}),
  15719. }
  15720. for _, opt := range opts {
  15721. opt(m)
  15722. }
  15723. return m
  15724. }
  15725. // withCreditBalanceID sets the ID field of the mutation.
  15726. func withCreditBalanceID(id uint64) creditbalanceOption {
  15727. return func(m *CreditBalanceMutation) {
  15728. var (
  15729. err error
  15730. once sync.Once
  15731. value *CreditBalance
  15732. )
  15733. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  15734. once.Do(func() {
  15735. if m.done {
  15736. err = errors.New("querying old values post mutation is not allowed")
  15737. } else {
  15738. value, err = m.Client().CreditBalance.Get(ctx, id)
  15739. }
  15740. })
  15741. return value, err
  15742. }
  15743. m.id = &id
  15744. }
  15745. }
  15746. // withCreditBalance sets the old CreditBalance of the mutation.
  15747. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  15748. return func(m *CreditBalanceMutation) {
  15749. m.oldValue = func(context.Context) (*CreditBalance, error) {
  15750. return node, nil
  15751. }
  15752. m.id = &node.ID
  15753. }
  15754. }
  15755. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15756. // executed in a transaction (ent.Tx), a transactional client is returned.
  15757. func (m CreditBalanceMutation) Client() *Client {
  15758. client := &Client{config: m.config}
  15759. client.init()
  15760. return client
  15761. }
  15762. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15763. // it returns an error otherwise.
  15764. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  15765. if _, ok := m.driver.(*txDriver); !ok {
  15766. return nil, errors.New("ent: mutation is not running in a transaction")
  15767. }
  15768. tx := &Tx{config: m.config}
  15769. tx.init()
  15770. return tx, nil
  15771. }
  15772. // SetID sets the value of the id field. Note that this
  15773. // operation is only accepted on creation of CreditBalance entities.
  15774. func (m *CreditBalanceMutation) SetID(id uint64) {
  15775. m.id = &id
  15776. }
  15777. // ID returns the ID value in the mutation. Note that the ID is only available
  15778. // if it was provided to the builder or after it was returned from the database.
  15779. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  15780. if m.id == nil {
  15781. return
  15782. }
  15783. return *m.id, true
  15784. }
  15785. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15786. // That means, if the mutation is applied within a transaction with an isolation level such
  15787. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15788. // or updated by the mutation.
  15789. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  15790. switch {
  15791. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15792. id, exists := m.ID()
  15793. if exists {
  15794. return []uint64{id}, nil
  15795. }
  15796. fallthrough
  15797. case m.op.Is(OpUpdate | OpDelete):
  15798. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  15799. default:
  15800. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15801. }
  15802. }
  15803. // SetCreatedAt sets the "created_at" field.
  15804. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  15805. m.created_at = &t
  15806. }
  15807. // CreatedAt returns the value of the "created_at" field in the mutation.
  15808. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  15809. v := m.created_at
  15810. if v == nil {
  15811. return
  15812. }
  15813. return *v, true
  15814. }
  15815. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  15816. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15818. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15819. if !m.op.Is(OpUpdateOne) {
  15820. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15821. }
  15822. if m.id == nil || m.oldValue == nil {
  15823. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15824. }
  15825. oldValue, err := m.oldValue(ctx)
  15826. if err != nil {
  15827. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15828. }
  15829. return oldValue.CreatedAt, nil
  15830. }
  15831. // ResetCreatedAt resets all changes to the "created_at" field.
  15832. func (m *CreditBalanceMutation) ResetCreatedAt() {
  15833. m.created_at = nil
  15834. }
  15835. // SetUpdatedAt sets the "updated_at" field.
  15836. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  15837. m.updated_at = &t
  15838. }
  15839. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15840. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  15841. v := m.updated_at
  15842. if v == nil {
  15843. return
  15844. }
  15845. return *v, true
  15846. }
  15847. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  15848. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15850. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15851. if !m.op.Is(OpUpdateOne) {
  15852. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15853. }
  15854. if m.id == nil || m.oldValue == nil {
  15855. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15856. }
  15857. oldValue, err := m.oldValue(ctx)
  15858. if err != nil {
  15859. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15860. }
  15861. return oldValue.UpdatedAt, nil
  15862. }
  15863. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15864. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  15865. m.updated_at = nil
  15866. }
  15867. // SetDeletedAt sets the "deleted_at" field.
  15868. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  15869. m.deleted_at = &t
  15870. }
  15871. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15872. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  15873. v := m.deleted_at
  15874. if v == nil {
  15875. return
  15876. }
  15877. return *v, true
  15878. }
  15879. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  15880. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15882. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15883. if !m.op.Is(OpUpdateOne) {
  15884. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15885. }
  15886. if m.id == nil || m.oldValue == nil {
  15887. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15888. }
  15889. oldValue, err := m.oldValue(ctx)
  15890. if err != nil {
  15891. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15892. }
  15893. return oldValue.DeletedAt, nil
  15894. }
  15895. // ClearDeletedAt clears the value of the "deleted_at" field.
  15896. func (m *CreditBalanceMutation) ClearDeletedAt() {
  15897. m.deleted_at = nil
  15898. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  15899. }
  15900. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15901. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  15902. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  15903. return ok
  15904. }
  15905. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15906. func (m *CreditBalanceMutation) ResetDeletedAt() {
  15907. m.deleted_at = nil
  15908. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  15909. }
  15910. // SetUserID sets the "user_id" field.
  15911. func (m *CreditBalanceMutation) SetUserID(s string) {
  15912. m.user_id = &s
  15913. }
  15914. // UserID returns the value of the "user_id" field in the mutation.
  15915. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  15916. v := m.user_id
  15917. if v == nil {
  15918. return
  15919. }
  15920. return *v, true
  15921. }
  15922. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  15923. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15925. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  15926. if !m.op.Is(OpUpdateOne) {
  15927. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15928. }
  15929. if m.id == nil || m.oldValue == nil {
  15930. return v, errors.New("OldUserID requires an ID field in the mutation")
  15931. }
  15932. oldValue, err := m.oldValue(ctx)
  15933. if err != nil {
  15934. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15935. }
  15936. return oldValue.UserID, nil
  15937. }
  15938. // ClearUserID clears the value of the "user_id" field.
  15939. func (m *CreditBalanceMutation) ClearUserID() {
  15940. m.user_id = nil
  15941. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  15942. }
  15943. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15944. func (m *CreditBalanceMutation) UserIDCleared() bool {
  15945. _, ok := m.clearedFields[creditbalance.FieldUserID]
  15946. return ok
  15947. }
  15948. // ResetUserID resets all changes to the "user_id" field.
  15949. func (m *CreditBalanceMutation) ResetUserID() {
  15950. m.user_id = nil
  15951. delete(m.clearedFields, creditbalance.FieldUserID)
  15952. }
  15953. // SetBalance sets the "balance" field.
  15954. func (m *CreditBalanceMutation) SetBalance(f float64) {
  15955. m.balance = &f
  15956. m.addbalance = nil
  15957. }
  15958. // Balance returns the value of the "balance" field in the mutation.
  15959. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  15960. v := m.balance
  15961. if v == nil {
  15962. return
  15963. }
  15964. return *v, true
  15965. }
  15966. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  15967. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15969. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  15970. if !m.op.Is(OpUpdateOne) {
  15971. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  15972. }
  15973. if m.id == nil || m.oldValue == nil {
  15974. return v, errors.New("OldBalance requires an ID field in the mutation")
  15975. }
  15976. oldValue, err := m.oldValue(ctx)
  15977. if err != nil {
  15978. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  15979. }
  15980. return oldValue.Balance, nil
  15981. }
  15982. // AddBalance adds f to the "balance" field.
  15983. func (m *CreditBalanceMutation) AddBalance(f float64) {
  15984. if m.addbalance != nil {
  15985. *m.addbalance += f
  15986. } else {
  15987. m.addbalance = &f
  15988. }
  15989. }
  15990. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  15991. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  15992. v := m.addbalance
  15993. if v == nil {
  15994. return
  15995. }
  15996. return *v, true
  15997. }
  15998. // ResetBalance resets all changes to the "balance" field.
  15999. func (m *CreditBalanceMutation) ResetBalance() {
  16000. m.balance = nil
  16001. m.addbalance = nil
  16002. }
  16003. // SetStatus sets the "status" field.
  16004. func (m *CreditBalanceMutation) SetStatus(i int) {
  16005. m.status = &i
  16006. m.addstatus = nil
  16007. }
  16008. // Status returns the value of the "status" field in the mutation.
  16009. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  16010. v := m.status
  16011. if v == nil {
  16012. return
  16013. }
  16014. return *v, true
  16015. }
  16016. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  16017. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16019. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  16020. if !m.op.Is(OpUpdateOne) {
  16021. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16022. }
  16023. if m.id == nil || m.oldValue == nil {
  16024. return v, errors.New("OldStatus requires an ID field in the mutation")
  16025. }
  16026. oldValue, err := m.oldValue(ctx)
  16027. if err != nil {
  16028. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16029. }
  16030. return oldValue.Status, nil
  16031. }
  16032. // AddStatus adds i to the "status" field.
  16033. func (m *CreditBalanceMutation) AddStatus(i int) {
  16034. if m.addstatus != nil {
  16035. *m.addstatus += i
  16036. } else {
  16037. m.addstatus = &i
  16038. }
  16039. }
  16040. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16041. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  16042. v := m.addstatus
  16043. if v == nil {
  16044. return
  16045. }
  16046. return *v, true
  16047. }
  16048. // ClearStatus clears the value of the "status" field.
  16049. func (m *CreditBalanceMutation) ClearStatus() {
  16050. m.status = nil
  16051. m.addstatus = nil
  16052. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  16053. }
  16054. // StatusCleared returns if the "status" field was cleared in this mutation.
  16055. func (m *CreditBalanceMutation) StatusCleared() bool {
  16056. _, ok := m.clearedFields[creditbalance.FieldStatus]
  16057. return ok
  16058. }
  16059. // ResetStatus resets all changes to the "status" field.
  16060. func (m *CreditBalanceMutation) ResetStatus() {
  16061. m.status = nil
  16062. m.addstatus = nil
  16063. delete(m.clearedFields, creditbalance.FieldStatus)
  16064. }
  16065. // SetOrganizationID sets the "organization_id" field.
  16066. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  16067. m.organization_id = &u
  16068. m.addorganization_id = nil
  16069. }
  16070. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16071. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  16072. v := m.organization_id
  16073. if v == nil {
  16074. return
  16075. }
  16076. return *v, true
  16077. }
  16078. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  16079. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16081. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16082. if !m.op.Is(OpUpdateOne) {
  16083. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16084. }
  16085. if m.id == nil || m.oldValue == nil {
  16086. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16087. }
  16088. oldValue, err := m.oldValue(ctx)
  16089. if err != nil {
  16090. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16091. }
  16092. return oldValue.OrganizationID, nil
  16093. }
  16094. // AddOrganizationID adds u to the "organization_id" field.
  16095. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  16096. if m.addorganization_id != nil {
  16097. *m.addorganization_id += u
  16098. } else {
  16099. m.addorganization_id = &u
  16100. }
  16101. }
  16102. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16103. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  16104. v := m.addorganization_id
  16105. if v == nil {
  16106. return
  16107. }
  16108. return *v, true
  16109. }
  16110. // ClearOrganizationID clears the value of the "organization_id" field.
  16111. func (m *CreditBalanceMutation) ClearOrganizationID() {
  16112. m.organization_id = nil
  16113. m.addorganization_id = nil
  16114. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  16115. }
  16116. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16117. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  16118. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  16119. return ok
  16120. }
  16121. // ResetOrganizationID resets all changes to the "organization_id" field.
  16122. func (m *CreditBalanceMutation) ResetOrganizationID() {
  16123. m.organization_id = nil
  16124. m.addorganization_id = nil
  16125. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  16126. }
  16127. // Where appends a list predicates to the CreditBalanceMutation builder.
  16128. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  16129. m.predicates = append(m.predicates, ps...)
  16130. }
  16131. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  16132. // users can use type-assertion to append predicates that do not depend on any generated package.
  16133. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  16134. p := make([]predicate.CreditBalance, len(ps))
  16135. for i := range ps {
  16136. p[i] = ps[i]
  16137. }
  16138. m.Where(p...)
  16139. }
  16140. // Op returns the operation name.
  16141. func (m *CreditBalanceMutation) Op() Op {
  16142. return m.op
  16143. }
  16144. // SetOp allows setting the mutation operation.
  16145. func (m *CreditBalanceMutation) SetOp(op Op) {
  16146. m.op = op
  16147. }
  16148. // Type returns the node type of this mutation (CreditBalance).
  16149. func (m *CreditBalanceMutation) Type() string {
  16150. return m.typ
  16151. }
  16152. // Fields returns all fields that were changed during this mutation. Note that in
  16153. // order to get all numeric fields that were incremented/decremented, call
  16154. // AddedFields().
  16155. func (m *CreditBalanceMutation) Fields() []string {
  16156. fields := make([]string, 0, 7)
  16157. if m.created_at != nil {
  16158. fields = append(fields, creditbalance.FieldCreatedAt)
  16159. }
  16160. if m.updated_at != nil {
  16161. fields = append(fields, creditbalance.FieldUpdatedAt)
  16162. }
  16163. if m.deleted_at != nil {
  16164. fields = append(fields, creditbalance.FieldDeletedAt)
  16165. }
  16166. if m.user_id != nil {
  16167. fields = append(fields, creditbalance.FieldUserID)
  16168. }
  16169. if m.balance != nil {
  16170. fields = append(fields, creditbalance.FieldBalance)
  16171. }
  16172. if m.status != nil {
  16173. fields = append(fields, creditbalance.FieldStatus)
  16174. }
  16175. if m.organization_id != nil {
  16176. fields = append(fields, creditbalance.FieldOrganizationID)
  16177. }
  16178. return fields
  16179. }
  16180. // Field returns the value of a field with the given name. The second boolean
  16181. // return value indicates that this field was not set, or was not defined in the
  16182. // schema.
  16183. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  16184. switch name {
  16185. case creditbalance.FieldCreatedAt:
  16186. return m.CreatedAt()
  16187. case creditbalance.FieldUpdatedAt:
  16188. return m.UpdatedAt()
  16189. case creditbalance.FieldDeletedAt:
  16190. return m.DeletedAt()
  16191. case creditbalance.FieldUserID:
  16192. return m.UserID()
  16193. case creditbalance.FieldBalance:
  16194. return m.Balance()
  16195. case creditbalance.FieldStatus:
  16196. return m.Status()
  16197. case creditbalance.FieldOrganizationID:
  16198. return m.OrganizationID()
  16199. }
  16200. return nil, false
  16201. }
  16202. // OldField returns the old value of the field from the database. An error is
  16203. // returned if the mutation operation is not UpdateOne, or the query to the
  16204. // database failed.
  16205. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16206. switch name {
  16207. case creditbalance.FieldCreatedAt:
  16208. return m.OldCreatedAt(ctx)
  16209. case creditbalance.FieldUpdatedAt:
  16210. return m.OldUpdatedAt(ctx)
  16211. case creditbalance.FieldDeletedAt:
  16212. return m.OldDeletedAt(ctx)
  16213. case creditbalance.FieldUserID:
  16214. return m.OldUserID(ctx)
  16215. case creditbalance.FieldBalance:
  16216. return m.OldBalance(ctx)
  16217. case creditbalance.FieldStatus:
  16218. return m.OldStatus(ctx)
  16219. case creditbalance.FieldOrganizationID:
  16220. return m.OldOrganizationID(ctx)
  16221. }
  16222. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  16223. }
  16224. // SetField sets the value of a field with the given name. It returns an error if
  16225. // the field is not defined in the schema, or if the type mismatched the field
  16226. // type.
  16227. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  16228. switch name {
  16229. case creditbalance.FieldCreatedAt:
  16230. v, ok := value.(time.Time)
  16231. if !ok {
  16232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16233. }
  16234. m.SetCreatedAt(v)
  16235. return nil
  16236. case creditbalance.FieldUpdatedAt:
  16237. v, ok := value.(time.Time)
  16238. if !ok {
  16239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16240. }
  16241. m.SetUpdatedAt(v)
  16242. return nil
  16243. case creditbalance.FieldDeletedAt:
  16244. v, ok := value.(time.Time)
  16245. if !ok {
  16246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16247. }
  16248. m.SetDeletedAt(v)
  16249. return nil
  16250. case creditbalance.FieldUserID:
  16251. v, ok := value.(string)
  16252. if !ok {
  16253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16254. }
  16255. m.SetUserID(v)
  16256. return nil
  16257. case creditbalance.FieldBalance:
  16258. v, ok := value.(float64)
  16259. if !ok {
  16260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16261. }
  16262. m.SetBalance(v)
  16263. return nil
  16264. case creditbalance.FieldStatus:
  16265. v, ok := value.(int)
  16266. if !ok {
  16267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16268. }
  16269. m.SetStatus(v)
  16270. return nil
  16271. case creditbalance.FieldOrganizationID:
  16272. v, ok := value.(uint64)
  16273. if !ok {
  16274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16275. }
  16276. m.SetOrganizationID(v)
  16277. return nil
  16278. }
  16279. return fmt.Errorf("unknown CreditBalance field %s", name)
  16280. }
  16281. // AddedFields returns all numeric fields that were incremented/decremented during
  16282. // this mutation.
  16283. func (m *CreditBalanceMutation) AddedFields() []string {
  16284. var fields []string
  16285. if m.addbalance != nil {
  16286. fields = append(fields, creditbalance.FieldBalance)
  16287. }
  16288. if m.addstatus != nil {
  16289. fields = append(fields, creditbalance.FieldStatus)
  16290. }
  16291. if m.addorganization_id != nil {
  16292. fields = append(fields, creditbalance.FieldOrganizationID)
  16293. }
  16294. return fields
  16295. }
  16296. // AddedField returns the numeric value that was incremented/decremented on a field
  16297. // with the given name. The second boolean return value indicates that this field
  16298. // was not set, or was not defined in the schema.
  16299. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  16300. switch name {
  16301. case creditbalance.FieldBalance:
  16302. return m.AddedBalance()
  16303. case creditbalance.FieldStatus:
  16304. return m.AddedStatus()
  16305. case creditbalance.FieldOrganizationID:
  16306. return m.AddedOrganizationID()
  16307. }
  16308. return nil, false
  16309. }
  16310. // AddField adds the value to the field with the given name. It returns an error if
  16311. // the field is not defined in the schema, or if the type mismatched the field
  16312. // type.
  16313. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  16314. switch name {
  16315. case creditbalance.FieldBalance:
  16316. v, ok := value.(float64)
  16317. if !ok {
  16318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16319. }
  16320. m.AddBalance(v)
  16321. return nil
  16322. case creditbalance.FieldStatus:
  16323. v, ok := value.(int)
  16324. if !ok {
  16325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16326. }
  16327. m.AddStatus(v)
  16328. return nil
  16329. case creditbalance.FieldOrganizationID:
  16330. v, ok := value.(int64)
  16331. if !ok {
  16332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16333. }
  16334. m.AddOrganizationID(v)
  16335. return nil
  16336. }
  16337. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  16338. }
  16339. // ClearedFields returns all nullable fields that were cleared during this
  16340. // mutation.
  16341. func (m *CreditBalanceMutation) ClearedFields() []string {
  16342. var fields []string
  16343. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  16344. fields = append(fields, creditbalance.FieldDeletedAt)
  16345. }
  16346. if m.FieldCleared(creditbalance.FieldUserID) {
  16347. fields = append(fields, creditbalance.FieldUserID)
  16348. }
  16349. if m.FieldCleared(creditbalance.FieldStatus) {
  16350. fields = append(fields, creditbalance.FieldStatus)
  16351. }
  16352. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  16353. fields = append(fields, creditbalance.FieldOrganizationID)
  16354. }
  16355. return fields
  16356. }
  16357. // FieldCleared returns a boolean indicating if a field with the given name was
  16358. // cleared in this mutation.
  16359. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  16360. _, ok := m.clearedFields[name]
  16361. return ok
  16362. }
  16363. // ClearField clears the value of the field with the given name. It returns an
  16364. // error if the field is not defined in the schema.
  16365. func (m *CreditBalanceMutation) ClearField(name string) error {
  16366. switch name {
  16367. case creditbalance.FieldDeletedAt:
  16368. m.ClearDeletedAt()
  16369. return nil
  16370. case creditbalance.FieldUserID:
  16371. m.ClearUserID()
  16372. return nil
  16373. case creditbalance.FieldStatus:
  16374. m.ClearStatus()
  16375. return nil
  16376. case creditbalance.FieldOrganizationID:
  16377. m.ClearOrganizationID()
  16378. return nil
  16379. }
  16380. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  16381. }
  16382. // ResetField resets all changes in the mutation for the field with the given name.
  16383. // It returns an error if the field is not defined in the schema.
  16384. func (m *CreditBalanceMutation) ResetField(name string) error {
  16385. switch name {
  16386. case creditbalance.FieldCreatedAt:
  16387. m.ResetCreatedAt()
  16388. return nil
  16389. case creditbalance.FieldUpdatedAt:
  16390. m.ResetUpdatedAt()
  16391. return nil
  16392. case creditbalance.FieldDeletedAt:
  16393. m.ResetDeletedAt()
  16394. return nil
  16395. case creditbalance.FieldUserID:
  16396. m.ResetUserID()
  16397. return nil
  16398. case creditbalance.FieldBalance:
  16399. m.ResetBalance()
  16400. return nil
  16401. case creditbalance.FieldStatus:
  16402. m.ResetStatus()
  16403. return nil
  16404. case creditbalance.FieldOrganizationID:
  16405. m.ResetOrganizationID()
  16406. return nil
  16407. }
  16408. return fmt.Errorf("unknown CreditBalance field %s", name)
  16409. }
  16410. // AddedEdges returns all edge names that were set/added in this mutation.
  16411. func (m *CreditBalanceMutation) AddedEdges() []string {
  16412. edges := make([]string, 0, 0)
  16413. return edges
  16414. }
  16415. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16416. // name in this mutation.
  16417. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  16418. return nil
  16419. }
  16420. // RemovedEdges returns all edge names that were removed in this mutation.
  16421. func (m *CreditBalanceMutation) RemovedEdges() []string {
  16422. edges := make([]string, 0, 0)
  16423. return edges
  16424. }
  16425. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16426. // the given name in this mutation.
  16427. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  16428. return nil
  16429. }
  16430. // ClearedEdges returns all edge names that were cleared in this mutation.
  16431. func (m *CreditBalanceMutation) ClearedEdges() []string {
  16432. edges := make([]string, 0, 0)
  16433. return edges
  16434. }
  16435. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16436. // was cleared in this mutation.
  16437. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  16438. return false
  16439. }
  16440. // ClearEdge clears the value of the edge with the given name. It returns an error
  16441. // if that edge is not defined in the schema.
  16442. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  16443. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  16444. }
  16445. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16446. // It returns an error if the edge is not defined in the schema.
  16447. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  16448. return fmt.Errorf("unknown CreditBalance edge %s", name)
  16449. }
  16450. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  16451. type CreditUsageMutation struct {
  16452. config
  16453. op Op
  16454. typ string
  16455. id *uint64
  16456. created_at *time.Time
  16457. updated_at *time.Time
  16458. deleted_at *time.Time
  16459. user_id *string
  16460. number *float64
  16461. addnumber *float64
  16462. pay_number *float64
  16463. addpay_number *float64
  16464. before_number *float64
  16465. addbefore_number *float64
  16466. after_number *float64
  16467. addafter_number *float64
  16468. pay_method *int
  16469. addpay_method *int
  16470. status *int
  16471. addstatus *int
  16472. ntype *int
  16473. addntype *int
  16474. table *string
  16475. organization_id *uint64
  16476. addorganization_id *int64
  16477. nid *uint64
  16478. addnid *int64
  16479. reason *string
  16480. operator *string
  16481. clearedFields map[string]struct{}
  16482. done bool
  16483. oldValue func(context.Context) (*CreditUsage, error)
  16484. predicates []predicate.CreditUsage
  16485. }
  16486. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  16487. // creditusageOption allows management of the mutation configuration using functional options.
  16488. type creditusageOption func(*CreditUsageMutation)
  16489. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  16490. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  16491. m := &CreditUsageMutation{
  16492. config: c,
  16493. op: op,
  16494. typ: TypeCreditUsage,
  16495. clearedFields: make(map[string]struct{}),
  16496. }
  16497. for _, opt := range opts {
  16498. opt(m)
  16499. }
  16500. return m
  16501. }
  16502. // withCreditUsageID sets the ID field of the mutation.
  16503. func withCreditUsageID(id uint64) creditusageOption {
  16504. return func(m *CreditUsageMutation) {
  16505. var (
  16506. err error
  16507. once sync.Once
  16508. value *CreditUsage
  16509. )
  16510. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  16511. once.Do(func() {
  16512. if m.done {
  16513. err = errors.New("querying old values post mutation is not allowed")
  16514. } else {
  16515. value, err = m.Client().CreditUsage.Get(ctx, id)
  16516. }
  16517. })
  16518. return value, err
  16519. }
  16520. m.id = &id
  16521. }
  16522. }
  16523. // withCreditUsage sets the old CreditUsage of the mutation.
  16524. func withCreditUsage(node *CreditUsage) creditusageOption {
  16525. return func(m *CreditUsageMutation) {
  16526. m.oldValue = func(context.Context) (*CreditUsage, error) {
  16527. return node, nil
  16528. }
  16529. m.id = &node.ID
  16530. }
  16531. }
  16532. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16533. // executed in a transaction (ent.Tx), a transactional client is returned.
  16534. func (m CreditUsageMutation) Client() *Client {
  16535. client := &Client{config: m.config}
  16536. client.init()
  16537. return client
  16538. }
  16539. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16540. // it returns an error otherwise.
  16541. func (m CreditUsageMutation) Tx() (*Tx, error) {
  16542. if _, ok := m.driver.(*txDriver); !ok {
  16543. return nil, errors.New("ent: mutation is not running in a transaction")
  16544. }
  16545. tx := &Tx{config: m.config}
  16546. tx.init()
  16547. return tx, nil
  16548. }
  16549. // SetID sets the value of the id field. Note that this
  16550. // operation is only accepted on creation of CreditUsage entities.
  16551. func (m *CreditUsageMutation) SetID(id uint64) {
  16552. m.id = &id
  16553. }
  16554. // ID returns the ID value in the mutation. Note that the ID is only available
  16555. // if it was provided to the builder or after it was returned from the database.
  16556. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  16557. if m.id == nil {
  16558. return
  16559. }
  16560. return *m.id, true
  16561. }
  16562. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16563. // That means, if the mutation is applied within a transaction with an isolation level such
  16564. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16565. // or updated by the mutation.
  16566. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16567. switch {
  16568. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16569. id, exists := m.ID()
  16570. if exists {
  16571. return []uint64{id}, nil
  16572. }
  16573. fallthrough
  16574. case m.op.Is(OpUpdate | OpDelete):
  16575. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  16576. default:
  16577. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16578. }
  16579. }
  16580. // SetCreatedAt sets the "created_at" field.
  16581. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  16582. m.created_at = &t
  16583. }
  16584. // CreatedAt returns the value of the "created_at" field in the mutation.
  16585. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  16586. v := m.created_at
  16587. if v == nil {
  16588. return
  16589. }
  16590. return *v, true
  16591. }
  16592. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  16593. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16595. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16596. if !m.op.Is(OpUpdateOne) {
  16597. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16598. }
  16599. if m.id == nil || m.oldValue == nil {
  16600. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16601. }
  16602. oldValue, err := m.oldValue(ctx)
  16603. if err != nil {
  16604. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16605. }
  16606. return oldValue.CreatedAt, nil
  16607. }
  16608. // ResetCreatedAt resets all changes to the "created_at" field.
  16609. func (m *CreditUsageMutation) ResetCreatedAt() {
  16610. m.created_at = nil
  16611. }
  16612. // SetUpdatedAt sets the "updated_at" field.
  16613. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  16614. m.updated_at = &t
  16615. }
  16616. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16617. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  16618. v := m.updated_at
  16619. if v == nil {
  16620. return
  16621. }
  16622. return *v, true
  16623. }
  16624. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  16625. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16627. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16628. if !m.op.Is(OpUpdateOne) {
  16629. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16630. }
  16631. if m.id == nil || m.oldValue == nil {
  16632. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16633. }
  16634. oldValue, err := m.oldValue(ctx)
  16635. if err != nil {
  16636. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16637. }
  16638. return oldValue.UpdatedAt, nil
  16639. }
  16640. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16641. func (m *CreditUsageMutation) ResetUpdatedAt() {
  16642. m.updated_at = nil
  16643. }
  16644. // SetDeletedAt sets the "deleted_at" field.
  16645. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  16646. m.deleted_at = &t
  16647. }
  16648. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16649. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  16650. v := m.deleted_at
  16651. if v == nil {
  16652. return
  16653. }
  16654. return *v, true
  16655. }
  16656. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  16657. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16659. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16660. if !m.op.Is(OpUpdateOne) {
  16661. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16662. }
  16663. if m.id == nil || m.oldValue == nil {
  16664. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16665. }
  16666. oldValue, err := m.oldValue(ctx)
  16667. if err != nil {
  16668. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16669. }
  16670. return oldValue.DeletedAt, nil
  16671. }
  16672. // ClearDeletedAt clears the value of the "deleted_at" field.
  16673. func (m *CreditUsageMutation) ClearDeletedAt() {
  16674. m.deleted_at = nil
  16675. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  16676. }
  16677. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16678. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  16679. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  16680. return ok
  16681. }
  16682. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16683. func (m *CreditUsageMutation) ResetDeletedAt() {
  16684. m.deleted_at = nil
  16685. delete(m.clearedFields, creditusage.FieldDeletedAt)
  16686. }
  16687. // SetUserID sets the "user_id" field.
  16688. func (m *CreditUsageMutation) SetUserID(s string) {
  16689. m.user_id = &s
  16690. }
  16691. // UserID returns the value of the "user_id" field in the mutation.
  16692. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  16693. v := m.user_id
  16694. if v == nil {
  16695. return
  16696. }
  16697. return *v, true
  16698. }
  16699. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  16700. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16702. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  16703. if !m.op.Is(OpUpdateOne) {
  16704. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16705. }
  16706. if m.id == nil || m.oldValue == nil {
  16707. return v, errors.New("OldUserID requires an ID field in the mutation")
  16708. }
  16709. oldValue, err := m.oldValue(ctx)
  16710. if err != nil {
  16711. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16712. }
  16713. return oldValue.UserID, nil
  16714. }
  16715. // ClearUserID clears the value of the "user_id" field.
  16716. func (m *CreditUsageMutation) ClearUserID() {
  16717. m.user_id = nil
  16718. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  16719. }
  16720. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16721. func (m *CreditUsageMutation) UserIDCleared() bool {
  16722. _, ok := m.clearedFields[creditusage.FieldUserID]
  16723. return ok
  16724. }
  16725. // ResetUserID resets all changes to the "user_id" field.
  16726. func (m *CreditUsageMutation) ResetUserID() {
  16727. m.user_id = nil
  16728. delete(m.clearedFields, creditusage.FieldUserID)
  16729. }
  16730. // SetNumber sets the "number" field.
  16731. func (m *CreditUsageMutation) SetNumber(f float64) {
  16732. m.number = &f
  16733. m.addnumber = nil
  16734. }
  16735. // Number returns the value of the "number" field in the mutation.
  16736. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  16737. v := m.number
  16738. if v == nil {
  16739. return
  16740. }
  16741. return *v, true
  16742. }
  16743. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  16744. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16746. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  16747. if !m.op.Is(OpUpdateOne) {
  16748. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  16749. }
  16750. if m.id == nil || m.oldValue == nil {
  16751. return v, errors.New("OldNumber requires an ID field in the mutation")
  16752. }
  16753. oldValue, err := m.oldValue(ctx)
  16754. if err != nil {
  16755. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  16756. }
  16757. return oldValue.Number, nil
  16758. }
  16759. // AddNumber adds f to the "number" field.
  16760. func (m *CreditUsageMutation) AddNumber(f float64) {
  16761. if m.addnumber != nil {
  16762. *m.addnumber += f
  16763. } else {
  16764. m.addnumber = &f
  16765. }
  16766. }
  16767. // AddedNumber returns the value that was added to the "number" field in this mutation.
  16768. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  16769. v := m.addnumber
  16770. if v == nil {
  16771. return
  16772. }
  16773. return *v, true
  16774. }
  16775. // ResetNumber resets all changes to the "number" field.
  16776. func (m *CreditUsageMutation) ResetNumber() {
  16777. m.number = nil
  16778. m.addnumber = nil
  16779. }
  16780. // SetPayNumber sets the "pay_number" field.
  16781. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  16782. m.pay_number = &f
  16783. m.addpay_number = nil
  16784. }
  16785. // PayNumber returns the value of the "pay_number" field in the mutation.
  16786. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  16787. v := m.pay_number
  16788. if v == nil {
  16789. return
  16790. }
  16791. return *v, true
  16792. }
  16793. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  16794. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16796. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  16797. if !m.op.Is(OpUpdateOne) {
  16798. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  16799. }
  16800. if m.id == nil || m.oldValue == nil {
  16801. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  16802. }
  16803. oldValue, err := m.oldValue(ctx)
  16804. if err != nil {
  16805. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  16806. }
  16807. return oldValue.PayNumber, nil
  16808. }
  16809. // AddPayNumber adds f to the "pay_number" field.
  16810. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  16811. if m.addpay_number != nil {
  16812. *m.addpay_number += f
  16813. } else {
  16814. m.addpay_number = &f
  16815. }
  16816. }
  16817. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  16818. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  16819. v := m.addpay_number
  16820. if v == nil {
  16821. return
  16822. }
  16823. return *v, true
  16824. }
  16825. // ClearPayNumber clears the value of the "pay_number" field.
  16826. func (m *CreditUsageMutation) ClearPayNumber() {
  16827. m.pay_number = nil
  16828. m.addpay_number = nil
  16829. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  16830. }
  16831. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  16832. func (m *CreditUsageMutation) PayNumberCleared() bool {
  16833. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  16834. return ok
  16835. }
  16836. // ResetPayNumber resets all changes to the "pay_number" field.
  16837. func (m *CreditUsageMutation) ResetPayNumber() {
  16838. m.pay_number = nil
  16839. m.addpay_number = nil
  16840. delete(m.clearedFields, creditusage.FieldPayNumber)
  16841. }
  16842. // SetBeforeNumber sets the "before_number" field.
  16843. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  16844. m.before_number = &f
  16845. m.addbefore_number = nil
  16846. }
  16847. // BeforeNumber returns the value of the "before_number" field in the mutation.
  16848. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  16849. v := m.before_number
  16850. if v == nil {
  16851. return
  16852. }
  16853. return *v, true
  16854. }
  16855. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  16856. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16858. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  16859. if !m.op.Is(OpUpdateOne) {
  16860. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  16861. }
  16862. if m.id == nil || m.oldValue == nil {
  16863. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  16864. }
  16865. oldValue, err := m.oldValue(ctx)
  16866. if err != nil {
  16867. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  16868. }
  16869. return oldValue.BeforeNumber, nil
  16870. }
  16871. // AddBeforeNumber adds f to the "before_number" field.
  16872. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  16873. if m.addbefore_number != nil {
  16874. *m.addbefore_number += f
  16875. } else {
  16876. m.addbefore_number = &f
  16877. }
  16878. }
  16879. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  16880. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  16881. v := m.addbefore_number
  16882. if v == nil {
  16883. return
  16884. }
  16885. return *v, true
  16886. }
  16887. // ClearBeforeNumber clears the value of the "before_number" field.
  16888. func (m *CreditUsageMutation) ClearBeforeNumber() {
  16889. m.before_number = nil
  16890. m.addbefore_number = nil
  16891. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  16892. }
  16893. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  16894. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  16895. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  16896. return ok
  16897. }
  16898. // ResetBeforeNumber resets all changes to the "before_number" field.
  16899. func (m *CreditUsageMutation) ResetBeforeNumber() {
  16900. m.before_number = nil
  16901. m.addbefore_number = nil
  16902. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  16903. }
  16904. // SetAfterNumber sets the "after_number" field.
  16905. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  16906. m.after_number = &f
  16907. m.addafter_number = nil
  16908. }
  16909. // AfterNumber returns the value of the "after_number" field in the mutation.
  16910. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  16911. v := m.after_number
  16912. if v == nil {
  16913. return
  16914. }
  16915. return *v, true
  16916. }
  16917. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  16918. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16920. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  16921. if !m.op.Is(OpUpdateOne) {
  16922. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  16923. }
  16924. if m.id == nil || m.oldValue == nil {
  16925. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  16926. }
  16927. oldValue, err := m.oldValue(ctx)
  16928. if err != nil {
  16929. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  16930. }
  16931. return oldValue.AfterNumber, nil
  16932. }
  16933. // AddAfterNumber adds f to the "after_number" field.
  16934. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  16935. if m.addafter_number != nil {
  16936. *m.addafter_number += f
  16937. } else {
  16938. m.addafter_number = &f
  16939. }
  16940. }
  16941. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  16942. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  16943. v := m.addafter_number
  16944. if v == nil {
  16945. return
  16946. }
  16947. return *v, true
  16948. }
  16949. // ClearAfterNumber clears the value of the "after_number" field.
  16950. func (m *CreditUsageMutation) ClearAfterNumber() {
  16951. m.after_number = nil
  16952. m.addafter_number = nil
  16953. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  16954. }
  16955. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  16956. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  16957. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  16958. return ok
  16959. }
  16960. // ResetAfterNumber resets all changes to the "after_number" field.
  16961. func (m *CreditUsageMutation) ResetAfterNumber() {
  16962. m.after_number = nil
  16963. m.addafter_number = nil
  16964. delete(m.clearedFields, creditusage.FieldAfterNumber)
  16965. }
  16966. // SetPayMethod sets the "pay_method" field.
  16967. func (m *CreditUsageMutation) SetPayMethod(i int) {
  16968. m.pay_method = &i
  16969. m.addpay_method = nil
  16970. }
  16971. // PayMethod returns the value of the "pay_method" field in the mutation.
  16972. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  16973. v := m.pay_method
  16974. if v == nil {
  16975. return
  16976. }
  16977. return *v, true
  16978. }
  16979. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  16980. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16982. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  16983. if !m.op.Is(OpUpdateOne) {
  16984. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  16985. }
  16986. if m.id == nil || m.oldValue == nil {
  16987. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  16988. }
  16989. oldValue, err := m.oldValue(ctx)
  16990. if err != nil {
  16991. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  16992. }
  16993. return oldValue.PayMethod, nil
  16994. }
  16995. // AddPayMethod adds i to the "pay_method" field.
  16996. func (m *CreditUsageMutation) AddPayMethod(i int) {
  16997. if m.addpay_method != nil {
  16998. *m.addpay_method += i
  16999. } else {
  17000. m.addpay_method = &i
  17001. }
  17002. }
  17003. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  17004. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  17005. v := m.addpay_method
  17006. if v == nil {
  17007. return
  17008. }
  17009. return *v, true
  17010. }
  17011. // ClearPayMethod clears the value of the "pay_method" field.
  17012. func (m *CreditUsageMutation) ClearPayMethod() {
  17013. m.pay_method = nil
  17014. m.addpay_method = nil
  17015. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  17016. }
  17017. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  17018. func (m *CreditUsageMutation) PayMethodCleared() bool {
  17019. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  17020. return ok
  17021. }
  17022. // ResetPayMethod resets all changes to the "pay_method" field.
  17023. func (m *CreditUsageMutation) ResetPayMethod() {
  17024. m.pay_method = nil
  17025. m.addpay_method = nil
  17026. delete(m.clearedFields, creditusage.FieldPayMethod)
  17027. }
  17028. // SetStatus sets the "status" field.
  17029. func (m *CreditUsageMutation) SetStatus(i int) {
  17030. m.status = &i
  17031. m.addstatus = nil
  17032. }
  17033. // Status returns the value of the "status" field in the mutation.
  17034. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  17035. v := m.status
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  17042. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17044. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  17045. if !m.op.Is(OpUpdateOne) {
  17046. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17047. }
  17048. if m.id == nil || m.oldValue == nil {
  17049. return v, errors.New("OldStatus requires an ID field in the mutation")
  17050. }
  17051. oldValue, err := m.oldValue(ctx)
  17052. if err != nil {
  17053. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17054. }
  17055. return oldValue.Status, nil
  17056. }
  17057. // AddStatus adds i to the "status" field.
  17058. func (m *CreditUsageMutation) AddStatus(i int) {
  17059. if m.addstatus != nil {
  17060. *m.addstatus += i
  17061. } else {
  17062. m.addstatus = &i
  17063. }
  17064. }
  17065. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17066. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  17067. v := m.addstatus
  17068. if v == nil {
  17069. return
  17070. }
  17071. return *v, true
  17072. }
  17073. // ClearStatus clears the value of the "status" field.
  17074. func (m *CreditUsageMutation) ClearStatus() {
  17075. m.status = nil
  17076. m.addstatus = nil
  17077. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  17078. }
  17079. // StatusCleared returns if the "status" field was cleared in this mutation.
  17080. func (m *CreditUsageMutation) StatusCleared() bool {
  17081. _, ok := m.clearedFields[creditusage.FieldStatus]
  17082. return ok
  17083. }
  17084. // ResetStatus resets all changes to the "status" field.
  17085. func (m *CreditUsageMutation) ResetStatus() {
  17086. m.status = nil
  17087. m.addstatus = nil
  17088. delete(m.clearedFields, creditusage.FieldStatus)
  17089. }
  17090. // SetNtype sets the "ntype" field.
  17091. func (m *CreditUsageMutation) SetNtype(i int) {
  17092. m.ntype = &i
  17093. m.addntype = nil
  17094. }
  17095. // Ntype returns the value of the "ntype" field in the mutation.
  17096. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  17097. v := m.ntype
  17098. if v == nil {
  17099. return
  17100. }
  17101. return *v, true
  17102. }
  17103. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  17104. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17106. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  17107. if !m.op.Is(OpUpdateOne) {
  17108. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  17109. }
  17110. if m.id == nil || m.oldValue == nil {
  17111. return v, errors.New("OldNtype requires an ID field in the mutation")
  17112. }
  17113. oldValue, err := m.oldValue(ctx)
  17114. if err != nil {
  17115. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  17116. }
  17117. return oldValue.Ntype, nil
  17118. }
  17119. // AddNtype adds i to the "ntype" field.
  17120. func (m *CreditUsageMutation) AddNtype(i int) {
  17121. if m.addntype != nil {
  17122. *m.addntype += i
  17123. } else {
  17124. m.addntype = &i
  17125. }
  17126. }
  17127. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  17128. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  17129. v := m.addntype
  17130. if v == nil {
  17131. return
  17132. }
  17133. return *v, true
  17134. }
  17135. // ResetNtype resets all changes to the "ntype" field.
  17136. func (m *CreditUsageMutation) ResetNtype() {
  17137. m.ntype = nil
  17138. m.addntype = nil
  17139. }
  17140. // SetTable sets the "table" field.
  17141. func (m *CreditUsageMutation) SetTable(s string) {
  17142. m.table = &s
  17143. }
  17144. // Table returns the value of the "table" field in the mutation.
  17145. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  17146. v := m.table
  17147. if v == nil {
  17148. return
  17149. }
  17150. return *v, true
  17151. }
  17152. // OldTable returns the old "table" field's value of the CreditUsage entity.
  17153. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17155. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  17156. if !m.op.Is(OpUpdateOne) {
  17157. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  17158. }
  17159. if m.id == nil || m.oldValue == nil {
  17160. return v, errors.New("OldTable requires an ID field in the mutation")
  17161. }
  17162. oldValue, err := m.oldValue(ctx)
  17163. if err != nil {
  17164. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  17165. }
  17166. return oldValue.Table, nil
  17167. }
  17168. // ResetTable resets all changes to the "table" field.
  17169. func (m *CreditUsageMutation) ResetTable() {
  17170. m.table = nil
  17171. }
  17172. // SetOrganizationID sets the "organization_id" field.
  17173. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  17174. m.organization_id = &u
  17175. m.addorganization_id = nil
  17176. }
  17177. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17178. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  17179. v := m.organization_id
  17180. if v == nil {
  17181. return
  17182. }
  17183. return *v, true
  17184. }
  17185. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  17186. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17188. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17189. if !m.op.Is(OpUpdateOne) {
  17190. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17191. }
  17192. if m.id == nil || m.oldValue == nil {
  17193. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17194. }
  17195. oldValue, err := m.oldValue(ctx)
  17196. if err != nil {
  17197. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17198. }
  17199. return oldValue.OrganizationID, nil
  17200. }
  17201. // AddOrganizationID adds u to the "organization_id" field.
  17202. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  17203. if m.addorganization_id != nil {
  17204. *m.addorganization_id += u
  17205. } else {
  17206. m.addorganization_id = &u
  17207. }
  17208. }
  17209. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17210. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  17211. v := m.addorganization_id
  17212. if v == nil {
  17213. return
  17214. }
  17215. return *v, true
  17216. }
  17217. // ClearOrganizationID clears the value of the "organization_id" field.
  17218. func (m *CreditUsageMutation) ClearOrganizationID() {
  17219. m.organization_id = nil
  17220. m.addorganization_id = nil
  17221. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  17222. }
  17223. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17224. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  17225. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  17226. return ok
  17227. }
  17228. // ResetOrganizationID resets all changes to the "organization_id" field.
  17229. func (m *CreditUsageMutation) ResetOrganizationID() {
  17230. m.organization_id = nil
  17231. m.addorganization_id = nil
  17232. delete(m.clearedFields, creditusage.FieldOrganizationID)
  17233. }
  17234. // SetNid sets the "nid" field.
  17235. func (m *CreditUsageMutation) SetNid(u uint64) {
  17236. m.nid = &u
  17237. m.addnid = nil
  17238. }
  17239. // Nid returns the value of the "nid" field in the mutation.
  17240. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  17241. v := m.nid
  17242. if v == nil {
  17243. return
  17244. }
  17245. return *v, true
  17246. }
  17247. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  17248. // If the CreditUsage 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 *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  17251. if !m.op.Is(OpUpdateOne) {
  17252. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  17253. }
  17254. if m.id == nil || m.oldValue == nil {
  17255. return v, errors.New("OldNid 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 OldNid: %w", err)
  17260. }
  17261. return oldValue.Nid, nil
  17262. }
  17263. // AddNid adds u to the "nid" field.
  17264. func (m *CreditUsageMutation) AddNid(u int64) {
  17265. if m.addnid != nil {
  17266. *m.addnid += u
  17267. } else {
  17268. m.addnid = &u
  17269. }
  17270. }
  17271. // AddedNid returns the value that was added to the "nid" field in this mutation.
  17272. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  17273. v := m.addnid
  17274. if v == nil {
  17275. return
  17276. }
  17277. return *v, true
  17278. }
  17279. // ResetNid resets all changes to the "nid" field.
  17280. func (m *CreditUsageMutation) ResetNid() {
  17281. m.nid = nil
  17282. m.addnid = nil
  17283. }
  17284. // SetReason sets the "reason" field.
  17285. func (m *CreditUsageMutation) SetReason(s string) {
  17286. m.reason = &s
  17287. }
  17288. // Reason returns the value of the "reason" field in the mutation.
  17289. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  17290. v := m.reason
  17291. if v == nil {
  17292. return
  17293. }
  17294. return *v, true
  17295. }
  17296. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  17297. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17299. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  17300. if !m.op.Is(OpUpdateOne) {
  17301. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  17302. }
  17303. if m.id == nil || m.oldValue == nil {
  17304. return v, errors.New("OldReason requires an ID field in the mutation")
  17305. }
  17306. oldValue, err := m.oldValue(ctx)
  17307. if err != nil {
  17308. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  17309. }
  17310. return oldValue.Reason, nil
  17311. }
  17312. // ResetReason resets all changes to the "reason" field.
  17313. func (m *CreditUsageMutation) ResetReason() {
  17314. m.reason = nil
  17315. }
  17316. // SetOperator sets the "operator" field.
  17317. func (m *CreditUsageMutation) SetOperator(s string) {
  17318. m.operator = &s
  17319. }
  17320. // Operator returns the value of the "operator" field in the mutation.
  17321. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  17322. v := m.operator
  17323. if v == nil {
  17324. return
  17325. }
  17326. return *v, true
  17327. }
  17328. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  17329. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17331. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  17332. if !m.op.Is(OpUpdateOne) {
  17333. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  17334. }
  17335. if m.id == nil || m.oldValue == nil {
  17336. return v, errors.New("OldOperator requires an ID field in the mutation")
  17337. }
  17338. oldValue, err := m.oldValue(ctx)
  17339. if err != nil {
  17340. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  17341. }
  17342. return oldValue.Operator, nil
  17343. }
  17344. // ResetOperator resets all changes to the "operator" field.
  17345. func (m *CreditUsageMutation) ResetOperator() {
  17346. m.operator = nil
  17347. }
  17348. // Where appends a list predicates to the CreditUsageMutation builder.
  17349. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  17350. m.predicates = append(m.predicates, ps...)
  17351. }
  17352. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  17353. // users can use type-assertion to append predicates that do not depend on any generated package.
  17354. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  17355. p := make([]predicate.CreditUsage, len(ps))
  17356. for i := range ps {
  17357. p[i] = ps[i]
  17358. }
  17359. m.Where(p...)
  17360. }
  17361. // Op returns the operation name.
  17362. func (m *CreditUsageMutation) Op() Op {
  17363. return m.op
  17364. }
  17365. // SetOp allows setting the mutation operation.
  17366. func (m *CreditUsageMutation) SetOp(op Op) {
  17367. m.op = op
  17368. }
  17369. // Type returns the node type of this mutation (CreditUsage).
  17370. func (m *CreditUsageMutation) Type() string {
  17371. return m.typ
  17372. }
  17373. // Fields returns all fields that were changed during this mutation. Note that in
  17374. // order to get all numeric fields that were incremented/decremented, call
  17375. // AddedFields().
  17376. func (m *CreditUsageMutation) Fields() []string {
  17377. fields := make([]string, 0, 16)
  17378. if m.created_at != nil {
  17379. fields = append(fields, creditusage.FieldCreatedAt)
  17380. }
  17381. if m.updated_at != nil {
  17382. fields = append(fields, creditusage.FieldUpdatedAt)
  17383. }
  17384. if m.deleted_at != nil {
  17385. fields = append(fields, creditusage.FieldDeletedAt)
  17386. }
  17387. if m.user_id != nil {
  17388. fields = append(fields, creditusage.FieldUserID)
  17389. }
  17390. if m.number != nil {
  17391. fields = append(fields, creditusage.FieldNumber)
  17392. }
  17393. if m.pay_number != nil {
  17394. fields = append(fields, creditusage.FieldPayNumber)
  17395. }
  17396. if m.before_number != nil {
  17397. fields = append(fields, creditusage.FieldBeforeNumber)
  17398. }
  17399. if m.after_number != nil {
  17400. fields = append(fields, creditusage.FieldAfterNumber)
  17401. }
  17402. if m.pay_method != nil {
  17403. fields = append(fields, creditusage.FieldPayMethod)
  17404. }
  17405. if m.status != nil {
  17406. fields = append(fields, creditusage.FieldStatus)
  17407. }
  17408. if m.ntype != nil {
  17409. fields = append(fields, creditusage.FieldNtype)
  17410. }
  17411. if m.table != nil {
  17412. fields = append(fields, creditusage.FieldTable)
  17413. }
  17414. if m.organization_id != nil {
  17415. fields = append(fields, creditusage.FieldOrganizationID)
  17416. }
  17417. if m.nid != nil {
  17418. fields = append(fields, creditusage.FieldNid)
  17419. }
  17420. if m.reason != nil {
  17421. fields = append(fields, creditusage.FieldReason)
  17422. }
  17423. if m.operator != nil {
  17424. fields = append(fields, creditusage.FieldOperator)
  17425. }
  17426. return fields
  17427. }
  17428. // Field returns the value of a field with the given name. The second boolean
  17429. // return value indicates that this field was not set, or was not defined in the
  17430. // schema.
  17431. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  17432. switch name {
  17433. case creditusage.FieldCreatedAt:
  17434. return m.CreatedAt()
  17435. case creditusage.FieldUpdatedAt:
  17436. return m.UpdatedAt()
  17437. case creditusage.FieldDeletedAt:
  17438. return m.DeletedAt()
  17439. case creditusage.FieldUserID:
  17440. return m.UserID()
  17441. case creditusage.FieldNumber:
  17442. return m.Number()
  17443. case creditusage.FieldPayNumber:
  17444. return m.PayNumber()
  17445. case creditusage.FieldBeforeNumber:
  17446. return m.BeforeNumber()
  17447. case creditusage.FieldAfterNumber:
  17448. return m.AfterNumber()
  17449. case creditusage.FieldPayMethod:
  17450. return m.PayMethod()
  17451. case creditusage.FieldStatus:
  17452. return m.Status()
  17453. case creditusage.FieldNtype:
  17454. return m.Ntype()
  17455. case creditusage.FieldTable:
  17456. return m.Table()
  17457. case creditusage.FieldOrganizationID:
  17458. return m.OrganizationID()
  17459. case creditusage.FieldNid:
  17460. return m.Nid()
  17461. case creditusage.FieldReason:
  17462. return m.Reason()
  17463. case creditusage.FieldOperator:
  17464. return m.Operator()
  17465. }
  17466. return nil, false
  17467. }
  17468. // OldField returns the old value of the field from the database. An error is
  17469. // returned if the mutation operation is not UpdateOne, or the query to the
  17470. // database failed.
  17471. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17472. switch name {
  17473. case creditusage.FieldCreatedAt:
  17474. return m.OldCreatedAt(ctx)
  17475. case creditusage.FieldUpdatedAt:
  17476. return m.OldUpdatedAt(ctx)
  17477. case creditusage.FieldDeletedAt:
  17478. return m.OldDeletedAt(ctx)
  17479. case creditusage.FieldUserID:
  17480. return m.OldUserID(ctx)
  17481. case creditusage.FieldNumber:
  17482. return m.OldNumber(ctx)
  17483. case creditusage.FieldPayNumber:
  17484. return m.OldPayNumber(ctx)
  17485. case creditusage.FieldBeforeNumber:
  17486. return m.OldBeforeNumber(ctx)
  17487. case creditusage.FieldAfterNumber:
  17488. return m.OldAfterNumber(ctx)
  17489. case creditusage.FieldPayMethod:
  17490. return m.OldPayMethod(ctx)
  17491. case creditusage.FieldStatus:
  17492. return m.OldStatus(ctx)
  17493. case creditusage.FieldNtype:
  17494. return m.OldNtype(ctx)
  17495. case creditusage.FieldTable:
  17496. return m.OldTable(ctx)
  17497. case creditusage.FieldOrganizationID:
  17498. return m.OldOrganizationID(ctx)
  17499. case creditusage.FieldNid:
  17500. return m.OldNid(ctx)
  17501. case creditusage.FieldReason:
  17502. return m.OldReason(ctx)
  17503. case creditusage.FieldOperator:
  17504. return m.OldOperator(ctx)
  17505. }
  17506. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  17507. }
  17508. // SetField sets the value of a field with the given name. It returns an error if
  17509. // the field is not defined in the schema, or if the type mismatched the field
  17510. // type.
  17511. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  17512. switch name {
  17513. case creditusage.FieldCreatedAt:
  17514. v, ok := value.(time.Time)
  17515. if !ok {
  17516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17517. }
  17518. m.SetCreatedAt(v)
  17519. return nil
  17520. case creditusage.FieldUpdatedAt:
  17521. v, ok := value.(time.Time)
  17522. if !ok {
  17523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17524. }
  17525. m.SetUpdatedAt(v)
  17526. return nil
  17527. case creditusage.FieldDeletedAt:
  17528. v, ok := value.(time.Time)
  17529. if !ok {
  17530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17531. }
  17532. m.SetDeletedAt(v)
  17533. return nil
  17534. case creditusage.FieldUserID:
  17535. v, ok := value.(string)
  17536. if !ok {
  17537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17538. }
  17539. m.SetUserID(v)
  17540. return nil
  17541. case creditusage.FieldNumber:
  17542. v, ok := value.(float64)
  17543. if !ok {
  17544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17545. }
  17546. m.SetNumber(v)
  17547. return nil
  17548. case creditusage.FieldPayNumber:
  17549. v, ok := value.(float64)
  17550. if !ok {
  17551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17552. }
  17553. m.SetPayNumber(v)
  17554. return nil
  17555. case creditusage.FieldBeforeNumber:
  17556. v, ok := value.(float64)
  17557. if !ok {
  17558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17559. }
  17560. m.SetBeforeNumber(v)
  17561. return nil
  17562. case creditusage.FieldAfterNumber:
  17563. v, ok := value.(float64)
  17564. if !ok {
  17565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17566. }
  17567. m.SetAfterNumber(v)
  17568. return nil
  17569. case creditusage.FieldPayMethod:
  17570. v, ok := value.(int)
  17571. if !ok {
  17572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17573. }
  17574. m.SetPayMethod(v)
  17575. return nil
  17576. case creditusage.FieldStatus:
  17577. v, ok := value.(int)
  17578. if !ok {
  17579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17580. }
  17581. m.SetStatus(v)
  17582. return nil
  17583. case creditusage.FieldNtype:
  17584. v, ok := value.(int)
  17585. if !ok {
  17586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17587. }
  17588. m.SetNtype(v)
  17589. return nil
  17590. case creditusage.FieldTable:
  17591. v, ok := value.(string)
  17592. if !ok {
  17593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17594. }
  17595. m.SetTable(v)
  17596. return nil
  17597. case creditusage.FieldOrganizationID:
  17598. v, ok := value.(uint64)
  17599. if !ok {
  17600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17601. }
  17602. m.SetOrganizationID(v)
  17603. return nil
  17604. case creditusage.FieldNid:
  17605. v, ok := value.(uint64)
  17606. if !ok {
  17607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17608. }
  17609. m.SetNid(v)
  17610. return nil
  17611. case creditusage.FieldReason:
  17612. v, ok := value.(string)
  17613. if !ok {
  17614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17615. }
  17616. m.SetReason(v)
  17617. return nil
  17618. case creditusage.FieldOperator:
  17619. v, ok := value.(string)
  17620. if !ok {
  17621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17622. }
  17623. m.SetOperator(v)
  17624. return nil
  17625. }
  17626. return fmt.Errorf("unknown CreditUsage field %s", name)
  17627. }
  17628. // AddedFields returns all numeric fields that were incremented/decremented during
  17629. // this mutation.
  17630. func (m *CreditUsageMutation) AddedFields() []string {
  17631. var fields []string
  17632. if m.addnumber != nil {
  17633. fields = append(fields, creditusage.FieldNumber)
  17634. }
  17635. if m.addpay_number != nil {
  17636. fields = append(fields, creditusage.FieldPayNumber)
  17637. }
  17638. if m.addbefore_number != nil {
  17639. fields = append(fields, creditusage.FieldBeforeNumber)
  17640. }
  17641. if m.addafter_number != nil {
  17642. fields = append(fields, creditusage.FieldAfterNumber)
  17643. }
  17644. if m.addpay_method != nil {
  17645. fields = append(fields, creditusage.FieldPayMethod)
  17646. }
  17647. if m.addstatus != nil {
  17648. fields = append(fields, creditusage.FieldStatus)
  17649. }
  17650. if m.addntype != nil {
  17651. fields = append(fields, creditusage.FieldNtype)
  17652. }
  17653. if m.addorganization_id != nil {
  17654. fields = append(fields, creditusage.FieldOrganizationID)
  17655. }
  17656. if m.addnid != nil {
  17657. fields = append(fields, creditusage.FieldNid)
  17658. }
  17659. return fields
  17660. }
  17661. // AddedField returns the numeric value that was incremented/decremented on a field
  17662. // with the given name. The second boolean return value indicates that this field
  17663. // was not set, or was not defined in the schema.
  17664. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  17665. switch name {
  17666. case creditusage.FieldNumber:
  17667. return m.AddedNumber()
  17668. case creditusage.FieldPayNumber:
  17669. return m.AddedPayNumber()
  17670. case creditusage.FieldBeforeNumber:
  17671. return m.AddedBeforeNumber()
  17672. case creditusage.FieldAfterNumber:
  17673. return m.AddedAfterNumber()
  17674. case creditusage.FieldPayMethod:
  17675. return m.AddedPayMethod()
  17676. case creditusage.FieldStatus:
  17677. return m.AddedStatus()
  17678. case creditusage.FieldNtype:
  17679. return m.AddedNtype()
  17680. case creditusage.FieldOrganizationID:
  17681. return m.AddedOrganizationID()
  17682. case creditusage.FieldNid:
  17683. return m.AddedNid()
  17684. }
  17685. return nil, false
  17686. }
  17687. // AddField adds the value to the field with the given name. It returns an error if
  17688. // the field is not defined in the schema, or if the type mismatched the field
  17689. // type.
  17690. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  17691. switch name {
  17692. case creditusage.FieldNumber:
  17693. v, ok := value.(float64)
  17694. if !ok {
  17695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17696. }
  17697. m.AddNumber(v)
  17698. return nil
  17699. case creditusage.FieldPayNumber:
  17700. v, ok := value.(float64)
  17701. if !ok {
  17702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17703. }
  17704. m.AddPayNumber(v)
  17705. return nil
  17706. case creditusage.FieldBeforeNumber:
  17707. v, ok := value.(float64)
  17708. if !ok {
  17709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17710. }
  17711. m.AddBeforeNumber(v)
  17712. return nil
  17713. case creditusage.FieldAfterNumber:
  17714. v, ok := value.(float64)
  17715. if !ok {
  17716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17717. }
  17718. m.AddAfterNumber(v)
  17719. return nil
  17720. case creditusage.FieldPayMethod:
  17721. v, ok := value.(int)
  17722. if !ok {
  17723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17724. }
  17725. m.AddPayMethod(v)
  17726. return nil
  17727. case creditusage.FieldStatus:
  17728. v, ok := value.(int)
  17729. if !ok {
  17730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17731. }
  17732. m.AddStatus(v)
  17733. return nil
  17734. case creditusage.FieldNtype:
  17735. v, ok := value.(int)
  17736. if !ok {
  17737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17738. }
  17739. m.AddNtype(v)
  17740. return nil
  17741. case creditusage.FieldOrganizationID:
  17742. v, ok := value.(int64)
  17743. if !ok {
  17744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17745. }
  17746. m.AddOrganizationID(v)
  17747. return nil
  17748. case creditusage.FieldNid:
  17749. v, ok := value.(int64)
  17750. if !ok {
  17751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17752. }
  17753. m.AddNid(v)
  17754. return nil
  17755. }
  17756. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  17757. }
  17758. // ClearedFields returns all nullable fields that were cleared during this
  17759. // mutation.
  17760. func (m *CreditUsageMutation) ClearedFields() []string {
  17761. var fields []string
  17762. if m.FieldCleared(creditusage.FieldDeletedAt) {
  17763. fields = append(fields, creditusage.FieldDeletedAt)
  17764. }
  17765. if m.FieldCleared(creditusage.FieldUserID) {
  17766. fields = append(fields, creditusage.FieldUserID)
  17767. }
  17768. if m.FieldCleared(creditusage.FieldPayNumber) {
  17769. fields = append(fields, creditusage.FieldPayNumber)
  17770. }
  17771. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  17772. fields = append(fields, creditusage.FieldBeforeNumber)
  17773. }
  17774. if m.FieldCleared(creditusage.FieldAfterNumber) {
  17775. fields = append(fields, creditusage.FieldAfterNumber)
  17776. }
  17777. if m.FieldCleared(creditusage.FieldPayMethod) {
  17778. fields = append(fields, creditusage.FieldPayMethod)
  17779. }
  17780. if m.FieldCleared(creditusage.FieldStatus) {
  17781. fields = append(fields, creditusage.FieldStatus)
  17782. }
  17783. if m.FieldCleared(creditusage.FieldOrganizationID) {
  17784. fields = append(fields, creditusage.FieldOrganizationID)
  17785. }
  17786. return fields
  17787. }
  17788. // FieldCleared returns a boolean indicating if a field with the given name was
  17789. // cleared in this mutation.
  17790. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  17791. _, ok := m.clearedFields[name]
  17792. return ok
  17793. }
  17794. // ClearField clears the value of the field with the given name. It returns an
  17795. // error if the field is not defined in the schema.
  17796. func (m *CreditUsageMutation) ClearField(name string) error {
  17797. switch name {
  17798. case creditusage.FieldDeletedAt:
  17799. m.ClearDeletedAt()
  17800. return nil
  17801. case creditusage.FieldUserID:
  17802. m.ClearUserID()
  17803. return nil
  17804. case creditusage.FieldPayNumber:
  17805. m.ClearPayNumber()
  17806. return nil
  17807. case creditusage.FieldBeforeNumber:
  17808. m.ClearBeforeNumber()
  17809. return nil
  17810. case creditusage.FieldAfterNumber:
  17811. m.ClearAfterNumber()
  17812. return nil
  17813. case creditusage.FieldPayMethod:
  17814. m.ClearPayMethod()
  17815. return nil
  17816. case creditusage.FieldStatus:
  17817. m.ClearStatus()
  17818. return nil
  17819. case creditusage.FieldOrganizationID:
  17820. m.ClearOrganizationID()
  17821. return nil
  17822. }
  17823. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  17824. }
  17825. // ResetField resets all changes in the mutation for the field with the given name.
  17826. // It returns an error if the field is not defined in the schema.
  17827. func (m *CreditUsageMutation) ResetField(name string) error {
  17828. switch name {
  17829. case creditusage.FieldCreatedAt:
  17830. m.ResetCreatedAt()
  17831. return nil
  17832. case creditusage.FieldUpdatedAt:
  17833. m.ResetUpdatedAt()
  17834. return nil
  17835. case creditusage.FieldDeletedAt:
  17836. m.ResetDeletedAt()
  17837. return nil
  17838. case creditusage.FieldUserID:
  17839. m.ResetUserID()
  17840. return nil
  17841. case creditusage.FieldNumber:
  17842. m.ResetNumber()
  17843. return nil
  17844. case creditusage.FieldPayNumber:
  17845. m.ResetPayNumber()
  17846. return nil
  17847. case creditusage.FieldBeforeNumber:
  17848. m.ResetBeforeNumber()
  17849. return nil
  17850. case creditusage.FieldAfterNumber:
  17851. m.ResetAfterNumber()
  17852. return nil
  17853. case creditusage.FieldPayMethod:
  17854. m.ResetPayMethod()
  17855. return nil
  17856. case creditusage.FieldStatus:
  17857. m.ResetStatus()
  17858. return nil
  17859. case creditusage.FieldNtype:
  17860. m.ResetNtype()
  17861. return nil
  17862. case creditusage.FieldTable:
  17863. m.ResetTable()
  17864. return nil
  17865. case creditusage.FieldOrganizationID:
  17866. m.ResetOrganizationID()
  17867. return nil
  17868. case creditusage.FieldNid:
  17869. m.ResetNid()
  17870. return nil
  17871. case creditusage.FieldReason:
  17872. m.ResetReason()
  17873. return nil
  17874. case creditusage.FieldOperator:
  17875. m.ResetOperator()
  17876. return nil
  17877. }
  17878. return fmt.Errorf("unknown CreditUsage field %s", name)
  17879. }
  17880. // AddedEdges returns all edge names that were set/added in this mutation.
  17881. func (m *CreditUsageMutation) AddedEdges() []string {
  17882. edges := make([]string, 0, 0)
  17883. return edges
  17884. }
  17885. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17886. // name in this mutation.
  17887. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  17888. return nil
  17889. }
  17890. // RemovedEdges returns all edge names that were removed in this mutation.
  17891. func (m *CreditUsageMutation) RemovedEdges() []string {
  17892. edges := make([]string, 0, 0)
  17893. return edges
  17894. }
  17895. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17896. // the given name in this mutation.
  17897. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  17898. return nil
  17899. }
  17900. // ClearedEdges returns all edge names that were cleared in this mutation.
  17901. func (m *CreditUsageMutation) ClearedEdges() []string {
  17902. edges := make([]string, 0, 0)
  17903. return edges
  17904. }
  17905. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17906. // was cleared in this mutation.
  17907. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  17908. return false
  17909. }
  17910. // ClearEdge clears the value of the edge with the given name. It returns an error
  17911. // if that edge is not defined in the schema.
  17912. func (m *CreditUsageMutation) ClearEdge(name string) error {
  17913. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  17914. }
  17915. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17916. // It returns an error if the edge is not defined in the schema.
  17917. func (m *CreditUsageMutation) ResetEdge(name string) error {
  17918. return fmt.Errorf("unknown CreditUsage edge %s", name)
  17919. }
  17920. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  17921. type EmployeeMutation struct {
  17922. config
  17923. op Op
  17924. typ string
  17925. id *uint64
  17926. created_at *time.Time
  17927. updated_at *time.Time
  17928. deleted_at *time.Time
  17929. title *string
  17930. avatar *string
  17931. tags *string
  17932. hire_count *int
  17933. addhire_count *int
  17934. service_count *int
  17935. addservice_count *int
  17936. achievement_count *int
  17937. addachievement_count *int
  17938. intro *string
  17939. estimate *string
  17940. skill *string
  17941. ability_type *string
  17942. scene *string
  17943. switch_in *string
  17944. video_url *string
  17945. organization_id *uint64
  17946. addorganization_id *int64
  17947. category_id *uint64
  17948. addcategory_id *int64
  17949. api_base *string
  17950. api_key *string
  17951. ai_info *string
  17952. is_vip *int
  17953. addis_vip *int
  17954. chat_url *string
  17955. clearedFields map[string]struct{}
  17956. em_work_experiences map[uint64]struct{}
  17957. removedem_work_experiences map[uint64]struct{}
  17958. clearedem_work_experiences bool
  17959. em_tutorial map[uint64]struct{}
  17960. removedem_tutorial map[uint64]struct{}
  17961. clearedem_tutorial bool
  17962. done bool
  17963. oldValue func(context.Context) (*Employee, error)
  17964. predicates []predicate.Employee
  17965. }
  17966. var _ ent.Mutation = (*EmployeeMutation)(nil)
  17967. // employeeOption allows management of the mutation configuration using functional options.
  17968. type employeeOption func(*EmployeeMutation)
  17969. // newEmployeeMutation creates new mutation for the Employee entity.
  17970. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  17971. m := &EmployeeMutation{
  17972. config: c,
  17973. op: op,
  17974. typ: TypeEmployee,
  17975. clearedFields: make(map[string]struct{}),
  17976. }
  17977. for _, opt := range opts {
  17978. opt(m)
  17979. }
  17980. return m
  17981. }
  17982. // withEmployeeID sets the ID field of the mutation.
  17983. func withEmployeeID(id uint64) employeeOption {
  17984. return func(m *EmployeeMutation) {
  17985. var (
  17986. err error
  17987. once sync.Once
  17988. value *Employee
  17989. )
  17990. m.oldValue = func(ctx context.Context) (*Employee, error) {
  17991. once.Do(func() {
  17992. if m.done {
  17993. err = errors.New("querying old values post mutation is not allowed")
  17994. } else {
  17995. value, err = m.Client().Employee.Get(ctx, id)
  17996. }
  17997. })
  17998. return value, err
  17999. }
  18000. m.id = &id
  18001. }
  18002. }
  18003. // withEmployee sets the old Employee of the mutation.
  18004. func withEmployee(node *Employee) employeeOption {
  18005. return func(m *EmployeeMutation) {
  18006. m.oldValue = func(context.Context) (*Employee, error) {
  18007. return node, nil
  18008. }
  18009. m.id = &node.ID
  18010. }
  18011. }
  18012. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18013. // executed in a transaction (ent.Tx), a transactional client is returned.
  18014. func (m EmployeeMutation) Client() *Client {
  18015. client := &Client{config: m.config}
  18016. client.init()
  18017. return client
  18018. }
  18019. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18020. // it returns an error otherwise.
  18021. func (m EmployeeMutation) Tx() (*Tx, error) {
  18022. if _, ok := m.driver.(*txDriver); !ok {
  18023. return nil, errors.New("ent: mutation is not running in a transaction")
  18024. }
  18025. tx := &Tx{config: m.config}
  18026. tx.init()
  18027. return tx, nil
  18028. }
  18029. // SetID sets the value of the id field. Note that this
  18030. // operation is only accepted on creation of Employee entities.
  18031. func (m *EmployeeMutation) SetID(id uint64) {
  18032. m.id = &id
  18033. }
  18034. // ID returns the ID value in the mutation. Note that the ID is only available
  18035. // if it was provided to the builder or after it was returned from the database.
  18036. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  18037. if m.id == nil {
  18038. return
  18039. }
  18040. return *m.id, true
  18041. }
  18042. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18043. // That means, if the mutation is applied within a transaction with an isolation level such
  18044. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18045. // or updated by the mutation.
  18046. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  18047. switch {
  18048. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18049. id, exists := m.ID()
  18050. if exists {
  18051. return []uint64{id}, nil
  18052. }
  18053. fallthrough
  18054. case m.op.Is(OpUpdate | OpDelete):
  18055. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  18056. default:
  18057. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18058. }
  18059. }
  18060. // SetCreatedAt sets the "created_at" field.
  18061. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  18062. m.created_at = &t
  18063. }
  18064. // CreatedAt returns the value of the "created_at" field in the mutation.
  18065. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  18066. v := m.created_at
  18067. if v == nil {
  18068. return
  18069. }
  18070. return *v, true
  18071. }
  18072. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  18073. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18075. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18076. if !m.op.Is(OpUpdateOne) {
  18077. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18078. }
  18079. if m.id == nil || m.oldValue == nil {
  18080. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18081. }
  18082. oldValue, err := m.oldValue(ctx)
  18083. if err != nil {
  18084. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18085. }
  18086. return oldValue.CreatedAt, nil
  18087. }
  18088. // ResetCreatedAt resets all changes to the "created_at" field.
  18089. func (m *EmployeeMutation) ResetCreatedAt() {
  18090. m.created_at = nil
  18091. }
  18092. // SetUpdatedAt sets the "updated_at" field.
  18093. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  18094. m.updated_at = &t
  18095. }
  18096. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18097. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  18098. v := m.updated_at
  18099. if v == nil {
  18100. return
  18101. }
  18102. return *v, true
  18103. }
  18104. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  18105. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18107. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18108. if !m.op.Is(OpUpdateOne) {
  18109. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18110. }
  18111. if m.id == nil || m.oldValue == nil {
  18112. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18113. }
  18114. oldValue, err := m.oldValue(ctx)
  18115. if err != nil {
  18116. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18117. }
  18118. return oldValue.UpdatedAt, nil
  18119. }
  18120. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18121. func (m *EmployeeMutation) ResetUpdatedAt() {
  18122. m.updated_at = nil
  18123. }
  18124. // SetDeletedAt sets the "deleted_at" field.
  18125. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  18126. m.deleted_at = &t
  18127. }
  18128. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18129. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  18130. v := m.deleted_at
  18131. if v == nil {
  18132. return
  18133. }
  18134. return *v, true
  18135. }
  18136. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  18137. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18139. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18140. if !m.op.Is(OpUpdateOne) {
  18141. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18142. }
  18143. if m.id == nil || m.oldValue == nil {
  18144. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18145. }
  18146. oldValue, err := m.oldValue(ctx)
  18147. if err != nil {
  18148. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18149. }
  18150. return oldValue.DeletedAt, nil
  18151. }
  18152. // ClearDeletedAt clears the value of the "deleted_at" field.
  18153. func (m *EmployeeMutation) ClearDeletedAt() {
  18154. m.deleted_at = nil
  18155. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  18156. }
  18157. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18158. func (m *EmployeeMutation) DeletedAtCleared() bool {
  18159. _, ok := m.clearedFields[employee.FieldDeletedAt]
  18160. return ok
  18161. }
  18162. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18163. func (m *EmployeeMutation) ResetDeletedAt() {
  18164. m.deleted_at = nil
  18165. delete(m.clearedFields, employee.FieldDeletedAt)
  18166. }
  18167. // SetTitle sets the "title" field.
  18168. func (m *EmployeeMutation) SetTitle(s string) {
  18169. m.title = &s
  18170. }
  18171. // Title returns the value of the "title" field in the mutation.
  18172. func (m *EmployeeMutation) Title() (r string, exists bool) {
  18173. v := m.title
  18174. if v == nil {
  18175. return
  18176. }
  18177. return *v, true
  18178. }
  18179. // OldTitle returns the old "title" field's value of the Employee entity.
  18180. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18182. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  18183. if !m.op.Is(OpUpdateOne) {
  18184. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18185. }
  18186. if m.id == nil || m.oldValue == nil {
  18187. return v, errors.New("OldTitle requires an ID field in the mutation")
  18188. }
  18189. oldValue, err := m.oldValue(ctx)
  18190. if err != nil {
  18191. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18192. }
  18193. return oldValue.Title, nil
  18194. }
  18195. // ResetTitle resets all changes to the "title" field.
  18196. func (m *EmployeeMutation) ResetTitle() {
  18197. m.title = nil
  18198. }
  18199. // SetAvatar sets the "avatar" field.
  18200. func (m *EmployeeMutation) SetAvatar(s string) {
  18201. m.avatar = &s
  18202. }
  18203. // Avatar returns the value of the "avatar" field in the mutation.
  18204. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  18205. v := m.avatar
  18206. if v == nil {
  18207. return
  18208. }
  18209. return *v, true
  18210. }
  18211. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  18212. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18214. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  18215. if !m.op.Is(OpUpdateOne) {
  18216. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  18217. }
  18218. if m.id == nil || m.oldValue == nil {
  18219. return v, errors.New("OldAvatar requires an ID field in the mutation")
  18220. }
  18221. oldValue, err := m.oldValue(ctx)
  18222. if err != nil {
  18223. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  18224. }
  18225. return oldValue.Avatar, nil
  18226. }
  18227. // ResetAvatar resets all changes to the "avatar" field.
  18228. func (m *EmployeeMutation) ResetAvatar() {
  18229. m.avatar = nil
  18230. }
  18231. // SetTags sets the "tags" field.
  18232. func (m *EmployeeMutation) SetTags(s string) {
  18233. m.tags = &s
  18234. }
  18235. // Tags returns the value of the "tags" field in the mutation.
  18236. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  18237. v := m.tags
  18238. if v == nil {
  18239. return
  18240. }
  18241. return *v, true
  18242. }
  18243. // OldTags returns the old "tags" field's value of the Employee entity.
  18244. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18246. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  18247. if !m.op.Is(OpUpdateOne) {
  18248. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  18249. }
  18250. if m.id == nil || m.oldValue == nil {
  18251. return v, errors.New("OldTags requires an ID field in the mutation")
  18252. }
  18253. oldValue, err := m.oldValue(ctx)
  18254. if err != nil {
  18255. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  18256. }
  18257. return oldValue.Tags, nil
  18258. }
  18259. // ResetTags resets all changes to the "tags" field.
  18260. func (m *EmployeeMutation) ResetTags() {
  18261. m.tags = nil
  18262. }
  18263. // SetHireCount sets the "hire_count" field.
  18264. func (m *EmployeeMutation) SetHireCount(i int) {
  18265. m.hire_count = &i
  18266. m.addhire_count = nil
  18267. }
  18268. // HireCount returns the value of the "hire_count" field in the mutation.
  18269. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  18270. v := m.hire_count
  18271. if v == nil {
  18272. return
  18273. }
  18274. return *v, true
  18275. }
  18276. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  18277. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18279. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  18280. if !m.op.Is(OpUpdateOne) {
  18281. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  18282. }
  18283. if m.id == nil || m.oldValue == nil {
  18284. return v, errors.New("OldHireCount requires an ID field in the mutation")
  18285. }
  18286. oldValue, err := m.oldValue(ctx)
  18287. if err != nil {
  18288. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  18289. }
  18290. return oldValue.HireCount, nil
  18291. }
  18292. // AddHireCount adds i to the "hire_count" field.
  18293. func (m *EmployeeMutation) AddHireCount(i int) {
  18294. if m.addhire_count != nil {
  18295. *m.addhire_count += i
  18296. } else {
  18297. m.addhire_count = &i
  18298. }
  18299. }
  18300. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  18301. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  18302. v := m.addhire_count
  18303. if v == nil {
  18304. return
  18305. }
  18306. return *v, true
  18307. }
  18308. // ResetHireCount resets all changes to the "hire_count" field.
  18309. func (m *EmployeeMutation) ResetHireCount() {
  18310. m.hire_count = nil
  18311. m.addhire_count = nil
  18312. }
  18313. // SetServiceCount sets the "service_count" field.
  18314. func (m *EmployeeMutation) SetServiceCount(i int) {
  18315. m.service_count = &i
  18316. m.addservice_count = nil
  18317. }
  18318. // ServiceCount returns the value of the "service_count" field in the mutation.
  18319. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  18320. v := m.service_count
  18321. if v == nil {
  18322. return
  18323. }
  18324. return *v, true
  18325. }
  18326. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  18327. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18329. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  18330. if !m.op.Is(OpUpdateOne) {
  18331. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  18332. }
  18333. if m.id == nil || m.oldValue == nil {
  18334. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  18335. }
  18336. oldValue, err := m.oldValue(ctx)
  18337. if err != nil {
  18338. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  18339. }
  18340. return oldValue.ServiceCount, nil
  18341. }
  18342. // AddServiceCount adds i to the "service_count" field.
  18343. func (m *EmployeeMutation) AddServiceCount(i int) {
  18344. if m.addservice_count != nil {
  18345. *m.addservice_count += i
  18346. } else {
  18347. m.addservice_count = &i
  18348. }
  18349. }
  18350. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  18351. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  18352. v := m.addservice_count
  18353. if v == nil {
  18354. return
  18355. }
  18356. return *v, true
  18357. }
  18358. // ResetServiceCount resets all changes to the "service_count" field.
  18359. func (m *EmployeeMutation) ResetServiceCount() {
  18360. m.service_count = nil
  18361. m.addservice_count = nil
  18362. }
  18363. // SetAchievementCount sets the "achievement_count" field.
  18364. func (m *EmployeeMutation) SetAchievementCount(i int) {
  18365. m.achievement_count = &i
  18366. m.addachievement_count = nil
  18367. }
  18368. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  18369. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  18370. v := m.achievement_count
  18371. if v == nil {
  18372. return
  18373. }
  18374. return *v, true
  18375. }
  18376. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  18377. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18379. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  18380. if !m.op.Is(OpUpdateOne) {
  18381. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  18382. }
  18383. if m.id == nil || m.oldValue == nil {
  18384. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  18385. }
  18386. oldValue, err := m.oldValue(ctx)
  18387. if err != nil {
  18388. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  18389. }
  18390. return oldValue.AchievementCount, nil
  18391. }
  18392. // AddAchievementCount adds i to the "achievement_count" field.
  18393. func (m *EmployeeMutation) AddAchievementCount(i int) {
  18394. if m.addachievement_count != nil {
  18395. *m.addachievement_count += i
  18396. } else {
  18397. m.addachievement_count = &i
  18398. }
  18399. }
  18400. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  18401. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  18402. v := m.addachievement_count
  18403. if v == nil {
  18404. return
  18405. }
  18406. return *v, true
  18407. }
  18408. // ResetAchievementCount resets all changes to the "achievement_count" field.
  18409. func (m *EmployeeMutation) ResetAchievementCount() {
  18410. m.achievement_count = nil
  18411. m.addachievement_count = nil
  18412. }
  18413. // SetIntro sets the "intro" field.
  18414. func (m *EmployeeMutation) SetIntro(s string) {
  18415. m.intro = &s
  18416. }
  18417. // Intro returns the value of the "intro" field in the mutation.
  18418. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  18419. v := m.intro
  18420. if v == nil {
  18421. return
  18422. }
  18423. return *v, true
  18424. }
  18425. // OldIntro returns the old "intro" field's value of the Employee entity.
  18426. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18428. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  18429. if !m.op.Is(OpUpdateOne) {
  18430. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  18431. }
  18432. if m.id == nil || m.oldValue == nil {
  18433. return v, errors.New("OldIntro requires an ID field in the mutation")
  18434. }
  18435. oldValue, err := m.oldValue(ctx)
  18436. if err != nil {
  18437. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  18438. }
  18439. return oldValue.Intro, nil
  18440. }
  18441. // ResetIntro resets all changes to the "intro" field.
  18442. func (m *EmployeeMutation) ResetIntro() {
  18443. m.intro = nil
  18444. }
  18445. // SetEstimate sets the "estimate" field.
  18446. func (m *EmployeeMutation) SetEstimate(s string) {
  18447. m.estimate = &s
  18448. }
  18449. // Estimate returns the value of the "estimate" field in the mutation.
  18450. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  18451. v := m.estimate
  18452. if v == nil {
  18453. return
  18454. }
  18455. return *v, true
  18456. }
  18457. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  18458. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18460. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  18461. if !m.op.Is(OpUpdateOne) {
  18462. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  18463. }
  18464. if m.id == nil || m.oldValue == nil {
  18465. return v, errors.New("OldEstimate requires an ID field in the mutation")
  18466. }
  18467. oldValue, err := m.oldValue(ctx)
  18468. if err != nil {
  18469. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  18470. }
  18471. return oldValue.Estimate, nil
  18472. }
  18473. // ResetEstimate resets all changes to the "estimate" field.
  18474. func (m *EmployeeMutation) ResetEstimate() {
  18475. m.estimate = nil
  18476. }
  18477. // SetSkill sets the "skill" field.
  18478. func (m *EmployeeMutation) SetSkill(s string) {
  18479. m.skill = &s
  18480. }
  18481. // Skill returns the value of the "skill" field in the mutation.
  18482. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  18483. v := m.skill
  18484. if v == nil {
  18485. return
  18486. }
  18487. return *v, true
  18488. }
  18489. // OldSkill returns the old "skill" field's value of the Employee entity.
  18490. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18492. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  18493. if !m.op.Is(OpUpdateOne) {
  18494. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  18495. }
  18496. if m.id == nil || m.oldValue == nil {
  18497. return v, errors.New("OldSkill requires an ID field in the mutation")
  18498. }
  18499. oldValue, err := m.oldValue(ctx)
  18500. if err != nil {
  18501. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  18502. }
  18503. return oldValue.Skill, nil
  18504. }
  18505. // ResetSkill resets all changes to the "skill" field.
  18506. func (m *EmployeeMutation) ResetSkill() {
  18507. m.skill = nil
  18508. }
  18509. // SetAbilityType sets the "ability_type" field.
  18510. func (m *EmployeeMutation) SetAbilityType(s string) {
  18511. m.ability_type = &s
  18512. }
  18513. // AbilityType returns the value of the "ability_type" field in the mutation.
  18514. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  18515. v := m.ability_type
  18516. if v == nil {
  18517. return
  18518. }
  18519. return *v, true
  18520. }
  18521. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  18522. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18524. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  18525. if !m.op.Is(OpUpdateOne) {
  18526. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  18527. }
  18528. if m.id == nil || m.oldValue == nil {
  18529. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  18530. }
  18531. oldValue, err := m.oldValue(ctx)
  18532. if err != nil {
  18533. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  18534. }
  18535. return oldValue.AbilityType, nil
  18536. }
  18537. // ResetAbilityType resets all changes to the "ability_type" field.
  18538. func (m *EmployeeMutation) ResetAbilityType() {
  18539. m.ability_type = nil
  18540. }
  18541. // SetScene sets the "scene" field.
  18542. func (m *EmployeeMutation) SetScene(s string) {
  18543. m.scene = &s
  18544. }
  18545. // Scene returns the value of the "scene" field in the mutation.
  18546. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  18547. v := m.scene
  18548. if v == nil {
  18549. return
  18550. }
  18551. return *v, true
  18552. }
  18553. // OldScene returns the old "scene" field's value of the Employee entity.
  18554. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18556. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  18557. if !m.op.Is(OpUpdateOne) {
  18558. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  18559. }
  18560. if m.id == nil || m.oldValue == nil {
  18561. return v, errors.New("OldScene requires an ID field in the mutation")
  18562. }
  18563. oldValue, err := m.oldValue(ctx)
  18564. if err != nil {
  18565. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  18566. }
  18567. return oldValue.Scene, nil
  18568. }
  18569. // ResetScene resets all changes to the "scene" field.
  18570. func (m *EmployeeMutation) ResetScene() {
  18571. m.scene = nil
  18572. }
  18573. // SetSwitchIn sets the "switch_in" field.
  18574. func (m *EmployeeMutation) SetSwitchIn(s string) {
  18575. m.switch_in = &s
  18576. }
  18577. // SwitchIn returns the value of the "switch_in" field in the mutation.
  18578. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  18579. v := m.switch_in
  18580. if v == nil {
  18581. return
  18582. }
  18583. return *v, true
  18584. }
  18585. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  18586. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18588. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  18589. if !m.op.Is(OpUpdateOne) {
  18590. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  18591. }
  18592. if m.id == nil || m.oldValue == nil {
  18593. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  18594. }
  18595. oldValue, err := m.oldValue(ctx)
  18596. if err != nil {
  18597. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  18598. }
  18599. return oldValue.SwitchIn, nil
  18600. }
  18601. // ResetSwitchIn resets all changes to the "switch_in" field.
  18602. func (m *EmployeeMutation) ResetSwitchIn() {
  18603. m.switch_in = nil
  18604. }
  18605. // SetVideoURL sets the "video_url" field.
  18606. func (m *EmployeeMutation) SetVideoURL(s string) {
  18607. m.video_url = &s
  18608. }
  18609. // VideoURL returns the value of the "video_url" field in the mutation.
  18610. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  18611. v := m.video_url
  18612. if v == nil {
  18613. return
  18614. }
  18615. return *v, true
  18616. }
  18617. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  18618. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18620. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  18621. if !m.op.Is(OpUpdateOne) {
  18622. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  18623. }
  18624. if m.id == nil || m.oldValue == nil {
  18625. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  18626. }
  18627. oldValue, err := m.oldValue(ctx)
  18628. if err != nil {
  18629. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  18630. }
  18631. return oldValue.VideoURL, nil
  18632. }
  18633. // ResetVideoURL resets all changes to the "video_url" field.
  18634. func (m *EmployeeMutation) ResetVideoURL() {
  18635. m.video_url = nil
  18636. }
  18637. // SetOrganizationID sets the "organization_id" field.
  18638. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  18639. m.organization_id = &u
  18640. m.addorganization_id = nil
  18641. }
  18642. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18643. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  18644. v := m.organization_id
  18645. if v == nil {
  18646. return
  18647. }
  18648. return *v, true
  18649. }
  18650. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  18651. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18653. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18654. if !m.op.Is(OpUpdateOne) {
  18655. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18656. }
  18657. if m.id == nil || m.oldValue == nil {
  18658. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18659. }
  18660. oldValue, err := m.oldValue(ctx)
  18661. if err != nil {
  18662. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18663. }
  18664. return oldValue.OrganizationID, nil
  18665. }
  18666. // AddOrganizationID adds u to the "organization_id" field.
  18667. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  18668. if m.addorganization_id != nil {
  18669. *m.addorganization_id += u
  18670. } else {
  18671. m.addorganization_id = &u
  18672. }
  18673. }
  18674. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18675. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  18676. v := m.addorganization_id
  18677. if v == nil {
  18678. return
  18679. }
  18680. return *v, true
  18681. }
  18682. // ResetOrganizationID resets all changes to the "organization_id" field.
  18683. func (m *EmployeeMutation) ResetOrganizationID() {
  18684. m.organization_id = nil
  18685. m.addorganization_id = nil
  18686. }
  18687. // SetCategoryID sets the "category_id" field.
  18688. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  18689. m.category_id = &u
  18690. m.addcategory_id = nil
  18691. }
  18692. // CategoryID returns the value of the "category_id" field in the mutation.
  18693. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  18694. v := m.category_id
  18695. if v == nil {
  18696. return
  18697. }
  18698. return *v, true
  18699. }
  18700. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  18701. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18703. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  18704. if !m.op.Is(OpUpdateOne) {
  18705. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  18706. }
  18707. if m.id == nil || m.oldValue == nil {
  18708. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  18709. }
  18710. oldValue, err := m.oldValue(ctx)
  18711. if err != nil {
  18712. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  18713. }
  18714. return oldValue.CategoryID, nil
  18715. }
  18716. // AddCategoryID adds u to the "category_id" field.
  18717. func (m *EmployeeMutation) AddCategoryID(u int64) {
  18718. if m.addcategory_id != nil {
  18719. *m.addcategory_id += u
  18720. } else {
  18721. m.addcategory_id = &u
  18722. }
  18723. }
  18724. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  18725. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  18726. v := m.addcategory_id
  18727. if v == nil {
  18728. return
  18729. }
  18730. return *v, true
  18731. }
  18732. // ResetCategoryID resets all changes to the "category_id" field.
  18733. func (m *EmployeeMutation) ResetCategoryID() {
  18734. m.category_id = nil
  18735. m.addcategory_id = nil
  18736. }
  18737. // SetAPIBase sets the "api_base" field.
  18738. func (m *EmployeeMutation) SetAPIBase(s string) {
  18739. m.api_base = &s
  18740. }
  18741. // APIBase returns the value of the "api_base" field in the mutation.
  18742. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  18743. v := m.api_base
  18744. if v == nil {
  18745. return
  18746. }
  18747. return *v, true
  18748. }
  18749. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  18750. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18752. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18753. if !m.op.Is(OpUpdateOne) {
  18754. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18755. }
  18756. if m.id == nil || m.oldValue == nil {
  18757. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18758. }
  18759. oldValue, err := m.oldValue(ctx)
  18760. if err != nil {
  18761. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18762. }
  18763. return oldValue.APIBase, nil
  18764. }
  18765. // ResetAPIBase resets all changes to the "api_base" field.
  18766. func (m *EmployeeMutation) ResetAPIBase() {
  18767. m.api_base = nil
  18768. }
  18769. // SetAPIKey sets the "api_key" field.
  18770. func (m *EmployeeMutation) SetAPIKey(s string) {
  18771. m.api_key = &s
  18772. }
  18773. // APIKey returns the value of the "api_key" field in the mutation.
  18774. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  18775. v := m.api_key
  18776. if v == nil {
  18777. return
  18778. }
  18779. return *v, true
  18780. }
  18781. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  18782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18784. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18785. if !m.op.Is(OpUpdateOne) {
  18786. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18787. }
  18788. if m.id == nil || m.oldValue == nil {
  18789. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18790. }
  18791. oldValue, err := m.oldValue(ctx)
  18792. if err != nil {
  18793. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  18794. }
  18795. return oldValue.APIKey, nil
  18796. }
  18797. // ResetAPIKey resets all changes to the "api_key" field.
  18798. func (m *EmployeeMutation) ResetAPIKey() {
  18799. m.api_key = nil
  18800. }
  18801. // SetAiInfo sets the "ai_info" field.
  18802. func (m *EmployeeMutation) SetAiInfo(s string) {
  18803. m.ai_info = &s
  18804. }
  18805. // AiInfo returns the value of the "ai_info" field in the mutation.
  18806. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  18807. v := m.ai_info
  18808. if v == nil {
  18809. return
  18810. }
  18811. return *v, true
  18812. }
  18813. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  18814. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18816. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  18817. if !m.op.Is(OpUpdateOne) {
  18818. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  18819. }
  18820. if m.id == nil || m.oldValue == nil {
  18821. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  18822. }
  18823. oldValue, err := m.oldValue(ctx)
  18824. if err != nil {
  18825. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  18826. }
  18827. return oldValue.AiInfo, nil
  18828. }
  18829. // ClearAiInfo clears the value of the "ai_info" field.
  18830. func (m *EmployeeMutation) ClearAiInfo() {
  18831. m.ai_info = nil
  18832. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  18833. }
  18834. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  18835. func (m *EmployeeMutation) AiInfoCleared() bool {
  18836. _, ok := m.clearedFields[employee.FieldAiInfo]
  18837. return ok
  18838. }
  18839. // ResetAiInfo resets all changes to the "ai_info" field.
  18840. func (m *EmployeeMutation) ResetAiInfo() {
  18841. m.ai_info = nil
  18842. delete(m.clearedFields, employee.FieldAiInfo)
  18843. }
  18844. // SetIsVip sets the "is_vip" field.
  18845. func (m *EmployeeMutation) SetIsVip(i int) {
  18846. m.is_vip = &i
  18847. m.addis_vip = nil
  18848. }
  18849. // IsVip returns the value of the "is_vip" field in the mutation.
  18850. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  18851. v := m.is_vip
  18852. if v == nil {
  18853. return
  18854. }
  18855. return *v, true
  18856. }
  18857. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  18858. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18860. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  18861. if !m.op.Is(OpUpdateOne) {
  18862. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  18863. }
  18864. if m.id == nil || m.oldValue == nil {
  18865. return v, errors.New("OldIsVip requires an ID field in the mutation")
  18866. }
  18867. oldValue, err := m.oldValue(ctx)
  18868. if err != nil {
  18869. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  18870. }
  18871. return oldValue.IsVip, nil
  18872. }
  18873. // AddIsVip adds i to the "is_vip" field.
  18874. func (m *EmployeeMutation) AddIsVip(i int) {
  18875. if m.addis_vip != nil {
  18876. *m.addis_vip += i
  18877. } else {
  18878. m.addis_vip = &i
  18879. }
  18880. }
  18881. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  18882. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  18883. v := m.addis_vip
  18884. if v == nil {
  18885. return
  18886. }
  18887. return *v, true
  18888. }
  18889. // ResetIsVip resets all changes to the "is_vip" field.
  18890. func (m *EmployeeMutation) ResetIsVip() {
  18891. m.is_vip = nil
  18892. m.addis_vip = nil
  18893. }
  18894. // SetChatURL sets the "chat_url" field.
  18895. func (m *EmployeeMutation) SetChatURL(s string) {
  18896. m.chat_url = &s
  18897. }
  18898. // ChatURL returns the value of the "chat_url" field in the mutation.
  18899. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  18900. v := m.chat_url
  18901. if v == nil {
  18902. return
  18903. }
  18904. return *v, true
  18905. }
  18906. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  18907. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18909. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  18910. if !m.op.Is(OpUpdateOne) {
  18911. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  18912. }
  18913. if m.id == nil || m.oldValue == nil {
  18914. return v, errors.New("OldChatURL requires an ID field in the mutation")
  18915. }
  18916. oldValue, err := m.oldValue(ctx)
  18917. if err != nil {
  18918. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  18919. }
  18920. return oldValue.ChatURL, nil
  18921. }
  18922. // ResetChatURL resets all changes to the "chat_url" field.
  18923. func (m *EmployeeMutation) ResetChatURL() {
  18924. m.chat_url = nil
  18925. }
  18926. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  18927. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  18928. if m.em_work_experiences == nil {
  18929. m.em_work_experiences = make(map[uint64]struct{})
  18930. }
  18931. for i := range ids {
  18932. m.em_work_experiences[ids[i]] = struct{}{}
  18933. }
  18934. }
  18935. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  18936. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  18937. m.clearedem_work_experiences = true
  18938. }
  18939. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  18940. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  18941. return m.clearedem_work_experiences
  18942. }
  18943. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  18944. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  18945. if m.removedem_work_experiences == nil {
  18946. m.removedem_work_experiences = make(map[uint64]struct{})
  18947. }
  18948. for i := range ids {
  18949. delete(m.em_work_experiences, ids[i])
  18950. m.removedem_work_experiences[ids[i]] = struct{}{}
  18951. }
  18952. }
  18953. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  18954. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  18955. for id := range m.removedem_work_experiences {
  18956. ids = append(ids, id)
  18957. }
  18958. return
  18959. }
  18960. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  18961. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  18962. for id := range m.em_work_experiences {
  18963. ids = append(ids, id)
  18964. }
  18965. return
  18966. }
  18967. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  18968. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  18969. m.em_work_experiences = nil
  18970. m.clearedem_work_experiences = false
  18971. m.removedem_work_experiences = nil
  18972. }
  18973. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  18974. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  18975. if m.em_tutorial == nil {
  18976. m.em_tutorial = make(map[uint64]struct{})
  18977. }
  18978. for i := range ids {
  18979. m.em_tutorial[ids[i]] = struct{}{}
  18980. }
  18981. }
  18982. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  18983. func (m *EmployeeMutation) ClearEmTutorial() {
  18984. m.clearedem_tutorial = true
  18985. }
  18986. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  18987. func (m *EmployeeMutation) EmTutorialCleared() bool {
  18988. return m.clearedem_tutorial
  18989. }
  18990. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  18991. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  18992. if m.removedem_tutorial == nil {
  18993. m.removedem_tutorial = make(map[uint64]struct{})
  18994. }
  18995. for i := range ids {
  18996. delete(m.em_tutorial, ids[i])
  18997. m.removedem_tutorial[ids[i]] = struct{}{}
  18998. }
  18999. }
  19000. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  19001. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  19002. for id := range m.removedem_tutorial {
  19003. ids = append(ids, id)
  19004. }
  19005. return
  19006. }
  19007. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  19008. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  19009. for id := range m.em_tutorial {
  19010. ids = append(ids, id)
  19011. }
  19012. return
  19013. }
  19014. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  19015. func (m *EmployeeMutation) ResetEmTutorial() {
  19016. m.em_tutorial = nil
  19017. m.clearedem_tutorial = false
  19018. m.removedem_tutorial = nil
  19019. }
  19020. // Where appends a list predicates to the EmployeeMutation builder.
  19021. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  19022. m.predicates = append(m.predicates, ps...)
  19023. }
  19024. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  19025. // users can use type-assertion to append predicates that do not depend on any generated package.
  19026. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  19027. p := make([]predicate.Employee, len(ps))
  19028. for i := range ps {
  19029. p[i] = ps[i]
  19030. }
  19031. m.Where(p...)
  19032. }
  19033. // Op returns the operation name.
  19034. func (m *EmployeeMutation) Op() Op {
  19035. return m.op
  19036. }
  19037. // SetOp allows setting the mutation operation.
  19038. func (m *EmployeeMutation) SetOp(op Op) {
  19039. m.op = op
  19040. }
  19041. // Type returns the node type of this mutation (Employee).
  19042. func (m *EmployeeMutation) Type() string {
  19043. return m.typ
  19044. }
  19045. // Fields returns all fields that were changed during this mutation. Note that in
  19046. // order to get all numeric fields that were incremented/decremented, call
  19047. // AddedFields().
  19048. func (m *EmployeeMutation) Fields() []string {
  19049. fields := make([]string, 0, 23)
  19050. if m.created_at != nil {
  19051. fields = append(fields, employee.FieldCreatedAt)
  19052. }
  19053. if m.updated_at != nil {
  19054. fields = append(fields, employee.FieldUpdatedAt)
  19055. }
  19056. if m.deleted_at != nil {
  19057. fields = append(fields, employee.FieldDeletedAt)
  19058. }
  19059. if m.title != nil {
  19060. fields = append(fields, employee.FieldTitle)
  19061. }
  19062. if m.avatar != nil {
  19063. fields = append(fields, employee.FieldAvatar)
  19064. }
  19065. if m.tags != nil {
  19066. fields = append(fields, employee.FieldTags)
  19067. }
  19068. if m.hire_count != nil {
  19069. fields = append(fields, employee.FieldHireCount)
  19070. }
  19071. if m.service_count != nil {
  19072. fields = append(fields, employee.FieldServiceCount)
  19073. }
  19074. if m.achievement_count != nil {
  19075. fields = append(fields, employee.FieldAchievementCount)
  19076. }
  19077. if m.intro != nil {
  19078. fields = append(fields, employee.FieldIntro)
  19079. }
  19080. if m.estimate != nil {
  19081. fields = append(fields, employee.FieldEstimate)
  19082. }
  19083. if m.skill != nil {
  19084. fields = append(fields, employee.FieldSkill)
  19085. }
  19086. if m.ability_type != nil {
  19087. fields = append(fields, employee.FieldAbilityType)
  19088. }
  19089. if m.scene != nil {
  19090. fields = append(fields, employee.FieldScene)
  19091. }
  19092. if m.switch_in != nil {
  19093. fields = append(fields, employee.FieldSwitchIn)
  19094. }
  19095. if m.video_url != nil {
  19096. fields = append(fields, employee.FieldVideoURL)
  19097. }
  19098. if m.organization_id != nil {
  19099. fields = append(fields, employee.FieldOrganizationID)
  19100. }
  19101. if m.category_id != nil {
  19102. fields = append(fields, employee.FieldCategoryID)
  19103. }
  19104. if m.api_base != nil {
  19105. fields = append(fields, employee.FieldAPIBase)
  19106. }
  19107. if m.api_key != nil {
  19108. fields = append(fields, employee.FieldAPIKey)
  19109. }
  19110. if m.ai_info != nil {
  19111. fields = append(fields, employee.FieldAiInfo)
  19112. }
  19113. if m.is_vip != nil {
  19114. fields = append(fields, employee.FieldIsVip)
  19115. }
  19116. if m.chat_url != nil {
  19117. fields = append(fields, employee.FieldChatURL)
  19118. }
  19119. return fields
  19120. }
  19121. // Field returns the value of a field with the given name. The second boolean
  19122. // return value indicates that this field was not set, or was not defined in the
  19123. // schema.
  19124. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  19125. switch name {
  19126. case employee.FieldCreatedAt:
  19127. return m.CreatedAt()
  19128. case employee.FieldUpdatedAt:
  19129. return m.UpdatedAt()
  19130. case employee.FieldDeletedAt:
  19131. return m.DeletedAt()
  19132. case employee.FieldTitle:
  19133. return m.Title()
  19134. case employee.FieldAvatar:
  19135. return m.Avatar()
  19136. case employee.FieldTags:
  19137. return m.Tags()
  19138. case employee.FieldHireCount:
  19139. return m.HireCount()
  19140. case employee.FieldServiceCount:
  19141. return m.ServiceCount()
  19142. case employee.FieldAchievementCount:
  19143. return m.AchievementCount()
  19144. case employee.FieldIntro:
  19145. return m.Intro()
  19146. case employee.FieldEstimate:
  19147. return m.Estimate()
  19148. case employee.FieldSkill:
  19149. return m.Skill()
  19150. case employee.FieldAbilityType:
  19151. return m.AbilityType()
  19152. case employee.FieldScene:
  19153. return m.Scene()
  19154. case employee.FieldSwitchIn:
  19155. return m.SwitchIn()
  19156. case employee.FieldVideoURL:
  19157. return m.VideoURL()
  19158. case employee.FieldOrganizationID:
  19159. return m.OrganizationID()
  19160. case employee.FieldCategoryID:
  19161. return m.CategoryID()
  19162. case employee.FieldAPIBase:
  19163. return m.APIBase()
  19164. case employee.FieldAPIKey:
  19165. return m.APIKey()
  19166. case employee.FieldAiInfo:
  19167. return m.AiInfo()
  19168. case employee.FieldIsVip:
  19169. return m.IsVip()
  19170. case employee.FieldChatURL:
  19171. return m.ChatURL()
  19172. }
  19173. return nil, false
  19174. }
  19175. // OldField returns the old value of the field from the database. An error is
  19176. // returned if the mutation operation is not UpdateOne, or the query to the
  19177. // database failed.
  19178. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19179. switch name {
  19180. case employee.FieldCreatedAt:
  19181. return m.OldCreatedAt(ctx)
  19182. case employee.FieldUpdatedAt:
  19183. return m.OldUpdatedAt(ctx)
  19184. case employee.FieldDeletedAt:
  19185. return m.OldDeletedAt(ctx)
  19186. case employee.FieldTitle:
  19187. return m.OldTitle(ctx)
  19188. case employee.FieldAvatar:
  19189. return m.OldAvatar(ctx)
  19190. case employee.FieldTags:
  19191. return m.OldTags(ctx)
  19192. case employee.FieldHireCount:
  19193. return m.OldHireCount(ctx)
  19194. case employee.FieldServiceCount:
  19195. return m.OldServiceCount(ctx)
  19196. case employee.FieldAchievementCount:
  19197. return m.OldAchievementCount(ctx)
  19198. case employee.FieldIntro:
  19199. return m.OldIntro(ctx)
  19200. case employee.FieldEstimate:
  19201. return m.OldEstimate(ctx)
  19202. case employee.FieldSkill:
  19203. return m.OldSkill(ctx)
  19204. case employee.FieldAbilityType:
  19205. return m.OldAbilityType(ctx)
  19206. case employee.FieldScene:
  19207. return m.OldScene(ctx)
  19208. case employee.FieldSwitchIn:
  19209. return m.OldSwitchIn(ctx)
  19210. case employee.FieldVideoURL:
  19211. return m.OldVideoURL(ctx)
  19212. case employee.FieldOrganizationID:
  19213. return m.OldOrganizationID(ctx)
  19214. case employee.FieldCategoryID:
  19215. return m.OldCategoryID(ctx)
  19216. case employee.FieldAPIBase:
  19217. return m.OldAPIBase(ctx)
  19218. case employee.FieldAPIKey:
  19219. return m.OldAPIKey(ctx)
  19220. case employee.FieldAiInfo:
  19221. return m.OldAiInfo(ctx)
  19222. case employee.FieldIsVip:
  19223. return m.OldIsVip(ctx)
  19224. case employee.FieldChatURL:
  19225. return m.OldChatURL(ctx)
  19226. }
  19227. return nil, fmt.Errorf("unknown Employee field %s", name)
  19228. }
  19229. // SetField sets the value of a field with the given name. It returns an error if
  19230. // the field is not defined in the schema, or if the type mismatched the field
  19231. // type.
  19232. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  19233. switch name {
  19234. case employee.FieldCreatedAt:
  19235. v, ok := value.(time.Time)
  19236. if !ok {
  19237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19238. }
  19239. m.SetCreatedAt(v)
  19240. return nil
  19241. case employee.FieldUpdatedAt:
  19242. v, ok := value.(time.Time)
  19243. if !ok {
  19244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19245. }
  19246. m.SetUpdatedAt(v)
  19247. return nil
  19248. case employee.FieldDeletedAt:
  19249. v, ok := value.(time.Time)
  19250. if !ok {
  19251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19252. }
  19253. m.SetDeletedAt(v)
  19254. return nil
  19255. case employee.FieldTitle:
  19256. v, ok := value.(string)
  19257. if !ok {
  19258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19259. }
  19260. m.SetTitle(v)
  19261. return nil
  19262. case employee.FieldAvatar:
  19263. v, ok := value.(string)
  19264. if !ok {
  19265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19266. }
  19267. m.SetAvatar(v)
  19268. return nil
  19269. case employee.FieldTags:
  19270. v, ok := value.(string)
  19271. if !ok {
  19272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19273. }
  19274. m.SetTags(v)
  19275. return nil
  19276. case employee.FieldHireCount:
  19277. v, ok := value.(int)
  19278. if !ok {
  19279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19280. }
  19281. m.SetHireCount(v)
  19282. return nil
  19283. case employee.FieldServiceCount:
  19284. v, ok := value.(int)
  19285. if !ok {
  19286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19287. }
  19288. m.SetServiceCount(v)
  19289. return nil
  19290. case employee.FieldAchievementCount:
  19291. v, ok := value.(int)
  19292. if !ok {
  19293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19294. }
  19295. m.SetAchievementCount(v)
  19296. return nil
  19297. case employee.FieldIntro:
  19298. v, ok := value.(string)
  19299. if !ok {
  19300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19301. }
  19302. m.SetIntro(v)
  19303. return nil
  19304. case employee.FieldEstimate:
  19305. v, ok := value.(string)
  19306. if !ok {
  19307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19308. }
  19309. m.SetEstimate(v)
  19310. return nil
  19311. case employee.FieldSkill:
  19312. v, ok := value.(string)
  19313. if !ok {
  19314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19315. }
  19316. m.SetSkill(v)
  19317. return nil
  19318. case employee.FieldAbilityType:
  19319. v, ok := value.(string)
  19320. if !ok {
  19321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19322. }
  19323. m.SetAbilityType(v)
  19324. return nil
  19325. case employee.FieldScene:
  19326. v, ok := value.(string)
  19327. if !ok {
  19328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19329. }
  19330. m.SetScene(v)
  19331. return nil
  19332. case employee.FieldSwitchIn:
  19333. v, ok := value.(string)
  19334. if !ok {
  19335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19336. }
  19337. m.SetSwitchIn(v)
  19338. return nil
  19339. case employee.FieldVideoURL:
  19340. v, ok := value.(string)
  19341. if !ok {
  19342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19343. }
  19344. m.SetVideoURL(v)
  19345. return nil
  19346. case employee.FieldOrganizationID:
  19347. v, ok := value.(uint64)
  19348. if !ok {
  19349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19350. }
  19351. m.SetOrganizationID(v)
  19352. return nil
  19353. case employee.FieldCategoryID:
  19354. v, ok := value.(uint64)
  19355. if !ok {
  19356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19357. }
  19358. m.SetCategoryID(v)
  19359. return nil
  19360. case employee.FieldAPIBase:
  19361. v, ok := value.(string)
  19362. if !ok {
  19363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19364. }
  19365. m.SetAPIBase(v)
  19366. return nil
  19367. case employee.FieldAPIKey:
  19368. v, ok := value.(string)
  19369. if !ok {
  19370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19371. }
  19372. m.SetAPIKey(v)
  19373. return nil
  19374. case employee.FieldAiInfo:
  19375. v, ok := value.(string)
  19376. if !ok {
  19377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19378. }
  19379. m.SetAiInfo(v)
  19380. return nil
  19381. case employee.FieldIsVip:
  19382. v, ok := value.(int)
  19383. if !ok {
  19384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19385. }
  19386. m.SetIsVip(v)
  19387. return nil
  19388. case employee.FieldChatURL:
  19389. v, ok := value.(string)
  19390. if !ok {
  19391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19392. }
  19393. m.SetChatURL(v)
  19394. return nil
  19395. }
  19396. return fmt.Errorf("unknown Employee field %s", name)
  19397. }
  19398. // AddedFields returns all numeric fields that were incremented/decremented during
  19399. // this mutation.
  19400. func (m *EmployeeMutation) AddedFields() []string {
  19401. var fields []string
  19402. if m.addhire_count != nil {
  19403. fields = append(fields, employee.FieldHireCount)
  19404. }
  19405. if m.addservice_count != nil {
  19406. fields = append(fields, employee.FieldServiceCount)
  19407. }
  19408. if m.addachievement_count != nil {
  19409. fields = append(fields, employee.FieldAchievementCount)
  19410. }
  19411. if m.addorganization_id != nil {
  19412. fields = append(fields, employee.FieldOrganizationID)
  19413. }
  19414. if m.addcategory_id != nil {
  19415. fields = append(fields, employee.FieldCategoryID)
  19416. }
  19417. if m.addis_vip != nil {
  19418. fields = append(fields, employee.FieldIsVip)
  19419. }
  19420. return fields
  19421. }
  19422. // AddedField returns the numeric value that was incremented/decremented on a field
  19423. // with the given name. The second boolean return value indicates that this field
  19424. // was not set, or was not defined in the schema.
  19425. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  19426. switch name {
  19427. case employee.FieldHireCount:
  19428. return m.AddedHireCount()
  19429. case employee.FieldServiceCount:
  19430. return m.AddedServiceCount()
  19431. case employee.FieldAchievementCount:
  19432. return m.AddedAchievementCount()
  19433. case employee.FieldOrganizationID:
  19434. return m.AddedOrganizationID()
  19435. case employee.FieldCategoryID:
  19436. return m.AddedCategoryID()
  19437. case employee.FieldIsVip:
  19438. return m.AddedIsVip()
  19439. }
  19440. return nil, false
  19441. }
  19442. // AddField adds the value to the field with the given name. It returns an error if
  19443. // the field is not defined in the schema, or if the type mismatched the field
  19444. // type.
  19445. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  19446. switch name {
  19447. case employee.FieldHireCount:
  19448. v, ok := value.(int)
  19449. if !ok {
  19450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19451. }
  19452. m.AddHireCount(v)
  19453. return nil
  19454. case employee.FieldServiceCount:
  19455. v, ok := value.(int)
  19456. if !ok {
  19457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19458. }
  19459. m.AddServiceCount(v)
  19460. return nil
  19461. case employee.FieldAchievementCount:
  19462. v, ok := value.(int)
  19463. if !ok {
  19464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19465. }
  19466. m.AddAchievementCount(v)
  19467. return nil
  19468. case employee.FieldOrganizationID:
  19469. v, ok := value.(int64)
  19470. if !ok {
  19471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19472. }
  19473. m.AddOrganizationID(v)
  19474. return nil
  19475. case employee.FieldCategoryID:
  19476. v, ok := value.(int64)
  19477. if !ok {
  19478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19479. }
  19480. m.AddCategoryID(v)
  19481. return nil
  19482. case employee.FieldIsVip:
  19483. v, ok := value.(int)
  19484. if !ok {
  19485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19486. }
  19487. m.AddIsVip(v)
  19488. return nil
  19489. }
  19490. return fmt.Errorf("unknown Employee numeric field %s", name)
  19491. }
  19492. // ClearedFields returns all nullable fields that were cleared during this
  19493. // mutation.
  19494. func (m *EmployeeMutation) ClearedFields() []string {
  19495. var fields []string
  19496. if m.FieldCleared(employee.FieldDeletedAt) {
  19497. fields = append(fields, employee.FieldDeletedAt)
  19498. }
  19499. if m.FieldCleared(employee.FieldAiInfo) {
  19500. fields = append(fields, employee.FieldAiInfo)
  19501. }
  19502. return fields
  19503. }
  19504. // FieldCleared returns a boolean indicating if a field with the given name was
  19505. // cleared in this mutation.
  19506. func (m *EmployeeMutation) FieldCleared(name string) bool {
  19507. _, ok := m.clearedFields[name]
  19508. return ok
  19509. }
  19510. // ClearField clears the value of the field with the given name. It returns an
  19511. // error if the field is not defined in the schema.
  19512. func (m *EmployeeMutation) ClearField(name string) error {
  19513. switch name {
  19514. case employee.FieldDeletedAt:
  19515. m.ClearDeletedAt()
  19516. return nil
  19517. case employee.FieldAiInfo:
  19518. m.ClearAiInfo()
  19519. return nil
  19520. }
  19521. return fmt.Errorf("unknown Employee nullable field %s", name)
  19522. }
  19523. // ResetField resets all changes in the mutation for the field with the given name.
  19524. // It returns an error if the field is not defined in the schema.
  19525. func (m *EmployeeMutation) ResetField(name string) error {
  19526. switch name {
  19527. case employee.FieldCreatedAt:
  19528. m.ResetCreatedAt()
  19529. return nil
  19530. case employee.FieldUpdatedAt:
  19531. m.ResetUpdatedAt()
  19532. return nil
  19533. case employee.FieldDeletedAt:
  19534. m.ResetDeletedAt()
  19535. return nil
  19536. case employee.FieldTitle:
  19537. m.ResetTitle()
  19538. return nil
  19539. case employee.FieldAvatar:
  19540. m.ResetAvatar()
  19541. return nil
  19542. case employee.FieldTags:
  19543. m.ResetTags()
  19544. return nil
  19545. case employee.FieldHireCount:
  19546. m.ResetHireCount()
  19547. return nil
  19548. case employee.FieldServiceCount:
  19549. m.ResetServiceCount()
  19550. return nil
  19551. case employee.FieldAchievementCount:
  19552. m.ResetAchievementCount()
  19553. return nil
  19554. case employee.FieldIntro:
  19555. m.ResetIntro()
  19556. return nil
  19557. case employee.FieldEstimate:
  19558. m.ResetEstimate()
  19559. return nil
  19560. case employee.FieldSkill:
  19561. m.ResetSkill()
  19562. return nil
  19563. case employee.FieldAbilityType:
  19564. m.ResetAbilityType()
  19565. return nil
  19566. case employee.FieldScene:
  19567. m.ResetScene()
  19568. return nil
  19569. case employee.FieldSwitchIn:
  19570. m.ResetSwitchIn()
  19571. return nil
  19572. case employee.FieldVideoURL:
  19573. m.ResetVideoURL()
  19574. return nil
  19575. case employee.FieldOrganizationID:
  19576. m.ResetOrganizationID()
  19577. return nil
  19578. case employee.FieldCategoryID:
  19579. m.ResetCategoryID()
  19580. return nil
  19581. case employee.FieldAPIBase:
  19582. m.ResetAPIBase()
  19583. return nil
  19584. case employee.FieldAPIKey:
  19585. m.ResetAPIKey()
  19586. return nil
  19587. case employee.FieldAiInfo:
  19588. m.ResetAiInfo()
  19589. return nil
  19590. case employee.FieldIsVip:
  19591. m.ResetIsVip()
  19592. return nil
  19593. case employee.FieldChatURL:
  19594. m.ResetChatURL()
  19595. return nil
  19596. }
  19597. return fmt.Errorf("unknown Employee field %s", name)
  19598. }
  19599. // AddedEdges returns all edge names that were set/added in this mutation.
  19600. func (m *EmployeeMutation) AddedEdges() []string {
  19601. edges := make([]string, 0, 2)
  19602. if m.em_work_experiences != nil {
  19603. edges = append(edges, employee.EdgeEmWorkExperiences)
  19604. }
  19605. if m.em_tutorial != nil {
  19606. edges = append(edges, employee.EdgeEmTutorial)
  19607. }
  19608. return edges
  19609. }
  19610. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19611. // name in this mutation.
  19612. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  19613. switch name {
  19614. case employee.EdgeEmWorkExperiences:
  19615. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  19616. for id := range m.em_work_experiences {
  19617. ids = append(ids, id)
  19618. }
  19619. return ids
  19620. case employee.EdgeEmTutorial:
  19621. ids := make([]ent.Value, 0, len(m.em_tutorial))
  19622. for id := range m.em_tutorial {
  19623. ids = append(ids, id)
  19624. }
  19625. return ids
  19626. }
  19627. return nil
  19628. }
  19629. // RemovedEdges returns all edge names that were removed in this mutation.
  19630. func (m *EmployeeMutation) RemovedEdges() []string {
  19631. edges := make([]string, 0, 2)
  19632. if m.removedem_work_experiences != nil {
  19633. edges = append(edges, employee.EdgeEmWorkExperiences)
  19634. }
  19635. if m.removedem_tutorial != nil {
  19636. edges = append(edges, employee.EdgeEmTutorial)
  19637. }
  19638. return edges
  19639. }
  19640. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19641. // the given name in this mutation.
  19642. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  19643. switch name {
  19644. case employee.EdgeEmWorkExperiences:
  19645. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  19646. for id := range m.removedem_work_experiences {
  19647. ids = append(ids, id)
  19648. }
  19649. return ids
  19650. case employee.EdgeEmTutorial:
  19651. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  19652. for id := range m.removedem_tutorial {
  19653. ids = append(ids, id)
  19654. }
  19655. return ids
  19656. }
  19657. return nil
  19658. }
  19659. // ClearedEdges returns all edge names that were cleared in this mutation.
  19660. func (m *EmployeeMutation) ClearedEdges() []string {
  19661. edges := make([]string, 0, 2)
  19662. if m.clearedem_work_experiences {
  19663. edges = append(edges, employee.EdgeEmWorkExperiences)
  19664. }
  19665. if m.clearedem_tutorial {
  19666. edges = append(edges, employee.EdgeEmTutorial)
  19667. }
  19668. return edges
  19669. }
  19670. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19671. // was cleared in this mutation.
  19672. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  19673. switch name {
  19674. case employee.EdgeEmWorkExperiences:
  19675. return m.clearedem_work_experiences
  19676. case employee.EdgeEmTutorial:
  19677. return m.clearedem_tutorial
  19678. }
  19679. return false
  19680. }
  19681. // ClearEdge clears the value of the edge with the given name. It returns an error
  19682. // if that edge is not defined in the schema.
  19683. func (m *EmployeeMutation) ClearEdge(name string) error {
  19684. switch name {
  19685. }
  19686. return fmt.Errorf("unknown Employee unique edge %s", name)
  19687. }
  19688. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19689. // It returns an error if the edge is not defined in the schema.
  19690. func (m *EmployeeMutation) ResetEdge(name string) error {
  19691. switch name {
  19692. case employee.EdgeEmWorkExperiences:
  19693. m.ResetEmWorkExperiences()
  19694. return nil
  19695. case employee.EdgeEmTutorial:
  19696. m.ResetEmTutorial()
  19697. return nil
  19698. }
  19699. return fmt.Errorf("unknown Employee edge %s", name)
  19700. }
  19701. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  19702. type EmployeeConfigMutation struct {
  19703. config
  19704. op Op
  19705. typ string
  19706. id *uint64
  19707. created_at *time.Time
  19708. updated_at *time.Time
  19709. deleted_at *time.Time
  19710. stype *string
  19711. title *string
  19712. photo *string
  19713. organization_id *uint64
  19714. addorganization_id *int64
  19715. clearedFields map[string]struct{}
  19716. done bool
  19717. oldValue func(context.Context) (*EmployeeConfig, error)
  19718. predicates []predicate.EmployeeConfig
  19719. }
  19720. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  19721. // employeeconfigOption allows management of the mutation configuration using functional options.
  19722. type employeeconfigOption func(*EmployeeConfigMutation)
  19723. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  19724. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  19725. m := &EmployeeConfigMutation{
  19726. config: c,
  19727. op: op,
  19728. typ: TypeEmployeeConfig,
  19729. clearedFields: make(map[string]struct{}),
  19730. }
  19731. for _, opt := range opts {
  19732. opt(m)
  19733. }
  19734. return m
  19735. }
  19736. // withEmployeeConfigID sets the ID field of the mutation.
  19737. func withEmployeeConfigID(id uint64) employeeconfigOption {
  19738. return func(m *EmployeeConfigMutation) {
  19739. var (
  19740. err error
  19741. once sync.Once
  19742. value *EmployeeConfig
  19743. )
  19744. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  19745. once.Do(func() {
  19746. if m.done {
  19747. err = errors.New("querying old values post mutation is not allowed")
  19748. } else {
  19749. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  19750. }
  19751. })
  19752. return value, err
  19753. }
  19754. m.id = &id
  19755. }
  19756. }
  19757. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  19758. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  19759. return func(m *EmployeeConfigMutation) {
  19760. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  19761. return node, nil
  19762. }
  19763. m.id = &node.ID
  19764. }
  19765. }
  19766. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19767. // executed in a transaction (ent.Tx), a transactional client is returned.
  19768. func (m EmployeeConfigMutation) Client() *Client {
  19769. client := &Client{config: m.config}
  19770. client.init()
  19771. return client
  19772. }
  19773. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19774. // it returns an error otherwise.
  19775. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  19776. if _, ok := m.driver.(*txDriver); !ok {
  19777. return nil, errors.New("ent: mutation is not running in a transaction")
  19778. }
  19779. tx := &Tx{config: m.config}
  19780. tx.init()
  19781. return tx, nil
  19782. }
  19783. // SetID sets the value of the id field. Note that this
  19784. // operation is only accepted on creation of EmployeeConfig entities.
  19785. func (m *EmployeeConfigMutation) SetID(id uint64) {
  19786. m.id = &id
  19787. }
  19788. // ID returns the ID value in the mutation. Note that the ID is only available
  19789. // if it was provided to the builder or after it was returned from the database.
  19790. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  19791. if m.id == nil {
  19792. return
  19793. }
  19794. return *m.id, true
  19795. }
  19796. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19797. // That means, if the mutation is applied within a transaction with an isolation level such
  19798. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19799. // or updated by the mutation.
  19800. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  19801. switch {
  19802. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19803. id, exists := m.ID()
  19804. if exists {
  19805. return []uint64{id}, nil
  19806. }
  19807. fallthrough
  19808. case m.op.Is(OpUpdate | OpDelete):
  19809. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  19810. default:
  19811. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19812. }
  19813. }
  19814. // SetCreatedAt sets the "created_at" field.
  19815. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  19816. m.created_at = &t
  19817. }
  19818. // CreatedAt returns the value of the "created_at" field in the mutation.
  19819. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  19820. v := m.created_at
  19821. if v == nil {
  19822. return
  19823. }
  19824. return *v, true
  19825. }
  19826. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  19827. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19829. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19830. if !m.op.Is(OpUpdateOne) {
  19831. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19832. }
  19833. if m.id == nil || m.oldValue == nil {
  19834. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19835. }
  19836. oldValue, err := m.oldValue(ctx)
  19837. if err != nil {
  19838. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19839. }
  19840. return oldValue.CreatedAt, nil
  19841. }
  19842. // ResetCreatedAt resets all changes to the "created_at" field.
  19843. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  19844. m.created_at = nil
  19845. }
  19846. // SetUpdatedAt sets the "updated_at" field.
  19847. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  19848. m.updated_at = &t
  19849. }
  19850. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19851. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  19852. v := m.updated_at
  19853. if v == nil {
  19854. return
  19855. }
  19856. return *v, true
  19857. }
  19858. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  19859. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19861. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19862. if !m.op.Is(OpUpdateOne) {
  19863. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19864. }
  19865. if m.id == nil || m.oldValue == nil {
  19866. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19867. }
  19868. oldValue, err := m.oldValue(ctx)
  19869. if err != nil {
  19870. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19871. }
  19872. return oldValue.UpdatedAt, nil
  19873. }
  19874. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19875. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  19876. m.updated_at = nil
  19877. }
  19878. // SetDeletedAt sets the "deleted_at" field.
  19879. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  19880. m.deleted_at = &t
  19881. }
  19882. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19883. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  19884. v := m.deleted_at
  19885. if v == nil {
  19886. return
  19887. }
  19888. return *v, true
  19889. }
  19890. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  19891. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19893. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19894. if !m.op.Is(OpUpdateOne) {
  19895. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19896. }
  19897. if m.id == nil || m.oldValue == nil {
  19898. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19899. }
  19900. oldValue, err := m.oldValue(ctx)
  19901. if err != nil {
  19902. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19903. }
  19904. return oldValue.DeletedAt, nil
  19905. }
  19906. // ClearDeletedAt clears the value of the "deleted_at" field.
  19907. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  19908. m.deleted_at = nil
  19909. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  19910. }
  19911. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19912. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  19913. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  19914. return ok
  19915. }
  19916. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19917. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  19918. m.deleted_at = nil
  19919. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  19920. }
  19921. // SetStype sets the "stype" field.
  19922. func (m *EmployeeConfigMutation) SetStype(s string) {
  19923. m.stype = &s
  19924. }
  19925. // Stype returns the value of the "stype" field in the mutation.
  19926. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  19927. v := m.stype
  19928. if v == nil {
  19929. return
  19930. }
  19931. return *v, true
  19932. }
  19933. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  19934. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19936. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  19937. if !m.op.Is(OpUpdateOne) {
  19938. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  19939. }
  19940. if m.id == nil || m.oldValue == nil {
  19941. return v, errors.New("OldStype requires an ID field in the mutation")
  19942. }
  19943. oldValue, err := m.oldValue(ctx)
  19944. if err != nil {
  19945. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  19946. }
  19947. return oldValue.Stype, nil
  19948. }
  19949. // ResetStype resets all changes to the "stype" field.
  19950. func (m *EmployeeConfigMutation) ResetStype() {
  19951. m.stype = nil
  19952. }
  19953. // SetTitle sets the "title" field.
  19954. func (m *EmployeeConfigMutation) SetTitle(s string) {
  19955. m.title = &s
  19956. }
  19957. // Title returns the value of the "title" field in the mutation.
  19958. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  19959. v := m.title
  19960. if v == nil {
  19961. return
  19962. }
  19963. return *v, true
  19964. }
  19965. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  19966. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19968. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  19969. if !m.op.Is(OpUpdateOne) {
  19970. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  19971. }
  19972. if m.id == nil || m.oldValue == nil {
  19973. return v, errors.New("OldTitle requires an ID field in the mutation")
  19974. }
  19975. oldValue, err := m.oldValue(ctx)
  19976. if err != nil {
  19977. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  19978. }
  19979. return oldValue.Title, nil
  19980. }
  19981. // ResetTitle resets all changes to the "title" field.
  19982. func (m *EmployeeConfigMutation) ResetTitle() {
  19983. m.title = nil
  19984. }
  19985. // SetPhoto sets the "photo" field.
  19986. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  19987. m.photo = &s
  19988. }
  19989. // Photo returns the value of the "photo" field in the mutation.
  19990. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  19991. v := m.photo
  19992. if v == nil {
  19993. return
  19994. }
  19995. return *v, true
  19996. }
  19997. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  19998. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20000. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  20001. if !m.op.Is(OpUpdateOne) {
  20002. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  20003. }
  20004. if m.id == nil || m.oldValue == nil {
  20005. return v, errors.New("OldPhoto requires an ID field in the mutation")
  20006. }
  20007. oldValue, err := m.oldValue(ctx)
  20008. if err != nil {
  20009. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  20010. }
  20011. return oldValue.Photo, nil
  20012. }
  20013. // ResetPhoto resets all changes to the "photo" field.
  20014. func (m *EmployeeConfigMutation) ResetPhoto() {
  20015. m.photo = nil
  20016. }
  20017. // SetOrganizationID sets the "organization_id" field.
  20018. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  20019. m.organization_id = &u
  20020. m.addorganization_id = nil
  20021. }
  20022. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20023. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  20024. v := m.organization_id
  20025. if v == nil {
  20026. return
  20027. }
  20028. return *v, true
  20029. }
  20030. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  20031. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20033. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20034. if !m.op.Is(OpUpdateOne) {
  20035. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20036. }
  20037. if m.id == nil || m.oldValue == nil {
  20038. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20039. }
  20040. oldValue, err := m.oldValue(ctx)
  20041. if err != nil {
  20042. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20043. }
  20044. return oldValue.OrganizationID, nil
  20045. }
  20046. // AddOrganizationID adds u to the "organization_id" field.
  20047. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  20048. if m.addorganization_id != nil {
  20049. *m.addorganization_id += u
  20050. } else {
  20051. m.addorganization_id = &u
  20052. }
  20053. }
  20054. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20055. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  20056. v := m.addorganization_id
  20057. if v == nil {
  20058. return
  20059. }
  20060. return *v, true
  20061. }
  20062. // ClearOrganizationID clears the value of the "organization_id" field.
  20063. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  20064. m.organization_id = nil
  20065. m.addorganization_id = nil
  20066. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  20067. }
  20068. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20069. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  20070. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  20071. return ok
  20072. }
  20073. // ResetOrganizationID resets all changes to the "organization_id" field.
  20074. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  20075. m.organization_id = nil
  20076. m.addorganization_id = nil
  20077. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  20078. }
  20079. // Where appends a list predicates to the EmployeeConfigMutation builder.
  20080. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  20081. m.predicates = append(m.predicates, ps...)
  20082. }
  20083. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  20084. // users can use type-assertion to append predicates that do not depend on any generated package.
  20085. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  20086. p := make([]predicate.EmployeeConfig, len(ps))
  20087. for i := range ps {
  20088. p[i] = ps[i]
  20089. }
  20090. m.Where(p...)
  20091. }
  20092. // Op returns the operation name.
  20093. func (m *EmployeeConfigMutation) Op() Op {
  20094. return m.op
  20095. }
  20096. // SetOp allows setting the mutation operation.
  20097. func (m *EmployeeConfigMutation) SetOp(op Op) {
  20098. m.op = op
  20099. }
  20100. // Type returns the node type of this mutation (EmployeeConfig).
  20101. func (m *EmployeeConfigMutation) Type() string {
  20102. return m.typ
  20103. }
  20104. // Fields returns all fields that were changed during this mutation. Note that in
  20105. // order to get all numeric fields that were incremented/decremented, call
  20106. // AddedFields().
  20107. func (m *EmployeeConfigMutation) Fields() []string {
  20108. fields := make([]string, 0, 7)
  20109. if m.created_at != nil {
  20110. fields = append(fields, employeeconfig.FieldCreatedAt)
  20111. }
  20112. if m.updated_at != nil {
  20113. fields = append(fields, employeeconfig.FieldUpdatedAt)
  20114. }
  20115. if m.deleted_at != nil {
  20116. fields = append(fields, employeeconfig.FieldDeletedAt)
  20117. }
  20118. if m.stype != nil {
  20119. fields = append(fields, employeeconfig.FieldStype)
  20120. }
  20121. if m.title != nil {
  20122. fields = append(fields, employeeconfig.FieldTitle)
  20123. }
  20124. if m.photo != nil {
  20125. fields = append(fields, employeeconfig.FieldPhoto)
  20126. }
  20127. if m.organization_id != nil {
  20128. fields = append(fields, employeeconfig.FieldOrganizationID)
  20129. }
  20130. return fields
  20131. }
  20132. // Field returns the value of a field with the given name. The second boolean
  20133. // return value indicates that this field was not set, or was not defined in the
  20134. // schema.
  20135. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  20136. switch name {
  20137. case employeeconfig.FieldCreatedAt:
  20138. return m.CreatedAt()
  20139. case employeeconfig.FieldUpdatedAt:
  20140. return m.UpdatedAt()
  20141. case employeeconfig.FieldDeletedAt:
  20142. return m.DeletedAt()
  20143. case employeeconfig.FieldStype:
  20144. return m.Stype()
  20145. case employeeconfig.FieldTitle:
  20146. return m.Title()
  20147. case employeeconfig.FieldPhoto:
  20148. return m.Photo()
  20149. case employeeconfig.FieldOrganizationID:
  20150. return m.OrganizationID()
  20151. }
  20152. return nil, false
  20153. }
  20154. // OldField returns the old value of the field from the database. An error is
  20155. // returned if the mutation operation is not UpdateOne, or the query to the
  20156. // database failed.
  20157. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20158. switch name {
  20159. case employeeconfig.FieldCreatedAt:
  20160. return m.OldCreatedAt(ctx)
  20161. case employeeconfig.FieldUpdatedAt:
  20162. return m.OldUpdatedAt(ctx)
  20163. case employeeconfig.FieldDeletedAt:
  20164. return m.OldDeletedAt(ctx)
  20165. case employeeconfig.FieldStype:
  20166. return m.OldStype(ctx)
  20167. case employeeconfig.FieldTitle:
  20168. return m.OldTitle(ctx)
  20169. case employeeconfig.FieldPhoto:
  20170. return m.OldPhoto(ctx)
  20171. case employeeconfig.FieldOrganizationID:
  20172. return m.OldOrganizationID(ctx)
  20173. }
  20174. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  20175. }
  20176. // SetField sets the value of a field with the given name. It returns an error if
  20177. // the field is not defined in the schema, or if the type mismatched the field
  20178. // type.
  20179. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  20180. switch name {
  20181. case employeeconfig.FieldCreatedAt:
  20182. v, ok := value.(time.Time)
  20183. if !ok {
  20184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20185. }
  20186. m.SetCreatedAt(v)
  20187. return nil
  20188. case employeeconfig.FieldUpdatedAt:
  20189. v, ok := value.(time.Time)
  20190. if !ok {
  20191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20192. }
  20193. m.SetUpdatedAt(v)
  20194. return nil
  20195. case employeeconfig.FieldDeletedAt:
  20196. v, ok := value.(time.Time)
  20197. if !ok {
  20198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20199. }
  20200. m.SetDeletedAt(v)
  20201. return nil
  20202. case employeeconfig.FieldStype:
  20203. v, ok := value.(string)
  20204. if !ok {
  20205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20206. }
  20207. m.SetStype(v)
  20208. return nil
  20209. case employeeconfig.FieldTitle:
  20210. v, ok := value.(string)
  20211. if !ok {
  20212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20213. }
  20214. m.SetTitle(v)
  20215. return nil
  20216. case employeeconfig.FieldPhoto:
  20217. v, ok := value.(string)
  20218. if !ok {
  20219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20220. }
  20221. m.SetPhoto(v)
  20222. return nil
  20223. case employeeconfig.FieldOrganizationID:
  20224. v, ok := value.(uint64)
  20225. if !ok {
  20226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20227. }
  20228. m.SetOrganizationID(v)
  20229. return nil
  20230. }
  20231. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20232. }
  20233. // AddedFields returns all numeric fields that were incremented/decremented during
  20234. // this mutation.
  20235. func (m *EmployeeConfigMutation) AddedFields() []string {
  20236. var fields []string
  20237. if m.addorganization_id != nil {
  20238. fields = append(fields, employeeconfig.FieldOrganizationID)
  20239. }
  20240. return fields
  20241. }
  20242. // AddedField returns the numeric value that was incremented/decremented on a field
  20243. // with the given name. The second boolean return value indicates that this field
  20244. // was not set, or was not defined in the schema.
  20245. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  20246. switch name {
  20247. case employeeconfig.FieldOrganizationID:
  20248. return m.AddedOrganizationID()
  20249. }
  20250. return nil, false
  20251. }
  20252. // AddField adds the value to the field with the given name. It returns an error if
  20253. // the field is not defined in the schema, or if the type mismatched the field
  20254. // type.
  20255. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  20256. switch name {
  20257. case employeeconfig.FieldOrganizationID:
  20258. v, ok := value.(int64)
  20259. if !ok {
  20260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20261. }
  20262. m.AddOrganizationID(v)
  20263. return nil
  20264. }
  20265. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  20266. }
  20267. // ClearedFields returns all nullable fields that were cleared during this
  20268. // mutation.
  20269. func (m *EmployeeConfigMutation) ClearedFields() []string {
  20270. var fields []string
  20271. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  20272. fields = append(fields, employeeconfig.FieldDeletedAt)
  20273. }
  20274. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  20275. fields = append(fields, employeeconfig.FieldOrganizationID)
  20276. }
  20277. return fields
  20278. }
  20279. // FieldCleared returns a boolean indicating if a field with the given name was
  20280. // cleared in this mutation.
  20281. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  20282. _, ok := m.clearedFields[name]
  20283. return ok
  20284. }
  20285. // ClearField clears the value of the field with the given name. It returns an
  20286. // error if the field is not defined in the schema.
  20287. func (m *EmployeeConfigMutation) ClearField(name string) error {
  20288. switch name {
  20289. case employeeconfig.FieldDeletedAt:
  20290. m.ClearDeletedAt()
  20291. return nil
  20292. case employeeconfig.FieldOrganizationID:
  20293. m.ClearOrganizationID()
  20294. return nil
  20295. }
  20296. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  20297. }
  20298. // ResetField resets all changes in the mutation for the field with the given name.
  20299. // It returns an error if the field is not defined in the schema.
  20300. func (m *EmployeeConfigMutation) ResetField(name string) error {
  20301. switch name {
  20302. case employeeconfig.FieldCreatedAt:
  20303. m.ResetCreatedAt()
  20304. return nil
  20305. case employeeconfig.FieldUpdatedAt:
  20306. m.ResetUpdatedAt()
  20307. return nil
  20308. case employeeconfig.FieldDeletedAt:
  20309. m.ResetDeletedAt()
  20310. return nil
  20311. case employeeconfig.FieldStype:
  20312. m.ResetStype()
  20313. return nil
  20314. case employeeconfig.FieldTitle:
  20315. m.ResetTitle()
  20316. return nil
  20317. case employeeconfig.FieldPhoto:
  20318. m.ResetPhoto()
  20319. return nil
  20320. case employeeconfig.FieldOrganizationID:
  20321. m.ResetOrganizationID()
  20322. return nil
  20323. }
  20324. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20325. }
  20326. // AddedEdges returns all edge names that were set/added in this mutation.
  20327. func (m *EmployeeConfigMutation) AddedEdges() []string {
  20328. edges := make([]string, 0, 0)
  20329. return edges
  20330. }
  20331. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20332. // name in this mutation.
  20333. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  20334. return nil
  20335. }
  20336. // RemovedEdges returns all edge names that were removed in this mutation.
  20337. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  20338. edges := make([]string, 0, 0)
  20339. return edges
  20340. }
  20341. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20342. // the given name in this mutation.
  20343. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  20344. return nil
  20345. }
  20346. // ClearedEdges returns all edge names that were cleared in this mutation.
  20347. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  20348. edges := make([]string, 0, 0)
  20349. return edges
  20350. }
  20351. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20352. // was cleared in this mutation.
  20353. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  20354. return false
  20355. }
  20356. // ClearEdge clears the value of the edge with the given name. It returns an error
  20357. // if that edge is not defined in the schema.
  20358. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  20359. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  20360. }
  20361. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20362. // It returns an error if the edge is not defined in the schema.
  20363. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  20364. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  20365. }
  20366. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  20367. type LabelMutation struct {
  20368. config
  20369. op Op
  20370. typ string
  20371. id *uint64
  20372. created_at *time.Time
  20373. updated_at *time.Time
  20374. status *uint8
  20375. addstatus *int8
  20376. _type *int
  20377. add_type *int
  20378. name *string
  20379. from *int
  20380. addfrom *int
  20381. mode *int
  20382. addmode *int
  20383. conditions *string
  20384. organization_id *uint64
  20385. addorganization_id *int64
  20386. clearedFields map[string]struct{}
  20387. label_relationships map[uint64]struct{}
  20388. removedlabel_relationships map[uint64]struct{}
  20389. clearedlabel_relationships bool
  20390. done bool
  20391. oldValue func(context.Context) (*Label, error)
  20392. predicates []predicate.Label
  20393. }
  20394. var _ ent.Mutation = (*LabelMutation)(nil)
  20395. // labelOption allows management of the mutation configuration using functional options.
  20396. type labelOption func(*LabelMutation)
  20397. // newLabelMutation creates new mutation for the Label entity.
  20398. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  20399. m := &LabelMutation{
  20400. config: c,
  20401. op: op,
  20402. typ: TypeLabel,
  20403. clearedFields: make(map[string]struct{}),
  20404. }
  20405. for _, opt := range opts {
  20406. opt(m)
  20407. }
  20408. return m
  20409. }
  20410. // withLabelID sets the ID field of the mutation.
  20411. func withLabelID(id uint64) labelOption {
  20412. return func(m *LabelMutation) {
  20413. var (
  20414. err error
  20415. once sync.Once
  20416. value *Label
  20417. )
  20418. m.oldValue = func(ctx context.Context) (*Label, error) {
  20419. once.Do(func() {
  20420. if m.done {
  20421. err = errors.New("querying old values post mutation is not allowed")
  20422. } else {
  20423. value, err = m.Client().Label.Get(ctx, id)
  20424. }
  20425. })
  20426. return value, err
  20427. }
  20428. m.id = &id
  20429. }
  20430. }
  20431. // withLabel sets the old Label of the mutation.
  20432. func withLabel(node *Label) labelOption {
  20433. return func(m *LabelMutation) {
  20434. m.oldValue = func(context.Context) (*Label, error) {
  20435. return node, nil
  20436. }
  20437. m.id = &node.ID
  20438. }
  20439. }
  20440. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20441. // executed in a transaction (ent.Tx), a transactional client is returned.
  20442. func (m LabelMutation) Client() *Client {
  20443. client := &Client{config: m.config}
  20444. client.init()
  20445. return client
  20446. }
  20447. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20448. // it returns an error otherwise.
  20449. func (m LabelMutation) Tx() (*Tx, error) {
  20450. if _, ok := m.driver.(*txDriver); !ok {
  20451. return nil, errors.New("ent: mutation is not running in a transaction")
  20452. }
  20453. tx := &Tx{config: m.config}
  20454. tx.init()
  20455. return tx, nil
  20456. }
  20457. // SetID sets the value of the id field. Note that this
  20458. // operation is only accepted on creation of Label entities.
  20459. func (m *LabelMutation) SetID(id uint64) {
  20460. m.id = &id
  20461. }
  20462. // ID returns the ID value in the mutation. Note that the ID is only available
  20463. // if it was provided to the builder or after it was returned from the database.
  20464. func (m *LabelMutation) ID() (id uint64, exists bool) {
  20465. if m.id == nil {
  20466. return
  20467. }
  20468. return *m.id, true
  20469. }
  20470. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20471. // That means, if the mutation is applied within a transaction with an isolation level such
  20472. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20473. // or updated by the mutation.
  20474. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  20475. switch {
  20476. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20477. id, exists := m.ID()
  20478. if exists {
  20479. return []uint64{id}, nil
  20480. }
  20481. fallthrough
  20482. case m.op.Is(OpUpdate | OpDelete):
  20483. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  20484. default:
  20485. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20486. }
  20487. }
  20488. // SetCreatedAt sets the "created_at" field.
  20489. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  20490. m.created_at = &t
  20491. }
  20492. // CreatedAt returns the value of the "created_at" field in the mutation.
  20493. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  20494. v := m.created_at
  20495. if v == nil {
  20496. return
  20497. }
  20498. return *v, true
  20499. }
  20500. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  20501. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20503. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20504. if !m.op.Is(OpUpdateOne) {
  20505. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20506. }
  20507. if m.id == nil || m.oldValue == nil {
  20508. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20509. }
  20510. oldValue, err := m.oldValue(ctx)
  20511. if err != nil {
  20512. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20513. }
  20514. return oldValue.CreatedAt, nil
  20515. }
  20516. // ResetCreatedAt resets all changes to the "created_at" field.
  20517. func (m *LabelMutation) ResetCreatedAt() {
  20518. m.created_at = nil
  20519. }
  20520. // SetUpdatedAt sets the "updated_at" field.
  20521. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  20522. m.updated_at = &t
  20523. }
  20524. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20525. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  20526. v := m.updated_at
  20527. if v == nil {
  20528. return
  20529. }
  20530. return *v, true
  20531. }
  20532. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  20533. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20535. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20536. if !m.op.Is(OpUpdateOne) {
  20537. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20538. }
  20539. if m.id == nil || m.oldValue == nil {
  20540. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20541. }
  20542. oldValue, err := m.oldValue(ctx)
  20543. if err != nil {
  20544. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20545. }
  20546. return oldValue.UpdatedAt, nil
  20547. }
  20548. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20549. func (m *LabelMutation) ResetUpdatedAt() {
  20550. m.updated_at = nil
  20551. }
  20552. // SetStatus sets the "status" field.
  20553. func (m *LabelMutation) SetStatus(u uint8) {
  20554. m.status = &u
  20555. m.addstatus = nil
  20556. }
  20557. // Status returns the value of the "status" field in the mutation.
  20558. func (m *LabelMutation) Status() (r uint8, exists bool) {
  20559. v := m.status
  20560. if v == nil {
  20561. return
  20562. }
  20563. return *v, true
  20564. }
  20565. // OldStatus returns the old "status" field's value of the Label entity.
  20566. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20568. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20569. if !m.op.Is(OpUpdateOne) {
  20570. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20571. }
  20572. if m.id == nil || m.oldValue == nil {
  20573. return v, errors.New("OldStatus requires an ID field in the mutation")
  20574. }
  20575. oldValue, err := m.oldValue(ctx)
  20576. if err != nil {
  20577. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20578. }
  20579. return oldValue.Status, nil
  20580. }
  20581. // AddStatus adds u to the "status" field.
  20582. func (m *LabelMutation) AddStatus(u int8) {
  20583. if m.addstatus != nil {
  20584. *m.addstatus += u
  20585. } else {
  20586. m.addstatus = &u
  20587. }
  20588. }
  20589. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20590. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  20591. v := m.addstatus
  20592. if v == nil {
  20593. return
  20594. }
  20595. return *v, true
  20596. }
  20597. // ClearStatus clears the value of the "status" field.
  20598. func (m *LabelMutation) ClearStatus() {
  20599. m.status = nil
  20600. m.addstatus = nil
  20601. m.clearedFields[label.FieldStatus] = struct{}{}
  20602. }
  20603. // StatusCleared returns if the "status" field was cleared in this mutation.
  20604. func (m *LabelMutation) StatusCleared() bool {
  20605. _, ok := m.clearedFields[label.FieldStatus]
  20606. return ok
  20607. }
  20608. // ResetStatus resets all changes to the "status" field.
  20609. func (m *LabelMutation) ResetStatus() {
  20610. m.status = nil
  20611. m.addstatus = nil
  20612. delete(m.clearedFields, label.FieldStatus)
  20613. }
  20614. // SetType sets the "type" field.
  20615. func (m *LabelMutation) SetType(i int) {
  20616. m._type = &i
  20617. m.add_type = nil
  20618. }
  20619. // GetType returns the value of the "type" field in the mutation.
  20620. func (m *LabelMutation) GetType() (r int, exists bool) {
  20621. v := m._type
  20622. if v == nil {
  20623. return
  20624. }
  20625. return *v, true
  20626. }
  20627. // OldType returns the old "type" field's value of the Label entity.
  20628. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20630. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  20631. if !m.op.Is(OpUpdateOne) {
  20632. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20633. }
  20634. if m.id == nil || m.oldValue == nil {
  20635. return v, errors.New("OldType requires an ID field in the mutation")
  20636. }
  20637. oldValue, err := m.oldValue(ctx)
  20638. if err != nil {
  20639. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20640. }
  20641. return oldValue.Type, nil
  20642. }
  20643. // AddType adds i to the "type" field.
  20644. func (m *LabelMutation) AddType(i int) {
  20645. if m.add_type != nil {
  20646. *m.add_type += i
  20647. } else {
  20648. m.add_type = &i
  20649. }
  20650. }
  20651. // AddedType returns the value that was added to the "type" field in this mutation.
  20652. func (m *LabelMutation) AddedType() (r int, exists bool) {
  20653. v := m.add_type
  20654. if v == nil {
  20655. return
  20656. }
  20657. return *v, true
  20658. }
  20659. // ResetType resets all changes to the "type" field.
  20660. func (m *LabelMutation) ResetType() {
  20661. m._type = nil
  20662. m.add_type = nil
  20663. }
  20664. // SetName sets the "name" field.
  20665. func (m *LabelMutation) SetName(s string) {
  20666. m.name = &s
  20667. }
  20668. // Name returns the value of the "name" field in the mutation.
  20669. func (m *LabelMutation) Name() (r string, exists bool) {
  20670. v := m.name
  20671. if v == nil {
  20672. return
  20673. }
  20674. return *v, true
  20675. }
  20676. // OldName returns the old "name" field's value of the Label entity.
  20677. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20679. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  20680. if !m.op.Is(OpUpdateOne) {
  20681. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20682. }
  20683. if m.id == nil || m.oldValue == nil {
  20684. return v, errors.New("OldName requires an ID field in the mutation")
  20685. }
  20686. oldValue, err := m.oldValue(ctx)
  20687. if err != nil {
  20688. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20689. }
  20690. return oldValue.Name, nil
  20691. }
  20692. // ResetName resets all changes to the "name" field.
  20693. func (m *LabelMutation) ResetName() {
  20694. m.name = nil
  20695. }
  20696. // SetFrom sets the "from" field.
  20697. func (m *LabelMutation) SetFrom(i int) {
  20698. m.from = &i
  20699. m.addfrom = nil
  20700. }
  20701. // From returns the value of the "from" field in the mutation.
  20702. func (m *LabelMutation) From() (r int, exists bool) {
  20703. v := m.from
  20704. if v == nil {
  20705. return
  20706. }
  20707. return *v, true
  20708. }
  20709. // OldFrom returns the old "from" field's value of the Label entity.
  20710. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20712. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  20713. if !m.op.Is(OpUpdateOne) {
  20714. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  20715. }
  20716. if m.id == nil || m.oldValue == nil {
  20717. return v, errors.New("OldFrom requires an ID field in the mutation")
  20718. }
  20719. oldValue, err := m.oldValue(ctx)
  20720. if err != nil {
  20721. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  20722. }
  20723. return oldValue.From, nil
  20724. }
  20725. // AddFrom adds i to the "from" field.
  20726. func (m *LabelMutation) AddFrom(i int) {
  20727. if m.addfrom != nil {
  20728. *m.addfrom += i
  20729. } else {
  20730. m.addfrom = &i
  20731. }
  20732. }
  20733. // AddedFrom returns the value that was added to the "from" field in this mutation.
  20734. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  20735. v := m.addfrom
  20736. if v == nil {
  20737. return
  20738. }
  20739. return *v, true
  20740. }
  20741. // ResetFrom resets all changes to the "from" field.
  20742. func (m *LabelMutation) ResetFrom() {
  20743. m.from = nil
  20744. m.addfrom = nil
  20745. }
  20746. // SetMode sets the "mode" field.
  20747. func (m *LabelMutation) SetMode(i int) {
  20748. m.mode = &i
  20749. m.addmode = nil
  20750. }
  20751. // Mode returns the value of the "mode" field in the mutation.
  20752. func (m *LabelMutation) Mode() (r int, exists bool) {
  20753. v := m.mode
  20754. if v == nil {
  20755. return
  20756. }
  20757. return *v, true
  20758. }
  20759. // OldMode returns the old "mode" field's value of the Label entity.
  20760. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20762. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  20763. if !m.op.Is(OpUpdateOne) {
  20764. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  20765. }
  20766. if m.id == nil || m.oldValue == nil {
  20767. return v, errors.New("OldMode requires an ID field in the mutation")
  20768. }
  20769. oldValue, err := m.oldValue(ctx)
  20770. if err != nil {
  20771. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  20772. }
  20773. return oldValue.Mode, nil
  20774. }
  20775. // AddMode adds i to the "mode" field.
  20776. func (m *LabelMutation) AddMode(i int) {
  20777. if m.addmode != nil {
  20778. *m.addmode += i
  20779. } else {
  20780. m.addmode = &i
  20781. }
  20782. }
  20783. // AddedMode returns the value that was added to the "mode" field in this mutation.
  20784. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  20785. v := m.addmode
  20786. if v == nil {
  20787. return
  20788. }
  20789. return *v, true
  20790. }
  20791. // ResetMode resets all changes to the "mode" field.
  20792. func (m *LabelMutation) ResetMode() {
  20793. m.mode = nil
  20794. m.addmode = nil
  20795. }
  20796. // SetConditions sets the "conditions" field.
  20797. func (m *LabelMutation) SetConditions(s string) {
  20798. m.conditions = &s
  20799. }
  20800. // Conditions returns the value of the "conditions" field in the mutation.
  20801. func (m *LabelMutation) Conditions() (r string, exists bool) {
  20802. v := m.conditions
  20803. if v == nil {
  20804. return
  20805. }
  20806. return *v, true
  20807. }
  20808. // OldConditions returns the old "conditions" field's value of the Label entity.
  20809. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20811. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  20812. if !m.op.Is(OpUpdateOne) {
  20813. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20814. }
  20815. if m.id == nil || m.oldValue == nil {
  20816. return v, errors.New("OldConditions requires an ID field in the mutation")
  20817. }
  20818. oldValue, err := m.oldValue(ctx)
  20819. if err != nil {
  20820. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20821. }
  20822. return oldValue.Conditions, nil
  20823. }
  20824. // ClearConditions clears the value of the "conditions" field.
  20825. func (m *LabelMutation) ClearConditions() {
  20826. m.conditions = nil
  20827. m.clearedFields[label.FieldConditions] = struct{}{}
  20828. }
  20829. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  20830. func (m *LabelMutation) ConditionsCleared() bool {
  20831. _, ok := m.clearedFields[label.FieldConditions]
  20832. return ok
  20833. }
  20834. // ResetConditions resets all changes to the "conditions" field.
  20835. func (m *LabelMutation) ResetConditions() {
  20836. m.conditions = nil
  20837. delete(m.clearedFields, label.FieldConditions)
  20838. }
  20839. // SetOrganizationID sets the "organization_id" field.
  20840. func (m *LabelMutation) SetOrganizationID(u uint64) {
  20841. m.organization_id = &u
  20842. m.addorganization_id = nil
  20843. }
  20844. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20845. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  20846. v := m.organization_id
  20847. if v == nil {
  20848. return
  20849. }
  20850. return *v, true
  20851. }
  20852. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  20853. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20855. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20856. if !m.op.Is(OpUpdateOne) {
  20857. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20858. }
  20859. if m.id == nil || m.oldValue == nil {
  20860. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20861. }
  20862. oldValue, err := m.oldValue(ctx)
  20863. if err != nil {
  20864. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20865. }
  20866. return oldValue.OrganizationID, nil
  20867. }
  20868. // AddOrganizationID adds u to the "organization_id" field.
  20869. func (m *LabelMutation) AddOrganizationID(u int64) {
  20870. if m.addorganization_id != nil {
  20871. *m.addorganization_id += u
  20872. } else {
  20873. m.addorganization_id = &u
  20874. }
  20875. }
  20876. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20877. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  20878. v := m.addorganization_id
  20879. if v == nil {
  20880. return
  20881. }
  20882. return *v, true
  20883. }
  20884. // ClearOrganizationID clears the value of the "organization_id" field.
  20885. func (m *LabelMutation) ClearOrganizationID() {
  20886. m.organization_id = nil
  20887. m.addorganization_id = nil
  20888. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  20889. }
  20890. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20891. func (m *LabelMutation) OrganizationIDCleared() bool {
  20892. _, ok := m.clearedFields[label.FieldOrganizationID]
  20893. return ok
  20894. }
  20895. // ResetOrganizationID resets all changes to the "organization_id" field.
  20896. func (m *LabelMutation) ResetOrganizationID() {
  20897. m.organization_id = nil
  20898. m.addorganization_id = nil
  20899. delete(m.clearedFields, label.FieldOrganizationID)
  20900. }
  20901. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  20902. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  20903. if m.label_relationships == nil {
  20904. m.label_relationships = make(map[uint64]struct{})
  20905. }
  20906. for i := range ids {
  20907. m.label_relationships[ids[i]] = struct{}{}
  20908. }
  20909. }
  20910. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  20911. func (m *LabelMutation) ClearLabelRelationships() {
  20912. m.clearedlabel_relationships = true
  20913. }
  20914. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  20915. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  20916. return m.clearedlabel_relationships
  20917. }
  20918. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  20919. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  20920. if m.removedlabel_relationships == nil {
  20921. m.removedlabel_relationships = make(map[uint64]struct{})
  20922. }
  20923. for i := range ids {
  20924. delete(m.label_relationships, ids[i])
  20925. m.removedlabel_relationships[ids[i]] = struct{}{}
  20926. }
  20927. }
  20928. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  20929. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  20930. for id := range m.removedlabel_relationships {
  20931. ids = append(ids, id)
  20932. }
  20933. return
  20934. }
  20935. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  20936. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  20937. for id := range m.label_relationships {
  20938. ids = append(ids, id)
  20939. }
  20940. return
  20941. }
  20942. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  20943. func (m *LabelMutation) ResetLabelRelationships() {
  20944. m.label_relationships = nil
  20945. m.clearedlabel_relationships = false
  20946. m.removedlabel_relationships = nil
  20947. }
  20948. // Where appends a list predicates to the LabelMutation builder.
  20949. func (m *LabelMutation) Where(ps ...predicate.Label) {
  20950. m.predicates = append(m.predicates, ps...)
  20951. }
  20952. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  20953. // users can use type-assertion to append predicates that do not depend on any generated package.
  20954. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  20955. p := make([]predicate.Label, len(ps))
  20956. for i := range ps {
  20957. p[i] = ps[i]
  20958. }
  20959. m.Where(p...)
  20960. }
  20961. // Op returns the operation name.
  20962. func (m *LabelMutation) Op() Op {
  20963. return m.op
  20964. }
  20965. // SetOp allows setting the mutation operation.
  20966. func (m *LabelMutation) SetOp(op Op) {
  20967. m.op = op
  20968. }
  20969. // Type returns the node type of this mutation (Label).
  20970. func (m *LabelMutation) Type() string {
  20971. return m.typ
  20972. }
  20973. // Fields returns all fields that were changed during this mutation. Note that in
  20974. // order to get all numeric fields that were incremented/decremented, call
  20975. // AddedFields().
  20976. func (m *LabelMutation) Fields() []string {
  20977. fields := make([]string, 0, 9)
  20978. if m.created_at != nil {
  20979. fields = append(fields, label.FieldCreatedAt)
  20980. }
  20981. if m.updated_at != nil {
  20982. fields = append(fields, label.FieldUpdatedAt)
  20983. }
  20984. if m.status != nil {
  20985. fields = append(fields, label.FieldStatus)
  20986. }
  20987. if m._type != nil {
  20988. fields = append(fields, label.FieldType)
  20989. }
  20990. if m.name != nil {
  20991. fields = append(fields, label.FieldName)
  20992. }
  20993. if m.from != nil {
  20994. fields = append(fields, label.FieldFrom)
  20995. }
  20996. if m.mode != nil {
  20997. fields = append(fields, label.FieldMode)
  20998. }
  20999. if m.conditions != nil {
  21000. fields = append(fields, label.FieldConditions)
  21001. }
  21002. if m.organization_id != nil {
  21003. fields = append(fields, label.FieldOrganizationID)
  21004. }
  21005. return fields
  21006. }
  21007. // Field returns the value of a field with the given name. The second boolean
  21008. // return value indicates that this field was not set, or was not defined in the
  21009. // schema.
  21010. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  21011. switch name {
  21012. case label.FieldCreatedAt:
  21013. return m.CreatedAt()
  21014. case label.FieldUpdatedAt:
  21015. return m.UpdatedAt()
  21016. case label.FieldStatus:
  21017. return m.Status()
  21018. case label.FieldType:
  21019. return m.GetType()
  21020. case label.FieldName:
  21021. return m.Name()
  21022. case label.FieldFrom:
  21023. return m.From()
  21024. case label.FieldMode:
  21025. return m.Mode()
  21026. case label.FieldConditions:
  21027. return m.Conditions()
  21028. case label.FieldOrganizationID:
  21029. return m.OrganizationID()
  21030. }
  21031. return nil, false
  21032. }
  21033. // OldField returns the old value of the field from the database. An error is
  21034. // returned if the mutation operation is not UpdateOne, or the query to the
  21035. // database failed.
  21036. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21037. switch name {
  21038. case label.FieldCreatedAt:
  21039. return m.OldCreatedAt(ctx)
  21040. case label.FieldUpdatedAt:
  21041. return m.OldUpdatedAt(ctx)
  21042. case label.FieldStatus:
  21043. return m.OldStatus(ctx)
  21044. case label.FieldType:
  21045. return m.OldType(ctx)
  21046. case label.FieldName:
  21047. return m.OldName(ctx)
  21048. case label.FieldFrom:
  21049. return m.OldFrom(ctx)
  21050. case label.FieldMode:
  21051. return m.OldMode(ctx)
  21052. case label.FieldConditions:
  21053. return m.OldConditions(ctx)
  21054. case label.FieldOrganizationID:
  21055. return m.OldOrganizationID(ctx)
  21056. }
  21057. return nil, fmt.Errorf("unknown Label field %s", name)
  21058. }
  21059. // SetField sets the value of a field with the given name. It returns an error if
  21060. // the field is not defined in the schema, or if the type mismatched the field
  21061. // type.
  21062. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  21063. switch name {
  21064. case label.FieldCreatedAt:
  21065. v, ok := value.(time.Time)
  21066. if !ok {
  21067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21068. }
  21069. m.SetCreatedAt(v)
  21070. return nil
  21071. case label.FieldUpdatedAt:
  21072. v, ok := value.(time.Time)
  21073. if !ok {
  21074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21075. }
  21076. m.SetUpdatedAt(v)
  21077. return nil
  21078. case label.FieldStatus:
  21079. v, ok := value.(uint8)
  21080. if !ok {
  21081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21082. }
  21083. m.SetStatus(v)
  21084. return nil
  21085. case label.FieldType:
  21086. v, ok := value.(int)
  21087. if !ok {
  21088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21089. }
  21090. m.SetType(v)
  21091. return nil
  21092. case label.FieldName:
  21093. v, ok := value.(string)
  21094. if !ok {
  21095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21096. }
  21097. m.SetName(v)
  21098. return nil
  21099. case label.FieldFrom:
  21100. v, ok := value.(int)
  21101. if !ok {
  21102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21103. }
  21104. m.SetFrom(v)
  21105. return nil
  21106. case label.FieldMode:
  21107. v, ok := value.(int)
  21108. if !ok {
  21109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21110. }
  21111. m.SetMode(v)
  21112. return nil
  21113. case label.FieldConditions:
  21114. v, ok := value.(string)
  21115. if !ok {
  21116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21117. }
  21118. m.SetConditions(v)
  21119. return nil
  21120. case label.FieldOrganizationID:
  21121. v, ok := value.(uint64)
  21122. if !ok {
  21123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21124. }
  21125. m.SetOrganizationID(v)
  21126. return nil
  21127. }
  21128. return fmt.Errorf("unknown Label field %s", name)
  21129. }
  21130. // AddedFields returns all numeric fields that were incremented/decremented during
  21131. // this mutation.
  21132. func (m *LabelMutation) AddedFields() []string {
  21133. var fields []string
  21134. if m.addstatus != nil {
  21135. fields = append(fields, label.FieldStatus)
  21136. }
  21137. if m.add_type != nil {
  21138. fields = append(fields, label.FieldType)
  21139. }
  21140. if m.addfrom != nil {
  21141. fields = append(fields, label.FieldFrom)
  21142. }
  21143. if m.addmode != nil {
  21144. fields = append(fields, label.FieldMode)
  21145. }
  21146. if m.addorganization_id != nil {
  21147. fields = append(fields, label.FieldOrganizationID)
  21148. }
  21149. return fields
  21150. }
  21151. // AddedField returns the numeric value that was incremented/decremented on a field
  21152. // with the given name. The second boolean return value indicates that this field
  21153. // was not set, or was not defined in the schema.
  21154. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  21155. switch name {
  21156. case label.FieldStatus:
  21157. return m.AddedStatus()
  21158. case label.FieldType:
  21159. return m.AddedType()
  21160. case label.FieldFrom:
  21161. return m.AddedFrom()
  21162. case label.FieldMode:
  21163. return m.AddedMode()
  21164. case label.FieldOrganizationID:
  21165. return m.AddedOrganizationID()
  21166. }
  21167. return nil, false
  21168. }
  21169. // AddField adds the value to the field with the given name. It returns an error if
  21170. // the field is not defined in the schema, or if the type mismatched the field
  21171. // type.
  21172. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  21173. switch name {
  21174. case label.FieldStatus:
  21175. v, ok := value.(int8)
  21176. if !ok {
  21177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21178. }
  21179. m.AddStatus(v)
  21180. return nil
  21181. case label.FieldType:
  21182. v, ok := value.(int)
  21183. if !ok {
  21184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21185. }
  21186. m.AddType(v)
  21187. return nil
  21188. case label.FieldFrom:
  21189. v, ok := value.(int)
  21190. if !ok {
  21191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21192. }
  21193. m.AddFrom(v)
  21194. return nil
  21195. case label.FieldMode:
  21196. v, ok := value.(int)
  21197. if !ok {
  21198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21199. }
  21200. m.AddMode(v)
  21201. return nil
  21202. case label.FieldOrganizationID:
  21203. v, ok := value.(int64)
  21204. if !ok {
  21205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21206. }
  21207. m.AddOrganizationID(v)
  21208. return nil
  21209. }
  21210. return fmt.Errorf("unknown Label numeric field %s", name)
  21211. }
  21212. // ClearedFields returns all nullable fields that were cleared during this
  21213. // mutation.
  21214. func (m *LabelMutation) ClearedFields() []string {
  21215. var fields []string
  21216. if m.FieldCleared(label.FieldStatus) {
  21217. fields = append(fields, label.FieldStatus)
  21218. }
  21219. if m.FieldCleared(label.FieldConditions) {
  21220. fields = append(fields, label.FieldConditions)
  21221. }
  21222. if m.FieldCleared(label.FieldOrganizationID) {
  21223. fields = append(fields, label.FieldOrganizationID)
  21224. }
  21225. return fields
  21226. }
  21227. // FieldCleared returns a boolean indicating if a field with the given name was
  21228. // cleared in this mutation.
  21229. func (m *LabelMutation) FieldCleared(name string) bool {
  21230. _, ok := m.clearedFields[name]
  21231. return ok
  21232. }
  21233. // ClearField clears the value of the field with the given name. It returns an
  21234. // error if the field is not defined in the schema.
  21235. func (m *LabelMutation) ClearField(name string) error {
  21236. switch name {
  21237. case label.FieldStatus:
  21238. m.ClearStatus()
  21239. return nil
  21240. case label.FieldConditions:
  21241. m.ClearConditions()
  21242. return nil
  21243. case label.FieldOrganizationID:
  21244. m.ClearOrganizationID()
  21245. return nil
  21246. }
  21247. return fmt.Errorf("unknown Label nullable field %s", name)
  21248. }
  21249. // ResetField resets all changes in the mutation for the field with the given name.
  21250. // It returns an error if the field is not defined in the schema.
  21251. func (m *LabelMutation) ResetField(name string) error {
  21252. switch name {
  21253. case label.FieldCreatedAt:
  21254. m.ResetCreatedAt()
  21255. return nil
  21256. case label.FieldUpdatedAt:
  21257. m.ResetUpdatedAt()
  21258. return nil
  21259. case label.FieldStatus:
  21260. m.ResetStatus()
  21261. return nil
  21262. case label.FieldType:
  21263. m.ResetType()
  21264. return nil
  21265. case label.FieldName:
  21266. m.ResetName()
  21267. return nil
  21268. case label.FieldFrom:
  21269. m.ResetFrom()
  21270. return nil
  21271. case label.FieldMode:
  21272. m.ResetMode()
  21273. return nil
  21274. case label.FieldConditions:
  21275. m.ResetConditions()
  21276. return nil
  21277. case label.FieldOrganizationID:
  21278. m.ResetOrganizationID()
  21279. return nil
  21280. }
  21281. return fmt.Errorf("unknown Label field %s", name)
  21282. }
  21283. // AddedEdges returns all edge names that were set/added in this mutation.
  21284. func (m *LabelMutation) AddedEdges() []string {
  21285. edges := make([]string, 0, 1)
  21286. if m.label_relationships != nil {
  21287. edges = append(edges, label.EdgeLabelRelationships)
  21288. }
  21289. return edges
  21290. }
  21291. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21292. // name in this mutation.
  21293. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  21294. switch name {
  21295. case label.EdgeLabelRelationships:
  21296. ids := make([]ent.Value, 0, len(m.label_relationships))
  21297. for id := range m.label_relationships {
  21298. ids = append(ids, id)
  21299. }
  21300. return ids
  21301. }
  21302. return nil
  21303. }
  21304. // RemovedEdges returns all edge names that were removed in this mutation.
  21305. func (m *LabelMutation) RemovedEdges() []string {
  21306. edges := make([]string, 0, 1)
  21307. if m.removedlabel_relationships != nil {
  21308. edges = append(edges, label.EdgeLabelRelationships)
  21309. }
  21310. return edges
  21311. }
  21312. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21313. // the given name in this mutation.
  21314. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  21315. switch name {
  21316. case label.EdgeLabelRelationships:
  21317. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  21318. for id := range m.removedlabel_relationships {
  21319. ids = append(ids, id)
  21320. }
  21321. return ids
  21322. }
  21323. return nil
  21324. }
  21325. // ClearedEdges returns all edge names that were cleared in this mutation.
  21326. func (m *LabelMutation) ClearedEdges() []string {
  21327. edges := make([]string, 0, 1)
  21328. if m.clearedlabel_relationships {
  21329. edges = append(edges, label.EdgeLabelRelationships)
  21330. }
  21331. return edges
  21332. }
  21333. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21334. // was cleared in this mutation.
  21335. func (m *LabelMutation) EdgeCleared(name string) bool {
  21336. switch name {
  21337. case label.EdgeLabelRelationships:
  21338. return m.clearedlabel_relationships
  21339. }
  21340. return false
  21341. }
  21342. // ClearEdge clears the value of the edge with the given name. It returns an error
  21343. // if that edge is not defined in the schema.
  21344. func (m *LabelMutation) ClearEdge(name string) error {
  21345. switch name {
  21346. }
  21347. return fmt.Errorf("unknown Label unique edge %s", name)
  21348. }
  21349. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21350. // It returns an error if the edge is not defined in the schema.
  21351. func (m *LabelMutation) ResetEdge(name string) error {
  21352. switch name {
  21353. case label.EdgeLabelRelationships:
  21354. m.ResetLabelRelationships()
  21355. return nil
  21356. }
  21357. return fmt.Errorf("unknown Label edge %s", name)
  21358. }
  21359. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  21360. type LabelLogMutation struct {
  21361. config
  21362. op Op
  21363. typ string
  21364. id *uint64
  21365. created_at *time.Time
  21366. updated_at *time.Time
  21367. label_name *string
  21368. label_id *int
  21369. addlabel_id *int
  21370. wx_id *string
  21371. organization_id *uint64
  21372. addorganization_id *int64
  21373. clearedFields map[string]struct{}
  21374. done bool
  21375. oldValue func(context.Context) (*LabelLog, error)
  21376. predicates []predicate.LabelLog
  21377. }
  21378. var _ ent.Mutation = (*LabelLogMutation)(nil)
  21379. // labellogOption allows management of the mutation configuration using functional options.
  21380. type labellogOption func(*LabelLogMutation)
  21381. // newLabelLogMutation creates new mutation for the LabelLog entity.
  21382. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  21383. m := &LabelLogMutation{
  21384. config: c,
  21385. op: op,
  21386. typ: TypeLabelLog,
  21387. clearedFields: make(map[string]struct{}),
  21388. }
  21389. for _, opt := range opts {
  21390. opt(m)
  21391. }
  21392. return m
  21393. }
  21394. // withLabelLogID sets the ID field of the mutation.
  21395. func withLabelLogID(id uint64) labellogOption {
  21396. return func(m *LabelLogMutation) {
  21397. var (
  21398. err error
  21399. once sync.Once
  21400. value *LabelLog
  21401. )
  21402. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  21403. once.Do(func() {
  21404. if m.done {
  21405. err = errors.New("querying old values post mutation is not allowed")
  21406. } else {
  21407. value, err = m.Client().LabelLog.Get(ctx, id)
  21408. }
  21409. })
  21410. return value, err
  21411. }
  21412. m.id = &id
  21413. }
  21414. }
  21415. // withLabelLog sets the old LabelLog of the mutation.
  21416. func withLabelLog(node *LabelLog) labellogOption {
  21417. return func(m *LabelLogMutation) {
  21418. m.oldValue = func(context.Context) (*LabelLog, error) {
  21419. return node, nil
  21420. }
  21421. m.id = &node.ID
  21422. }
  21423. }
  21424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21425. // executed in a transaction (ent.Tx), a transactional client is returned.
  21426. func (m LabelLogMutation) Client() *Client {
  21427. client := &Client{config: m.config}
  21428. client.init()
  21429. return client
  21430. }
  21431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21432. // it returns an error otherwise.
  21433. func (m LabelLogMutation) Tx() (*Tx, error) {
  21434. if _, ok := m.driver.(*txDriver); !ok {
  21435. return nil, errors.New("ent: mutation is not running in a transaction")
  21436. }
  21437. tx := &Tx{config: m.config}
  21438. tx.init()
  21439. return tx, nil
  21440. }
  21441. // SetID sets the value of the id field. Note that this
  21442. // operation is only accepted on creation of LabelLog entities.
  21443. func (m *LabelLogMutation) SetID(id uint64) {
  21444. m.id = &id
  21445. }
  21446. // ID returns the ID value in the mutation. Note that the ID is only available
  21447. // if it was provided to the builder or after it was returned from the database.
  21448. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  21449. if m.id == nil {
  21450. return
  21451. }
  21452. return *m.id, true
  21453. }
  21454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21455. // That means, if the mutation is applied within a transaction with an isolation level such
  21456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21457. // or updated by the mutation.
  21458. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  21459. switch {
  21460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21461. id, exists := m.ID()
  21462. if exists {
  21463. return []uint64{id}, nil
  21464. }
  21465. fallthrough
  21466. case m.op.Is(OpUpdate | OpDelete):
  21467. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  21468. default:
  21469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21470. }
  21471. }
  21472. // SetCreatedAt sets the "created_at" field.
  21473. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  21474. m.created_at = &t
  21475. }
  21476. // CreatedAt returns the value of the "created_at" field in the mutation.
  21477. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  21478. v := m.created_at
  21479. if v == nil {
  21480. return
  21481. }
  21482. return *v, true
  21483. }
  21484. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  21485. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21487. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21488. if !m.op.Is(OpUpdateOne) {
  21489. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21490. }
  21491. if m.id == nil || m.oldValue == nil {
  21492. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21493. }
  21494. oldValue, err := m.oldValue(ctx)
  21495. if err != nil {
  21496. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21497. }
  21498. return oldValue.CreatedAt, nil
  21499. }
  21500. // ResetCreatedAt resets all changes to the "created_at" field.
  21501. func (m *LabelLogMutation) ResetCreatedAt() {
  21502. m.created_at = nil
  21503. }
  21504. // SetUpdatedAt sets the "updated_at" field.
  21505. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  21506. m.updated_at = &t
  21507. }
  21508. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21509. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  21510. v := m.updated_at
  21511. if v == nil {
  21512. return
  21513. }
  21514. return *v, true
  21515. }
  21516. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  21517. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21519. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21520. if !m.op.Is(OpUpdateOne) {
  21521. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21522. }
  21523. if m.id == nil || m.oldValue == nil {
  21524. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21525. }
  21526. oldValue, err := m.oldValue(ctx)
  21527. if err != nil {
  21528. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21529. }
  21530. return oldValue.UpdatedAt, nil
  21531. }
  21532. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21533. func (m *LabelLogMutation) ResetUpdatedAt() {
  21534. m.updated_at = nil
  21535. }
  21536. // SetLabelName sets the "label_name" field.
  21537. func (m *LabelLogMutation) SetLabelName(s string) {
  21538. m.label_name = &s
  21539. }
  21540. // LabelName returns the value of the "label_name" field in the mutation.
  21541. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  21542. v := m.label_name
  21543. if v == nil {
  21544. return
  21545. }
  21546. return *v, true
  21547. }
  21548. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  21549. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21551. func (m *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  21552. if !m.op.Is(OpUpdateOne) {
  21553. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  21554. }
  21555. if m.id == nil || m.oldValue == nil {
  21556. return v, errors.New("OldLabelName requires an ID field in the mutation")
  21557. }
  21558. oldValue, err := m.oldValue(ctx)
  21559. if err != nil {
  21560. return v, fmt.Errorf("querying old value for OldLabelName: %w", err)
  21561. }
  21562. return oldValue.LabelName, nil
  21563. }
  21564. // ResetLabelName resets all changes to the "label_name" field.
  21565. func (m *LabelLogMutation) ResetLabelName() {
  21566. m.label_name = nil
  21567. }
  21568. // SetLabelID sets the "label_id" field.
  21569. func (m *LabelLogMutation) SetLabelID(i int) {
  21570. m.label_id = &i
  21571. m.addlabel_id = nil
  21572. }
  21573. // LabelID returns the value of the "label_id" field in the mutation.
  21574. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  21575. v := m.label_id
  21576. if v == nil {
  21577. return
  21578. }
  21579. return *v, true
  21580. }
  21581. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  21582. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21584. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  21585. if !m.op.Is(OpUpdateOne) {
  21586. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  21587. }
  21588. if m.id == nil || m.oldValue == nil {
  21589. return v, errors.New("OldLabelID requires an ID field in the mutation")
  21590. }
  21591. oldValue, err := m.oldValue(ctx)
  21592. if err != nil {
  21593. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  21594. }
  21595. return oldValue.LabelID, nil
  21596. }
  21597. // AddLabelID adds i to the "label_id" field.
  21598. func (m *LabelLogMutation) AddLabelID(i int) {
  21599. if m.addlabel_id != nil {
  21600. *m.addlabel_id += i
  21601. } else {
  21602. m.addlabel_id = &i
  21603. }
  21604. }
  21605. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  21606. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  21607. v := m.addlabel_id
  21608. if v == nil {
  21609. return
  21610. }
  21611. return *v, true
  21612. }
  21613. // ResetLabelID resets all changes to the "label_id" field.
  21614. func (m *LabelLogMutation) ResetLabelID() {
  21615. m.label_id = nil
  21616. m.addlabel_id = nil
  21617. }
  21618. // SetWxID sets the "wx_id" field.
  21619. func (m *LabelLogMutation) SetWxID(s string) {
  21620. m.wx_id = &s
  21621. }
  21622. // WxID returns the value of the "wx_id" field in the mutation.
  21623. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  21624. v := m.wx_id
  21625. if v == nil {
  21626. return
  21627. }
  21628. return *v, true
  21629. }
  21630. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  21631. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21633. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  21634. if !m.op.Is(OpUpdateOne) {
  21635. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  21636. }
  21637. if m.id == nil || m.oldValue == nil {
  21638. return v, errors.New("OldWxID requires an ID field in the mutation")
  21639. }
  21640. oldValue, err := m.oldValue(ctx)
  21641. if err != nil {
  21642. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  21643. }
  21644. return oldValue.WxID, nil
  21645. }
  21646. // ResetWxID resets all changes to the "wx_id" field.
  21647. func (m *LabelLogMutation) ResetWxID() {
  21648. m.wx_id = nil
  21649. }
  21650. // SetOrganizationID sets the "organization_id" field.
  21651. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  21652. m.organization_id = &u
  21653. m.addorganization_id = nil
  21654. }
  21655. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21656. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  21657. v := m.organization_id
  21658. if v == nil {
  21659. return
  21660. }
  21661. return *v, true
  21662. }
  21663. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  21664. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21666. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21667. if !m.op.Is(OpUpdateOne) {
  21668. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21669. }
  21670. if m.id == nil || m.oldValue == nil {
  21671. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21672. }
  21673. oldValue, err := m.oldValue(ctx)
  21674. if err != nil {
  21675. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21676. }
  21677. return oldValue.OrganizationID, nil
  21678. }
  21679. // AddOrganizationID adds u to the "organization_id" field.
  21680. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  21681. if m.addorganization_id != nil {
  21682. *m.addorganization_id += u
  21683. } else {
  21684. m.addorganization_id = &u
  21685. }
  21686. }
  21687. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21688. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  21689. v := m.addorganization_id
  21690. if v == nil {
  21691. return
  21692. }
  21693. return *v, true
  21694. }
  21695. // ClearOrganizationID clears the value of the "organization_id" field.
  21696. func (m *LabelLogMutation) ClearOrganizationID() {
  21697. m.organization_id = nil
  21698. m.addorganization_id = nil
  21699. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  21700. }
  21701. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21702. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  21703. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  21704. return ok
  21705. }
  21706. // ResetOrganizationID resets all changes to the "organization_id" field.
  21707. func (m *LabelLogMutation) ResetOrganizationID() {
  21708. m.organization_id = nil
  21709. m.addorganization_id = nil
  21710. delete(m.clearedFields, labellog.FieldOrganizationID)
  21711. }
  21712. // Where appends a list predicates to the LabelLogMutation builder.
  21713. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  21714. m.predicates = append(m.predicates, ps...)
  21715. }
  21716. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  21717. // users can use type-assertion to append predicates that do not depend on any generated package.
  21718. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  21719. p := make([]predicate.LabelLog, len(ps))
  21720. for i := range ps {
  21721. p[i] = ps[i]
  21722. }
  21723. m.Where(p...)
  21724. }
  21725. // Op returns the operation name.
  21726. func (m *LabelLogMutation) Op() Op {
  21727. return m.op
  21728. }
  21729. // SetOp allows setting the mutation operation.
  21730. func (m *LabelLogMutation) SetOp(op Op) {
  21731. m.op = op
  21732. }
  21733. // Type returns the node type of this mutation (LabelLog).
  21734. func (m *LabelLogMutation) Type() string {
  21735. return m.typ
  21736. }
  21737. // Fields returns all fields that were changed during this mutation. Note that in
  21738. // order to get all numeric fields that were incremented/decremented, call
  21739. // AddedFields().
  21740. func (m *LabelLogMutation) Fields() []string {
  21741. fields := make([]string, 0, 6)
  21742. if m.created_at != nil {
  21743. fields = append(fields, labellog.FieldCreatedAt)
  21744. }
  21745. if m.updated_at != nil {
  21746. fields = append(fields, labellog.FieldUpdatedAt)
  21747. }
  21748. if m.label_name != nil {
  21749. fields = append(fields, labellog.FieldLabelName)
  21750. }
  21751. if m.label_id != nil {
  21752. fields = append(fields, labellog.FieldLabelID)
  21753. }
  21754. if m.wx_id != nil {
  21755. fields = append(fields, labellog.FieldWxID)
  21756. }
  21757. if m.organization_id != nil {
  21758. fields = append(fields, labellog.FieldOrganizationID)
  21759. }
  21760. return fields
  21761. }
  21762. // Field returns the value of a field with the given name. The second boolean
  21763. // return value indicates that this field was not set, or was not defined in the
  21764. // schema.
  21765. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  21766. switch name {
  21767. case labellog.FieldCreatedAt:
  21768. return m.CreatedAt()
  21769. case labellog.FieldUpdatedAt:
  21770. return m.UpdatedAt()
  21771. case labellog.FieldLabelName:
  21772. return m.LabelName()
  21773. case labellog.FieldLabelID:
  21774. return m.LabelID()
  21775. case labellog.FieldWxID:
  21776. return m.WxID()
  21777. case labellog.FieldOrganizationID:
  21778. return m.OrganizationID()
  21779. }
  21780. return nil, false
  21781. }
  21782. // OldField returns the old value of the field from the database. An error is
  21783. // returned if the mutation operation is not UpdateOne, or the query to the
  21784. // database failed.
  21785. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21786. switch name {
  21787. case labellog.FieldCreatedAt:
  21788. return m.OldCreatedAt(ctx)
  21789. case labellog.FieldUpdatedAt:
  21790. return m.OldUpdatedAt(ctx)
  21791. case labellog.FieldLabelName:
  21792. return m.OldLabelName(ctx)
  21793. case labellog.FieldLabelID:
  21794. return m.OldLabelID(ctx)
  21795. case labellog.FieldWxID:
  21796. return m.OldWxID(ctx)
  21797. case labellog.FieldOrganizationID:
  21798. return m.OldOrganizationID(ctx)
  21799. }
  21800. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  21801. }
  21802. // SetField sets the value of a field with the given name. It returns an error if
  21803. // the field is not defined in the schema, or if the type mismatched the field
  21804. // type.
  21805. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  21806. switch name {
  21807. case labellog.FieldCreatedAt:
  21808. v, ok := value.(time.Time)
  21809. if !ok {
  21810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21811. }
  21812. m.SetCreatedAt(v)
  21813. return nil
  21814. case labellog.FieldUpdatedAt:
  21815. v, ok := value.(time.Time)
  21816. if !ok {
  21817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21818. }
  21819. m.SetUpdatedAt(v)
  21820. return nil
  21821. case labellog.FieldLabelName:
  21822. v, ok := value.(string)
  21823. if !ok {
  21824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21825. }
  21826. m.SetLabelName(v)
  21827. return nil
  21828. case labellog.FieldLabelID:
  21829. v, ok := value.(int)
  21830. if !ok {
  21831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21832. }
  21833. m.SetLabelID(v)
  21834. return nil
  21835. case labellog.FieldWxID:
  21836. v, ok := value.(string)
  21837. if !ok {
  21838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21839. }
  21840. m.SetWxID(v)
  21841. return nil
  21842. case labellog.FieldOrganizationID:
  21843. v, ok := value.(uint64)
  21844. if !ok {
  21845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21846. }
  21847. m.SetOrganizationID(v)
  21848. return nil
  21849. }
  21850. return fmt.Errorf("unknown LabelLog field %s", name)
  21851. }
  21852. // AddedFields returns all numeric fields that were incremented/decremented during
  21853. // this mutation.
  21854. func (m *LabelLogMutation) AddedFields() []string {
  21855. var fields []string
  21856. if m.addlabel_id != nil {
  21857. fields = append(fields, labellog.FieldLabelID)
  21858. }
  21859. if m.addorganization_id != nil {
  21860. fields = append(fields, labellog.FieldOrganizationID)
  21861. }
  21862. return fields
  21863. }
  21864. // AddedField returns the numeric value that was incremented/decremented on a field
  21865. // with the given name. The second boolean return value indicates that this field
  21866. // was not set, or was not defined in the schema.
  21867. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  21868. switch name {
  21869. case labellog.FieldLabelID:
  21870. return m.AddedLabelID()
  21871. case labellog.FieldOrganizationID:
  21872. return m.AddedOrganizationID()
  21873. }
  21874. return nil, false
  21875. }
  21876. // AddField adds the value to the field with the given name. It returns an error if
  21877. // the field is not defined in the schema, or if the type mismatched the field
  21878. // type.
  21879. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  21880. switch name {
  21881. case labellog.FieldLabelID:
  21882. v, ok := value.(int)
  21883. if !ok {
  21884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21885. }
  21886. m.AddLabelID(v)
  21887. return nil
  21888. case labellog.FieldOrganizationID:
  21889. v, ok := value.(int64)
  21890. if !ok {
  21891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21892. }
  21893. m.AddOrganizationID(v)
  21894. return nil
  21895. }
  21896. return fmt.Errorf("unknown LabelLog numeric field %s", name)
  21897. }
  21898. // ClearedFields returns all nullable fields that were cleared during this
  21899. // mutation.
  21900. func (m *LabelLogMutation) ClearedFields() []string {
  21901. var fields []string
  21902. if m.FieldCleared(labellog.FieldOrganizationID) {
  21903. fields = append(fields, labellog.FieldOrganizationID)
  21904. }
  21905. return fields
  21906. }
  21907. // FieldCleared returns a boolean indicating if a field with the given name was
  21908. // cleared in this mutation.
  21909. func (m *LabelLogMutation) FieldCleared(name string) bool {
  21910. _, ok := m.clearedFields[name]
  21911. return ok
  21912. }
  21913. // ClearField clears the value of the field with the given name. It returns an
  21914. // error if the field is not defined in the schema.
  21915. func (m *LabelLogMutation) ClearField(name string) error {
  21916. switch name {
  21917. case labellog.FieldOrganizationID:
  21918. m.ClearOrganizationID()
  21919. return nil
  21920. }
  21921. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  21922. }
  21923. // ResetField resets all changes in the mutation for the field with the given name.
  21924. // It returns an error if the field is not defined in the schema.
  21925. func (m *LabelLogMutation) ResetField(name string) error {
  21926. switch name {
  21927. case labellog.FieldCreatedAt:
  21928. m.ResetCreatedAt()
  21929. return nil
  21930. case labellog.FieldUpdatedAt:
  21931. m.ResetUpdatedAt()
  21932. return nil
  21933. case labellog.FieldLabelName:
  21934. m.ResetLabelName()
  21935. return nil
  21936. case labellog.FieldLabelID:
  21937. m.ResetLabelID()
  21938. return nil
  21939. case labellog.FieldWxID:
  21940. m.ResetWxID()
  21941. return nil
  21942. case labellog.FieldOrganizationID:
  21943. m.ResetOrganizationID()
  21944. return nil
  21945. }
  21946. return fmt.Errorf("unknown LabelLog field %s", name)
  21947. }
  21948. // AddedEdges returns all edge names that were set/added in this mutation.
  21949. func (m *LabelLogMutation) AddedEdges() []string {
  21950. edges := make([]string, 0, 0)
  21951. return edges
  21952. }
  21953. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21954. // name in this mutation.
  21955. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  21956. return nil
  21957. }
  21958. // RemovedEdges returns all edge names that were removed in this mutation.
  21959. func (m *LabelLogMutation) RemovedEdges() []string {
  21960. edges := make([]string, 0, 0)
  21961. return edges
  21962. }
  21963. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21964. // the given name in this mutation.
  21965. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  21966. return nil
  21967. }
  21968. // ClearedEdges returns all edge names that were cleared in this mutation.
  21969. func (m *LabelLogMutation) ClearedEdges() []string {
  21970. edges := make([]string, 0, 0)
  21971. return edges
  21972. }
  21973. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21974. // was cleared in this mutation.
  21975. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  21976. return false
  21977. }
  21978. // ClearEdge clears the value of the edge with the given name. It returns an error
  21979. // if that edge is not defined in the schema.
  21980. func (m *LabelLogMutation) ClearEdge(name string) error {
  21981. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  21982. }
  21983. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21984. // It returns an error if the edge is not defined in the schema.
  21985. func (m *LabelLogMutation) ResetEdge(name string) error {
  21986. return fmt.Errorf("unknown LabelLog edge %s", name)
  21987. }
  21988. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  21989. type LabelRelationshipMutation struct {
  21990. config
  21991. op Op
  21992. typ string
  21993. id *uint64
  21994. created_at *time.Time
  21995. updated_at *time.Time
  21996. status *uint8
  21997. addstatus *int8
  21998. organization_id *uint64
  21999. addorganization_id *int64
  22000. clearedFields map[string]struct{}
  22001. contacts *uint64
  22002. clearedcontacts bool
  22003. labels *uint64
  22004. clearedlabels bool
  22005. done bool
  22006. oldValue func(context.Context) (*LabelRelationship, error)
  22007. predicates []predicate.LabelRelationship
  22008. }
  22009. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  22010. // labelrelationshipOption allows management of the mutation configuration using functional options.
  22011. type labelrelationshipOption func(*LabelRelationshipMutation)
  22012. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  22013. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  22014. m := &LabelRelationshipMutation{
  22015. config: c,
  22016. op: op,
  22017. typ: TypeLabelRelationship,
  22018. clearedFields: make(map[string]struct{}),
  22019. }
  22020. for _, opt := range opts {
  22021. opt(m)
  22022. }
  22023. return m
  22024. }
  22025. // withLabelRelationshipID sets the ID field of the mutation.
  22026. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  22027. return func(m *LabelRelationshipMutation) {
  22028. var (
  22029. err error
  22030. once sync.Once
  22031. value *LabelRelationship
  22032. )
  22033. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  22034. once.Do(func() {
  22035. if m.done {
  22036. err = errors.New("querying old values post mutation is not allowed")
  22037. } else {
  22038. value, err = m.Client().LabelRelationship.Get(ctx, id)
  22039. }
  22040. })
  22041. return value, err
  22042. }
  22043. m.id = &id
  22044. }
  22045. }
  22046. // withLabelRelationship sets the old LabelRelationship of the mutation.
  22047. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  22048. return func(m *LabelRelationshipMutation) {
  22049. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  22050. return node, nil
  22051. }
  22052. m.id = &node.ID
  22053. }
  22054. }
  22055. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22056. // executed in a transaction (ent.Tx), a transactional client is returned.
  22057. func (m LabelRelationshipMutation) Client() *Client {
  22058. client := &Client{config: m.config}
  22059. client.init()
  22060. return client
  22061. }
  22062. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22063. // it returns an error otherwise.
  22064. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  22065. if _, ok := m.driver.(*txDriver); !ok {
  22066. return nil, errors.New("ent: mutation is not running in a transaction")
  22067. }
  22068. tx := &Tx{config: m.config}
  22069. tx.init()
  22070. return tx, nil
  22071. }
  22072. // SetID sets the value of the id field. Note that this
  22073. // operation is only accepted on creation of LabelRelationship entities.
  22074. func (m *LabelRelationshipMutation) SetID(id uint64) {
  22075. m.id = &id
  22076. }
  22077. // ID returns the ID value in the mutation. Note that the ID is only available
  22078. // if it was provided to the builder or after it was returned from the database.
  22079. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  22080. if m.id == nil {
  22081. return
  22082. }
  22083. return *m.id, true
  22084. }
  22085. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22086. // That means, if the mutation is applied within a transaction with an isolation level such
  22087. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22088. // or updated by the mutation.
  22089. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  22090. switch {
  22091. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22092. id, exists := m.ID()
  22093. if exists {
  22094. return []uint64{id}, nil
  22095. }
  22096. fallthrough
  22097. case m.op.Is(OpUpdate | OpDelete):
  22098. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  22099. default:
  22100. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22101. }
  22102. }
  22103. // SetCreatedAt sets the "created_at" field.
  22104. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  22105. m.created_at = &t
  22106. }
  22107. // CreatedAt returns the value of the "created_at" field in the mutation.
  22108. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  22109. v := m.created_at
  22110. if v == nil {
  22111. return
  22112. }
  22113. return *v, true
  22114. }
  22115. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  22116. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22118. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22119. if !m.op.Is(OpUpdateOne) {
  22120. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22121. }
  22122. if m.id == nil || m.oldValue == nil {
  22123. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22124. }
  22125. oldValue, err := m.oldValue(ctx)
  22126. if err != nil {
  22127. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22128. }
  22129. return oldValue.CreatedAt, nil
  22130. }
  22131. // ResetCreatedAt resets all changes to the "created_at" field.
  22132. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  22133. m.created_at = nil
  22134. }
  22135. // SetUpdatedAt sets the "updated_at" field.
  22136. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  22137. m.updated_at = &t
  22138. }
  22139. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22140. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  22141. v := m.updated_at
  22142. if v == nil {
  22143. return
  22144. }
  22145. return *v, true
  22146. }
  22147. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  22148. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22150. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22151. if !m.op.Is(OpUpdateOne) {
  22152. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22153. }
  22154. if m.id == nil || m.oldValue == nil {
  22155. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22156. }
  22157. oldValue, err := m.oldValue(ctx)
  22158. if err != nil {
  22159. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22160. }
  22161. return oldValue.UpdatedAt, nil
  22162. }
  22163. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22164. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  22165. m.updated_at = nil
  22166. }
  22167. // SetStatus sets the "status" field.
  22168. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  22169. m.status = &u
  22170. m.addstatus = nil
  22171. }
  22172. // Status returns the value of the "status" field in the mutation.
  22173. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  22174. v := m.status
  22175. if v == nil {
  22176. return
  22177. }
  22178. return *v, true
  22179. }
  22180. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  22181. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22183. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22184. if !m.op.Is(OpUpdateOne) {
  22185. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22186. }
  22187. if m.id == nil || m.oldValue == nil {
  22188. return v, errors.New("OldStatus requires an ID field in the mutation")
  22189. }
  22190. oldValue, err := m.oldValue(ctx)
  22191. if err != nil {
  22192. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22193. }
  22194. return oldValue.Status, nil
  22195. }
  22196. // AddStatus adds u to the "status" field.
  22197. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  22198. if m.addstatus != nil {
  22199. *m.addstatus += u
  22200. } else {
  22201. m.addstatus = &u
  22202. }
  22203. }
  22204. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22205. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  22206. v := m.addstatus
  22207. if v == nil {
  22208. return
  22209. }
  22210. return *v, true
  22211. }
  22212. // ClearStatus clears the value of the "status" field.
  22213. func (m *LabelRelationshipMutation) ClearStatus() {
  22214. m.status = nil
  22215. m.addstatus = nil
  22216. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  22217. }
  22218. // StatusCleared returns if the "status" field was cleared in this mutation.
  22219. func (m *LabelRelationshipMutation) StatusCleared() bool {
  22220. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  22221. return ok
  22222. }
  22223. // ResetStatus resets all changes to the "status" field.
  22224. func (m *LabelRelationshipMutation) ResetStatus() {
  22225. m.status = nil
  22226. m.addstatus = nil
  22227. delete(m.clearedFields, labelrelationship.FieldStatus)
  22228. }
  22229. // SetLabelID sets the "label_id" field.
  22230. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  22231. m.labels = &u
  22232. }
  22233. // LabelID returns the value of the "label_id" field in the mutation.
  22234. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  22235. v := m.labels
  22236. if v == nil {
  22237. return
  22238. }
  22239. return *v, true
  22240. }
  22241. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  22242. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22244. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  22245. if !m.op.Is(OpUpdateOne) {
  22246. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  22247. }
  22248. if m.id == nil || m.oldValue == nil {
  22249. return v, errors.New("OldLabelID requires an ID field in the mutation")
  22250. }
  22251. oldValue, err := m.oldValue(ctx)
  22252. if err != nil {
  22253. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  22254. }
  22255. return oldValue.LabelID, nil
  22256. }
  22257. // ResetLabelID resets all changes to the "label_id" field.
  22258. func (m *LabelRelationshipMutation) ResetLabelID() {
  22259. m.labels = nil
  22260. }
  22261. // SetContactID sets the "contact_id" field.
  22262. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  22263. m.contacts = &u
  22264. }
  22265. // ContactID returns the value of the "contact_id" field in the mutation.
  22266. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  22267. v := m.contacts
  22268. if v == nil {
  22269. return
  22270. }
  22271. return *v, true
  22272. }
  22273. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  22274. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22276. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22277. if !m.op.Is(OpUpdateOne) {
  22278. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22279. }
  22280. if m.id == nil || m.oldValue == nil {
  22281. return v, errors.New("OldContactID requires an ID field in the mutation")
  22282. }
  22283. oldValue, err := m.oldValue(ctx)
  22284. if err != nil {
  22285. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22286. }
  22287. return oldValue.ContactID, nil
  22288. }
  22289. // ResetContactID resets all changes to the "contact_id" field.
  22290. func (m *LabelRelationshipMutation) ResetContactID() {
  22291. m.contacts = nil
  22292. }
  22293. // SetOrganizationID sets the "organization_id" field.
  22294. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  22295. m.organization_id = &u
  22296. m.addorganization_id = nil
  22297. }
  22298. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22299. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  22300. v := m.organization_id
  22301. if v == nil {
  22302. return
  22303. }
  22304. return *v, true
  22305. }
  22306. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  22307. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22309. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22310. if !m.op.Is(OpUpdateOne) {
  22311. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22312. }
  22313. if m.id == nil || m.oldValue == nil {
  22314. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22315. }
  22316. oldValue, err := m.oldValue(ctx)
  22317. if err != nil {
  22318. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22319. }
  22320. return oldValue.OrganizationID, nil
  22321. }
  22322. // AddOrganizationID adds u to the "organization_id" field.
  22323. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  22324. if m.addorganization_id != nil {
  22325. *m.addorganization_id += u
  22326. } else {
  22327. m.addorganization_id = &u
  22328. }
  22329. }
  22330. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22331. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  22332. v := m.addorganization_id
  22333. if v == nil {
  22334. return
  22335. }
  22336. return *v, true
  22337. }
  22338. // ClearOrganizationID clears the value of the "organization_id" field.
  22339. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  22340. m.organization_id = nil
  22341. m.addorganization_id = nil
  22342. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  22343. }
  22344. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22345. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  22346. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  22347. return ok
  22348. }
  22349. // ResetOrganizationID resets all changes to the "organization_id" field.
  22350. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  22351. m.organization_id = nil
  22352. m.addorganization_id = nil
  22353. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  22354. }
  22355. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  22356. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  22357. m.contacts = &id
  22358. }
  22359. // ClearContacts clears the "contacts" edge to the Contact entity.
  22360. func (m *LabelRelationshipMutation) ClearContacts() {
  22361. m.clearedcontacts = true
  22362. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  22363. }
  22364. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  22365. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  22366. return m.clearedcontacts
  22367. }
  22368. // ContactsID returns the "contacts" edge ID in the mutation.
  22369. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  22370. if m.contacts != nil {
  22371. return *m.contacts, true
  22372. }
  22373. return
  22374. }
  22375. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  22376. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22377. // ContactsID instead. It exists only for internal usage by the builders.
  22378. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  22379. if id := m.contacts; id != nil {
  22380. ids = append(ids, *id)
  22381. }
  22382. return
  22383. }
  22384. // ResetContacts resets all changes to the "contacts" edge.
  22385. func (m *LabelRelationshipMutation) ResetContacts() {
  22386. m.contacts = nil
  22387. m.clearedcontacts = false
  22388. }
  22389. // SetLabelsID sets the "labels" edge to the Label entity by id.
  22390. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  22391. m.labels = &id
  22392. }
  22393. // ClearLabels clears the "labels" edge to the Label entity.
  22394. func (m *LabelRelationshipMutation) ClearLabels() {
  22395. m.clearedlabels = true
  22396. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  22397. }
  22398. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  22399. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  22400. return m.clearedlabels
  22401. }
  22402. // LabelsID returns the "labels" edge ID in the mutation.
  22403. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  22404. if m.labels != nil {
  22405. return *m.labels, true
  22406. }
  22407. return
  22408. }
  22409. // LabelsIDs returns the "labels" edge IDs in the mutation.
  22410. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22411. // LabelsID instead. It exists only for internal usage by the builders.
  22412. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  22413. if id := m.labels; id != nil {
  22414. ids = append(ids, *id)
  22415. }
  22416. return
  22417. }
  22418. // ResetLabels resets all changes to the "labels" edge.
  22419. func (m *LabelRelationshipMutation) ResetLabels() {
  22420. m.labels = nil
  22421. m.clearedlabels = false
  22422. }
  22423. // Where appends a list predicates to the LabelRelationshipMutation builder.
  22424. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  22425. m.predicates = append(m.predicates, ps...)
  22426. }
  22427. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  22428. // users can use type-assertion to append predicates that do not depend on any generated package.
  22429. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  22430. p := make([]predicate.LabelRelationship, len(ps))
  22431. for i := range ps {
  22432. p[i] = ps[i]
  22433. }
  22434. m.Where(p...)
  22435. }
  22436. // Op returns the operation name.
  22437. func (m *LabelRelationshipMutation) Op() Op {
  22438. return m.op
  22439. }
  22440. // SetOp allows setting the mutation operation.
  22441. func (m *LabelRelationshipMutation) SetOp(op Op) {
  22442. m.op = op
  22443. }
  22444. // Type returns the node type of this mutation (LabelRelationship).
  22445. func (m *LabelRelationshipMutation) Type() string {
  22446. return m.typ
  22447. }
  22448. // Fields returns all fields that were changed during this mutation. Note that in
  22449. // order to get all numeric fields that were incremented/decremented, call
  22450. // AddedFields().
  22451. func (m *LabelRelationshipMutation) Fields() []string {
  22452. fields := make([]string, 0, 6)
  22453. if m.created_at != nil {
  22454. fields = append(fields, labelrelationship.FieldCreatedAt)
  22455. }
  22456. if m.updated_at != nil {
  22457. fields = append(fields, labelrelationship.FieldUpdatedAt)
  22458. }
  22459. if m.status != nil {
  22460. fields = append(fields, labelrelationship.FieldStatus)
  22461. }
  22462. if m.labels != nil {
  22463. fields = append(fields, labelrelationship.FieldLabelID)
  22464. }
  22465. if m.contacts != nil {
  22466. fields = append(fields, labelrelationship.FieldContactID)
  22467. }
  22468. if m.organization_id != nil {
  22469. fields = append(fields, labelrelationship.FieldOrganizationID)
  22470. }
  22471. return fields
  22472. }
  22473. // Field returns the value of a field with the given name. The second boolean
  22474. // return value indicates that this field was not set, or was not defined in the
  22475. // schema.
  22476. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  22477. switch name {
  22478. case labelrelationship.FieldCreatedAt:
  22479. return m.CreatedAt()
  22480. case labelrelationship.FieldUpdatedAt:
  22481. return m.UpdatedAt()
  22482. case labelrelationship.FieldStatus:
  22483. return m.Status()
  22484. case labelrelationship.FieldLabelID:
  22485. return m.LabelID()
  22486. case labelrelationship.FieldContactID:
  22487. return m.ContactID()
  22488. case labelrelationship.FieldOrganizationID:
  22489. return m.OrganizationID()
  22490. }
  22491. return nil, false
  22492. }
  22493. // OldField returns the old value of the field from the database. An error is
  22494. // returned if the mutation operation is not UpdateOne, or the query to the
  22495. // database failed.
  22496. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22497. switch name {
  22498. case labelrelationship.FieldCreatedAt:
  22499. return m.OldCreatedAt(ctx)
  22500. case labelrelationship.FieldUpdatedAt:
  22501. return m.OldUpdatedAt(ctx)
  22502. case labelrelationship.FieldStatus:
  22503. return m.OldStatus(ctx)
  22504. case labelrelationship.FieldLabelID:
  22505. return m.OldLabelID(ctx)
  22506. case labelrelationship.FieldContactID:
  22507. return m.OldContactID(ctx)
  22508. case labelrelationship.FieldOrganizationID:
  22509. return m.OldOrganizationID(ctx)
  22510. }
  22511. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  22512. }
  22513. // SetField sets the value of a field with the given name. It returns an error if
  22514. // the field is not defined in the schema, or if the type mismatched the field
  22515. // type.
  22516. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  22517. switch name {
  22518. case labelrelationship.FieldCreatedAt:
  22519. v, ok := value.(time.Time)
  22520. if !ok {
  22521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22522. }
  22523. m.SetCreatedAt(v)
  22524. return nil
  22525. case labelrelationship.FieldUpdatedAt:
  22526. v, ok := value.(time.Time)
  22527. if !ok {
  22528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22529. }
  22530. m.SetUpdatedAt(v)
  22531. return nil
  22532. case labelrelationship.FieldStatus:
  22533. v, ok := value.(uint8)
  22534. if !ok {
  22535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22536. }
  22537. m.SetStatus(v)
  22538. return nil
  22539. case labelrelationship.FieldLabelID:
  22540. v, ok := value.(uint64)
  22541. if !ok {
  22542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22543. }
  22544. m.SetLabelID(v)
  22545. return nil
  22546. case labelrelationship.FieldContactID:
  22547. v, ok := value.(uint64)
  22548. if !ok {
  22549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22550. }
  22551. m.SetContactID(v)
  22552. return nil
  22553. case labelrelationship.FieldOrganizationID:
  22554. v, ok := value.(uint64)
  22555. if !ok {
  22556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22557. }
  22558. m.SetOrganizationID(v)
  22559. return nil
  22560. }
  22561. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22562. }
  22563. // AddedFields returns all numeric fields that were incremented/decremented during
  22564. // this mutation.
  22565. func (m *LabelRelationshipMutation) AddedFields() []string {
  22566. var fields []string
  22567. if m.addstatus != nil {
  22568. fields = append(fields, labelrelationship.FieldStatus)
  22569. }
  22570. if m.addorganization_id != nil {
  22571. fields = append(fields, labelrelationship.FieldOrganizationID)
  22572. }
  22573. return fields
  22574. }
  22575. // AddedField returns the numeric value that was incremented/decremented on a field
  22576. // with the given name. The second boolean return value indicates that this field
  22577. // was not set, or was not defined in the schema.
  22578. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  22579. switch name {
  22580. case labelrelationship.FieldStatus:
  22581. return m.AddedStatus()
  22582. case labelrelationship.FieldOrganizationID:
  22583. return m.AddedOrganizationID()
  22584. }
  22585. return nil, false
  22586. }
  22587. // AddField adds the value to the field with the given name. It returns an error if
  22588. // the field is not defined in the schema, or if the type mismatched the field
  22589. // type.
  22590. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  22591. switch name {
  22592. case labelrelationship.FieldStatus:
  22593. v, ok := value.(int8)
  22594. if !ok {
  22595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22596. }
  22597. m.AddStatus(v)
  22598. return nil
  22599. case labelrelationship.FieldOrganizationID:
  22600. v, ok := value.(int64)
  22601. if !ok {
  22602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22603. }
  22604. m.AddOrganizationID(v)
  22605. return nil
  22606. }
  22607. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  22608. }
  22609. // ClearedFields returns all nullable fields that were cleared during this
  22610. // mutation.
  22611. func (m *LabelRelationshipMutation) ClearedFields() []string {
  22612. var fields []string
  22613. if m.FieldCleared(labelrelationship.FieldStatus) {
  22614. fields = append(fields, labelrelationship.FieldStatus)
  22615. }
  22616. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  22617. fields = append(fields, labelrelationship.FieldOrganizationID)
  22618. }
  22619. return fields
  22620. }
  22621. // FieldCleared returns a boolean indicating if a field with the given name was
  22622. // cleared in this mutation.
  22623. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  22624. _, ok := m.clearedFields[name]
  22625. return ok
  22626. }
  22627. // ClearField clears the value of the field with the given name. It returns an
  22628. // error if the field is not defined in the schema.
  22629. func (m *LabelRelationshipMutation) ClearField(name string) error {
  22630. switch name {
  22631. case labelrelationship.FieldStatus:
  22632. m.ClearStatus()
  22633. return nil
  22634. case labelrelationship.FieldOrganizationID:
  22635. m.ClearOrganizationID()
  22636. return nil
  22637. }
  22638. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  22639. }
  22640. // ResetField resets all changes in the mutation for the field with the given name.
  22641. // It returns an error if the field is not defined in the schema.
  22642. func (m *LabelRelationshipMutation) ResetField(name string) error {
  22643. switch name {
  22644. case labelrelationship.FieldCreatedAt:
  22645. m.ResetCreatedAt()
  22646. return nil
  22647. case labelrelationship.FieldUpdatedAt:
  22648. m.ResetUpdatedAt()
  22649. return nil
  22650. case labelrelationship.FieldStatus:
  22651. m.ResetStatus()
  22652. return nil
  22653. case labelrelationship.FieldLabelID:
  22654. m.ResetLabelID()
  22655. return nil
  22656. case labelrelationship.FieldContactID:
  22657. m.ResetContactID()
  22658. return nil
  22659. case labelrelationship.FieldOrganizationID:
  22660. m.ResetOrganizationID()
  22661. return nil
  22662. }
  22663. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22664. }
  22665. // AddedEdges returns all edge names that were set/added in this mutation.
  22666. func (m *LabelRelationshipMutation) AddedEdges() []string {
  22667. edges := make([]string, 0, 2)
  22668. if m.contacts != nil {
  22669. edges = append(edges, labelrelationship.EdgeContacts)
  22670. }
  22671. if m.labels != nil {
  22672. edges = append(edges, labelrelationship.EdgeLabels)
  22673. }
  22674. return edges
  22675. }
  22676. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22677. // name in this mutation.
  22678. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  22679. switch name {
  22680. case labelrelationship.EdgeContacts:
  22681. if id := m.contacts; id != nil {
  22682. return []ent.Value{*id}
  22683. }
  22684. case labelrelationship.EdgeLabels:
  22685. if id := m.labels; id != nil {
  22686. return []ent.Value{*id}
  22687. }
  22688. }
  22689. return nil
  22690. }
  22691. // RemovedEdges returns all edge names that were removed in this mutation.
  22692. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  22693. edges := make([]string, 0, 2)
  22694. return edges
  22695. }
  22696. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22697. // the given name in this mutation.
  22698. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  22699. return nil
  22700. }
  22701. // ClearedEdges returns all edge names that were cleared in this mutation.
  22702. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  22703. edges := make([]string, 0, 2)
  22704. if m.clearedcontacts {
  22705. edges = append(edges, labelrelationship.EdgeContacts)
  22706. }
  22707. if m.clearedlabels {
  22708. edges = append(edges, labelrelationship.EdgeLabels)
  22709. }
  22710. return edges
  22711. }
  22712. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22713. // was cleared in this mutation.
  22714. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  22715. switch name {
  22716. case labelrelationship.EdgeContacts:
  22717. return m.clearedcontacts
  22718. case labelrelationship.EdgeLabels:
  22719. return m.clearedlabels
  22720. }
  22721. return false
  22722. }
  22723. // ClearEdge clears the value of the edge with the given name. It returns an error
  22724. // if that edge is not defined in the schema.
  22725. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  22726. switch name {
  22727. case labelrelationship.EdgeContacts:
  22728. m.ClearContacts()
  22729. return nil
  22730. case labelrelationship.EdgeLabels:
  22731. m.ClearLabels()
  22732. return nil
  22733. }
  22734. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  22735. }
  22736. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22737. // It returns an error if the edge is not defined in the schema.
  22738. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  22739. switch name {
  22740. case labelrelationship.EdgeContacts:
  22741. m.ResetContacts()
  22742. return nil
  22743. case labelrelationship.EdgeLabels:
  22744. m.ResetLabels()
  22745. return nil
  22746. }
  22747. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  22748. }
  22749. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  22750. type LabelTaggingMutation struct {
  22751. config
  22752. op Op
  22753. typ string
  22754. id *uint64
  22755. created_at *time.Time
  22756. updated_at *time.Time
  22757. status *uint8
  22758. addstatus *int8
  22759. deleted_at *time.Time
  22760. organization_id *uint64
  22761. addorganization_id *int64
  22762. _type *int
  22763. add_type *int
  22764. conditions *string
  22765. action_label_add *[]uint64
  22766. appendaction_label_add []uint64
  22767. action_label_del *[]uint64
  22768. appendaction_label_del []uint64
  22769. clearedFields map[string]struct{}
  22770. done bool
  22771. oldValue func(context.Context) (*LabelTagging, error)
  22772. predicates []predicate.LabelTagging
  22773. }
  22774. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  22775. // labeltaggingOption allows management of the mutation configuration using functional options.
  22776. type labeltaggingOption func(*LabelTaggingMutation)
  22777. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  22778. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  22779. m := &LabelTaggingMutation{
  22780. config: c,
  22781. op: op,
  22782. typ: TypeLabelTagging,
  22783. clearedFields: make(map[string]struct{}),
  22784. }
  22785. for _, opt := range opts {
  22786. opt(m)
  22787. }
  22788. return m
  22789. }
  22790. // withLabelTaggingID sets the ID field of the mutation.
  22791. func withLabelTaggingID(id uint64) labeltaggingOption {
  22792. return func(m *LabelTaggingMutation) {
  22793. var (
  22794. err error
  22795. once sync.Once
  22796. value *LabelTagging
  22797. )
  22798. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  22799. once.Do(func() {
  22800. if m.done {
  22801. err = errors.New("querying old values post mutation is not allowed")
  22802. } else {
  22803. value, err = m.Client().LabelTagging.Get(ctx, id)
  22804. }
  22805. })
  22806. return value, err
  22807. }
  22808. m.id = &id
  22809. }
  22810. }
  22811. // withLabelTagging sets the old LabelTagging of the mutation.
  22812. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  22813. return func(m *LabelTaggingMutation) {
  22814. m.oldValue = func(context.Context) (*LabelTagging, error) {
  22815. return node, nil
  22816. }
  22817. m.id = &node.ID
  22818. }
  22819. }
  22820. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22821. // executed in a transaction (ent.Tx), a transactional client is returned.
  22822. func (m LabelTaggingMutation) Client() *Client {
  22823. client := &Client{config: m.config}
  22824. client.init()
  22825. return client
  22826. }
  22827. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22828. // it returns an error otherwise.
  22829. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  22830. if _, ok := m.driver.(*txDriver); !ok {
  22831. return nil, errors.New("ent: mutation is not running in a transaction")
  22832. }
  22833. tx := &Tx{config: m.config}
  22834. tx.init()
  22835. return tx, nil
  22836. }
  22837. // SetID sets the value of the id field. Note that this
  22838. // operation is only accepted on creation of LabelTagging entities.
  22839. func (m *LabelTaggingMutation) SetID(id uint64) {
  22840. m.id = &id
  22841. }
  22842. // ID returns the ID value in the mutation. Note that the ID is only available
  22843. // if it was provided to the builder or after it was returned from the database.
  22844. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  22845. if m.id == nil {
  22846. return
  22847. }
  22848. return *m.id, true
  22849. }
  22850. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22851. // That means, if the mutation is applied within a transaction with an isolation level such
  22852. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22853. // or updated by the mutation.
  22854. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  22855. switch {
  22856. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22857. id, exists := m.ID()
  22858. if exists {
  22859. return []uint64{id}, nil
  22860. }
  22861. fallthrough
  22862. case m.op.Is(OpUpdate | OpDelete):
  22863. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  22864. default:
  22865. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22866. }
  22867. }
  22868. // SetCreatedAt sets the "created_at" field.
  22869. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  22870. m.created_at = &t
  22871. }
  22872. // CreatedAt returns the value of the "created_at" field in the mutation.
  22873. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  22874. v := m.created_at
  22875. if v == nil {
  22876. return
  22877. }
  22878. return *v, true
  22879. }
  22880. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  22881. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22883. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22884. if !m.op.Is(OpUpdateOne) {
  22885. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22886. }
  22887. if m.id == nil || m.oldValue == nil {
  22888. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22889. }
  22890. oldValue, err := m.oldValue(ctx)
  22891. if err != nil {
  22892. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22893. }
  22894. return oldValue.CreatedAt, nil
  22895. }
  22896. // ResetCreatedAt resets all changes to the "created_at" field.
  22897. func (m *LabelTaggingMutation) ResetCreatedAt() {
  22898. m.created_at = nil
  22899. }
  22900. // SetUpdatedAt sets the "updated_at" field.
  22901. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  22902. m.updated_at = &t
  22903. }
  22904. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22905. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  22906. v := m.updated_at
  22907. if v == nil {
  22908. return
  22909. }
  22910. return *v, true
  22911. }
  22912. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  22913. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22915. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22916. if !m.op.Is(OpUpdateOne) {
  22917. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22918. }
  22919. if m.id == nil || m.oldValue == nil {
  22920. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22921. }
  22922. oldValue, err := m.oldValue(ctx)
  22923. if err != nil {
  22924. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22925. }
  22926. return oldValue.UpdatedAt, nil
  22927. }
  22928. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22929. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  22930. m.updated_at = nil
  22931. }
  22932. // SetStatus sets the "status" field.
  22933. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  22934. m.status = &u
  22935. m.addstatus = nil
  22936. }
  22937. // Status returns the value of the "status" field in the mutation.
  22938. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  22939. v := m.status
  22940. if v == nil {
  22941. return
  22942. }
  22943. return *v, true
  22944. }
  22945. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  22946. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22948. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22949. if !m.op.Is(OpUpdateOne) {
  22950. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22951. }
  22952. if m.id == nil || m.oldValue == nil {
  22953. return v, errors.New("OldStatus requires an ID field in the mutation")
  22954. }
  22955. oldValue, err := m.oldValue(ctx)
  22956. if err != nil {
  22957. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22958. }
  22959. return oldValue.Status, nil
  22960. }
  22961. // AddStatus adds u to the "status" field.
  22962. func (m *LabelTaggingMutation) AddStatus(u int8) {
  22963. if m.addstatus != nil {
  22964. *m.addstatus += u
  22965. } else {
  22966. m.addstatus = &u
  22967. }
  22968. }
  22969. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22970. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  22971. v := m.addstatus
  22972. if v == nil {
  22973. return
  22974. }
  22975. return *v, true
  22976. }
  22977. // ClearStatus clears the value of the "status" field.
  22978. func (m *LabelTaggingMutation) ClearStatus() {
  22979. m.status = nil
  22980. m.addstatus = nil
  22981. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  22982. }
  22983. // StatusCleared returns if the "status" field was cleared in this mutation.
  22984. func (m *LabelTaggingMutation) StatusCleared() bool {
  22985. _, ok := m.clearedFields[labeltagging.FieldStatus]
  22986. return ok
  22987. }
  22988. // ResetStatus resets all changes to the "status" field.
  22989. func (m *LabelTaggingMutation) ResetStatus() {
  22990. m.status = nil
  22991. m.addstatus = nil
  22992. delete(m.clearedFields, labeltagging.FieldStatus)
  22993. }
  22994. // SetDeletedAt sets the "deleted_at" field.
  22995. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  22996. m.deleted_at = &t
  22997. }
  22998. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22999. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  23000. v := m.deleted_at
  23001. if v == nil {
  23002. return
  23003. }
  23004. return *v, true
  23005. }
  23006. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  23007. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23009. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23010. if !m.op.Is(OpUpdateOne) {
  23011. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23012. }
  23013. if m.id == nil || m.oldValue == nil {
  23014. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23015. }
  23016. oldValue, err := m.oldValue(ctx)
  23017. if err != nil {
  23018. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23019. }
  23020. return oldValue.DeletedAt, nil
  23021. }
  23022. // ClearDeletedAt clears the value of the "deleted_at" field.
  23023. func (m *LabelTaggingMutation) ClearDeletedAt() {
  23024. m.deleted_at = nil
  23025. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  23026. }
  23027. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23028. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  23029. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  23030. return ok
  23031. }
  23032. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23033. func (m *LabelTaggingMutation) ResetDeletedAt() {
  23034. m.deleted_at = nil
  23035. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  23036. }
  23037. // SetOrganizationID sets the "organization_id" field.
  23038. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  23039. m.organization_id = &u
  23040. m.addorganization_id = nil
  23041. }
  23042. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23043. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  23044. v := m.organization_id
  23045. if v == nil {
  23046. return
  23047. }
  23048. return *v, true
  23049. }
  23050. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  23051. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23053. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23054. if !m.op.Is(OpUpdateOne) {
  23055. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23056. }
  23057. if m.id == nil || m.oldValue == nil {
  23058. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23059. }
  23060. oldValue, err := m.oldValue(ctx)
  23061. if err != nil {
  23062. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23063. }
  23064. return oldValue.OrganizationID, nil
  23065. }
  23066. // AddOrganizationID adds u to the "organization_id" field.
  23067. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  23068. if m.addorganization_id != nil {
  23069. *m.addorganization_id += u
  23070. } else {
  23071. m.addorganization_id = &u
  23072. }
  23073. }
  23074. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23075. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  23076. v := m.addorganization_id
  23077. if v == nil {
  23078. return
  23079. }
  23080. return *v, true
  23081. }
  23082. // ResetOrganizationID resets all changes to the "organization_id" field.
  23083. func (m *LabelTaggingMutation) ResetOrganizationID() {
  23084. m.organization_id = nil
  23085. m.addorganization_id = nil
  23086. }
  23087. // SetType sets the "type" field.
  23088. func (m *LabelTaggingMutation) SetType(i int) {
  23089. m._type = &i
  23090. m.add_type = nil
  23091. }
  23092. // GetType returns the value of the "type" field in the mutation.
  23093. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  23094. v := m._type
  23095. if v == nil {
  23096. return
  23097. }
  23098. return *v, true
  23099. }
  23100. // OldType returns the old "type" field's value of the LabelTagging entity.
  23101. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23103. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  23104. if !m.op.Is(OpUpdateOne) {
  23105. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23106. }
  23107. if m.id == nil || m.oldValue == nil {
  23108. return v, errors.New("OldType requires an ID field in the mutation")
  23109. }
  23110. oldValue, err := m.oldValue(ctx)
  23111. if err != nil {
  23112. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23113. }
  23114. return oldValue.Type, nil
  23115. }
  23116. // AddType adds i to the "type" field.
  23117. func (m *LabelTaggingMutation) AddType(i int) {
  23118. if m.add_type != nil {
  23119. *m.add_type += i
  23120. } else {
  23121. m.add_type = &i
  23122. }
  23123. }
  23124. // AddedType returns the value that was added to the "type" field in this mutation.
  23125. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  23126. v := m.add_type
  23127. if v == nil {
  23128. return
  23129. }
  23130. return *v, true
  23131. }
  23132. // ResetType resets all changes to the "type" field.
  23133. func (m *LabelTaggingMutation) ResetType() {
  23134. m._type = nil
  23135. m.add_type = nil
  23136. }
  23137. // SetConditions sets the "conditions" field.
  23138. func (m *LabelTaggingMutation) SetConditions(s string) {
  23139. m.conditions = &s
  23140. }
  23141. // Conditions returns the value of the "conditions" field in the mutation.
  23142. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  23143. v := m.conditions
  23144. if v == nil {
  23145. return
  23146. }
  23147. return *v, true
  23148. }
  23149. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  23150. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23152. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  23153. if !m.op.Is(OpUpdateOne) {
  23154. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  23155. }
  23156. if m.id == nil || m.oldValue == nil {
  23157. return v, errors.New("OldConditions requires an ID field in the mutation")
  23158. }
  23159. oldValue, err := m.oldValue(ctx)
  23160. if err != nil {
  23161. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  23162. }
  23163. return oldValue.Conditions, nil
  23164. }
  23165. // ResetConditions resets all changes to the "conditions" field.
  23166. func (m *LabelTaggingMutation) ResetConditions() {
  23167. m.conditions = nil
  23168. }
  23169. // SetActionLabelAdd sets the "action_label_add" field.
  23170. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  23171. m.action_label_add = &u
  23172. m.appendaction_label_add = nil
  23173. }
  23174. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23175. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23176. v := m.action_label_add
  23177. if v == nil {
  23178. return
  23179. }
  23180. return *v, true
  23181. }
  23182. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  23183. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23185. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23186. if !m.op.Is(OpUpdateOne) {
  23187. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23188. }
  23189. if m.id == nil || m.oldValue == nil {
  23190. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23191. }
  23192. oldValue, err := m.oldValue(ctx)
  23193. if err != nil {
  23194. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23195. }
  23196. return oldValue.ActionLabelAdd, nil
  23197. }
  23198. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23199. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  23200. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23201. }
  23202. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23203. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23204. if len(m.appendaction_label_add) == 0 {
  23205. return nil, false
  23206. }
  23207. return m.appendaction_label_add, true
  23208. }
  23209. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23210. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  23211. m.action_label_add = nil
  23212. m.appendaction_label_add = nil
  23213. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  23214. }
  23215. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23216. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  23217. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  23218. return ok
  23219. }
  23220. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23221. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  23222. m.action_label_add = nil
  23223. m.appendaction_label_add = nil
  23224. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  23225. }
  23226. // SetActionLabelDel sets the "action_label_del" field.
  23227. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  23228. m.action_label_del = &u
  23229. m.appendaction_label_del = nil
  23230. }
  23231. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23232. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  23233. v := m.action_label_del
  23234. if v == nil {
  23235. return
  23236. }
  23237. return *v, true
  23238. }
  23239. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  23240. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23242. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23243. if !m.op.Is(OpUpdateOne) {
  23244. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23245. }
  23246. if m.id == nil || m.oldValue == nil {
  23247. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23248. }
  23249. oldValue, err := m.oldValue(ctx)
  23250. if err != nil {
  23251. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23252. }
  23253. return oldValue.ActionLabelDel, nil
  23254. }
  23255. // AppendActionLabelDel adds u to the "action_label_del" field.
  23256. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  23257. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23258. }
  23259. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23260. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23261. if len(m.appendaction_label_del) == 0 {
  23262. return nil, false
  23263. }
  23264. return m.appendaction_label_del, true
  23265. }
  23266. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23267. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  23268. m.action_label_del = nil
  23269. m.appendaction_label_del = nil
  23270. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  23271. }
  23272. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23273. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  23274. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  23275. return ok
  23276. }
  23277. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23278. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  23279. m.action_label_del = nil
  23280. m.appendaction_label_del = nil
  23281. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  23282. }
  23283. // Where appends a list predicates to the LabelTaggingMutation builder.
  23284. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  23285. m.predicates = append(m.predicates, ps...)
  23286. }
  23287. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  23288. // users can use type-assertion to append predicates that do not depend on any generated package.
  23289. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  23290. p := make([]predicate.LabelTagging, len(ps))
  23291. for i := range ps {
  23292. p[i] = ps[i]
  23293. }
  23294. m.Where(p...)
  23295. }
  23296. // Op returns the operation name.
  23297. func (m *LabelTaggingMutation) Op() Op {
  23298. return m.op
  23299. }
  23300. // SetOp allows setting the mutation operation.
  23301. func (m *LabelTaggingMutation) SetOp(op Op) {
  23302. m.op = op
  23303. }
  23304. // Type returns the node type of this mutation (LabelTagging).
  23305. func (m *LabelTaggingMutation) Type() string {
  23306. return m.typ
  23307. }
  23308. // Fields returns all fields that were changed during this mutation. Note that in
  23309. // order to get all numeric fields that were incremented/decremented, call
  23310. // AddedFields().
  23311. func (m *LabelTaggingMutation) Fields() []string {
  23312. fields := make([]string, 0, 9)
  23313. if m.created_at != nil {
  23314. fields = append(fields, labeltagging.FieldCreatedAt)
  23315. }
  23316. if m.updated_at != nil {
  23317. fields = append(fields, labeltagging.FieldUpdatedAt)
  23318. }
  23319. if m.status != nil {
  23320. fields = append(fields, labeltagging.FieldStatus)
  23321. }
  23322. if m.deleted_at != nil {
  23323. fields = append(fields, labeltagging.FieldDeletedAt)
  23324. }
  23325. if m.organization_id != nil {
  23326. fields = append(fields, labeltagging.FieldOrganizationID)
  23327. }
  23328. if m._type != nil {
  23329. fields = append(fields, labeltagging.FieldType)
  23330. }
  23331. if m.conditions != nil {
  23332. fields = append(fields, labeltagging.FieldConditions)
  23333. }
  23334. if m.action_label_add != nil {
  23335. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23336. }
  23337. if m.action_label_del != nil {
  23338. fields = append(fields, labeltagging.FieldActionLabelDel)
  23339. }
  23340. return fields
  23341. }
  23342. // Field returns the value of a field with the given name. The second boolean
  23343. // return value indicates that this field was not set, or was not defined in the
  23344. // schema.
  23345. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  23346. switch name {
  23347. case labeltagging.FieldCreatedAt:
  23348. return m.CreatedAt()
  23349. case labeltagging.FieldUpdatedAt:
  23350. return m.UpdatedAt()
  23351. case labeltagging.FieldStatus:
  23352. return m.Status()
  23353. case labeltagging.FieldDeletedAt:
  23354. return m.DeletedAt()
  23355. case labeltagging.FieldOrganizationID:
  23356. return m.OrganizationID()
  23357. case labeltagging.FieldType:
  23358. return m.GetType()
  23359. case labeltagging.FieldConditions:
  23360. return m.Conditions()
  23361. case labeltagging.FieldActionLabelAdd:
  23362. return m.ActionLabelAdd()
  23363. case labeltagging.FieldActionLabelDel:
  23364. return m.ActionLabelDel()
  23365. }
  23366. return nil, false
  23367. }
  23368. // OldField returns the old value of the field from the database. An error is
  23369. // returned if the mutation operation is not UpdateOne, or the query to the
  23370. // database failed.
  23371. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23372. switch name {
  23373. case labeltagging.FieldCreatedAt:
  23374. return m.OldCreatedAt(ctx)
  23375. case labeltagging.FieldUpdatedAt:
  23376. return m.OldUpdatedAt(ctx)
  23377. case labeltagging.FieldStatus:
  23378. return m.OldStatus(ctx)
  23379. case labeltagging.FieldDeletedAt:
  23380. return m.OldDeletedAt(ctx)
  23381. case labeltagging.FieldOrganizationID:
  23382. return m.OldOrganizationID(ctx)
  23383. case labeltagging.FieldType:
  23384. return m.OldType(ctx)
  23385. case labeltagging.FieldConditions:
  23386. return m.OldConditions(ctx)
  23387. case labeltagging.FieldActionLabelAdd:
  23388. return m.OldActionLabelAdd(ctx)
  23389. case labeltagging.FieldActionLabelDel:
  23390. return m.OldActionLabelDel(ctx)
  23391. }
  23392. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  23393. }
  23394. // SetField sets the value of a field with the given name. It returns an error if
  23395. // the field is not defined in the schema, or if the type mismatched the field
  23396. // type.
  23397. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  23398. switch name {
  23399. case labeltagging.FieldCreatedAt:
  23400. v, ok := value.(time.Time)
  23401. if !ok {
  23402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23403. }
  23404. m.SetCreatedAt(v)
  23405. return nil
  23406. case labeltagging.FieldUpdatedAt:
  23407. v, ok := value.(time.Time)
  23408. if !ok {
  23409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23410. }
  23411. m.SetUpdatedAt(v)
  23412. return nil
  23413. case labeltagging.FieldStatus:
  23414. v, ok := value.(uint8)
  23415. if !ok {
  23416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23417. }
  23418. m.SetStatus(v)
  23419. return nil
  23420. case labeltagging.FieldDeletedAt:
  23421. v, ok := value.(time.Time)
  23422. if !ok {
  23423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23424. }
  23425. m.SetDeletedAt(v)
  23426. return nil
  23427. case labeltagging.FieldOrganizationID:
  23428. v, ok := value.(uint64)
  23429. if !ok {
  23430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23431. }
  23432. m.SetOrganizationID(v)
  23433. return nil
  23434. case labeltagging.FieldType:
  23435. v, ok := value.(int)
  23436. if !ok {
  23437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23438. }
  23439. m.SetType(v)
  23440. return nil
  23441. case labeltagging.FieldConditions:
  23442. v, ok := value.(string)
  23443. if !ok {
  23444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23445. }
  23446. m.SetConditions(v)
  23447. return nil
  23448. case labeltagging.FieldActionLabelAdd:
  23449. v, ok := value.([]uint64)
  23450. if !ok {
  23451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23452. }
  23453. m.SetActionLabelAdd(v)
  23454. return nil
  23455. case labeltagging.FieldActionLabelDel:
  23456. v, ok := value.([]uint64)
  23457. if !ok {
  23458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23459. }
  23460. m.SetActionLabelDel(v)
  23461. return nil
  23462. }
  23463. return fmt.Errorf("unknown LabelTagging field %s", name)
  23464. }
  23465. // AddedFields returns all numeric fields that were incremented/decremented during
  23466. // this mutation.
  23467. func (m *LabelTaggingMutation) AddedFields() []string {
  23468. var fields []string
  23469. if m.addstatus != nil {
  23470. fields = append(fields, labeltagging.FieldStatus)
  23471. }
  23472. if m.addorganization_id != nil {
  23473. fields = append(fields, labeltagging.FieldOrganizationID)
  23474. }
  23475. if m.add_type != nil {
  23476. fields = append(fields, labeltagging.FieldType)
  23477. }
  23478. return fields
  23479. }
  23480. // AddedField returns the numeric value that was incremented/decremented on a field
  23481. // with the given name. The second boolean return value indicates that this field
  23482. // was not set, or was not defined in the schema.
  23483. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  23484. switch name {
  23485. case labeltagging.FieldStatus:
  23486. return m.AddedStatus()
  23487. case labeltagging.FieldOrganizationID:
  23488. return m.AddedOrganizationID()
  23489. case labeltagging.FieldType:
  23490. return m.AddedType()
  23491. }
  23492. return nil, false
  23493. }
  23494. // AddField adds the value to the field with the given name. It returns an error if
  23495. // the field is not defined in the schema, or if the type mismatched the field
  23496. // type.
  23497. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  23498. switch name {
  23499. case labeltagging.FieldStatus:
  23500. v, ok := value.(int8)
  23501. if !ok {
  23502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23503. }
  23504. m.AddStatus(v)
  23505. return nil
  23506. case labeltagging.FieldOrganizationID:
  23507. v, ok := value.(int64)
  23508. if !ok {
  23509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23510. }
  23511. m.AddOrganizationID(v)
  23512. return nil
  23513. case labeltagging.FieldType:
  23514. v, ok := value.(int)
  23515. if !ok {
  23516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23517. }
  23518. m.AddType(v)
  23519. return nil
  23520. }
  23521. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  23522. }
  23523. // ClearedFields returns all nullable fields that were cleared during this
  23524. // mutation.
  23525. func (m *LabelTaggingMutation) ClearedFields() []string {
  23526. var fields []string
  23527. if m.FieldCleared(labeltagging.FieldStatus) {
  23528. fields = append(fields, labeltagging.FieldStatus)
  23529. }
  23530. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  23531. fields = append(fields, labeltagging.FieldDeletedAt)
  23532. }
  23533. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  23534. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23535. }
  23536. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  23537. fields = append(fields, labeltagging.FieldActionLabelDel)
  23538. }
  23539. return fields
  23540. }
  23541. // FieldCleared returns a boolean indicating if a field with the given name was
  23542. // cleared in this mutation.
  23543. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  23544. _, ok := m.clearedFields[name]
  23545. return ok
  23546. }
  23547. // ClearField clears the value of the field with the given name. It returns an
  23548. // error if the field is not defined in the schema.
  23549. func (m *LabelTaggingMutation) ClearField(name string) error {
  23550. switch name {
  23551. case labeltagging.FieldStatus:
  23552. m.ClearStatus()
  23553. return nil
  23554. case labeltagging.FieldDeletedAt:
  23555. m.ClearDeletedAt()
  23556. return nil
  23557. case labeltagging.FieldActionLabelAdd:
  23558. m.ClearActionLabelAdd()
  23559. return nil
  23560. case labeltagging.FieldActionLabelDel:
  23561. m.ClearActionLabelDel()
  23562. return nil
  23563. }
  23564. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  23565. }
  23566. // ResetField resets all changes in the mutation for the field with the given name.
  23567. // It returns an error if the field is not defined in the schema.
  23568. func (m *LabelTaggingMutation) ResetField(name string) error {
  23569. switch name {
  23570. case labeltagging.FieldCreatedAt:
  23571. m.ResetCreatedAt()
  23572. return nil
  23573. case labeltagging.FieldUpdatedAt:
  23574. m.ResetUpdatedAt()
  23575. return nil
  23576. case labeltagging.FieldStatus:
  23577. m.ResetStatus()
  23578. return nil
  23579. case labeltagging.FieldDeletedAt:
  23580. m.ResetDeletedAt()
  23581. return nil
  23582. case labeltagging.FieldOrganizationID:
  23583. m.ResetOrganizationID()
  23584. return nil
  23585. case labeltagging.FieldType:
  23586. m.ResetType()
  23587. return nil
  23588. case labeltagging.FieldConditions:
  23589. m.ResetConditions()
  23590. return nil
  23591. case labeltagging.FieldActionLabelAdd:
  23592. m.ResetActionLabelAdd()
  23593. return nil
  23594. case labeltagging.FieldActionLabelDel:
  23595. m.ResetActionLabelDel()
  23596. return nil
  23597. }
  23598. return fmt.Errorf("unknown LabelTagging field %s", name)
  23599. }
  23600. // AddedEdges returns all edge names that were set/added in this mutation.
  23601. func (m *LabelTaggingMutation) AddedEdges() []string {
  23602. edges := make([]string, 0, 0)
  23603. return edges
  23604. }
  23605. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23606. // name in this mutation.
  23607. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  23608. return nil
  23609. }
  23610. // RemovedEdges returns all edge names that were removed in this mutation.
  23611. func (m *LabelTaggingMutation) RemovedEdges() []string {
  23612. edges := make([]string, 0, 0)
  23613. return edges
  23614. }
  23615. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23616. // the given name in this mutation.
  23617. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  23618. return nil
  23619. }
  23620. // ClearedEdges returns all edge names that were cleared in this mutation.
  23621. func (m *LabelTaggingMutation) ClearedEdges() []string {
  23622. edges := make([]string, 0, 0)
  23623. return edges
  23624. }
  23625. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23626. // was cleared in this mutation.
  23627. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  23628. return false
  23629. }
  23630. // ClearEdge clears the value of the edge with the given name. It returns an error
  23631. // if that edge is not defined in the schema.
  23632. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  23633. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  23634. }
  23635. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23636. // It returns an error if the edge is not defined in the schema.
  23637. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  23638. return fmt.Errorf("unknown LabelTagging edge %s", name)
  23639. }
  23640. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  23641. type MessageMutation struct {
  23642. config
  23643. op Op
  23644. typ string
  23645. id *int
  23646. wx_wxid *string
  23647. wxid *string
  23648. content *string
  23649. clearedFields map[string]struct{}
  23650. done bool
  23651. oldValue func(context.Context) (*Message, error)
  23652. predicates []predicate.Message
  23653. }
  23654. var _ ent.Mutation = (*MessageMutation)(nil)
  23655. // messageOption allows management of the mutation configuration using functional options.
  23656. type messageOption func(*MessageMutation)
  23657. // newMessageMutation creates new mutation for the Message entity.
  23658. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  23659. m := &MessageMutation{
  23660. config: c,
  23661. op: op,
  23662. typ: TypeMessage,
  23663. clearedFields: make(map[string]struct{}),
  23664. }
  23665. for _, opt := range opts {
  23666. opt(m)
  23667. }
  23668. return m
  23669. }
  23670. // withMessageID sets the ID field of the mutation.
  23671. func withMessageID(id int) messageOption {
  23672. return func(m *MessageMutation) {
  23673. var (
  23674. err error
  23675. once sync.Once
  23676. value *Message
  23677. )
  23678. m.oldValue = func(ctx context.Context) (*Message, error) {
  23679. once.Do(func() {
  23680. if m.done {
  23681. err = errors.New("querying old values post mutation is not allowed")
  23682. } else {
  23683. value, err = m.Client().Message.Get(ctx, id)
  23684. }
  23685. })
  23686. return value, err
  23687. }
  23688. m.id = &id
  23689. }
  23690. }
  23691. // withMessage sets the old Message of the mutation.
  23692. func withMessage(node *Message) messageOption {
  23693. return func(m *MessageMutation) {
  23694. m.oldValue = func(context.Context) (*Message, error) {
  23695. return node, nil
  23696. }
  23697. m.id = &node.ID
  23698. }
  23699. }
  23700. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23701. // executed in a transaction (ent.Tx), a transactional client is returned.
  23702. func (m MessageMutation) Client() *Client {
  23703. client := &Client{config: m.config}
  23704. client.init()
  23705. return client
  23706. }
  23707. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23708. // it returns an error otherwise.
  23709. func (m MessageMutation) Tx() (*Tx, error) {
  23710. if _, ok := m.driver.(*txDriver); !ok {
  23711. return nil, errors.New("ent: mutation is not running in a transaction")
  23712. }
  23713. tx := &Tx{config: m.config}
  23714. tx.init()
  23715. return tx, nil
  23716. }
  23717. // ID returns the ID value in the mutation. Note that the ID is only available
  23718. // if it was provided to the builder or after it was returned from the database.
  23719. func (m *MessageMutation) ID() (id int, exists bool) {
  23720. if m.id == nil {
  23721. return
  23722. }
  23723. return *m.id, true
  23724. }
  23725. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23726. // That means, if the mutation is applied within a transaction with an isolation level such
  23727. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23728. // or updated by the mutation.
  23729. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  23730. switch {
  23731. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23732. id, exists := m.ID()
  23733. if exists {
  23734. return []int{id}, nil
  23735. }
  23736. fallthrough
  23737. case m.op.Is(OpUpdate | OpDelete):
  23738. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  23739. default:
  23740. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23741. }
  23742. }
  23743. // SetWxWxid sets the "wx_wxid" field.
  23744. func (m *MessageMutation) SetWxWxid(s string) {
  23745. m.wx_wxid = &s
  23746. }
  23747. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  23748. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  23749. v := m.wx_wxid
  23750. if v == nil {
  23751. return
  23752. }
  23753. return *v, true
  23754. }
  23755. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  23756. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23758. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  23759. if !m.op.Is(OpUpdateOne) {
  23760. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  23761. }
  23762. if m.id == nil || m.oldValue == nil {
  23763. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  23764. }
  23765. oldValue, err := m.oldValue(ctx)
  23766. if err != nil {
  23767. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  23768. }
  23769. return oldValue.WxWxid, nil
  23770. }
  23771. // ClearWxWxid clears the value of the "wx_wxid" field.
  23772. func (m *MessageMutation) ClearWxWxid() {
  23773. m.wx_wxid = nil
  23774. m.clearedFields[message.FieldWxWxid] = struct{}{}
  23775. }
  23776. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  23777. func (m *MessageMutation) WxWxidCleared() bool {
  23778. _, ok := m.clearedFields[message.FieldWxWxid]
  23779. return ok
  23780. }
  23781. // ResetWxWxid resets all changes to the "wx_wxid" field.
  23782. func (m *MessageMutation) ResetWxWxid() {
  23783. m.wx_wxid = nil
  23784. delete(m.clearedFields, message.FieldWxWxid)
  23785. }
  23786. // SetWxid sets the "wxid" field.
  23787. func (m *MessageMutation) SetWxid(s string) {
  23788. m.wxid = &s
  23789. }
  23790. // Wxid returns the value of the "wxid" field in the mutation.
  23791. func (m *MessageMutation) Wxid() (r string, exists bool) {
  23792. v := m.wxid
  23793. if v == nil {
  23794. return
  23795. }
  23796. return *v, true
  23797. }
  23798. // OldWxid returns the old "wxid" field's value of the Message entity.
  23799. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23801. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  23802. if !m.op.Is(OpUpdateOne) {
  23803. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  23804. }
  23805. if m.id == nil || m.oldValue == nil {
  23806. return v, errors.New("OldWxid requires an ID field in the mutation")
  23807. }
  23808. oldValue, err := m.oldValue(ctx)
  23809. if err != nil {
  23810. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  23811. }
  23812. return oldValue.Wxid, nil
  23813. }
  23814. // ResetWxid resets all changes to the "wxid" field.
  23815. func (m *MessageMutation) ResetWxid() {
  23816. m.wxid = nil
  23817. }
  23818. // SetContent sets the "content" field.
  23819. func (m *MessageMutation) SetContent(s string) {
  23820. m.content = &s
  23821. }
  23822. // Content returns the value of the "content" field in the mutation.
  23823. func (m *MessageMutation) Content() (r string, exists bool) {
  23824. v := m.content
  23825. if v == nil {
  23826. return
  23827. }
  23828. return *v, true
  23829. }
  23830. // OldContent returns the old "content" field's value of the Message entity.
  23831. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23833. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  23834. if !m.op.Is(OpUpdateOne) {
  23835. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23836. }
  23837. if m.id == nil || m.oldValue == nil {
  23838. return v, errors.New("OldContent requires an ID field in the mutation")
  23839. }
  23840. oldValue, err := m.oldValue(ctx)
  23841. if err != nil {
  23842. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23843. }
  23844. return oldValue.Content, nil
  23845. }
  23846. // ResetContent resets all changes to the "content" field.
  23847. func (m *MessageMutation) ResetContent() {
  23848. m.content = nil
  23849. }
  23850. // Where appends a list predicates to the MessageMutation builder.
  23851. func (m *MessageMutation) Where(ps ...predicate.Message) {
  23852. m.predicates = append(m.predicates, ps...)
  23853. }
  23854. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  23855. // users can use type-assertion to append predicates that do not depend on any generated package.
  23856. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  23857. p := make([]predicate.Message, len(ps))
  23858. for i := range ps {
  23859. p[i] = ps[i]
  23860. }
  23861. m.Where(p...)
  23862. }
  23863. // Op returns the operation name.
  23864. func (m *MessageMutation) Op() Op {
  23865. return m.op
  23866. }
  23867. // SetOp allows setting the mutation operation.
  23868. func (m *MessageMutation) SetOp(op Op) {
  23869. m.op = op
  23870. }
  23871. // Type returns the node type of this mutation (Message).
  23872. func (m *MessageMutation) Type() string {
  23873. return m.typ
  23874. }
  23875. // Fields returns all fields that were changed during this mutation. Note that in
  23876. // order to get all numeric fields that were incremented/decremented, call
  23877. // AddedFields().
  23878. func (m *MessageMutation) Fields() []string {
  23879. fields := make([]string, 0, 3)
  23880. if m.wx_wxid != nil {
  23881. fields = append(fields, message.FieldWxWxid)
  23882. }
  23883. if m.wxid != nil {
  23884. fields = append(fields, message.FieldWxid)
  23885. }
  23886. if m.content != nil {
  23887. fields = append(fields, message.FieldContent)
  23888. }
  23889. return fields
  23890. }
  23891. // Field returns the value of a field with the given name. The second boolean
  23892. // return value indicates that this field was not set, or was not defined in the
  23893. // schema.
  23894. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  23895. switch name {
  23896. case message.FieldWxWxid:
  23897. return m.WxWxid()
  23898. case message.FieldWxid:
  23899. return m.Wxid()
  23900. case message.FieldContent:
  23901. return m.Content()
  23902. }
  23903. return nil, false
  23904. }
  23905. // OldField returns the old value of the field from the database. An error is
  23906. // returned if the mutation operation is not UpdateOne, or the query to the
  23907. // database failed.
  23908. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23909. switch name {
  23910. case message.FieldWxWxid:
  23911. return m.OldWxWxid(ctx)
  23912. case message.FieldWxid:
  23913. return m.OldWxid(ctx)
  23914. case message.FieldContent:
  23915. return m.OldContent(ctx)
  23916. }
  23917. return nil, fmt.Errorf("unknown Message field %s", name)
  23918. }
  23919. // SetField sets the value of a field with the given name. It returns an error if
  23920. // the field is not defined in the schema, or if the type mismatched the field
  23921. // type.
  23922. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  23923. switch name {
  23924. case message.FieldWxWxid:
  23925. v, ok := value.(string)
  23926. if !ok {
  23927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23928. }
  23929. m.SetWxWxid(v)
  23930. return nil
  23931. case message.FieldWxid:
  23932. v, ok := value.(string)
  23933. if !ok {
  23934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23935. }
  23936. m.SetWxid(v)
  23937. return nil
  23938. case message.FieldContent:
  23939. v, ok := value.(string)
  23940. if !ok {
  23941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23942. }
  23943. m.SetContent(v)
  23944. return nil
  23945. }
  23946. return fmt.Errorf("unknown Message field %s", name)
  23947. }
  23948. // AddedFields returns all numeric fields that were incremented/decremented during
  23949. // this mutation.
  23950. func (m *MessageMutation) AddedFields() []string {
  23951. return nil
  23952. }
  23953. // AddedField returns the numeric value that was incremented/decremented on a field
  23954. // with the given name. The second boolean return value indicates that this field
  23955. // was not set, or was not defined in the schema.
  23956. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  23957. return nil, false
  23958. }
  23959. // AddField adds the value to the field with the given name. It returns an error if
  23960. // the field is not defined in the schema, or if the type mismatched the field
  23961. // type.
  23962. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  23963. switch name {
  23964. }
  23965. return fmt.Errorf("unknown Message numeric field %s", name)
  23966. }
  23967. // ClearedFields returns all nullable fields that were cleared during this
  23968. // mutation.
  23969. func (m *MessageMutation) ClearedFields() []string {
  23970. var fields []string
  23971. if m.FieldCleared(message.FieldWxWxid) {
  23972. fields = append(fields, message.FieldWxWxid)
  23973. }
  23974. return fields
  23975. }
  23976. // FieldCleared returns a boolean indicating if a field with the given name was
  23977. // cleared in this mutation.
  23978. func (m *MessageMutation) FieldCleared(name string) bool {
  23979. _, ok := m.clearedFields[name]
  23980. return ok
  23981. }
  23982. // ClearField clears the value of the field with the given name. It returns an
  23983. // error if the field is not defined in the schema.
  23984. func (m *MessageMutation) ClearField(name string) error {
  23985. switch name {
  23986. case message.FieldWxWxid:
  23987. m.ClearWxWxid()
  23988. return nil
  23989. }
  23990. return fmt.Errorf("unknown Message nullable field %s", name)
  23991. }
  23992. // ResetField resets all changes in the mutation for the field with the given name.
  23993. // It returns an error if the field is not defined in the schema.
  23994. func (m *MessageMutation) ResetField(name string) error {
  23995. switch name {
  23996. case message.FieldWxWxid:
  23997. m.ResetWxWxid()
  23998. return nil
  23999. case message.FieldWxid:
  24000. m.ResetWxid()
  24001. return nil
  24002. case message.FieldContent:
  24003. m.ResetContent()
  24004. return nil
  24005. }
  24006. return fmt.Errorf("unknown Message field %s", name)
  24007. }
  24008. // AddedEdges returns all edge names that were set/added in this mutation.
  24009. func (m *MessageMutation) AddedEdges() []string {
  24010. edges := make([]string, 0, 0)
  24011. return edges
  24012. }
  24013. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24014. // name in this mutation.
  24015. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  24016. return nil
  24017. }
  24018. // RemovedEdges returns all edge names that were removed in this mutation.
  24019. func (m *MessageMutation) RemovedEdges() []string {
  24020. edges := make([]string, 0, 0)
  24021. return edges
  24022. }
  24023. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24024. // the given name in this mutation.
  24025. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  24026. return nil
  24027. }
  24028. // ClearedEdges returns all edge names that were cleared in this mutation.
  24029. func (m *MessageMutation) ClearedEdges() []string {
  24030. edges := make([]string, 0, 0)
  24031. return edges
  24032. }
  24033. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24034. // was cleared in this mutation.
  24035. func (m *MessageMutation) EdgeCleared(name string) bool {
  24036. return false
  24037. }
  24038. // ClearEdge clears the value of the edge with the given name. It returns an error
  24039. // if that edge is not defined in the schema.
  24040. func (m *MessageMutation) ClearEdge(name string) error {
  24041. return fmt.Errorf("unknown Message unique edge %s", name)
  24042. }
  24043. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24044. // It returns an error if the edge is not defined in the schema.
  24045. func (m *MessageMutation) ResetEdge(name string) error {
  24046. return fmt.Errorf("unknown Message edge %s", name)
  24047. }
  24048. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  24049. type MessageRecordsMutation struct {
  24050. config
  24051. op Op
  24052. typ string
  24053. id *uint64
  24054. created_at *time.Time
  24055. updated_at *time.Time
  24056. status *uint8
  24057. addstatus *int8
  24058. bot_wxid *string
  24059. contact_type *int
  24060. addcontact_type *int
  24061. contact_wxid *string
  24062. content_type *int
  24063. addcontent_type *int
  24064. content *string
  24065. meta *custom_types.Meta
  24066. error_detail *string
  24067. send_time *time.Time
  24068. source_type *int
  24069. addsource_type *int
  24070. organization_id *uint64
  24071. addorganization_id *int64
  24072. clearedFields map[string]struct{}
  24073. sop_stage *uint64
  24074. clearedsop_stage bool
  24075. sop_node *uint64
  24076. clearedsop_node bool
  24077. message_contact *uint64
  24078. clearedmessage_contact bool
  24079. done bool
  24080. oldValue func(context.Context) (*MessageRecords, error)
  24081. predicates []predicate.MessageRecords
  24082. }
  24083. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  24084. // messagerecordsOption allows management of the mutation configuration using functional options.
  24085. type messagerecordsOption func(*MessageRecordsMutation)
  24086. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  24087. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  24088. m := &MessageRecordsMutation{
  24089. config: c,
  24090. op: op,
  24091. typ: TypeMessageRecords,
  24092. clearedFields: make(map[string]struct{}),
  24093. }
  24094. for _, opt := range opts {
  24095. opt(m)
  24096. }
  24097. return m
  24098. }
  24099. // withMessageRecordsID sets the ID field of the mutation.
  24100. func withMessageRecordsID(id uint64) messagerecordsOption {
  24101. return func(m *MessageRecordsMutation) {
  24102. var (
  24103. err error
  24104. once sync.Once
  24105. value *MessageRecords
  24106. )
  24107. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  24108. once.Do(func() {
  24109. if m.done {
  24110. err = errors.New("querying old values post mutation is not allowed")
  24111. } else {
  24112. value, err = m.Client().MessageRecords.Get(ctx, id)
  24113. }
  24114. })
  24115. return value, err
  24116. }
  24117. m.id = &id
  24118. }
  24119. }
  24120. // withMessageRecords sets the old MessageRecords of the mutation.
  24121. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  24122. return func(m *MessageRecordsMutation) {
  24123. m.oldValue = func(context.Context) (*MessageRecords, error) {
  24124. return node, nil
  24125. }
  24126. m.id = &node.ID
  24127. }
  24128. }
  24129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24130. // executed in a transaction (ent.Tx), a transactional client is returned.
  24131. func (m MessageRecordsMutation) Client() *Client {
  24132. client := &Client{config: m.config}
  24133. client.init()
  24134. return client
  24135. }
  24136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24137. // it returns an error otherwise.
  24138. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  24139. if _, ok := m.driver.(*txDriver); !ok {
  24140. return nil, errors.New("ent: mutation is not running in a transaction")
  24141. }
  24142. tx := &Tx{config: m.config}
  24143. tx.init()
  24144. return tx, nil
  24145. }
  24146. // SetID sets the value of the id field. Note that this
  24147. // operation is only accepted on creation of MessageRecords entities.
  24148. func (m *MessageRecordsMutation) SetID(id uint64) {
  24149. m.id = &id
  24150. }
  24151. // ID returns the ID value in the mutation. Note that the ID is only available
  24152. // if it was provided to the builder or after it was returned from the database.
  24153. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  24154. if m.id == nil {
  24155. return
  24156. }
  24157. return *m.id, true
  24158. }
  24159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24160. // That means, if the mutation is applied within a transaction with an isolation level such
  24161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24162. // or updated by the mutation.
  24163. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  24164. switch {
  24165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24166. id, exists := m.ID()
  24167. if exists {
  24168. return []uint64{id}, nil
  24169. }
  24170. fallthrough
  24171. case m.op.Is(OpUpdate | OpDelete):
  24172. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  24173. default:
  24174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24175. }
  24176. }
  24177. // SetCreatedAt sets the "created_at" field.
  24178. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  24179. m.created_at = &t
  24180. }
  24181. // CreatedAt returns the value of the "created_at" field in the mutation.
  24182. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  24183. v := m.created_at
  24184. if v == nil {
  24185. return
  24186. }
  24187. return *v, true
  24188. }
  24189. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  24190. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24192. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24193. if !m.op.Is(OpUpdateOne) {
  24194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24195. }
  24196. if m.id == nil || m.oldValue == nil {
  24197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24198. }
  24199. oldValue, err := m.oldValue(ctx)
  24200. if err != nil {
  24201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24202. }
  24203. return oldValue.CreatedAt, nil
  24204. }
  24205. // ResetCreatedAt resets all changes to the "created_at" field.
  24206. func (m *MessageRecordsMutation) ResetCreatedAt() {
  24207. m.created_at = nil
  24208. }
  24209. // SetUpdatedAt sets the "updated_at" field.
  24210. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  24211. m.updated_at = &t
  24212. }
  24213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24214. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  24215. v := m.updated_at
  24216. if v == nil {
  24217. return
  24218. }
  24219. return *v, true
  24220. }
  24221. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  24222. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24224. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24225. if !m.op.Is(OpUpdateOne) {
  24226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24227. }
  24228. if m.id == nil || m.oldValue == nil {
  24229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24230. }
  24231. oldValue, err := m.oldValue(ctx)
  24232. if err != nil {
  24233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24234. }
  24235. return oldValue.UpdatedAt, nil
  24236. }
  24237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24238. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  24239. m.updated_at = nil
  24240. }
  24241. // SetStatus sets the "status" field.
  24242. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  24243. m.status = &u
  24244. m.addstatus = nil
  24245. }
  24246. // Status returns the value of the "status" field in the mutation.
  24247. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  24248. v := m.status
  24249. if v == nil {
  24250. return
  24251. }
  24252. return *v, true
  24253. }
  24254. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  24255. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24257. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24258. if !m.op.Is(OpUpdateOne) {
  24259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24260. }
  24261. if m.id == nil || m.oldValue == nil {
  24262. return v, errors.New("OldStatus requires an ID field in the mutation")
  24263. }
  24264. oldValue, err := m.oldValue(ctx)
  24265. if err != nil {
  24266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24267. }
  24268. return oldValue.Status, nil
  24269. }
  24270. // AddStatus adds u to the "status" field.
  24271. func (m *MessageRecordsMutation) AddStatus(u int8) {
  24272. if m.addstatus != nil {
  24273. *m.addstatus += u
  24274. } else {
  24275. m.addstatus = &u
  24276. }
  24277. }
  24278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24279. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  24280. v := m.addstatus
  24281. if v == nil {
  24282. return
  24283. }
  24284. return *v, true
  24285. }
  24286. // ClearStatus clears the value of the "status" field.
  24287. func (m *MessageRecordsMutation) ClearStatus() {
  24288. m.status = nil
  24289. m.addstatus = nil
  24290. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  24291. }
  24292. // StatusCleared returns if the "status" field was cleared in this mutation.
  24293. func (m *MessageRecordsMutation) StatusCleared() bool {
  24294. _, ok := m.clearedFields[messagerecords.FieldStatus]
  24295. return ok
  24296. }
  24297. // ResetStatus resets all changes to the "status" field.
  24298. func (m *MessageRecordsMutation) ResetStatus() {
  24299. m.status = nil
  24300. m.addstatus = nil
  24301. delete(m.clearedFields, messagerecords.FieldStatus)
  24302. }
  24303. // SetBotWxid sets the "bot_wxid" field.
  24304. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  24305. m.bot_wxid = &s
  24306. }
  24307. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  24308. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  24309. v := m.bot_wxid
  24310. if v == nil {
  24311. return
  24312. }
  24313. return *v, true
  24314. }
  24315. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  24316. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24318. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  24319. if !m.op.Is(OpUpdateOne) {
  24320. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  24321. }
  24322. if m.id == nil || m.oldValue == nil {
  24323. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  24324. }
  24325. oldValue, err := m.oldValue(ctx)
  24326. if err != nil {
  24327. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  24328. }
  24329. return oldValue.BotWxid, nil
  24330. }
  24331. // ResetBotWxid resets all changes to the "bot_wxid" field.
  24332. func (m *MessageRecordsMutation) ResetBotWxid() {
  24333. m.bot_wxid = nil
  24334. }
  24335. // SetContactID sets the "contact_id" field.
  24336. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  24337. m.message_contact = &u
  24338. }
  24339. // ContactID returns the value of the "contact_id" field in the mutation.
  24340. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  24341. v := m.message_contact
  24342. if v == nil {
  24343. return
  24344. }
  24345. return *v, true
  24346. }
  24347. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  24348. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24350. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  24351. if !m.op.Is(OpUpdateOne) {
  24352. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  24353. }
  24354. if m.id == nil || m.oldValue == nil {
  24355. return v, errors.New("OldContactID requires an ID field in the mutation")
  24356. }
  24357. oldValue, err := m.oldValue(ctx)
  24358. if err != nil {
  24359. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  24360. }
  24361. return oldValue.ContactID, nil
  24362. }
  24363. // ClearContactID clears the value of the "contact_id" field.
  24364. func (m *MessageRecordsMutation) ClearContactID() {
  24365. m.message_contact = nil
  24366. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  24367. }
  24368. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  24369. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  24370. _, ok := m.clearedFields[messagerecords.FieldContactID]
  24371. return ok
  24372. }
  24373. // ResetContactID resets all changes to the "contact_id" field.
  24374. func (m *MessageRecordsMutation) ResetContactID() {
  24375. m.message_contact = nil
  24376. delete(m.clearedFields, messagerecords.FieldContactID)
  24377. }
  24378. // SetContactType sets the "contact_type" field.
  24379. func (m *MessageRecordsMutation) SetContactType(i int) {
  24380. m.contact_type = &i
  24381. m.addcontact_type = nil
  24382. }
  24383. // ContactType returns the value of the "contact_type" field in the mutation.
  24384. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  24385. v := m.contact_type
  24386. if v == nil {
  24387. return
  24388. }
  24389. return *v, true
  24390. }
  24391. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  24392. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24394. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  24395. if !m.op.Is(OpUpdateOne) {
  24396. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  24397. }
  24398. if m.id == nil || m.oldValue == nil {
  24399. return v, errors.New("OldContactType requires an ID field in the mutation")
  24400. }
  24401. oldValue, err := m.oldValue(ctx)
  24402. if err != nil {
  24403. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  24404. }
  24405. return oldValue.ContactType, nil
  24406. }
  24407. // AddContactType adds i to the "contact_type" field.
  24408. func (m *MessageRecordsMutation) AddContactType(i int) {
  24409. if m.addcontact_type != nil {
  24410. *m.addcontact_type += i
  24411. } else {
  24412. m.addcontact_type = &i
  24413. }
  24414. }
  24415. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  24416. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  24417. v := m.addcontact_type
  24418. if v == nil {
  24419. return
  24420. }
  24421. return *v, true
  24422. }
  24423. // ResetContactType resets all changes to the "contact_type" field.
  24424. func (m *MessageRecordsMutation) ResetContactType() {
  24425. m.contact_type = nil
  24426. m.addcontact_type = nil
  24427. }
  24428. // SetContactWxid sets the "contact_wxid" field.
  24429. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  24430. m.contact_wxid = &s
  24431. }
  24432. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  24433. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  24434. v := m.contact_wxid
  24435. if v == nil {
  24436. return
  24437. }
  24438. return *v, true
  24439. }
  24440. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  24441. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24443. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  24444. if !m.op.Is(OpUpdateOne) {
  24445. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  24446. }
  24447. if m.id == nil || m.oldValue == nil {
  24448. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  24449. }
  24450. oldValue, err := m.oldValue(ctx)
  24451. if err != nil {
  24452. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  24453. }
  24454. return oldValue.ContactWxid, nil
  24455. }
  24456. // ResetContactWxid resets all changes to the "contact_wxid" field.
  24457. func (m *MessageRecordsMutation) ResetContactWxid() {
  24458. m.contact_wxid = nil
  24459. }
  24460. // SetContentType sets the "content_type" field.
  24461. func (m *MessageRecordsMutation) SetContentType(i int) {
  24462. m.content_type = &i
  24463. m.addcontent_type = nil
  24464. }
  24465. // ContentType returns the value of the "content_type" field in the mutation.
  24466. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  24467. v := m.content_type
  24468. if v == nil {
  24469. return
  24470. }
  24471. return *v, true
  24472. }
  24473. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  24474. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24476. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  24477. if !m.op.Is(OpUpdateOne) {
  24478. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  24479. }
  24480. if m.id == nil || m.oldValue == nil {
  24481. return v, errors.New("OldContentType requires an ID field in the mutation")
  24482. }
  24483. oldValue, err := m.oldValue(ctx)
  24484. if err != nil {
  24485. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  24486. }
  24487. return oldValue.ContentType, nil
  24488. }
  24489. // AddContentType adds i to the "content_type" field.
  24490. func (m *MessageRecordsMutation) AddContentType(i int) {
  24491. if m.addcontent_type != nil {
  24492. *m.addcontent_type += i
  24493. } else {
  24494. m.addcontent_type = &i
  24495. }
  24496. }
  24497. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  24498. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  24499. v := m.addcontent_type
  24500. if v == nil {
  24501. return
  24502. }
  24503. return *v, true
  24504. }
  24505. // ResetContentType resets all changes to the "content_type" field.
  24506. func (m *MessageRecordsMutation) ResetContentType() {
  24507. m.content_type = nil
  24508. m.addcontent_type = nil
  24509. }
  24510. // SetContent sets the "content" field.
  24511. func (m *MessageRecordsMutation) SetContent(s string) {
  24512. m.content = &s
  24513. }
  24514. // Content returns the value of the "content" field in the mutation.
  24515. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  24516. v := m.content
  24517. if v == nil {
  24518. return
  24519. }
  24520. return *v, true
  24521. }
  24522. // OldContent returns the old "content" field's value of the MessageRecords entity.
  24523. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24525. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  24526. if !m.op.Is(OpUpdateOne) {
  24527. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  24528. }
  24529. if m.id == nil || m.oldValue == nil {
  24530. return v, errors.New("OldContent requires an ID field in the mutation")
  24531. }
  24532. oldValue, err := m.oldValue(ctx)
  24533. if err != nil {
  24534. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  24535. }
  24536. return oldValue.Content, nil
  24537. }
  24538. // ResetContent resets all changes to the "content" field.
  24539. func (m *MessageRecordsMutation) ResetContent() {
  24540. m.content = nil
  24541. }
  24542. // SetMeta sets the "meta" field.
  24543. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  24544. m.meta = &ct
  24545. }
  24546. // Meta returns the value of the "meta" field in the mutation.
  24547. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  24548. v := m.meta
  24549. if v == nil {
  24550. return
  24551. }
  24552. return *v, true
  24553. }
  24554. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  24555. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24557. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  24558. if !m.op.Is(OpUpdateOne) {
  24559. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  24560. }
  24561. if m.id == nil || m.oldValue == nil {
  24562. return v, errors.New("OldMeta requires an ID field in the mutation")
  24563. }
  24564. oldValue, err := m.oldValue(ctx)
  24565. if err != nil {
  24566. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  24567. }
  24568. return oldValue.Meta, nil
  24569. }
  24570. // ClearMeta clears the value of the "meta" field.
  24571. func (m *MessageRecordsMutation) ClearMeta() {
  24572. m.meta = nil
  24573. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  24574. }
  24575. // MetaCleared returns if the "meta" field was cleared in this mutation.
  24576. func (m *MessageRecordsMutation) MetaCleared() bool {
  24577. _, ok := m.clearedFields[messagerecords.FieldMeta]
  24578. return ok
  24579. }
  24580. // ResetMeta resets all changes to the "meta" field.
  24581. func (m *MessageRecordsMutation) ResetMeta() {
  24582. m.meta = nil
  24583. delete(m.clearedFields, messagerecords.FieldMeta)
  24584. }
  24585. // SetErrorDetail sets the "error_detail" field.
  24586. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  24587. m.error_detail = &s
  24588. }
  24589. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  24590. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  24591. v := m.error_detail
  24592. if v == nil {
  24593. return
  24594. }
  24595. return *v, true
  24596. }
  24597. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  24598. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24600. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  24601. if !m.op.Is(OpUpdateOne) {
  24602. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  24603. }
  24604. if m.id == nil || m.oldValue == nil {
  24605. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  24606. }
  24607. oldValue, err := m.oldValue(ctx)
  24608. if err != nil {
  24609. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  24610. }
  24611. return oldValue.ErrorDetail, nil
  24612. }
  24613. // ResetErrorDetail resets all changes to the "error_detail" field.
  24614. func (m *MessageRecordsMutation) ResetErrorDetail() {
  24615. m.error_detail = nil
  24616. }
  24617. // SetSendTime sets the "send_time" field.
  24618. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  24619. m.send_time = &t
  24620. }
  24621. // SendTime returns the value of the "send_time" field in the mutation.
  24622. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  24623. v := m.send_time
  24624. if v == nil {
  24625. return
  24626. }
  24627. return *v, true
  24628. }
  24629. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  24630. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24632. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  24633. if !m.op.Is(OpUpdateOne) {
  24634. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  24635. }
  24636. if m.id == nil || m.oldValue == nil {
  24637. return v, errors.New("OldSendTime requires an ID field in the mutation")
  24638. }
  24639. oldValue, err := m.oldValue(ctx)
  24640. if err != nil {
  24641. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  24642. }
  24643. return oldValue.SendTime, nil
  24644. }
  24645. // ClearSendTime clears the value of the "send_time" field.
  24646. func (m *MessageRecordsMutation) ClearSendTime() {
  24647. m.send_time = nil
  24648. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  24649. }
  24650. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  24651. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  24652. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  24653. return ok
  24654. }
  24655. // ResetSendTime resets all changes to the "send_time" field.
  24656. func (m *MessageRecordsMutation) ResetSendTime() {
  24657. m.send_time = nil
  24658. delete(m.clearedFields, messagerecords.FieldSendTime)
  24659. }
  24660. // SetSourceType sets the "source_type" field.
  24661. func (m *MessageRecordsMutation) SetSourceType(i int) {
  24662. m.source_type = &i
  24663. m.addsource_type = nil
  24664. }
  24665. // SourceType returns the value of the "source_type" field in the mutation.
  24666. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  24667. v := m.source_type
  24668. if v == nil {
  24669. return
  24670. }
  24671. return *v, true
  24672. }
  24673. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  24674. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24676. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  24677. if !m.op.Is(OpUpdateOne) {
  24678. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  24679. }
  24680. if m.id == nil || m.oldValue == nil {
  24681. return v, errors.New("OldSourceType requires an ID field in the mutation")
  24682. }
  24683. oldValue, err := m.oldValue(ctx)
  24684. if err != nil {
  24685. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  24686. }
  24687. return oldValue.SourceType, nil
  24688. }
  24689. // AddSourceType adds i to the "source_type" field.
  24690. func (m *MessageRecordsMutation) AddSourceType(i int) {
  24691. if m.addsource_type != nil {
  24692. *m.addsource_type += i
  24693. } else {
  24694. m.addsource_type = &i
  24695. }
  24696. }
  24697. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  24698. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  24699. v := m.addsource_type
  24700. if v == nil {
  24701. return
  24702. }
  24703. return *v, true
  24704. }
  24705. // ResetSourceType resets all changes to the "source_type" field.
  24706. func (m *MessageRecordsMutation) ResetSourceType() {
  24707. m.source_type = nil
  24708. m.addsource_type = nil
  24709. }
  24710. // SetSourceID sets the "source_id" field.
  24711. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  24712. m.sop_stage = &u
  24713. }
  24714. // SourceID returns the value of the "source_id" field in the mutation.
  24715. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  24716. v := m.sop_stage
  24717. if v == nil {
  24718. return
  24719. }
  24720. return *v, true
  24721. }
  24722. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  24723. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24725. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  24726. if !m.op.Is(OpUpdateOne) {
  24727. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  24728. }
  24729. if m.id == nil || m.oldValue == nil {
  24730. return v, errors.New("OldSourceID requires an ID field in the mutation")
  24731. }
  24732. oldValue, err := m.oldValue(ctx)
  24733. if err != nil {
  24734. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  24735. }
  24736. return oldValue.SourceID, nil
  24737. }
  24738. // ClearSourceID clears the value of the "source_id" field.
  24739. func (m *MessageRecordsMutation) ClearSourceID() {
  24740. m.sop_stage = nil
  24741. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24742. }
  24743. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  24744. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  24745. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  24746. return ok
  24747. }
  24748. // ResetSourceID resets all changes to the "source_id" field.
  24749. func (m *MessageRecordsMutation) ResetSourceID() {
  24750. m.sop_stage = nil
  24751. delete(m.clearedFields, messagerecords.FieldSourceID)
  24752. }
  24753. // SetSubSourceID sets the "sub_source_id" field.
  24754. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  24755. m.sop_node = &u
  24756. }
  24757. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  24758. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  24759. v := m.sop_node
  24760. if v == nil {
  24761. return
  24762. }
  24763. return *v, true
  24764. }
  24765. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  24766. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24768. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  24769. if !m.op.Is(OpUpdateOne) {
  24770. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  24771. }
  24772. if m.id == nil || m.oldValue == nil {
  24773. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  24774. }
  24775. oldValue, err := m.oldValue(ctx)
  24776. if err != nil {
  24777. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  24778. }
  24779. return oldValue.SubSourceID, nil
  24780. }
  24781. // ClearSubSourceID clears the value of the "sub_source_id" field.
  24782. func (m *MessageRecordsMutation) ClearSubSourceID() {
  24783. m.sop_node = nil
  24784. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  24785. }
  24786. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  24787. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  24788. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  24789. return ok
  24790. }
  24791. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  24792. func (m *MessageRecordsMutation) ResetSubSourceID() {
  24793. m.sop_node = nil
  24794. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  24795. }
  24796. // SetOrganizationID sets the "organization_id" field.
  24797. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  24798. m.organization_id = &u
  24799. m.addorganization_id = nil
  24800. }
  24801. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24802. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  24803. v := m.organization_id
  24804. if v == nil {
  24805. return
  24806. }
  24807. return *v, true
  24808. }
  24809. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  24810. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24812. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24813. if !m.op.Is(OpUpdateOne) {
  24814. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24815. }
  24816. if m.id == nil || m.oldValue == nil {
  24817. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24818. }
  24819. oldValue, err := m.oldValue(ctx)
  24820. if err != nil {
  24821. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24822. }
  24823. return oldValue.OrganizationID, nil
  24824. }
  24825. // AddOrganizationID adds u to the "organization_id" field.
  24826. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  24827. if m.addorganization_id != nil {
  24828. *m.addorganization_id += u
  24829. } else {
  24830. m.addorganization_id = &u
  24831. }
  24832. }
  24833. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24834. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  24835. v := m.addorganization_id
  24836. if v == nil {
  24837. return
  24838. }
  24839. return *v, true
  24840. }
  24841. // ClearOrganizationID clears the value of the "organization_id" field.
  24842. func (m *MessageRecordsMutation) ClearOrganizationID() {
  24843. m.organization_id = nil
  24844. m.addorganization_id = nil
  24845. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  24846. }
  24847. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24848. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  24849. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  24850. return ok
  24851. }
  24852. // ResetOrganizationID resets all changes to the "organization_id" field.
  24853. func (m *MessageRecordsMutation) ResetOrganizationID() {
  24854. m.organization_id = nil
  24855. m.addorganization_id = nil
  24856. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  24857. }
  24858. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24859. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  24860. m.sop_stage = &id
  24861. }
  24862. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24863. func (m *MessageRecordsMutation) ClearSopStage() {
  24864. m.clearedsop_stage = true
  24865. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24866. }
  24867. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24868. func (m *MessageRecordsMutation) SopStageCleared() bool {
  24869. return m.SourceIDCleared() || m.clearedsop_stage
  24870. }
  24871. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24872. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  24873. if m.sop_stage != nil {
  24874. return *m.sop_stage, true
  24875. }
  24876. return
  24877. }
  24878. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24879. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24880. // SopStageID instead. It exists only for internal usage by the builders.
  24881. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  24882. if id := m.sop_stage; id != nil {
  24883. ids = append(ids, *id)
  24884. }
  24885. return
  24886. }
  24887. // ResetSopStage resets all changes to the "sop_stage" edge.
  24888. func (m *MessageRecordsMutation) ResetSopStage() {
  24889. m.sop_stage = nil
  24890. m.clearedsop_stage = false
  24891. }
  24892. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  24893. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  24894. m.sop_node = &id
  24895. }
  24896. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  24897. func (m *MessageRecordsMutation) ClearSopNode() {
  24898. m.clearedsop_node = true
  24899. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  24900. }
  24901. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  24902. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  24903. return m.SubSourceIDCleared() || m.clearedsop_node
  24904. }
  24905. // SopNodeID returns the "sop_node" edge ID in the mutation.
  24906. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  24907. if m.sop_node != nil {
  24908. return *m.sop_node, true
  24909. }
  24910. return
  24911. }
  24912. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  24913. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24914. // SopNodeID instead. It exists only for internal usage by the builders.
  24915. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  24916. if id := m.sop_node; id != nil {
  24917. ids = append(ids, *id)
  24918. }
  24919. return
  24920. }
  24921. // ResetSopNode resets all changes to the "sop_node" edge.
  24922. func (m *MessageRecordsMutation) ResetSopNode() {
  24923. m.sop_node = nil
  24924. m.clearedsop_node = false
  24925. }
  24926. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  24927. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  24928. m.message_contact = &id
  24929. }
  24930. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  24931. func (m *MessageRecordsMutation) ClearMessageContact() {
  24932. m.clearedmessage_contact = true
  24933. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  24934. }
  24935. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  24936. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  24937. return m.ContactIDCleared() || m.clearedmessage_contact
  24938. }
  24939. // MessageContactID returns the "message_contact" edge ID in the mutation.
  24940. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  24941. if m.message_contact != nil {
  24942. return *m.message_contact, true
  24943. }
  24944. return
  24945. }
  24946. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  24947. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24948. // MessageContactID instead. It exists only for internal usage by the builders.
  24949. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  24950. if id := m.message_contact; id != nil {
  24951. ids = append(ids, *id)
  24952. }
  24953. return
  24954. }
  24955. // ResetMessageContact resets all changes to the "message_contact" edge.
  24956. func (m *MessageRecordsMutation) ResetMessageContact() {
  24957. m.message_contact = nil
  24958. m.clearedmessage_contact = false
  24959. }
  24960. // Where appends a list predicates to the MessageRecordsMutation builder.
  24961. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  24962. m.predicates = append(m.predicates, ps...)
  24963. }
  24964. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  24965. // users can use type-assertion to append predicates that do not depend on any generated package.
  24966. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  24967. p := make([]predicate.MessageRecords, len(ps))
  24968. for i := range ps {
  24969. p[i] = ps[i]
  24970. }
  24971. m.Where(p...)
  24972. }
  24973. // Op returns the operation name.
  24974. func (m *MessageRecordsMutation) Op() Op {
  24975. return m.op
  24976. }
  24977. // SetOp allows setting the mutation operation.
  24978. func (m *MessageRecordsMutation) SetOp(op Op) {
  24979. m.op = op
  24980. }
  24981. // Type returns the node type of this mutation (MessageRecords).
  24982. func (m *MessageRecordsMutation) Type() string {
  24983. return m.typ
  24984. }
  24985. // Fields returns all fields that were changed during this mutation. Note that in
  24986. // order to get all numeric fields that were incremented/decremented, call
  24987. // AddedFields().
  24988. func (m *MessageRecordsMutation) Fields() []string {
  24989. fields := make([]string, 0, 16)
  24990. if m.created_at != nil {
  24991. fields = append(fields, messagerecords.FieldCreatedAt)
  24992. }
  24993. if m.updated_at != nil {
  24994. fields = append(fields, messagerecords.FieldUpdatedAt)
  24995. }
  24996. if m.status != nil {
  24997. fields = append(fields, messagerecords.FieldStatus)
  24998. }
  24999. if m.bot_wxid != nil {
  25000. fields = append(fields, messagerecords.FieldBotWxid)
  25001. }
  25002. if m.message_contact != nil {
  25003. fields = append(fields, messagerecords.FieldContactID)
  25004. }
  25005. if m.contact_type != nil {
  25006. fields = append(fields, messagerecords.FieldContactType)
  25007. }
  25008. if m.contact_wxid != nil {
  25009. fields = append(fields, messagerecords.FieldContactWxid)
  25010. }
  25011. if m.content_type != nil {
  25012. fields = append(fields, messagerecords.FieldContentType)
  25013. }
  25014. if m.content != nil {
  25015. fields = append(fields, messagerecords.FieldContent)
  25016. }
  25017. if m.meta != nil {
  25018. fields = append(fields, messagerecords.FieldMeta)
  25019. }
  25020. if m.error_detail != nil {
  25021. fields = append(fields, messagerecords.FieldErrorDetail)
  25022. }
  25023. if m.send_time != nil {
  25024. fields = append(fields, messagerecords.FieldSendTime)
  25025. }
  25026. if m.source_type != nil {
  25027. fields = append(fields, messagerecords.FieldSourceType)
  25028. }
  25029. if m.sop_stage != nil {
  25030. fields = append(fields, messagerecords.FieldSourceID)
  25031. }
  25032. if m.sop_node != nil {
  25033. fields = append(fields, messagerecords.FieldSubSourceID)
  25034. }
  25035. if m.organization_id != nil {
  25036. fields = append(fields, messagerecords.FieldOrganizationID)
  25037. }
  25038. return fields
  25039. }
  25040. // Field returns the value of a field with the given name. The second boolean
  25041. // return value indicates that this field was not set, or was not defined in the
  25042. // schema.
  25043. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  25044. switch name {
  25045. case messagerecords.FieldCreatedAt:
  25046. return m.CreatedAt()
  25047. case messagerecords.FieldUpdatedAt:
  25048. return m.UpdatedAt()
  25049. case messagerecords.FieldStatus:
  25050. return m.Status()
  25051. case messagerecords.FieldBotWxid:
  25052. return m.BotWxid()
  25053. case messagerecords.FieldContactID:
  25054. return m.ContactID()
  25055. case messagerecords.FieldContactType:
  25056. return m.ContactType()
  25057. case messagerecords.FieldContactWxid:
  25058. return m.ContactWxid()
  25059. case messagerecords.FieldContentType:
  25060. return m.ContentType()
  25061. case messagerecords.FieldContent:
  25062. return m.Content()
  25063. case messagerecords.FieldMeta:
  25064. return m.Meta()
  25065. case messagerecords.FieldErrorDetail:
  25066. return m.ErrorDetail()
  25067. case messagerecords.FieldSendTime:
  25068. return m.SendTime()
  25069. case messagerecords.FieldSourceType:
  25070. return m.SourceType()
  25071. case messagerecords.FieldSourceID:
  25072. return m.SourceID()
  25073. case messagerecords.FieldSubSourceID:
  25074. return m.SubSourceID()
  25075. case messagerecords.FieldOrganizationID:
  25076. return m.OrganizationID()
  25077. }
  25078. return nil, false
  25079. }
  25080. // OldField returns the old value of the field from the database. An error is
  25081. // returned if the mutation operation is not UpdateOne, or the query to the
  25082. // database failed.
  25083. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25084. switch name {
  25085. case messagerecords.FieldCreatedAt:
  25086. return m.OldCreatedAt(ctx)
  25087. case messagerecords.FieldUpdatedAt:
  25088. return m.OldUpdatedAt(ctx)
  25089. case messagerecords.FieldStatus:
  25090. return m.OldStatus(ctx)
  25091. case messagerecords.FieldBotWxid:
  25092. return m.OldBotWxid(ctx)
  25093. case messagerecords.FieldContactID:
  25094. return m.OldContactID(ctx)
  25095. case messagerecords.FieldContactType:
  25096. return m.OldContactType(ctx)
  25097. case messagerecords.FieldContactWxid:
  25098. return m.OldContactWxid(ctx)
  25099. case messagerecords.FieldContentType:
  25100. return m.OldContentType(ctx)
  25101. case messagerecords.FieldContent:
  25102. return m.OldContent(ctx)
  25103. case messagerecords.FieldMeta:
  25104. return m.OldMeta(ctx)
  25105. case messagerecords.FieldErrorDetail:
  25106. return m.OldErrorDetail(ctx)
  25107. case messagerecords.FieldSendTime:
  25108. return m.OldSendTime(ctx)
  25109. case messagerecords.FieldSourceType:
  25110. return m.OldSourceType(ctx)
  25111. case messagerecords.FieldSourceID:
  25112. return m.OldSourceID(ctx)
  25113. case messagerecords.FieldSubSourceID:
  25114. return m.OldSubSourceID(ctx)
  25115. case messagerecords.FieldOrganizationID:
  25116. return m.OldOrganizationID(ctx)
  25117. }
  25118. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  25119. }
  25120. // SetField sets the value of a field with the given name. It returns an error if
  25121. // the field is not defined in the schema, or if the type mismatched the field
  25122. // type.
  25123. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  25124. switch name {
  25125. case messagerecords.FieldCreatedAt:
  25126. v, ok := value.(time.Time)
  25127. if !ok {
  25128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25129. }
  25130. m.SetCreatedAt(v)
  25131. return nil
  25132. case messagerecords.FieldUpdatedAt:
  25133. v, ok := value.(time.Time)
  25134. if !ok {
  25135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25136. }
  25137. m.SetUpdatedAt(v)
  25138. return nil
  25139. case messagerecords.FieldStatus:
  25140. v, ok := value.(uint8)
  25141. if !ok {
  25142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25143. }
  25144. m.SetStatus(v)
  25145. return nil
  25146. case messagerecords.FieldBotWxid:
  25147. v, ok := value.(string)
  25148. if !ok {
  25149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25150. }
  25151. m.SetBotWxid(v)
  25152. return nil
  25153. case messagerecords.FieldContactID:
  25154. v, ok := value.(uint64)
  25155. if !ok {
  25156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25157. }
  25158. m.SetContactID(v)
  25159. return nil
  25160. case messagerecords.FieldContactType:
  25161. v, ok := value.(int)
  25162. if !ok {
  25163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25164. }
  25165. m.SetContactType(v)
  25166. return nil
  25167. case messagerecords.FieldContactWxid:
  25168. v, ok := value.(string)
  25169. if !ok {
  25170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25171. }
  25172. m.SetContactWxid(v)
  25173. return nil
  25174. case messagerecords.FieldContentType:
  25175. v, ok := value.(int)
  25176. if !ok {
  25177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25178. }
  25179. m.SetContentType(v)
  25180. return nil
  25181. case messagerecords.FieldContent:
  25182. v, ok := value.(string)
  25183. if !ok {
  25184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25185. }
  25186. m.SetContent(v)
  25187. return nil
  25188. case messagerecords.FieldMeta:
  25189. v, ok := value.(custom_types.Meta)
  25190. if !ok {
  25191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25192. }
  25193. m.SetMeta(v)
  25194. return nil
  25195. case messagerecords.FieldErrorDetail:
  25196. v, ok := value.(string)
  25197. if !ok {
  25198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25199. }
  25200. m.SetErrorDetail(v)
  25201. return nil
  25202. case messagerecords.FieldSendTime:
  25203. v, ok := value.(time.Time)
  25204. if !ok {
  25205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25206. }
  25207. m.SetSendTime(v)
  25208. return nil
  25209. case messagerecords.FieldSourceType:
  25210. v, ok := value.(int)
  25211. if !ok {
  25212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25213. }
  25214. m.SetSourceType(v)
  25215. return nil
  25216. case messagerecords.FieldSourceID:
  25217. v, ok := value.(uint64)
  25218. if !ok {
  25219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25220. }
  25221. m.SetSourceID(v)
  25222. return nil
  25223. case messagerecords.FieldSubSourceID:
  25224. v, ok := value.(uint64)
  25225. if !ok {
  25226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25227. }
  25228. m.SetSubSourceID(v)
  25229. return nil
  25230. case messagerecords.FieldOrganizationID:
  25231. v, ok := value.(uint64)
  25232. if !ok {
  25233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25234. }
  25235. m.SetOrganizationID(v)
  25236. return nil
  25237. }
  25238. return fmt.Errorf("unknown MessageRecords field %s", name)
  25239. }
  25240. // AddedFields returns all numeric fields that were incremented/decremented during
  25241. // this mutation.
  25242. func (m *MessageRecordsMutation) AddedFields() []string {
  25243. var fields []string
  25244. if m.addstatus != nil {
  25245. fields = append(fields, messagerecords.FieldStatus)
  25246. }
  25247. if m.addcontact_type != nil {
  25248. fields = append(fields, messagerecords.FieldContactType)
  25249. }
  25250. if m.addcontent_type != nil {
  25251. fields = append(fields, messagerecords.FieldContentType)
  25252. }
  25253. if m.addsource_type != nil {
  25254. fields = append(fields, messagerecords.FieldSourceType)
  25255. }
  25256. if m.addorganization_id != nil {
  25257. fields = append(fields, messagerecords.FieldOrganizationID)
  25258. }
  25259. return fields
  25260. }
  25261. // AddedField returns the numeric value that was incremented/decremented on a field
  25262. // with the given name. The second boolean return value indicates that this field
  25263. // was not set, or was not defined in the schema.
  25264. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  25265. switch name {
  25266. case messagerecords.FieldStatus:
  25267. return m.AddedStatus()
  25268. case messagerecords.FieldContactType:
  25269. return m.AddedContactType()
  25270. case messagerecords.FieldContentType:
  25271. return m.AddedContentType()
  25272. case messagerecords.FieldSourceType:
  25273. return m.AddedSourceType()
  25274. case messagerecords.FieldOrganizationID:
  25275. return m.AddedOrganizationID()
  25276. }
  25277. return nil, false
  25278. }
  25279. // AddField adds the value to the field with the given name. It returns an error if
  25280. // the field is not defined in the schema, or if the type mismatched the field
  25281. // type.
  25282. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  25283. switch name {
  25284. case messagerecords.FieldStatus:
  25285. v, ok := value.(int8)
  25286. if !ok {
  25287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25288. }
  25289. m.AddStatus(v)
  25290. return nil
  25291. case messagerecords.FieldContactType:
  25292. v, ok := value.(int)
  25293. if !ok {
  25294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25295. }
  25296. m.AddContactType(v)
  25297. return nil
  25298. case messagerecords.FieldContentType:
  25299. v, ok := value.(int)
  25300. if !ok {
  25301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25302. }
  25303. m.AddContentType(v)
  25304. return nil
  25305. case messagerecords.FieldSourceType:
  25306. v, ok := value.(int)
  25307. if !ok {
  25308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25309. }
  25310. m.AddSourceType(v)
  25311. return nil
  25312. case messagerecords.FieldOrganizationID:
  25313. v, ok := value.(int64)
  25314. if !ok {
  25315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25316. }
  25317. m.AddOrganizationID(v)
  25318. return nil
  25319. }
  25320. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  25321. }
  25322. // ClearedFields returns all nullable fields that were cleared during this
  25323. // mutation.
  25324. func (m *MessageRecordsMutation) ClearedFields() []string {
  25325. var fields []string
  25326. if m.FieldCleared(messagerecords.FieldStatus) {
  25327. fields = append(fields, messagerecords.FieldStatus)
  25328. }
  25329. if m.FieldCleared(messagerecords.FieldContactID) {
  25330. fields = append(fields, messagerecords.FieldContactID)
  25331. }
  25332. if m.FieldCleared(messagerecords.FieldMeta) {
  25333. fields = append(fields, messagerecords.FieldMeta)
  25334. }
  25335. if m.FieldCleared(messagerecords.FieldSendTime) {
  25336. fields = append(fields, messagerecords.FieldSendTime)
  25337. }
  25338. if m.FieldCleared(messagerecords.FieldSourceID) {
  25339. fields = append(fields, messagerecords.FieldSourceID)
  25340. }
  25341. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  25342. fields = append(fields, messagerecords.FieldSubSourceID)
  25343. }
  25344. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  25345. fields = append(fields, messagerecords.FieldOrganizationID)
  25346. }
  25347. return fields
  25348. }
  25349. // FieldCleared returns a boolean indicating if a field with the given name was
  25350. // cleared in this mutation.
  25351. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  25352. _, ok := m.clearedFields[name]
  25353. return ok
  25354. }
  25355. // ClearField clears the value of the field with the given name. It returns an
  25356. // error if the field is not defined in the schema.
  25357. func (m *MessageRecordsMutation) ClearField(name string) error {
  25358. switch name {
  25359. case messagerecords.FieldStatus:
  25360. m.ClearStatus()
  25361. return nil
  25362. case messagerecords.FieldContactID:
  25363. m.ClearContactID()
  25364. return nil
  25365. case messagerecords.FieldMeta:
  25366. m.ClearMeta()
  25367. return nil
  25368. case messagerecords.FieldSendTime:
  25369. m.ClearSendTime()
  25370. return nil
  25371. case messagerecords.FieldSourceID:
  25372. m.ClearSourceID()
  25373. return nil
  25374. case messagerecords.FieldSubSourceID:
  25375. m.ClearSubSourceID()
  25376. return nil
  25377. case messagerecords.FieldOrganizationID:
  25378. m.ClearOrganizationID()
  25379. return nil
  25380. }
  25381. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  25382. }
  25383. // ResetField resets all changes in the mutation for the field with the given name.
  25384. // It returns an error if the field is not defined in the schema.
  25385. func (m *MessageRecordsMutation) ResetField(name string) error {
  25386. switch name {
  25387. case messagerecords.FieldCreatedAt:
  25388. m.ResetCreatedAt()
  25389. return nil
  25390. case messagerecords.FieldUpdatedAt:
  25391. m.ResetUpdatedAt()
  25392. return nil
  25393. case messagerecords.FieldStatus:
  25394. m.ResetStatus()
  25395. return nil
  25396. case messagerecords.FieldBotWxid:
  25397. m.ResetBotWxid()
  25398. return nil
  25399. case messagerecords.FieldContactID:
  25400. m.ResetContactID()
  25401. return nil
  25402. case messagerecords.FieldContactType:
  25403. m.ResetContactType()
  25404. return nil
  25405. case messagerecords.FieldContactWxid:
  25406. m.ResetContactWxid()
  25407. return nil
  25408. case messagerecords.FieldContentType:
  25409. m.ResetContentType()
  25410. return nil
  25411. case messagerecords.FieldContent:
  25412. m.ResetContent()
  25413. return nil
  25414. case messagerecords.FieldMeta:
  25415. m.ResetMeta()
  25416. return nil
  25417. case messagerecords.FieldErrorDetail:
  25418. m.ResetErrorDetail()
  25419. return nil
  25420. case messagerecords.FieldSendTime:
  25421. m.ResetSendTime()
  25422. return nil
  25423. case messagerecords.FieldSourceType:
  25424. m.ResetSourceType()
  25425. return nil
  25426. case messagerecords.FieldSourceID:
  25427. m.ResetSourceID()
  25428. return nil
  25429. case messagerecords.FieldSubSourceID:
  25430. m.ResetSubSourceID()
  25431. return nil
  25432. case messagerecords.FieldOrganizationID:
  25433. m.ResetOrganizationID()
  25434. return nil
  25435. }
  25436. return fmt.Errorf("unknown MessageRecords field %s", name)
  25437. }
  25438. // AddedEdges returns all edge names that were set/added in this mutation.
  25439. func (m *MessageRecordsMutation) AddedEdges() []string {
  25440. edges := make([]string, 0, 3)
  25441. if m.sop_stage != nil {
  25442. edges = append(edges, messagerecords.EdgeSopStage)
  25443. }
  25444. if m.sop_node != nil {
  25445. edges = append(edges, messagerecords.EdgeSopNode)
  25446. }
  25447. if m.message_contact != nil {
  25448. edges = append(edges, messagerecords.EdgeMessageContact)
  25449. }
  25450. return edges
  25451. }
  25452. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25453. // name in this mutation.
  25454. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  25455. switch name {
  25456. case messagerecords.EdgeSopStage:
  25457. if id := m.sop_stage; id != nil {
  25458. return []ent.Value{*id}
  25459. }
  25460. case messagerecords.EdgeSopNode:
  25461. if id := m.sop_node; id != nil {
  25462. return []ent.Value{*id}
  25463. }
  25464. case messagerecords.EdgeMessageContact:
  25465. if id := m.message_contact; id != nil {
  25466. return []ent.Value{*id}
  25467. }
  25468. }
  25469. return nil
  25470. }
  25471. // RemovedEdges returns all edge names that were removed in this mutation.
  25472. func (m *MessageRecordsMutation) RemovedEdges() []string {
  25473. edges := make([]string, 0, 3)
  25474. return edges
  25475. }
  25476. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25477. // the given name in this mutation.
  25478. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  25479. return nil
  25480. }
  25481. // ClearedEdges returns all edge names that were cleared in this mutation.
  25482. func (m *MessageRecordsMutation) ClearedEdges() []string {
  25483. edges := make([]string, 0, 3)
  25484. if m.clearedsop_stage {
  25485. edges = append(edges, messagerecords.EdgeSopStage)
  25486. }
  25487. if m.clearedsop_node {
  25488. edges = append(edges, messagerecords.EdgeSopNode)
  25489. }
  25490. if m.clearedmessage_contact {
  25491. edges = append(edges, messagerecords.EdgeMessageContact)
  25492. }
  25493. return edges
  25494. }
  25495. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25496. // was cleared in this mutation.
  25497. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  25498. switch name {
  25499. case messagerecords.EdgeSopStage:
  25500. return m.clearedsop_stage
  25501. case messagerecords.EdgeSopNode:
  25502. return m.clearedsop_node
  25503. case messagerecords.EdgeMessageContact:
  25504. return m.clearedmessage_contact
  25505. }
  25506. return false
  25507. }
  25508. // ClearEdge clears the value of the edge with the given name. It returns an error
  25509. // if that edge is not defined in the schema.
  25510. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  25511. switch name {
  25512. case messagerecords.EdgeSopStage:
  25513. m.ClearSopStage()
  25514. return nil
  25515. case messagerecords.EdgeSopNode:
  25516. m.ClearSopNode()
  25517. return nil
  25518. case messagerecords.EdgeMessageContact:
  25519. m.ClearMessageContact()
  25520. return nil
  25521. }
  25522. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  25523. }
  25524. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25525. // It returns an error if the edge is not defined in the schema.
  25526. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  25527. switch name {
  25528. case messagerecords.EdgeSopStage:
  25529. m.ResetSopStage()
  25530. return nil
  25531. case messagerecords.EdgeSopNode:
  25532. m.ResetSopNode()
  25533. return nil
  25534. case messagerecords.EdgeMessageContact:
  25535. m.ResetMessageContact()
  25536. return nil
  25537. }
  25538. return fmt.Errorf("unknown MessageRecords edge %s", name)
  25539. }
  25540. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  25541. type MsgMutation struct {
  25542. config
  25543. op Op
  25544. typ string
  25545. id *uint64
  25546. created_at *time.Time
  25547. updated_at *time.Time
  25548. deleted_at *time.Time
  25549. status *uint8
  25550. addstatus *int8
  25551. fromwxid *string
  25552. toid *string
  25553. msgtype *int32
  25554. addmsgtype *int32
  25555. msg *string
  25556. batch_no *string
  25557. cc *string
  25558. phone *string
  25559. clearedFields map[string]struct{}
  25560. done bool
  25561. oldValue func(context.Context) (*Msg, error)
  25562. predicates []predicate.Msg
  25563. }
  25564. var _ ent.Mutation = (*MsgMutation)(nil)
  25565. // msgOption allows management of the mutation configuration using functional options.
  25566. type msgOption func(*MsgMutation)
  25567. // newMsgMutation creates new mutation for the Msg entity.
  25568. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  25569. m := &MsgMutation{
  25570. config: c,
  25571. op: op,
  25572. typ: TypeMsg,
  25573. clearedFields: make(map[string]struct{}),
  25574. }
  25575. for _, opt := range opts {
  25576. opt(m)
  25577. }
  25578. return m
  25579. }
  25580. // withMsgID sets the ID field of the mutation.
  25581. func withMsgID(id uint64) msgOption {
  25582. return func(m *MsgMutation) {
  25583. var (
  25584. err error
  25585. once sync.Once
  25586. value *Msg
  25587. )
  25588. m.oldValue = func(ctx context.Context) (*Msg, error) {
  25589. once.Do(func() {
  25590. if m.done {
  25591. err = errors.New("querying old values post mutation is not allowed")
  25592. } else {
  25593. value, err = m.Client().Msg.Get(ctx, id)
  25594. }
  25595. })
  25596. return value, err
  25597. }
  25598. m.id = &id
  25599. }
  25600. }
  25601. // withMsg sets the old Msg of the mutation.
  25602. func withMsg(node *Msg) msgOption {
  25603. return func(m *MsgMutation) {
  25604. m.oldValue = func(context.Context) (*Msg, error) {
  25605. return node, nil
  25606. }
  25607. m.id = &node.ID
  25608. }
  25609. }
  25610. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25611. // executed in a transaction (ent.Tx), a transactional client is returned.
  25612. func (m MsgMutation) Client() *Client {
  25613. client := &Client{config: m.config}
  25614. client.init()
  25615. return client
  25616. }
  25617. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25618. // it returns an error otherwise.
  25619. func (m MsgMutation) Tx() (*Tx, error) {
  25620. if _, ok := m.driver.(*txDriver); !ok {
  25621. return nil, errors.New("ent: mutation is not running in a transaction")
  25622. }
  25623. tx := &Tx{config: m.config}
  25624. tx.init()
  25625. return tx, nil
  25626. }
  25627. // SetID sets the value of the id field. Note that this
  25628. // operation is only accepted on creation of Msg entities.
  25629. func (m *MsgMutation) SetID(id uint64) {
  25630. m.id = &id
  25631. }
  25632. // ID returns the ID value in the mutation. Note that the ID is only available
  25633. // if it was provided to the builder or after it was returned from the database.
  25634. func (m *MsgMutation) ID() (id uint64, exists bool) {
  25635. if m.id == nil {
  25636. return
  25637. }
  25638. return *m.id, true
  25639. }
  25640. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25641. // That means, if the mutation is applied within a transaction with an isolation level such
  25642. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25643. // or updated by the mutation.
  25644. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  25645. switch {
  25646. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25647. id, exists := m.ID()
  25648. if exists {
  25649. return []uint64{id}, nil
  25650. }
  25651. fallthrough
  25652. case m.op.Is(OpUpdate | OpDelete):
  25653. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  25654. default:
  25655. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25656. }
  25657. }
  25658. // SetCreatedAt sets the "created_at" field.
  25659. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  25660. m.created_at = &t
  25661. }
  25662. // CreatedAt returns the value of the "created_at" field in the mutation.
  25663. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  25664. v := m.created_at
  25665. if v == nil {
  25666. return
  25667. }
  25668. return *v, true
  25669. }
  25670. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  25671. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25673. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25674. if !m.op.Is(OpUpdateOne) {
  25675. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25676. }
  25677. if m.id == nil || m.oldValue == nil {
  25678. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25679. }
  25680. oldValue, err := m.oldValue(ctx)
  25681. if err != nil {
  25682. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25683. }
  25684. return oldValue.CreatedAt, nil
  25685. }
  25686. // ResetCreatedAt resets all changes to the "created_at" field.
  25687. func (m *MsgMutation) ResetCreatedAt() {
  25688. m.created_at = nil
  25689. }
  25690. // SetUpdatedAt sets the "updated_at" field.
  25691. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  25692. m.updated_at = &t
  25693. }
  25694. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25695. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  25696. v := m.updated_at
  25697. if v == nil {
  25698. return
  25699. }
  25700. return *v, true
  25701. }
  25702. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  25703. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25705. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25706. if !m.op.Is(OpUpdateOne) {
  25707. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25708. }
  25709. if m.id == nil || m.oldValue == nil {
  25710. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25711. }
  25712. oldValue, err := m.oldValue(ctx)
  25713. if err != nil {
  25714. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25715. }
  25716. return oldValue.UpdatedAt, nil
  25717. }
  25718. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25719. func (m *MsgMutation) ResetUpdatedAt() {
  25720. m.updated_at = nil
  25721. }
  25722. // SetDeletedAt sets the "deleted_at" field.
  25723. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  25724. m.deleted_at = &t
  25725. }
  25726. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25727. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  25728. v := m.deleted_at
  25729. if v == nil {
  25730. return
  25731. }
  25732. return *v, true
  25733. }
  25734. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  25735. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25737. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25738. if !m.op.Is(OpUpdateOne) {
  25739. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25740. }
  25741. if m.id == nil || m.oldValue == nil {
  25742. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25743. }
  25744. oldValue, err := m.oldValue(ctx)
  25745. if err != nil {
  25746. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25747. }
  25748. return oldValue.DeletedAt, nil
  25749. }
  25750. // ClearDeletedAt clears the value of the "deleted_at" field.
  25751. func (m *MsgMutation) ClearDeletedAt() {
  25752. m.deleted_at = nil
  25753. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  25754. }
  25755. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25756. func (m *MsgMutation) DeletedAtCleared() bool {
  25757. _, ok := m.clearedFields[msg.FieldDeletedAt]
  25758. return ok
  25759. }
  25760. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25761. func (m *MsgMutation) ResetDeletedAt() {
  25762. m.deleted_at = nil
  25763. delete(m.clearedFields, msg.FieldDeletedAt)
  25764. }
  25765. // SetStatus sets the "status" field.
  25766. func (m *MsgMutation) SetStatus(u uint8) {
  25767. m.status = &u
  25768. m.addstatus = nil
  25769. }
  25770. // Status returns the value of the "status" field in the mutation.
  25771. func (m *MsgMutation) Status() (r uint8, exists bool) {
  25772. v := m.status
  25773. if v == nil {
  25774. return
  25775. }
  25776. return *v, true
  25777. }
  25778. // OldStatus returns the old "status" field's value of the Msg entity.
  25779. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25781. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25782. if !m.op.Is(OpUpdateOne) {
  25783. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25784. }
  25785. if m.id == nil || m.oldValue == nil {
  25786. return v, errors.New("OldStatus requires an ID field in the mutation")
  25787. }
  25788. oldValue, err := m.oldValue(ctx)
  25789. if err != nil {
  25790. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25791. }
  25792. return oldValue.Status, nil
  25793. }
  25794. // AddStatus adds u to the "status" field.
  25795. func (m *MsgMutation) AddStatus(u int8) {
  25796. if m.addstatus != nil {
  25797. *m.addstatus += u
  25798. } else {
  25799. m.addstatus = &u
  25800. }
  25801. }
  25802. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25803. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  25804. v := m.addstatus
  25805. if v == nil {
  25806. return
  25807. }
  25808. return *v, true
  25809. }
  25810. // ClearStatus clears the value of the "status" field.
  25811. func (m *MsgMutation) ClearStatus() {
  25812. m.status = nil
  25813. m.addstatus = nil
  25814. m.clearedFields[msg.FieldStatus] = struct{}{}
  25815. }
  25816. // StatusCleared returns if the "status" field was cleared in this mutation.
  25817. func (m *MsgMutation) StatusCleared() bool {
  25818. _, ok := m.clearedFields[msg.FieldStatus]
  25819. return ok
  25820. }
  25821. // ResetStatus resets all changes to the "status" field.
  25822. func (m *MsgMutation) ResetStatus() {
  25823. m.status = nil
  25824. m.addstatus = nil
  25825. delete(m.clearedFields, msg.FieldStatus)
  25826. }
  25827. // SetFromwxid sets the "fromwxid" field.
  25828. func (m *MsgMutation) SetFromwxid(s string) {
  25829. m.fromwxid = &s
  25830. }
  25831. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  25832. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  25833. v := m.fromwxid
  25834. if v == nil {
  25835. return
  25836. }
  25837. return *v, true
  25838. }
  25839. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  25840. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25842. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  25843. if !m.op.Is(OpUpdateOne) {
  25844. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  25845. }
  25846. if m.id == nil || m.oldValue == nil {
  25847. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  25848. }
  25849. oldValue, err := m.oldValue(ctx)
  25850. if err != nil {
  25851. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  25852. }
  25853. return oldValue.Fromwxid, nil
  25854. }
  25855. // ClearFromwxid clears the value of the "fromwxid" field.
  25856. func (m *MsgMutation) ClearFromwxid() {
  25857. m.fromwxid = nil
  25858. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  25859. }
  25860. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  25861. func (m *MsgMutation) FromwxidCleared() bool {
  25862. _, ok := m.clearedFields[msg.FieldFromwxid]
  25863. return ok
  25864. }
  25865. // ResetFromwxid resets all changes to the "fromwxid" field.
  25866. func (m *MsgMutation) ResetFromwxid() {
  25867. m.fromwxid = nil
  25868. delete(m.clearedFields, msg.FieldFromwxid)
  25869. }
  25870. // SetToid sets the "toid" field.
  25871. func (m *MsgMutation) SetToid(s string) {
  25872. m.toid = &s
  25873. }
  25874. // Toid returns the value of the "toid" field in the mutation.
  25875. func (m *MsgMutation) Toid() (r string, exists bool) {
  25876. v := m.toid
  25877. if v == nil {
  25878. return
  25879. }
  25880. return *v, true
  25881. }
  25882. // OldToid returns the old "toid" field's value of the Msg entity.
  25883. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25885. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  25886. if !m.op.Is(OpUpdateOne) {
  25887. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  25888. }
  25889. if m.id == nil || m.oldValue == nil {
  25890. return v, errors.New("OldToid requires an ID field in the mutation")
  25891. }
  25892. oldValue, err := m.oldValue(ctx)
  25893. if err != nil {
  25894. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  25895. }
  25896. return oldValue.Toid, nil
  25897. }
  25898. // ClearToid clears the value of the "toid" field.
  25899. func (m *MsgMutation) ClearToid() {
  25900. m.toid = nil
  25901. m.clearedFields[msg.FieldToid] = struct{}{}
  25902. }
  25903. // ToidCleared returns if the "toid" field was cleared in this mutation.
  25904. func (m *MsgMutation) ToidCleared() bool {
  25905. _, ok := m.clearedFields[msg.FieldToid]
  25906. return ok
  25907. }
  25908. // ResetToid resets all changes to the "toid" field.
  25909. func (m *MsgMutation) ResetToid() {
  25910. m.toid = nil
  25911. delete(m.clearedFields, msg.FieldToid)
  25912. }
  25913. // SetMsgtype sets the "msgtype" field.
  25914. func (m *MsgMutation) SetMsgtype(i int32) {
  25915. m.msgtype = &i
  25916. m.addmsgtype = nil
  25917. }
  25918. // Msgtype returns the value of the "msgtype" field in the mutation.
  25919. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  25920. v := m.msgtype
  25921. if v == nil {
  25922. return
  25923. }
  25924. return *v, true
  25925. }
  25926. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  25927. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25929. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  25930. if !m.op.Is(OpUpdateOne) {
  25931. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  25932. }
  25933. if m.id == nil || m.oldValue == nil {
  25934. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  25935. }
  25936. oldValue, err := m.oldValue(ctx)
  25937. if err != nil {
  25938. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  25939. }
  25940. return oldValue.Msgtype, nil
  25941. }
  25942. // AddMsgtype adds i to the "msgtype" field.
  25943. func (m *MsgMutation) AddMsgtype(i int32) {
  25944. if m.addmsgtype != nil {
  25945. *m.addmsgtype += i
  25946. } else {
  25947. m.addmsgtype = &i
  25948. }
  25949. }
  25950. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  25951. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  25952. v := m.addmsgtype
  25953. if v == nil {
  25954. return
  25955. }
  25956. return *v, true
  25957. }
  25958. // ClearMsgtype clears the value of the "msgtype" field.
  25959. func (m *MsgMutation) ClearMsgtype() {
  25960. m.msgtype = nil
  25961. m.addmsgtype = nil
  25962. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  25963. }
  25964. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  25965. func (m *MsgMutation) MsgtypeCleared() bool {
  25966. _, ok := m.clearedFields[msg.FieldMsgtype]
  25967. return ok
  25968. }
  25969. // ResetMsgtype resets all changes to the "msgtype" field.
  25970. func (m *MsgMutation) ResetMsgtype() {
  25971. m.msgtype = nil
  25972. m.addmsgtype = nil
  25973. delete(m.clearedFields, msg.FieldMsgtype)
  25974. }
  25975. // SetMsg sets the "msg" field.
  25976. func (m *MsgMutation) SetMsg(s string) {
  25977. m.msg = &s
  25978. }
  25979. // Msg returns the value of the "msg" field in the mutation.
  25980. func (m *MsgMutation) Msg() (r string, exists bool) {
  25981. v := m.msg
  25982. if v == nil {
  25983. return
  25984. }
  25985. return *v, true
  25986. }
  25987. // OldMsg returns the old "msg" field's value of the Msg entity.
  25988. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25990. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  25991. if !m.op.Is(OpUpdateOne) {
  25992. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  25993. }
  25994. if m.id == nil || m.oldValue == nil {
  25995. return v, errors.New("OldMsg requires an ID field in the mutation")
  25996. }
  25997. oldValue, err := m.oldValue(ctx)
  25998. if err != nil {
  25999. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  26000. }
  26001. return oldValue.Msg, nil
  26002. }
  26003. // ClearMsg clears the value of the "msg" field.
  26004. func (m *MsgMutation) ClearMsg() {
  26005. m.msg = nil
  26006. m.clearedFields[msg.FieldMsg] = struct{}{}
  26007. }
  26008. // MsgCleared returns if the "msg" field was cleared in this mutation.
  26009. func (m *MsgMutation) MsgCleared() bool {
  26010. _, ok := m.clearedFields[msg.FieldMsg]
  26011. return ok
  26012. }
  26013. // ResetMsg resets all changes to the "msg" field.
  26014. func (m *MsgMutation) ResetMsg() {
  26015. m.msg = nil
  26016. delete(m.clearedFields, msg.FieldMsg)
  26017. }
  26018. // SetBatchNo sets the "batch_no" field.
  26019. func (m *MsgMutation) SetBatchNo(s string) {
  26020. m.batch_no = &s
  26021. }
  26022. // BatchNo returns the value of the "batch_no" field in the mutation.
  26023. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  26024. v := m.batch_no
  26025. if v == nil {
  26026. return
  26027. }
  26028. return *v, true
  26029. }
  26030. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  26031. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26033. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  26034. if !m.op.Is(OpUpdateOne) {
  26035. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  26036. }
  26037. if m.id == nil || m.oldValue == nil {
  26038. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  26039. }
  26040. oldValue, err := m.oldValue(ctx)
  26041. if err != nil {
  26042. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  26043. }
  26044. return oldValue.BatchNo, nil
  26045. }
  26046. // ClearBatchNo clears the value of the "batch_no" field.
  26047. func (m *MsgMutation) ClearBatchNo() {
  26048. m.batch_no = nil
  26049. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  26050. }
  26051. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  26052. func (m *MsgMutation) BatchNoCleared() bool {
  26053. _, ok := m.clearedFields[msg.FieldBatchNo]
  26054. return ok
  26055. }
  26056. // ResetBatchNo resets all changes to the "batch_no" field.
  26057. func (m *MsgMutation) ResetBatchNo() {
  26058. m.batch_no = nil
  26059. delete(m.clearedFields, msg.FieldBatchNo)
  26060. }
  26061. // SetCc sets the "cc" field.
  26062. func (m *MsgMutation) SetCc(s string) {
  26063. m.cc = &s
  26064. }
  26065. // Cc returns the value of the "cc" field in the mutation.
  26066. func (m *MsgMutation) Cc() (r string, exists bool) {
  26067. v := m.cc
  26068. if v == nil {
  26069. return
  26070. }
  26071. return *v, true
  26072. }
  26073. // OldCc returns the old "cc" field's value of the Msg entity.
  26074. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26076. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  26077. if !m.op.Is(OpUpdateOne) {
  26078. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  26079. }
  26080. if m.id == nil || m.oldValue == nil {
  26081. return v, errors.New("OldCc requires an ID field in the mutation")
  26082. }
  26083. oldValue, err := m.oldValue(ctx)
  26084. if err != nil {
  26085. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  26086. }
  26087. return oldValue.Cc, nil
  26088. }
  26089. // ResetCc resets all changes to the "cc" field.
  26090. func (m *MsgMutation) ResetCc() {
  26091. m.cc = nil
  26092. }
  26093. // SetPhone sets the "phone" field.
  26094. func (m *MsgMutation) SetPhone(s string) {
  26095. m.phone = &s
  26096. }
  26097. // Phone returns the value of the "phone" field in the mutation.
  26098. func (m *MsgMutation) Phone() (r string, exists bool) {
  26099. v := m.phone
  26100. if v == nil {
  26101. return
  26102. }
  26103. return *v, true
  26104. }
  26105. // OldPhone returns the old "phone" field's value of the Msg entity.
  26106. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26108. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  26109. if !m.op.Is(OpUpdateOne) {
  26110. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26111. }
  26112. if m.id == nil || m.oldValue == nil {
  26113. return v, errors.New("OldPhone requires an ID field in the mutation")
  26114. }
  26115. oldValue, err := m.oldValue(ctx)
  26116. if err != nil {
  26117. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26118. }
  26119. return oldValue.Phone, nil
  26120. }
  26121. // ResetPhone resets all changes to the "phone" field.
  26122. func (m *MsgMutation) ResetPhone() {
  26123. m.phone = nil
  26124. }
  26125. // Where appends a list predicates to the MsgMutation builder.
  26126. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  26127. m.predicates = append(m.predicates, ps...)
  26128. }
  26129. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  26130. // users can use type-assertion to append predicates that do not depend on any generated package.
  26131. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  26132. p := make([]predicate.Msg, len(ps))
  26133. for i := range ps {
  26134. p[i] = ps[i]
  26135. }
  26136. m.Where(p...)
  26137. }
  26138. // Op returns the operation name.
  26139. func (m *MsgMutation) Op() Op {
  26140. return m.op
  26141. }
  26142. // SetOp allows setting the mutation operation.
  26143. func (m *MsgMutation) SetOp(op Op) {
  26144. m.op = op
  26145. }
  26146. // Type returns the node type of this mutation (Msg).
  26147. func (m *MsgMutation) Type() string {
  26148. return m.typ
  26149. }
  26150. // Fields returns all fields that were changed during this mutation. Note that in
  26151. // order to get all numeric fields that were incremented/decremented, call
  26152. // AddedFields().
  26153. func (m *MsgMutation) Fields() []string {
  26154. fields := make([]string, 0, 11)
  26155. if m.created_at != nil {
  26156. fields = append(fields, msg.FieldCreatedAt)
  26157. }
  26158. if m.updated_at != nil {
  26159. fields = append(fields, msg.FieldUpdatedAt)
  26160. }
  26161. if m.deleted_at != nil {
  26162. fields = append(fields, msg.FieldDeletedAt)
  26163. }
  26164. if m.status != nil {
  26165. fields = append(fields, msg.FieldStatus)
  26166. }
  26167. if m.fromwxid != nil {
  26168. fields = append(fields, msg.FieldFromwxid)
  26169. }
  26170. if m.toid != nil {
  26171. fields = append(fields, msg.FieldToid)
  26172. }
  26173. if m.msgtype != nil {
  26174. fields = append(fields, msg.FieldMsgtype)
  26175. }
  26176. if m.msg != nil {
  26177. fields = append(fields, msg.FieldMsg)
  26178. }
  26179. if m.batch_no != nil {
  26180. fields = append(fields, msg.FieldBatchNo)
  26181. }
  26182. if m.cc != nil {
  26183. fields = append(fields, msg.FieldCc)
  26184. }
  26185. if m.phone != nil {
  26186. fields = append(fields, msg.FieldPhone)
  26187. }
  26188. return fields
  26189. }
  26190. // Field returns the value of a field with the given name. The second boolean
  26191. // return value indicates that this field was not set, or was not defined in the
  26192. // schema.
  26193. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  26194. switch name {
  26195. case msg.FieldCreatedAt:
  26196. return m.CreatedAt()
  26197. case msg.FieldUpdatedAt:
  26198. return m.UpdatedAt()
  26199. case msg.FieldDeletedAt:
  26200. return m.DeletedAt()
  26201. case msg.FieldStatus:
  26202. return m.Status()
  26203. case msg.FieldFromwxid:
  26204. return m.Fromwxid()
  26205. case msg.FieldToid:
  26206. return m.Toid()
  26207. case msg.FieldMsgtype:
  26208. return m.Msgtype()
  26209. case msg.FieldMsg:
  26210. return m.Msg()
  26211. case msg.FieldBatchNo:
  26212. return m.BatchNo()
  26213. case msg.FieldCc:
  26214. return m.Cc()
  26215. case msg.FieldPhone:
  26216. return m.Phone()
  26217. }
  26218. return nil, false
  26219. }
  26220. // OldField returns the old value of the field from the database. An error is
  26221. // returned if the mutation operation is not UpdateOne, or the query to the
  26222. // database failed.
  26223. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26224. switch name {
  26225. case msg.FieldCreatedAt:
  26226. return m.OldCreatedAt(ctx)
  26227. case msg.FieldUpdatedAt:
  26228. return m.OldUpdatedAt(ctx)
  26229. case msg.FieldDeletedAt:
  26230. return m.OldDeletedAt(ctx)
  26231. case msg.FieldStatus:
  26232. return m.OldStatus(ctx)
  26233. case msg.FieldFromwxid:
  26234. return m.OldFromwxid(ctx)
  26235. case msg.FieldToid:
  26236. return m.OldToid(ctx)
  26237. case msg.FieldMsgtype:
  26238. return m.OldMsgtype(ctx)
  26239. case msg.FieldMsg:
  26240. return m.OldMsg(ctx)
  26241. case msg.FieldBatchNo:
  26242. return m.OldBatchNo(ctx)
  26243. case msg.FieldCc:
  26244. return m.OldCc(ctx)
  26245. case msg.FieldPhone:
  26246. return m.OldPhone(ctx)
  26247. }
  26248. return nil, fmt.Errorf("unknown Msg field %s", name)
  26249. }
  26250. // SetField sets the value of a field with the given name. It returns an error if
  26251. // the field is not defined in the schema, or if the type mismatched the field
  26252. // type.
  26253. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  26254. switch name {
  26255. case msg.FieldCreatedAt:
  26256. v, ok := value.(time.Time)
  26257. if !ok {
  26258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26259. }
  26260. m.SetCreatedAt(v)
  26261. return nil
  26262. case msg.FieldUpdatedAt:
  26263. v, ok := value.(time.Time)
  26264. if !ok {
  26265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26266. }
  26267. m.SetUpdatedAt(v)
  26268. return nil
  26269. case msg.FieldDeletedAt:
  26270. v, ok := value.(time.Time)
  26271. if !ok {
  26272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26273. }
  26274. m.SetDeletedAt(v)
  26275. return nil
  26276. case msg.FieldStatus:
  26277. v, ok := value.(uint8)
  26278. if !ok {
  26279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26280. }
  26281. m.SetStatus(v)
  26282. return nil
  26283. case msg.FieldFromwxid:
  26284. v, ok := value.(string)
  26285. if !ok {
  26286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26287. }
  26288. m.SetFromwxid(v)
  26289. return nil
  26290. case msg.FieldToid:
  26291. v, ok := value.(string)
  26292. if !ok {
  26293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26294. }
  26295. m.SetToid(v)
  26296. return nil
  26297. case msg.FieldMsgtype:
  26298. v, ok := value.(int32)
  26299. if !ok {
  26300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26301. }
  26302. m.SetMsgtype(v)
  26303. return nil
  26304. case msg.FieldMsg:
  26305. v, ok := value.(string)
  26306. if !ok {
  26307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26308. }
  26309. m.SetMsg(v)
  26310. return nil
  26311. case msg.FieldBatchNo:
  26312. v, ok := value.(string)
  26313. if !ok {
  26314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26315. }
  26316. m.SetBatchNo(v)
  26317. return nil
  26318. case msg.FieldCc:
  26319. v, ok := value.(string)
  26320. if !ok {
  26321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26322. }
  26323. m.SetCc(v)
  26324. return nil
  26325. case msg.FieldPhone:
  26326. v, ok := value.(string)
  26327. if !ok {
  26328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26329. }
  26330. m.SetPhone(v)
  26331. return nil
  26332. }
  26333. return fmt.Errorf("unknown Msg field %s", name)
  26334. }
  26335. // AddedFields returns all numeric fields that were incremented/decremented during
  26336. // this mutation.
  26337. func (m *MsgMutation) AddedFields() []string {
  26338. var fields []string
  26339. if m.addstatus != nil {
  26340. fields = append(fields, msg.FieldStatus)
  26341. }
  26342. if m.addmsgtype != nil {
  26343. fields = append(fields, msg.FieldMsgtype)
  26344. }
  26345. return fields
  26346. }
  26347. // AddedField returns the numeric value that was incremented/decremented on a field
  26348. // with the given name. The second boolean return value indicates that this field
  26349. // was not set, or was not defined in the schema.
  26350. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  26351. switch name {
  26352. case msg.FieldStatus:
  26353. return m.AddedStatus()
  26354. case msg.FieldMsgtype:
  26355. return m.AddedMsgtype()
  26356. }
  26357. return nil, false
  26358. }
  26359. // AddField adds the value to the field with the given name. It returns an error if
  26360. // the field is not defined in the schema, or if the type mismatched the field
  26361. // type.
  26362. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  26363. switch name {
  26364. case msg.FieldStatus:
  26365. v, ok := value.(int8)
  26366. if !ok {
  26367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26368. }
  26369. m.AddStatus(v)
  26370. return nil
  26371. case msg.FieldMsgtype:
  26372. v, ok := value.(int32)
  26373. if !ok {
  26374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26375. }
  26376. m.AddMsgtype(v)
  26377. return nil
  26378. }
  26379. return fmt.Errorf("unknown Msg numeric field %s", name)
  26380. }
  26381. // ClearedFields returns all nullable fields that were cleared during this
  26382. // mutation.
  26383. func (m *MsgMutation) ClearedFields() []string {
  26384. var fields []string
  26385. if m.FieldCleared(msg.FieldDeletedAt) {
  26386. fields = append(fields, msg.FieldDeletedAt)
  26387. }
  26388. if m.FieldCleared(msg.FieldStatus) {
  26389. fields = append(fields, msg.FieldStatus)
  26390. }
  26391. if m.FieldCleared(msg.FieldFromwxid) {
  26392. fields = append(fields, msg.FieldFromwxid)
  26393. }
  26394. if m.FieldCleared(msg.FieldToid) {
  26395. fields = append(fields, msg.FieldToid)
  26396. }
  26397. if m.FieldCleared(msg.FieldMsgtype) {
  26398. fields = append(fields, msg.FieldMsgtype)
  26399. }
  26400. if m.FieldCleared(msg.FieldMsg) {
  26401. fields = append(fields, msg.FieldMsg)
  26402. }
  26403. if m.FieldCleared(msg.FieldBatchNo) {
  26404. fields = append(fields, msg.FieldBatchNo)
  26405. }
  26406. return fields
  26407. }
  26408. // FieldCleared returns a boolean indicating if a field with the given name was
  26409. // cleared in this mutation.
  26410. func (m *MsgMutation) FieldCleared(name string) bool {
  26411. _, ok := m.clearedFields[name]
  26412. return ok
  26413. }
  26414. // ClearField clears the value of the field with the given name. It returns an
  26415. // error if the field is not defined in the schema.
  26416. func (m *MsgMutation) ClearField(name string) error {
  26417. switch name {
  26418. case msg.FieldDeletedAt:
  26419. m.ClearDeletedAt()
  26420. return nil
  26421. case msg.FieldStatus:
  26422. m.ClearStatus()
  26423. return nil
  26424. case msg.FieldFromwxid:
  26425. m.ClearFromwxid()
  26426. return nil
  26427. case msg.FieldToid:
  26428. m.ClearToid()
  26429. return nil
  26430. case msg.FieldMsgtype:
  26431. m.ClearMsgtype()
  26432. return nil
  26433. case msg.FieldMsg:
  26434. m.ClearMsg()
  26435. return nil
  26436. case msg.FieldBatchNo:
  26437. m.ClearBatchNo()
  26438. return nil
  26439. }
  26440. return fmt.Errorf("unknown Msg nullable field %s", name)
  26441. }
  26442. // ResetField resets all changes in the mutation for the field with the given name.
  26443. // It returns an error if the field is not defined in the schema.
  26444. func (m *MsgMutation) ResetField(name string) error {
  26445. switch name {
  26446. case msg.FieldCreatedAt:
  26447. m.ResetCreatedAt()
  26448. return nil
  26449. case msg.FieldUpdatedAt:
  26450. m.ResetUpdatedAt()
  26451. return nil
  26452. case msg.FieldDeletedAt:
  26453. m.ResetDeletedAt()
  26454. return nil
  26455. case msg.FieldStatus:
  26456. m.ResetStatus()
  26457. return nil
  26458. case msg.FieldFromwxid:
  26459. m.ResetFromwxid()
  26460. return nil
  26461. case msg.FieldToid:
  26462. m.ResetToid()
  26463. return nil
  26464. case msg.FieldMsgtype:
  26465. m.ResetMsgtype()
  26466. return nil
  26467. case msg.FieldMsg:
  26468. m.ResetMsg()
  26469. return nil
  26470. case msg.FieldBatchNo:
  26471. m.ResetBatchNo()
  26472. return nil
  26473. case msg.FieldCc:
  26474. m.ResetCc()
  26475. return nil
  26476. case msg.FieldPhone:
  26477. m.ResetPhone()
  26478. return nil
  26479. }
  26480. return fmt.Errorf("unknown Msg field %s", name)
  26481. }
  26482. // AddedEdges returns all edge names that were set/added in this mutation.
  26483. func (m *MsgMutation) AddedEdges() []string {
  26484. edges := make([]string, 0, 0)
  26485. return edges
  26486. }
  26487. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26488. // name in this mutation.
  26489. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  26490. return nil
  26491. }
  26492. // RemovedEdges returns all edge names that were removed in this mutation.
  26493. func (m *MsgMutation) RemovedEdges() []string {
  26494. edges := make([]string, 0, 0)
  26495. return edges
  26496. }
  26497. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26498. // the given name in this mutation.
  26499. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  26500. return nil
  26501. }
  26502. // ClearedEdges returns all edge names that were cleared in this mutation.
  26503. func (m *MsgMutation) ClearedEdges() []string {
  26504. edges := make([]string, 0, 0)
  26505. return edges
  26506. }
  26507. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26508. // was cleared in this mutation.
  26509. func (m *MsgMutation) EdgeCleared(name string) bool {
  26510. return false
  26511. }
  26512. // ClearEdge clears the value of the edge with the given name. It returns an error
  26513. // if that edge is not defined in the schema.
  26514. func (m *MsgMutation) ClearEdge(name string) error {
  26515. return fmt.Errorf("unknown Msg unique edge %s", name)
  26516. }
  26517. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26518. // It returns an error if the edge is not defined in the schema.
  26519. func (m *MsgMutation) ResetEdge(name string) error {
  26520. return fmt.Errorf("unknown Msg edge %s", name)
  26521. }
  26522. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  26523. type PayRechargeMutation struct {
  26524. config
  26525. op Op
  26526. typ string
  26527. id *uint64
  26528. created_at *time.Time
  26529. updated_at *time.Time
  26530. deleted_at *time.Time
  26531. user_id *string
  26532. number *float32
  26533. addnumber *float32
  26534. status *int
  26535. addstatus *int
  26536. money *float32
  26537. addmoney *float32
  26538. out_trade_no *string
  26539. organization_id *uint64
  26540. addorganization_id *int64
  26541. clearedFields map[string]struct{}
  26542. done bool
  26543. oldValue func(context.Context) (*PayRecharge, error)
  26544. predicates []predicate.PayRecharge
  26545. }
  26546. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  26547. // payrechargeOption allows management of the mutation configuration using functional options.
  26548. type payrechargeOption func(*PayRechargeMutation)
  26549. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  26550. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  26551. m := &PayRechargeMutation{
  26552. config: c,
  26553. op: op,
  26554. typ: TypePayRecharge,
  26555. clearedFields: make(map[string]struct{}),
  26556. }
  26557. for _, opt := range opts {
  26558. opt(m)
  26559. }
  26560. return m
  26561. }
  26562. // withPayRechargeID sets the ID field of the mutation.
  26563. func withPayRechargeID(id uint64) payrechargeOption {
  26564. return func(m *PayRechargeMutation) {
  26565. var (
  26566. err error
  26567. once sync.Once
  26568. value *PayRecharge
  26569. )
  26570. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  26571. once.Do(func() {
  26572. if m.done {
  26573. err = errors.New("querying old values post mutation is not allowed")
  26574. } else {
  26575. value, err = m.Client().PayRecharge.Get(ctx, id)
  26576. }
  26577. })
  26578. return value, err
  26579. }
  26580. m.id = &id
  26581. }
  26582. }
  26583. // withPayRecharge sets the old PayRecharge of the mutation.
  26584. func withPayRecharge(node *PayRecharge) payrechargeOption {
  26585. return func(m *PayRechargeMutation) {
  26586. m.oldValue = func(context.Context) (*PayRecharge, error) {
  26587. return node, nil
  26588. }
  26589. m.id = &node.ID
  26590. }
  26591. }
  26592. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26593. // executed in a transaction (ent.Tx), a transactional client is returned.
  26594. func (m PayRechargeMutation) Client() *Client {
  26595. client := &Client{config: m.config}
  26596. client.init()
  26597. return client
  26598. }
  26599. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26600. // it returns an error otherwise.
  26601. func (m PayRechargeMutation) Tx() (*Tx, error) {
  26602. if _, ok := m.driver.(*txDriver); !ok {
  26603. return nil, errors.New("ent: mutation is not running in a transaction")
  26604. }
  26605. tx := &Tx{config: m.config}
  26606. tx.init()
  26607. return tx, nil
  26608. }
  26609. // SetID sets the value of the id field. Note that this
  26610. // operation is only accepted on creation of PayRecharge entities.
  26611. func (m *PayRechargeMutation) SetID(id uint64) {
  26612. m.id = &id
  26613. }
  26614. // ID returns the ID value in the mutation. Note that the ID is only available
  26615. // if it was provided to the builder or after it was returned from the database.
  26616. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  26617. if m.id == nil {
  26618. return
  26619. }
  26620. return *m.id, true
  26621. }
  26622. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26623. // That means, if the mutation is applied within a transaction with an isolation level such
  26624. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26625. // or updated by the mutation.
  26626. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26627. switch {
  26628. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26629. id, exists := m.ID()
  26630. if exists {
  26631. return []uint64{id}, nil
  26632. }
  26633. fallthrough
  26634. case m.op.Is(OpUpdate | OpDelete):
  26635. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  26636. default:
  26637. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26638. }
  26639. }
  26640. // SetCreatedAt sets the "created_at" field.
  26641. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  26642. m.created_at = &t
  26643. }
  26644. // CreatedAt returns the value of the "created_at" field in the mutation.
  26645. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  26646. v := m.created_at
  26647. if v == nil {
  26648. return
  26649. }
  26650. return *v, true
  26651. }
  26652. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  26653. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26655. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26656. if !m.op.Is(OpUpdateOne) {
  26657. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26658. }
  26659. if m.id == nil || m.oldValue == nil {
  26660. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26661. }
  26662. oldValue, err := m.oldValue(ctx)
  26663. if err != nil {
  26664. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26665. }
  26666. return oldValue.CreatedAt, nil
  26667. }
  26668. // ResetCreatedAt resets all changes to the "created_at" field.
  26669. func (m *PayRechargeMutation) ResetCreatedAt() {
  26670. m.created_at = nil
  26671. }
  26672. // SetUpdatedAt sets the "updated_at" field.
  26673. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  26674. m.updated_at = &t
  26675. }
  26676. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26677. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  26678. v := m.updated_at
  26679. if v == nil {
  26680. return
  26681. }
  26682. return *v, true
  26683. }
  26684. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  26685. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26687. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26688. if !m.op.Is(OpUpdateOne) {
  26689. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26690. }
  26691. if m.id == nil || m.oldValue == nil {
  26692. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26693. }
  26694. oldValue, err := m.oldValue(ctx)
  26695. if err != nil {
  26696. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26697. }
  26698. return oldValue.UpdatedAt, nil
  26699. }
  26700. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26701. func (m *PayRechargeMutation) ResetUpdatedAt() {
  26702. m.updated_at = nil
  26703. }
  26704. // SetDeletedAt sets the "deleted_at" field.
  26705. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  26706. m.deleted_at = &t
  26707. }
  26708. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26709. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  26710. v := m.deleted_at
  26711. if v == nil {
  26712. return
  26713. }
  26714. return *v, true
  26715. }
  26716. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  26717. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26719. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26720. if !m.op.Is(OpUpdateOne) {
  26721. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26722. }
  26723. if m.id == nil || m.oldValue == nil {
  26724. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26725. }
  26726. oldValue, err := m.oldValue(ctx)
  26727. if err != nil {
  26728. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26729. }
  26730. return oldValue.DeletedAt, nil
  26731. }
  26732. // ClearDeletedAt clears the value of the "deleted_at" field.
  26733. func (m *PayRechargeMutation) ClearDeletedAt() {
  26734. m.deleted_at = nil
  26735. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  26736. }
  26737. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26738. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  26739. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  26740. return ok
  26741. }
  26742. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26743. func (m *PayRechargeMutation) ResetDeletedAt() {
  26744. m.deleted_at = nil
  26745. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  26746. }
  26747. // SetUserID sets the "user_id" field.
  26748. func (m *PayRechargeMutation) SetUserID(s string) {
  26749. m.user_id = &s
  26750. }
  26751. // UserID returns the value of the "user_id" field in the mutation.
  26752. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  26753. v := m.user_id
  26754. if v == nil {
  26755. return
  26756. }
  26757. return *v, true
  26758. }
  26759. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  26760. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26762. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  26763. if !m.op.Is(OpUpdateOne) {
  26764. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  26765. }
  26766. if m.id == nil || m.oldValue == nil {
  26767. return v, errors.New("OldUserID requires an ID field in the mutation")
  26768. }
  26769. oldValue, err := m.oldValue(ctx)
  26770. if err != nil {
  26771. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  26772. }
  26773. return oldValue.UserID, nil
  26774. }
  26775. // ResetUserID resets all changes to the "user_id" field.
  26776. func (m *PayRechargeMutation) ResetUserID() {
  26777. m.user_id = nil
  26778. }
  26779. // SetNumber sets the "number" field.
  26780. func (m *PayRechargeMutation) SetNumber(f float32) {
  26781. m.number = &f
  26782. m.addnumber = nil
  26783. }
  26784. // Number returns the value of the "number" field in the mutation.
  26785. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  26786. v := m.number
  26787. if v == nil {
  26788. return
  26789. }
  26790. return *v, true
  26791. }
  26792. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  26793. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26795. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  26796. if !m.op.Is(OpUpdateOne) {
  26797. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  26798. }
  26799. if m.id == nil || m.oldValue == nil {
  26800. return v, errors.New("OldNumber requires an ID field in the mutation")
  26801. }
  26802. oldValue, err := m.oldValue(ctx)
  26803. if err != nil {
  26804. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  26805. }
  26806. return oldValue.Number, nil
  26807. }
  26808. // AddNumber adds f to the "number" field.
  26809. func (m *PayRechargeMutation) AddNumber(f float32) {
  26810. if m.addnumber != nil {
  26811. *m.addnumber += f
  26812. } else {
  26813. m.addnumber = &f
  26814. }
  26815. }
  26816. // AddedNumber returns the value that was added to the "number" field in this mutation.
  26817. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  26818. v := m.addnumber
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // ResetNumber resets all changes to the "number" field.
  26825. func (m *PayRechargeMutation) ResetNumber() {
  26826. m.number = nil
  26827. m.addnumber = nil
  26828. }
  26829. // SetStatus sets the "status" field.
  26830. func (m *PayRechargeMutation) SetStatus(i int) {
  26831. m.status = &i
  26832. m.addstatus = nil
  26833. }
  26834. // Status returns the value of the "status" field in the mutation.
  26835. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  26836. v := m.status
  26837. if v == nil {
  26838. return
  26839. }
  26840. return *v, true
  26841. }
  26842. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  26843. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26845. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  26846. if !m.op.Is(OpUpdateOne) {
  26847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26848. }
  26849. if m.id == nil || m.oldValue == nil {
  26850. return v, errors.New("OldStatus requires an ID field in the mutation")
  26851. }
  26852. oldValue, err := m.oldValue(ctx)
  26853. if err != nil {
  26854. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26855. }
  26856. return oldValue.Status, nil
  26857. }
  26858. // AddStatus adds i to the "status" field.
  26859. func (m *PayRechargeMutation) AddStatus(i int) {
  26860. if m.addstatus != nil {
  26861. *m.addstatus += i
  26862. } else {
  26863. m.addstatus = &i
  26864. }
  26865. }
  26866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26867. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  26868. v := m.addstatus
  26869. if v == nil {
  26870. return
  26871. }
  26872. return *v, true
  26873. }
  26874. // ClearStatus clears the value of the "status" field.
  26875. func (m *PayRechargeMutation) ClearStatus() {
  26876. m.status = nil
  26877. m.addstatus = nil
  26878. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  26879. }
  26880. // StatusCleared returns if the "status" field was cleared in this mutation.
  26881. func (m *PayRechargeMutation) StatusCleared() bool {
  26882. _, ok := m.clearedFields[payrecharge.FieldStatus]
  26883. return ok
  26884. }
  26885. // ResetStatus resets all changes to the "status" field.
  26886. func (m *PayRechargeMutation) ResetStatus() {
  26887. m.status = nil
  26888. m.addstatus = nil
  26889. delete(m.clearedFields, payrecharge.FieldStatus)
  26890. }
  26891. // SetMoney sets the "money" field.
  26892. func (m *PayRechargeMutation) SetMoney(f float32) {
  26893. m.money = &f
  26894. m.addmoney = nil
  26895. }
  26896. // Money returns the value of the "money" field in the mutation.
  26897. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  26898. v := m.money
  26899. if v == nil {
  26900. return
  26901. }
  26902. return *v, true
  26903. }
  26904. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  26905. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26907. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  26908. if !m.op.Is(OpUpdateOne) {
  26909. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  26910. }
  26911. if m.id == nil || m.oldValue == nil {
  26912. return v, errors.New("OldMoney requires an ID field in the mutation")
  26913. }
  26914. oldValue, err := m.oldValue(ctx)
  26915. if err != nil {
  26916. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  26917. }
  26918. return oldValue.Money, nil
  26919. }
  26920. // AddMoney adds f to the "money" field.
  26921. func (m *PayRechargeMutation) AddMoney(f float32) {
  26922. if m.addmoney != nil {
  26923. *m.addmoney += f
  26924. } else {
  26925. m.addmoney = &f
  26926. }
  26927. }
  26928. // AddedMoney returns the value that was added to the "money" field in this mutation.
  26929. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  26930. v := m.addmoney
  26931. if v == nil {
  26932. return
  26933. }
  26934. return *v, true
  26935. }
  26936. // ClearMoney clears the value of the "money" field.
  26937. func (m *PayRechargeMutation) ClearMoney() {
  26938. m.money = nil
  26939. m.addmoney = nil
  26940. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  26941. }
  26942. // MoneyCleared returns if the "money" field was cleared in this mutation.
  26943. func (m *PayRechargeMutation) MoneyCleared() bool {
  26944. _, ok := m.clearedFields[payrecharge.FieldMoney]
  26945. return ok
  26946. }
  26947. // ResetMoney resets all changes to the "money" field.
  26948. func (m *PayRechargeMutation) ResetMoney() {
  26949. m.money = nil
  26950. m.addmoney = nil
  26951. delete(m.clearedFields, payrecharge.FieldMoney)
  26952. }
  26953. // SetOutTradeNo sets the "out_trade_no" field.
  26954. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  26955. m.out_trade_no = &s
  26956. }
  26957. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  26958. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  26959. v := m.out_trade_no
  26960. if v == nil {
  26961. return
  26962. }
  26963. return *v, true
  26964. }
  26965. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  26966. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26968. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  26969. if !m.op.Is(OpUpdateOne) {
  26970. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  26971. }
  26972. if m.id == nil || m.oldValue == nil {
  26973. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  26974. }
  26975. oldValue, err := m.oldValue(ctx)
  26976. if err != nil {
  26977. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  26978. }
  26979. return oldValue.OutTradeNo, nil
  26980. }
  26981. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  26982. func (m *PayRechargeMutation) ClearOutTradeNo() {
  26983. m.out_trade_no = nil
  26984. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  26985. }
  26986. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  26987. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  26988. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  26989. return ok
  26990. }
  26991. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  26992. func (m *PayRechargeMutation) ResetOutTradeNo() {
  26993. m.out_trade_no = nil
  26994. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  26995. }
  26996. // SetOrganizationID sets the "organization_id" field.
  26997. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  26998. m.organization_id = &u
  26999. m.addorganization_id = nil
  27000. }
  27001. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27002. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  27003. v := m.organization_id
  27004. if v == nil {
  27005. return
  27006. }
  27007. return *v, true
  27008. }
  27009. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  27010. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27012. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27013. if !m.op.Is(OpUpdateOne) {
  27014. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27015. }
  27016. if m.id == nil || m.oldValue == nil {
  27017. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27018. }
  27019. oldValue, err := m.oldValue(ctx)
  27020. if err != nil {
  27021. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27022. }
  27023. return oldValue.OrganizationID, nil
  27024. }
  27025. // AddOrganizationID adds u to the "organization_id" field.
  27026. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  27027. if m.addorganization_id != nil {
  27028. *m.addorganization_id += u
  27029. } else {
  27030. m.addorganization_id = &u
  27031. }
  27032. }
  27033. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27034. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  27035. v := m.addorganization_id
  27036. if v == nil {
  27037. return
  27038. }
  27039. return *v, true
  27040. }
  27041. // ResetOrganizationID resets all changes to the "organization_id" field.
  27042. func (m *PayRechargeMutation) ResetOrganizationID() {
  27043. m.organization_id = nil
  27044. m.addorganization_id = nil
  27045. }
  27046. // Where appends a list predicates to the PayRechargeMutation builder.
  27047. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  27048. m.predicates = append(m.predicates, ps...)
  27049. }
  27050. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  27051. // users can use type-assertion to append predicates that do not depend on any generated package.
  27052. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  27053. p := make([]predicate.PayRecharge, len(ps))
  27054. for i := range ps {
  27055. p[i] = ps[i]
  27056. }
  27057. m.Where(p...)
  27058. }
  27059. // Op returns the operation name.
  27060. func (m *PayRechargeMutation) Op() Op {
  27061. return m.op
  27062. }
  27063. // SetOp allows setting the mutation operation.
  27064. func (m *PayRechargeMutation) SetOp(op Op) {
  27065. m.op = op
  27066. }
  27067. // Type returns the node type of this mutation (PayRecharge).
  27068. func (m *PayRechargeMutation) Type() string {
  27069. return m.typ
  27070. }
  27071. // Fields returns all fields that were changed during this mutation. Note that in
  27072. // order to get all numeric fields that were incremented/decremented, call
  27073. // AddedFields().
  27074. func (m *PayRechargeMutation) Fields() []string {
  27075. fields := make([]string, 0, 9)
  27076. if m.created_at != nil {
  27077. fields = append(fields, payrecharge.FieldCreatedAt)
  27078. }
  27079. if m.updated_at != nil {
  27080. fields = append(fields, payrecharge.FieldUpdatedAt)
  27081. }
  27082. if m.deleted_at != nil {
  27083. fields = append(fields, payrecharge.FieldDeletedAt)
  27084. }
  27085. if m.user_id != nil {
  27086. fields = append(fields, payrecharge.FieldUserID)
  27087. }
  27088. if m.number != nil {
  27089. fields = append(fields, payrecharge.FieldNumber)
  27090. }
  27091. if m.status != nil {
  27092. fields = append(fields, payrecharge.FieldStatus)
  27093. }
  27094. if m.money != nil {
  27095. fields = append(fields, payrecharge.FieldMoney)
  27096. }
  27097. if m.out_trade_no != nil {
  27098. fields = append(fields, payrecharge.FieldOutTradeNo)
  27099. }
  27100. if m.organization_id != nil {
  27101. fields = append(fields, payrecharge.FieldOrganizationID)
  27102. }
  27103. return fields
  27104. }
  27105. // Field returns the value of a field with the given name. The second boolean
  27106. // return value indicates that this field was not set, or was not defined in the
  27107. // schema.
  27108. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  27109. switch name {
  27110. case payrecharge.FieldCreatedAt:
  27111. return m.CreatedAt()
  27112. case payrecharge.FieldUpdatedAt:
  27113. return m.UpdatedAt()
  27114. case payrecharge.FieldDeletedAt:
  27115. return m.DeletedAt()
  27116. case payrecharge.FieldUserID:
  27117. return m.UserID()
  27118. case payrecharge.FieldNumber:
  27119. return m.Number()
  27120. case payrecharge.FieldStatus:
  27121. return m.Status()
  27122. case payrecharge.FieldMoney:
  27123. return m.Money()
  27124. case payrecharge.FieldOutTradeNo:
  27125. return m.OutTradeNo()
  27126. case payrecharge.FieldOrganizationID:
  27127. return m.OrganizationID()
  27128. }
  27129. return nil, false
  27130. }
  27131. // OldField returns the old value of the field from the database. An error is
  27132. // returned if the mutation operation is not UpdateOne, or the query to the
  27133. // database failed.
  27134. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27135. switch name {
  27136. case payrecharge.FieldCreatedAt:
  27137. return m.OldCreatedAt(ctx)
  27138. case payrecharge.FieldUpdatedAt:
  27139. return m.OldUpdatedAt(ctx)
  27140. case payrecharge.FieldDeletedAt:
  27141. return m.OldDeletedAt(ctx)
  27142. case payrecharge.FieldUserID:
  27143. return m.OldUserID(ctx)
  27144. case payrecharge.FieldNumber:
  27145. return m.OldNumber(ctx)
  27146. case payrecharge.FieldStatus:
  27147. return m.OldStatus(ctx)
  27148. case payrecharge.FieldMoney:
  27149. return m.OldMoney(ctx)
  27150. case payrecharge.FieldOutTradeNo:
  27151. return m.OldOutTradeNo(ctx)
  27152. case payrecharge.FieldOrganizationID:
  27153. return m.OldOrganizationID(ctx)
  27154. }
  27155. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  27156. }
  27157. // SetField sets the value of a field with the given name. It returns an error if
  27158. // the field is not defined in the schema, or if the type mismatched the field
  27159. // type.
  27160. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  27161. switch name {
  27162. case payrecharge.FieldCreatedAt:
  27163. v, ok := value.(time.Time)
  27164. if !ok {
  27165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27166. }
  27167. m.SetCreatedAt(v)
  27168. return nil
  27169. case payrecharge.FieldUpdatedAt:
  27170. v, ok := value.(time.Time)
  27171. if !ok {
  27172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27173. }
  27174. m.SetUpdatedAt(v)
  27175. return nil
  27176. case payrecharge.FieldDeletedAt:
  27177. v, ok := value.(time.Time)
  27178. if !ok {
  27179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27180. }
  27181. m.SetDeletedAt(v)
  27182. return nil
  27183. case payrecharge.FieldUserID:
  27184. v, ok := value.(string)
  27185. if !ok {
  27186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27187. }
  27188. m.SetUserID(v)
  27189. return nil
  27190. case payrecharge.FieldNumber:
  27191. v, ok := value.(float32)
  27192. if !ok {
  27193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27194. }
  27195. m.SetNumber(v)
  27196. return nil
  27197. case payrecharge.FieldStatus:
  27198. v, ok := value.(int)
  27199. if !ok {
  27200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27201. }
  27202. m.SetStatus(v)
  27203. return nil
  27204. case payrecharge.FieldMoney:
  27205. v, ok := value.(float32)
  27206. if !ok {
  27207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27208. }
  27209. m.SetMoney(v)
  27210. return nil
  27211. case payrecharge.FieldOutTradeNo:
  27212. v, ok := value.(string)
  27213. if !ok {
  27214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27215. }
  27216. m.SetOutTradeNo(v)
  27217. return nil
  27218. case payrecharge.FieldOrganizationID:
  27219. v, ok := value.(uint64)
  27220. if !ok {
  27221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27222. }
  27223. m.SetOrganizationID(v)
  27224. return nil
  27225. }
  27226. return fmt.Errorf("unknown PayRecharge field %s", name)
  27227. }
  27228. // AddedFields returns all numeric fields that were incremented/decremented during
  27229. // this mutation.
  27230. func (m *PayRechargeMutation) AddedFields() []string {
  27231. var fields []string
  27232. if m.addnumber != nil {
  27233. fields = append(fields, payrecharge.FieldNumber)
  27234. }
  27235. if m.addstatus != nil {
  27236. fields = append(fields, payrecharge.FieldStatus)
  27237. }
  27238. if m.addmoney != nil {
  27239. fields = append(fields, payrecharge.FieldMoney)
  27240. }
  27241. if m.addorganization_id != nil {
  27242. fields = append(fields, payrecharge.FieldOrganizationID)
  27243. }
  27244. return fields
  27245. }
  27246. // AddedField returns the numeric value that was incremented/decremented on a field
  27247. // with the given name. The second boolean return value indicates that this field
  27248. // was not set, or was not defined in the schema.
  27249. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  27250. switch name {
  27251. case payrecharge.FieldNumber:
  27252. return m.AddedNumber()
  27253. case payrecharge.FieldStatus:
  27254. return m.AddedStatus()
  27255. case payrecharge.FieldMoney:
  27256. return m.AddedMoney()
  27257. case payrecharge.FieldOrganizationID:
  27258. return m.AddedOrganizationID()
  27259. }
  27260. return nil, false
  27261. }
  27262. // AddField adds the value to the field with the given name. It returns an error if
  27263. // the field is not defined in the schema, or if the type mismatched the field
  27264. // type.
  27265. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  27266. switch name {
  27267. case payrecharge.FieldNumber:
  27268. v, ok := value.(float32)
  27269. if !ok {
  27270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27271. }
  27272. m.AddNumber(v)
  27273. return nil
  27274. case payrecharge.FieldStatus:
  27275. v, ok := value.(int)
  27276. if !ok {
  27277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27278. }
  27279. m.AddStatus(v)
  27280. return nil
  27281. case payrecharge.FieldMoney:
  27282. v, ok := value.(float32)
  27283. if !ok {
  27284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27285. }
  27286. m.AddMoney(v)
  27287. return nil
  27288. case payrecharge.FieldOrganizationID:
  27289. v, ok := value.(int64)
  27290. if !ok {
  27291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27292. }
  27293. m.AddOrganizationID(v)
  27294. return nil
  27295. }
  27296. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  27297. }
  27298. // ClearedFields returns all nullable fields that were cleared during this
  27299. // mutation.
  27300. func (m *PayRechargeMutation) ClearedFields() []string {
  27301. var fields []string
  27302. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  27303. fields = append(fields, payrecharge.FieldDeletedAt)
  27304. }
  27305. if m.FieldCleared(payrecharge.FieldStatus) {
  27306. fields = append(fields, payrecharge.FieldStatus)
  27307. }
  27308. if m.FieldCleared(payrecharge.FieldMoney) {
  27309. fields = append(fields, payrecharge.FieldMoney)
  27310. }
  27311. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  27312. fields = append(fields, payrecharge.FieldOutTradeNo)
  27313. }
  27314. return fields
  27315. }
  27316. // FieldCleared returns a boolean indicating if a field with the given name was
  27317. // cleared in this mutation.
  27318. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  27319. _, ok := m.clearedFields[name]
  27320. return ok
  27321. }
  27322. // ClearField clears the value of the field with the given name. It returns an
  27323. // error if the field is not defined in the schema.
  27324. func (m *PayRechargeMutation) ClearField(name string) error {
  27325. switch name {
  27326. case payrecharge.FieldDeletedAt:
  27327. m.ClearDeletedAt()
  27328. return nil
  27329. case payrecharge.FieldStatus:
  27330. m.ClearStatus()
  27331. return nil
  27332. case payrecharge.FieldMoney:
  27333. m.ClearMoney()
  27334. return nil
  27335. case payrecharge.FieldOutTradeNo:
  27336. m.ClearOutTradeNo()
  27337. return nil
  27338. }
  27339. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  27340. }
  27341. // ResetField resets all changes in the mutation for the field with the given name.
  27342. // It returns an error if the field is not defined in the schema.
  27343. func (m *PayRechargeMutation) ResetField(name string) error {
  27344. switch name {
  27345. case payrecharge.FieldCreatedAt:
  27346. m.ResetCreatedAt()
  27347. return nil
  27348. case payrecharge.FieldUpdatedAt:
  27349. m.ResetUpdatedAt()
  27350. return nil
  27351. case payrecharge.FieldDeletedAt:
  27352. m.ResetDeletedAt()
  27353. return nil
  27354. case payrecharge.FieldUserID:
  27355. m.ResetUserID()
  27356. return nil
  27357. case payrecharge.FieldNumber:
  27358. m.ResetNumber()
  27359. return nil
  27360. case payrecharge.FieldStatus:
  27361. m.ResetStatus()
  27362. return nil
  27363. case payrecharge.FieldMoney:
  27364. m.ResetMoney()
  27365. return nil
  27366. case payrecharge.FieldOutTradeNo:
  27367. m.ResetOutTradeNo()
  27368. return nil
  27369. case payrecharge.FieldOrganizationID:
  27370. m.ResetOrganizationID()
  27371. return nil
  27372. }
  27373. return fmt.Errorf("unknown PayRecharge field %s", name)
  27374. }
  27375. // AddedEdges returns all edge names that were set/added in this mutation.
  27376. func (m *PayRechargeMutation) AddedEdges() []string {
  27377. edges := make([]string, 0, 0)
  27378. return edges
  27379. }
  27380. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27381. // name in this mutation.
  27382. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  27383. return nil
  27384. }
  27385. // RemovedEdges returns all edge names that were removed in this mutation.
  27386. func (m *PayRechargeMutation) RemovedEdges() []string {
  27387. edges := make([]string, 0, 0)
  27388. return edges
  27389. }
  27390. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27391. // the given name in this mutation.
  27392. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  27393. return nil
  27394. }
  27395. // ClearedEdges returns all edge names that were cleared in this mutation.
  27396. func (m *PayRechargeMutation) ClearedEdges() []string {
  27397. edges := make([]string, 0, 0)
  27398. return edges
  27399. }
  27400. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27401. // was cleared in this mutation.
  27402. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  27403. return false
  27404. }
  27405. // ClearEdge clears the value of the edge with the given name. It returns an error
  27406. // if that edge is not defined in the schema.
  27407. func (m *PayRechargeMutation) ClearEdge(name string) error {
  27408. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  27409. }
  27410. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27411. // It returns an error if the edge is not defined in the schema.
  27412. func (m *PayRechargeMutation) ResetEdge(name string) error {
  27413. return fmt.Errorf("unknown PayRecharge edge %s", name)
  27414. }
  27415. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  27416. type ServerMutation struct {
  27417. config
  27418. op Op
  27419. typ string
  27420. id *uint64
  27421. created_at *time.Time
  27422. updated_at *time.Time
  27423. status *uint8
  27424. addstatus *int8
  27425. deleted_at *time.Time
  27426. name *string
  27427. public_ip *string
  27428. private_ip *string
  27429. admin_port *string
  27430. clearedFields map[string]struct{}
  27431. wxs map[uint64]struct{}
  27432. removedwxs map[uint64]struct{}
  27433. clearedwxs bool
  27434. done bool
  27435. oldValue func(context.Context) (*Server, error)
  27436. predicates []predicate.Server
  27437. }
  27438. var _ ent.Mutation = (*ServerMutation)(nil)
  27439. // serverOption allows management of the mutation configuration using functional options.
  27440. type serverOption func(*ServerMutation)
  27441. // newServerMutation creates new mutation for the Server entity.
  27442. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  27443. m := &ServerMutation{
  27444. config: c,
  27445. op: op,
  27446. typ: TypeServer,
  27447. clearedFields: make(map[string]struct{}),
  27448. }
  27449. for _, opt := range opts {
  27450. opt(m)
  27451. }
  27452. return m
  27453. }
  27454. // withServerID sets the ID field of the mutation.
  27455. func withServerID(id uint64) serverOption {
  27456. return func(m *ServerMutation) {
  27457. var (
  27458. err error
  27459. once sync.Once
  27460. value *Server
  27461. )
  27462. m.oldValue = func(ctx context.Context) (*Server, error) {
  27463. once.Do(func() {
  27464. if m.done {
  27465. err = errors.New("querying old values post mutation is not allowed")
  27466. } else {
  27467. value, err = m.Client().Server.Get(ctx, id)
  27468. }
  27469. })
  27470. return value, err
  27471. }
  27472. m.id = &id
  27473. }
  27474. }
  27475. // withServer sets the old Server of the mutation.
  27476. func withServer(node *Server) serverOption {
  27477. return func(m *ServerMutation) {
  27478. m.oldValue = func(context.Context) (*Server, error) {
  27479. return node, nil
  27480. }
  27481. m.id = &node.ID
  27482. }
  27483. }
  27484. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27485. // executed in a transaction (ent.Tx), a transactional client is returned.
  27486. func (m ServerMutation) Client() *Client {
  27487. client := &Client{config: m.config}
  27488. client.init()
  27489. return client
  27490. }
  27491. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27492. // it returns an error otherwise.
  27493. func (m ServerMutation) Tx() (*Tx, error) {
  27494. if _, ok := m.driver.(*txDriver); !ok {
  27495. return nil, errors.New("ent: mutation is not running in a transaction")
  27496. }
  27497. tx := &Tx{config: m.config}
  27498. tx.init()
  27499. return tx, nil
  27500. }
  27501. // SetID sets the value of the id field. Note that this
  27502. // operation is only accepted on creation of Server entities.
  27503. func (m *ServerMutation) SetID(id uint64) {
  27504. m.id = &id
  27505. }
  27506. // ID returns the ID value in the mutation. Note that the ID is only available
  27507. // if it was provided to the builder or after it was returned from the database.
  27508. func (m *ServerMutation) ID() (id uint64, exists bool) {
  27509. if m.id == nil {
  27510. return
  27511. }
  27512. return *m.id, true
  27513. }
  27514. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27515. // That means, if the mutation is applied within a transaction with an isolation level such
  27516. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27517. // or updated by the mutation.
  27518. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  27519. switch {
  27520. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27521. id, exists := m.ID()
  27522. if exists {
  27523. return []uint64{id}, nil
  27524. }
  27525. fallthrough
  27526. case m.op.Is(OpUpdate | OpDelete):
  27527. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  27528. default:
  27529. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27530. }
  27531. }
  27532. // SetCreatedAt sets the "created_at" field.
  27533. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  27534. m.created_at = &t
  27535. }
  27536. // CreatedAt returns the value of the "created_at" field in the mutation.
  27537. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  27538. v := m.created_at
  27539. if v == nil {
  27540. return
  27541. }
  27542. return *v, true
  27543. }
  27544. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  27545. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27547. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27548. if !m.op.Is(OpUpdateOne) {
  27549. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27550. }
  27551. if m.id == nil || m.oldValue == nil {
  27552. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27553. }
  27554. oldValue, err := m.oldValue(ctx)
  27555. if err != nil {
  27556. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27557. }
  27558. return oldValue.CreatedAt, nil
  27559. }
  27560. // ResetCreatedAt resets all changes to the "created_at" field.
  27561. func (m *ServerMutation) ResetCreatedAt() {
  27562. m.created_at = nil
  27563. }
  27564. // SetUpdatedAt sets the "updated_at" field.
  27565. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  27566. m.updated_at = &t
  27567. }
  27568. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27569. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  27570. v := m.updated_at
  27571. if v == nil {
  27572. return
  27573. }
  27574. return *v, true
  27575. }
  27576. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  27577. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27579. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27580. if !m.op.Is(OpUpdateOne) {
  27581. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27582. }
  27583. if m.id == nil || m.oldValue == nil {
  27584. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27585. }
  27586. oldValue, err := m.oldValue(ctx)
  27587. if err != nil {
  27588. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27589. }
  27590. return oldValue.UpdatedAt, nil
  27591. }
  27592. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27593. func (m *ServerMutation) ResetUpdatedAt() {
  27594. m.updated_at = nil
  27595. }
  27596. // SetStatus sets the "status" field.
  27597. func (m *ServerMutation) SetStatus(u uint8) {
  27598. m.status = &u
  27599. m.addstatus = nil
  27600. }
  27601. // Status returns the value of the "status" field in the mutation.
  27602. func (m *ServerMutation) Status() (r uint8, exists bool) {
  27603. v := m.status
  27604. if v == nil {
  27605. return
  27606. }
  27607. return *v, true
  27608. }
  27609. // OldStatus returns the old "status" field's value of the Server entity.
  27610. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27612. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27613. if !m.op.Is(OpUpdateOne) {
  27614. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27615. }
  27616. if m.id == nil || m.oldValue == nil {
  27617. return v, errors.New("OldStatus requires an ID field in the mutation")
  27618. }
  27619. oldValue, err := m.oldValue(ctx)
  27620. if err != nil {
  27621. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27622. }
  27623. return oldValue.Status, nil
  27624. }
  27625. // AddStatus adds u to the "status" field.
  27626. func (m *ServerMutation) AddStatus(u int8) {
  27627. if m.addstatus != nil {
  27628. *m.addstatus += u
  27629. } else {
  27630. m.addstatus = &u
  27631. }
  27632. }
  27633. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27634. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  27635. v := m.addstatus
  27636. if v == nil {
  27637. return
  27638. }
  27639. return *v, true
  27640. }
  27641. // ClearStatus clears the value of the "status" field.
  27642. func (m *ServerMutation) ClearStatus() {
  27643. m.status = nil
  27644. m.addstatus = nil
  27645. m.clearedFields[server.FieldStatus] = struct{}{}
  27646. }
  27647. // StatusCleared returns if the "status" field was cleared in this mutation.
  27648. func (m *ServerMutation) StatusCleared() bool {
  27649. _, ok := m.clearedFields[server.FieldStatus]
  27650. return ok
  27651. }
  27652. // ResetStatus resets all changes to the "status" field.
  27653. func (m *ServerMutation) ResetStatus() {
  27654. m.status = nil
  27655. m.addstatus = nil
  27656. delete(m.clearedFields, server.FieldStatus)
  27657. }
  27658. // SetDeletedAt sets the "deleted_at" field.
  27659. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  27660. m.deleted_at = &t
  27661. }
  27662. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27663. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  27664. v := m.deleted_at
  27665. if v == nil {
  27666. return
  27667. }
  27668. return *v, true
  27669. }
  27670. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  27671. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27673. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27674. if !m.op.Is(OpUpdateOne) {
  27675. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27676. }
  27677. if m.id == nil || m.oldValue == nil {
  27678. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27679. }
  27680. oldValue, err := m.oldValue(ctx)
  27681. if err != nil {
  27682. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27683. }
  27684. return oldValue.DeletedAt, nil
  27685. }
  27686. // ClearDeletedAt clears the value of the "deleted_at" field.
  27687. func (m *ServerMutation) ClearDeletedAt() {
  27688. m.deleted_at = nil
  27689. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  27690. }
  27691. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27692. func (m *ServerMutation) DeletedAtCleared() bool {
  27693. _, ok := m.clearedFields[server.FieldDeletedAt]
  27694. return ok
  27695. }
  27696. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27697. func (m *ServerMutation) ResetDeletedAt() {
  27698. m.deleted_at = nil
  27699. delete(m.clearedFields, server.FieldDeletedAt)
  27700. }
  27701. // SetName sets the "name" field.
  27702. func (m *ServerMutation) SetName(s string) {
  27703. m.name = &s
  27704. }
  27705. // Name returns the value of the "name" field in the mutation.
  27706. func (m *ServerMutation) Name() (r string, exists bool) {
  27707. v := m.name
  27708. if v == nil {
  27709. return
  27710. }
  27711. return *v, true
  27712. }
  27713. // OldName returns the old "name" field's value of the Server entity.
  27714. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27716. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  27717. if !m.op.Is(OpUpdateOne) {
  27718. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27719. }
  27720. if m.id == nil || m.oldValue == nil {
  27721. return v, errors.New("OldName requires an ID field in the mutation")
  27722. }
  27723. oldValue, err := m.oldValue(ctx)
  27724. if err != nil {
  27725. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27726. }
  27727. return oldValue.Name, nil
  27728. }
  27729. // ResetName resets all changes to the "name" field.
  27730. func (m *ServerMutation) ResetName() {
  27731. m.name = nil
  27732. }
  27733. // SetPublicIP sets the "public_ip" field.
  27734. func (m *ServerMutation) SetPublicIP(s string) {
  27735. m.public_ip = &s
  27736. }
  27737. // PublicIP returns the value of the "public_ip" field in the mutation.
  27738. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  27739. v := m.public_ip
  27740. if v == nil {
  27741. return
  27742. }
  27743. return *v, true
  27744. }
  27745. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  27746. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27748. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  27749. if !m.op.Is(OpUpdateOne) {
  27750. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  27751. }
  27752. if m.id == nil || m.oldValue == nil {
  27753. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  27754. }
  27755. oldValue, err := m.oldValue(ctx)
  27756. if err != nil {
  27757. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  27758. }
  27759. return oldValue.PublicIP, nil
  27760. }
  27761. // ResetPublicIP resets all changes to the "public_ip" field.
  27762. func (m *ServerMutation) ResetPublicIP() {
  27763. m.public_ip = nil
  27764. }
  27765. // SetPrivateIP sets the "private_ip" field.
  27766. func (m *ServerMutation) SetPrivateIP(s string) {
  27767. m.private_ip = &s
  27768. }
  27769. // PrivateIP returns the value of the "private_ip" field in the mutation.
  27770. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  27771. v := m.private_ip
  27772. if v == nil {
  27773. return
  27774. }
  27775. return *v, true
  27776. }
  27777. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  27778. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27780. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  27781. if !m.op.Is(OpUpdateOne) {
  27782. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  27783. }
  27784. if m.id == nil || m.oldValue == nil {
  27785. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  27786. }
  27787. oldValue, err := m.oldValue(ctx)
  27788. if err != nil {
  27789. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  27790. }
  27791. return oldValue.PrivateIP, nil
  27792. }
  27793. // ResetPrivateIP resets all changes to the "private_ip" field.
  27794. func (m *ServerMutation) ResetPrivateIP() {
  27795. m.private_ip = nil
  27796. }
  27797. // SetAdminPort sets the "admin_port" field.
  27798. func (m *ServerMutation) SetAdminPort(s string) {
  27799. m.admin_port = &s
  27800. }
  27801. // AdminPort returns the value of the "admin_port" field in the mutation.
  27802. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  27803. v := m.admin_port
  27804. if v == nil {
  27805. return
  27806. }
  27807. return *v, true
  27808. }
  27809. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  27810. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27812. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  27813. if !m.op.Is(OpUpdateOne) {
  27814. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  27815. }
  27816. if m.id == nil || m.oldValue == nil {
  27817. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  27818. }
  27819. oldValue, err := m.oldValue(ctx)
  27820. if err != nil {
  27821. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  27822. }
  27823. return oldValue.AdminPort, nil
  27824. }
  27825. // ResetAdminPort resets all changes to the "admin_port" field.
  27826. func (m *ServerMutation) ResetAdminPort() {
  27827. m.admin_port = nil
  27828. }
  27829. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  27830. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  27831. if m.wxs == nil {
  27832. m.wxs = make(map[uint64]struct{})
  27833. }
  27834. for i := range ids {
  27835. m.wxs[ids[i]] = struct{}{}
  27836. }
  27837. }
  27838. // ClearWxs clears the "wxs" edge to the Wx entity.
  27839. func (m *ServerMutation) ClearWxs() {
  27840. m.clearedwxs = true
  27841. }
  27842. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  27843. func (m *ServerMutation) WxsCleared() bool {
  27844. return m.clearedwxs
  27845. }
  27846. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  27847. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  27848. if m.removedwxs == nil {
  27849. m.removedwxs = make(map[uint64]struct{})
  27850. }
  27851. for i := range ids {
  27852. delete(m.wxs, ids[i])
  27853. m.removedwxs[ids[i]] = struct{}{}
  27854. }
  27855. }
  27856. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  27857. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  27858. for id := range m.removedwxs {
  27859. ids = append(ids, id)
  27860. }
  27861. return
  27862. }
  27863. // WxsIDs returns the "wxs" edge IDs in the mutation.
  27864. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  27865. for id := range m.wxs {
  27866. ids = append(ids, id)
  27867. }
  27868. return
  27869. }
  27870. // ResetWxs resets all changes to the "wxs" edge.
  27871. func (m *ServerMutation) ResetWxs() {
  27872. m.wxs = nil
  27873. m.clearedwxs = false
  27874. m.removedwxs = nil
  27875. }
  27876. // Where appends a list predicates to the ServerMutation builder.
  27877. func (m *ServerMutation) Where(ps ...predicate.Server) {
  27878. m.predicates = append(m.predicates, ps...)
  27879. }
  27880. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  27881. // users can use type-assertion to append predicates that do not depend on any generated package.
  27882. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  27883. p := make([]predicate.Server, len(ps))
  27884. for i := range ps {
  27885. p[i] = ps[i]
  27886. }
  27887. m.Where(p...)
  27888. }
  27889. // Op returns the operation name.
  27890. func (m *ServerMutation) Op() Op {
  27891. return m.op
  27892. }
  27893. // SetOp allows setting the mutation operation.
  27894. func (m *ServerMutation) SetOp(op Op) {
  27895. m.op = op
  27896. }
  27897. // Type returns the node type of this mutation (Server).
  27898. func (m *ServerMutation) Type() string {
  27899. return m.typ
  27900. }
  27901. // Fields returns all fields that were changed during this mutation. Note that in
  27902. // order to get all numeric fields that were incremented/decremented, call
  27903. // AddedFields().
  27904. func (m *ServerMutation) Fields() []string {
  27905. fields := make([]string, 0, 8)
  27906. if m.created_at != nil {
  27907. fields = append(fields, server.FieldCreatedAt)
  27908. }
  27909. if m.updated_at != nil {
  27910. fields = append(fields, server.FieldUpdatedAt)
  27911. }
  27912. if m.status != nil {
  27913. fields = append(fields, server.FieldStatus)
  27914. }
  27915. if m.deleted_at != nil {
  27916. fields = append(fields, server.FieldDeletedAt)
  27917. }
  27918. if m.name != nil {
  27919. fields = append(fields, server.FieldName)
  27920. }
  27921. if m.public_ip != nil {
  27922. fields = append(fields, server.FieldPublicIP)
  27923. }
  27924. if m.private_ip != nil {
  27925. fields = append(fields, server.FieldPrivateIP)
  27926. }
  27927. if m.admin_port != nil {
  27928. fields = append(fields, server.FieldAdminPort)
  27929. }
  27930. return fields
  27931. }
  27932. // Field returns the value of a field with the given name. The second boolean
  27933. // return value indicates that this field was not set, or was not defined in the
  27934. // schema.
  27935. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  27936. switch name {
  27937. case server.FieldCreatedAt:
  27938. return m.CreatedAt()
  27939. case server.FieldUpdatedAt:
  27940. return m.UpdatedAt()
  27941. case server.FieldStatus:
  27942. return m.Status()
  27943. case server.FieldDeletedAt:
  27944. return m.DeletedAt()
  27945. case server.FieldName:
  27946. return m.Name()
  27947. case server.FieldPublicIP:
  27948. return m.PublicIP()
  27949. case server.FieldPrivateIP:
  27950. return m.PrivateIP()
  27951. case server.FieldAdminPort:
  27952. return m.AdminPort()
  27953. }
  27954. return nil, false
  27955. }
  27956. // OldField returns the old value of the field from the database. An error is
  27957. // returned if the mutation operation is not UpdateOne, or the query to the
  27958. // database failed.
  27959. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27960. switch name {
  27961. case server.FieldCreatedAt:
  27962. return m.OldCreatedAt(ctx)
  27963. case server.FieldUpdatedAt:
  27964. return m.OldUpdatedAt(ctx)
  27965. case server.FieldStatus:
  27966. return m.OldStatus(ctx)
  27967. case server.FieldDeletedAt:
  27968. return m.OldDeletedAt(ctx)
  27969. case server.FieldName:
  27970. return m.OldName(ctx)
  27971. case server.FieldPublicIP:
  27972. return m.OldPublicIP(ctx)
  27973. case server.FieldPrivateIP:
  27974. return m.OldPrivateIP(ctx)
  27975. case server.FieldAdminPort:
  27976. return m.OldAdminPort(ctx)
  27977. }
  27978. return nil, fmt.Errorf("unknown Server field %s", name)
  27979. }
  27980. // SetField sets the value of a field with the given name. It returns an error if
  27981. // the field is not defined in the schema, or if the type mismatched the field
  27982. // type.
  27983. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  27984. switch name {
  27985. case server.FieldCreatedAt:
  27986. v, ok := value.(time.Time)
  27987. if !ok {
  27988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27989. }
  27990. m.SetCreatedAt(v)
  27991. return nil
  27992. case server.FieldUpdatedAt:
  27993. v, ok := value.(time.Time)
  27994. if !ok {
  27995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27996. }
  27997. m.SetUpdatedAt(v)
  27998. return nil
  27999. case server.FieldStatus:
  28000. v, ok := value.(uint8)
  28001. if !ok {
  28002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28003. }
  28004. m.SetStatus(v)
  28005. return nil
  28006. case server.FieldDeletedAt:
  28007. v, ok := value.(time.Time)
  28008. if !ok {
  28009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28010. }
  28011. m.SetDeletedAt(v)
  28012. return nil
  28013. case server.FieldName:
  28014. v, ok := value.(string)
  28015. if !ok {
  28016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28017. }
  28018. m.SetName(v)
  28019. return nil
  28020. case server.FieldPublicIP:
  28021. v, ok := value.(string)
  28022. if !ok {
  28023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28024. }
  28025. m.SetPublicIP(v)
  28026. return nil
  28027. case server.FieldPrivateIP:
  28028. v, ok := value.(string)
  28029. if !ok {
  28030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28031. }
  28032. m.SetPrivateIP(v)
  28033. return nil
  28034. case server.FieldAdminPort:
  28035. v, ok := value.(string)
  28036. if !ok {
  28037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28038. }
  28039. m.SetAdminPort(v)
  28040. return nil
  28041. }
  28042. return fmt.Errorf("unknown Server field %s", name)
  28043. }
  28044. // AddedFields returns all numeric fields that were incremented/decremented during
  28045. // this mutation.
  28046. func (m *ServerMutation) AddedFields() []string {
  28047. var fields []string
  28048. if m.addstatus != nil {
  28049. fields = append(fields, server.FieldStatus)
  28050. }
  28051. return fields
  28052. }
  28053. // AddedField returns the numeric value that was incremented/decremented on a field
  28054. // with the given name. The second boolean return value indicates that this field
  28055. // was not set, or was not defined in the schema.
  28056. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  28057. switch name {
  28058. case server.FieldStatus:
  28059. return m.AddedStatus()
  28060. }
  28061. return nil, false
  28062. }
  28063. // AddField adds the value to the field with the given name. It returns an error if
  28064. // the field is not defined in the schema, or if the type mismatched the field
  28065. // type.
  28066. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  28067. switch name {
  28068. case server.FieldStatus:
  28069. v, ok := value.(int8)
  28070. if !ok {
  28071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28072. }
  28073. m.AddStatus(v)
  28074. return nil
  28075. }
  28076. return fmt.Errorf("unknown Server numeric field %s", name)
  28077. }
  28078. // ClearedFields returns all nullable fields that were cleared during this
  28079. // mutation.
  28080. func (m *ServerMutation) ClearedFields() []string {
  28081. var fields []string
  28082. if m.FieldCleared(server.FieldStatus) {
  28083. fields = append(fields, server.FieldStatus)
  28084. }
  28085. if m.FieldCleared(server.FieldDeletedAt) {
  28086. fields = append(fields, server.FieldDeletedAt)
  28087. }
  28088. return fields
  28089. }
  28090. // FieldCleared returns a boolean indicating if a field with the given name was
  28091. // cleared in this mutation.
  28092. func (m *ServerMutation) FieldCleared(name string) bool {
  28093. _, ok := m.clearedFields[name]
  28094. return ok
  28095. }
  28096. // ClearField clears the value of the field with the given name. It returns an
  28097. // error if the field is not defined in the schema.
  28098. func (m *ServerMutation) ClearField(name string) error {
  28099. switch name {
  28100. case server.FieldStatus:
  28101. m.ClearStatus()
  28102. return nil
  28103. case server.FieldDeletedAt:
  28104. m.ClearDeletedAt()
  28105. return nil
  28106. }
  28107. return fmt.Errorf("unknown Server nullable field %s", name)
  28108. }
  28109. // ResetField resets all changes in the mutation for the field with the given name.
  28110. // It returns an error if the field is not defined in the schema.
  28111. func (m *ServerMutation) ResetField(name string) error {
  28112. switch name {
  28113. case server.FieldCreatedAt:
  28114. m.ResetCreatedAt()
  28115. return nil
  28116. case server.FieldUpdatedAt:
  28117. m.ResetUpdatedAt()
  28118. return nil
  28119. case server.FieldStatus:
  28120. m.ResetStatus()
  28121. return nil
  28122. case server.FieldDeletedAt:
  28123. m.ResetDeletedAt()
  28124. return nil
  28125. case server.FieldName:
  28126. m.ResetName()
  28127. return nil
  28128. case server.FieldPublicIP:
  28129. m.ResetPublicIP()
  28130. return nil
  28131. case server.FieldPrivateIP:
  28132. m.ResetPrivateIP()
  28133. return nil
  28134. case server.FieldAdminPort:
  28135. m.ResetAdminPort()
  28136. return nil
  28137. }
  28138. return fmt.Errorf("unknown Server field %s", name)
  28139. }
  28140. // AddedEdges returns all edge names that were set/added in this mutation.
  28141. func (m *ServerMutation) AddedEdges() []string {
  28142. edges := make([]string, 0, 1)
  28143. if m.wxs != nil {
  28144. edges = append(edges, server.EdgeWxs)
  28145. }
  28146. return edges
  28147. }
  28148. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28149. // name in this mutation.
  28150. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  28151. switch name {
  28152. case server.EdgeWxs:
  28153. ids := make([]ent.Value, 0, len(m.wxs))
  28154. for id := range m.wxs {
  28155. ids = append(ids, id)
  28156. }
  28157. return ids
  28158. }
  28159. return nil
  28160. }
  28161. // RemovedEdges returns all edge names that were removed in this mutation.
  28162. func (m *ServerMutation) RemovedEdges() []string {
  28163. edges := make([]string, 0, 1)
  28164. if m.removedwxs != nil {
  28165. edges = append(edges, server.EdgeWxs)
  28166. }
  28167. return edges
  28168. }
  28169. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28170. // the given name in this mutation.
  28171. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  28172. switch name {
  28173. case server.EdgeWxs:
  28174. ids := make([]ent.Value, 0, len(m.removedwxs))
  28175. for id := range m.removedwxs {
  28176. ids = append(ids, id)
  28177. }
  28178. return ids
  28179. }
  28180. return nil
  28181. }
  28182. // ClearedEdges returns all edge names that were cleared in this mutation.
  28183. func (m *ServerMutation) ClearedEdges() []string {
  28184. edges := make([]string, 0, 1)
  28185. if m.clearedwxs {
  28186. edges = append(edges, server.EdgeWxs)
  28187. }
  28188. return edges
  28189. }
  28190. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28191. // was cleared in this mutation.
  28192. func (m *ServerMutation) EdgeCleared(name string) bool {
  28193. switch name {
  28194. case server.EdgeWxs:
  28195. return m.clearedwxs
  28196. }
  28197. return false
  28198. }
  28199. // ClearEdge clears the value of the edge with the given name. It returns an error
  28200. // if that edge is not defined in the schema.
  28201. func (m *ServerMutation) ClearEdge(name string) error {
  28202. switch name {
  28203. }
  28204. return fmt.Errorf("unknown Server unique edge %s", name)
  28205. }
  28206. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28207. // It returns an error if the edge is not defined in the schema.
  28208. func (m *ServerMutation) ResetEdge(name string) error {
  28209. switch name {
  28210. case server.EdgeWxs:
  28211. m.ResetWxs()
  28212. return nil
  28213. }
  28214. return fmt.Errorf("unknown Server edge %s", name)
  28215. }
  28216. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  28217. type SopNodeMutation struct {
  28218. config
  28219. op Op
  28220. typ string
  28221. id *uint64
  28222. created_at *time.Time
  28223. updated_at *time.Time
  28224. status *uint8
  28225. addstatus *int8
  28226. deleted_at *time.Time
  28227. parent_id *uint64
  28228. addparent_id *int64
  28229. name *string
  28230. condition_type *int
  28231. addcondition_type *int
  28232. condition_list *[]string
  28233. appendcondition_list []string
  28234. no_reply_condition *uint64
  28235. addno_reply_condition *int64
  28236. no_reply_unit *string
  28237. action_message *[]custom_types.Action
  28238. appendaction_message []custom_types.Action
  28239. action_label_add *[]uint64
  28240. appendaction_label_add []uint64
  28241. action_label_del *[]uint64
  28242. appendaction_label_del []uint64
  28243. action_forward **custom_types.ActionForward
  28244. clearedFields map[string]struct{}
  28245. sop_stage *uint64
  28246. clearedsop_stage bool
  28247. node_messages map[uint64]struct{}
  28248. removednode_messages map[uint64]struct{}
  28249. clearednode_messages bool
  28250. done bool
  28251. oldValue func(context.Context) (*SopNode, error)
  28252. predicates []predicate.SopNode
  28253. }
  28254. var _ ent.Mutation = (*SopNodeMutation)(nil)
  28255. // sopnodeOption allows management of the mutation configuration using functional options.
  28256. type sopnodeOption func(*SopNodeMutation)
  28257. // newSopNodeMutation creates new mutation for the SopNode entity.
  28258. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  28259. m := &SopNodeMutation{
  28260. config: c,
  28261. op: op,
  28262. typ: TypeSopNode,
  28263. clearedFields: make(map[string]struct{}),
  28264. }
  28265. for _, opt := range opts {
  28266. opt(m)
  28267. }
  28268. return m
  28269. }
  28270. // withSopNodeID sets the ID field of the mutation.
  28271. func withSopNodeID(id uint64) sopnodeOption {
  28272. return func(m *SopNodeMutation) {
  28273. var (
  28274. err error
  28275. once sync.Once
  28276. value *SopNode
  28277. )
  28278. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  28279. once.Do(func() {
  28280. if m.done {
  28281. err = errors.New("querying old values post mutation is not allowed")
  28282. } else {
  28283. value, err = m.Client().SopNode.Get(ctx, id)
  28284. }
  28285. })
  28286. return value, err
  28287. }
  28288. m.id = &id
  28289. }
  28290. }
  28291. // withSopNode sets the old SopNode of the mutation.
  28292. func withSopNode(node *SopNode) sopnodeOption {
  28293. return func(m *SopNodeMutation) {
  28294. m.oldValue = func(context.Context) (*SopNode, error) {
  28295. return node, nil
  28296. }
  28297. m.id = &node.ID
  28298. }
  28299. }
  28300. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28301. // executed in a transaction (ent.Tx), a transactional client is returned.
  28302. func (m SopNodeMutation) Client() *Client {
  28303. client := &Client{config: m.config}
  28304. client.init()
  28305. return client
  28306. }
  28307. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28308. // it returns an error otherwise.
  28309. func (m SopNodeMutation) Tx() (*Tx, error) {
  28310. if _, ok := m.driver.(*txDriver); !ok {
  28311. return nil, errors.New("ent: mutation is not running in a transaction")
  28312. }
  28313. tx := &Tx{config: m.config}
  28314. tx.init()
  28315. return tx, nil
  28316. }
  28317. // SetID sets the value of the id field. Note that this
  28318. // operation is only accepted on creation of SopNode entities.
  28319. func (m *SopNodeMutation) SetID(id uint64) {
  28320. m.id = &id
  28321. }
  28322. // ID returns the ID value in the mutation. Note that the ID is only available
  28323. // if it was provided to the builder or after it was returned from the database.
  28324. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  28325. if m.id == nil {
  28326. return
  28327. }
  28328. return *m.id, true
  28329. }
  28330. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28331. // That means, if the mutation is applied within a transaction with an isolation level such
  28332. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28333. // or updated by the mutation.
  28334. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  28335. switch {
  28336. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28337. id, exists := m.ID()
  28338. if exists {
  28339. return []uint64{id}, nil
  28340. }
  28341. fallthrough
  28342. case m.op.Is(OpUpdate | OpDelete):
  28343. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  28344. default:
  28345. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28346. }
  28347. }
  28348. // SetCreatedAt sets the "created_at" field.
  28349. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  28350. m.created_at = &t
  28351. }
  28352. // CreatedAt returns the value of the "created_at" field in the mutation.
  28353. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  28354. v := m.created_at
  28355. if v == nil {
  28356. return
  28357. }
  28358. return *v, true
  28359. }
  28360. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  28361. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28363. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28364. if !m.op.Is(OpUpdateOne) {
  28365. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28366. }
  28367. if m.id == nil || m.oldValue == nil {
  28368. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28369. }
  28370. oldValue, err := m.oldValue(ctx)
  28371. if err != nil {
  28372. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28373. }
  28374. return oldValue.CreatedAt, nil
  28375. }
  28376. // ResetCreatedAt resets all changes to the "created_at" field.
  28377. func (m *SopNodeMutation) ResetCreatedAt() {
  28378. m.created_at = nil
  28379. }
  28380. // SetUpdatedAt sets the "updated_at" field.
  28381. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  28382. m.updated_at = &t
  28383. }
  28384. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28385. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  28386. v := m.updated_at
  28387. if v == nil {
  28388. return
  28389. }
  28390. return *v, true
  28391. }
  28392. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  28393. // If the SopNode 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 *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28396. if !m.op.Is(OpUpdateOne) {
  28397. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28398. }
  28399. if m.id == nil || m.oldValue == nil {
  28400. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  28405. }
  28406. return oldValue.UpdatedAt, nil
  28407. }
  28408. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28409. func (m *SopNodeMutation) ResetUpdatedAt() {
  28410. m.updated_at = nil
  28411. }
  28412. // SetStatus sets the "status" field.
  28413. func (m *SopNodeMutation) SetStatus(u uint8) {
  28414. m.status = &u
  28415. m.addstatus = nil
  28416. }
  28417. // Status returns the value of the "status" field in the mutation.
  28418. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  28419. v := m.status
  28420. if v == nil {
  28421. return
  28422. }
  28423. return *v, true
  28424. }
  28425. // OldStatus returns the old "status" field's value of the SopNode entity.
  28426. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28428. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28429. if !m.op.Is(OpUpdateOne) {
  28430. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28431. }
  28432. if m.id == nil || m.oldValue == nil {
  28433. return v, errors.New("OldStatus requires an ID field in the mutation")
  28434. }
  28435. oldValue, err := m.oldValue(ctx)
  28436. if err != nil {
  28437. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28438. }
  28439. return oldValue.Status, nil
  28440. }
  28441. // AddStatus adds u to the "status" field.
  28442. func (m *SopNodeMutation) AddStatus(u int8) {
  28443. if m.addstatus != nil {
  28444. *m.addstatus += u
  28445. } else {
  28446. m.addstatus = &u
  28447. }
  28448. }
  28449. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28450. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  28451. v := m.addstatus
  28452. if v == nil {
  28453. return
  28454. }
  28455. return *v, true
  28456. }
  28457. // ClearStatus clears the value of the "status" field.
  28458. func (m *SopNodeMutation) ClearStatus() {
  28459. m.status = nil
  28460. m.addstatus = nil
  28461. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  28462. }
  28463. // StatusCleared returns if the "status" field was cleared in this mutation.
  28464. func (m *SopNodeMutation) StatusCleared() bool {
  28465. _, ok := m.clearedFields[sopnode.FieldStatus]
  28466. return ok
  28467. }
  28468. // ResetStatus resets all changes to the "status" field.
  28469. func (m *SopNodeMutation) ResetStatus() {
  28470. m.status = nil
  28471. m.addstatus = nil
  28472. delete(m.clearedFields, sopnode.FieldStatus)
  28473. }
  28474. // SetDeletedAt sets the "deleted_at" field.
  28475. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  28476. m.deleted_at = &t
  28477. }
  28478. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28479. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  28480. v := m.deleted_at
  28481. if v == nil {
  28482. return
  28483. }
  28484. return *v, true
  28485. }
  28486. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  28487. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28489. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28490. if !m.op.Is(OpUpdateOne) {
  28491. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28492. }
  28493. if m.id == nil || m.oldValue == nil {
  28494. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28495. }
  28496. oldValue, err := m.oldValue(ctx)
  28497. if err != nil {
  28498. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28499. }
  28500. return oldValue.DeletedAt, nil
  28501. }
  28502. // ClearDeletedAt clears the value of the "deleted_at" field.
  28503. func (m *SopNodeMutation) ClearDeletedAt() {
  28504. m.deleted_at = nil
  28505. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  28506. }
  28507. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28508. func (m *SopNodeMutation) DeletedAtCleared() bool {
  28509. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  28510. return ok
  28511. }
  28512. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28513. func (m *SopNodeMutation) ResetDeletedAt() {
  28514. m.deleted_at = nil
  28515. delete(m.clearedFields, sopnode.FieldDeletedAt)
  28516. }
  28517. // SetStageID sets the "stage_id" field.
  28518. func (m *SopNodeMutation) SetStageID(u uint64) {
  28519. m.sop_stage = &u
  28520. }
  28521. // StageID returns the value of the "stage_id" field in the mutation.
  28522. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  28523. v := m.sop_stage
  28524. if v == nil {
  28525. return
  28526. }
  28527. return *v, true
  28528. }
  28529. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  28530. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28532. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  28533. if !m.op.Is(OpUpdateOne) {
  28534. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  28535. }
  28536. if m.id == nil || m.oldValue == nil {
  28537. return v, errors.New("OldStageID requires an ID field in the mutation")
  28538. }
  28539. oldValue, err := m.oldValue(ctx)
  28540. if err != nil {
  28541. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  28542. }
  28543. return oldValue.StageID, nil
  28544. }
  28545. // ResetStageID resets all changes to the "stage_id" field.
  28546. func (m *SopNodeMutation) ResetStageID() {
  28547. m.sop_stage = nil
  28548. }
  28549. // SetParentID sets the "parent_id" field.
  28550. func (m *SopNodeMutation) SetParentID(u uint64) {
  28551. m.parent_id = &u
  28552. m.addparent_id = nil
  28553. }
  28554. // ParentID returns the value of the "parent_id" field in the mutation.
  28555. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  28556. v := m.parent_id
  28557. if v == nil {
  28558. return
  28559. }
  28560. return *v, true
  28561. }
  28562. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  28563. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28565. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  28566. if !m.op.Is(OpUpdateOne) {
  28567. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  28568. }
  28569. if m.id == nil || m.oldValue == nil {
  28570. return v, errors.New("OldParentID requires an ID field in the mutation")
  28571. }
  28572. oldValue, err := m.oldValue(ctx)
  28573. if err != nil {
  28574. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  28575. }
  28576. return oldValue.ParentID, nil
  28577. }
  28578. // AddParentID adds u to the "parent_id" field.
  28579. func (m *SopNodeMutation) AddParentID(u int64) {
  28580. if m.addparent_id != nil {
  28581. *m.addparent_id += u
  28582. } else {
  28583. m.addparent_id = &u
  28584. }
  28585. }
  28586. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  28587. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  28588. v := m.addparent_id
  28589. if v == nil {
  28590. return
  28591. }
  28592. return *v, true
  28593. }
  28594. // ResetParentID resets all changes to the "parent_id" field.
  28595. func (m *SopNodeMutation) ResetParentID() {
  28596. m.parent_id = nil
  28597. m.addparent_id = nil
  28598. }
  28599. // SetName sets the "name" field.
  28600. func (m *SopNodeMutation) SetName(s string) {
  28601. m.name = &s
  28602. }
  28603. // Name returns the value of the "name" field in the mutation.
  28604. func (m *SopNodeMutation) Name() (r string, exists bool) {
  28605. v := m.name
  28606. if v == nil {
  28607. return
  28608. }
  28609. return *v, true
  28610. }
  28611. // OldName returns the old "name" field's value of the SopNode entity.
  28612. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28614. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  28615. if !m.op.Is(OpUpdateOne) {
  28616. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28617. }
  28618. if m.id == nil || m.oldValue == nil {
  28619. return v, errors.New("OldName requires an ID field in the mutation")
  28620. }
  28621. oldValue, err := m.oldValue(ctx)
  28622. if err != nil {
  28623. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28624. }
  28625. return oldValue.Name, nil
  28626. }
  28627. // ResetName resets all changes to the "name" field.
  28628. func (m *SopNodeMutation) ResetName() {
  28629. m.name = nil
  28630. }
  28631. // SetConditionType sets the "condition_type" field.
  28632. func (m *SopNodeMutation) SetConditionType(i int) {
  28633. m.condition_type = &i
  28634. m.addcondition_type = nil
  28635. }
  28636. // ConditionType returns the value of the "condition_type" field in the mutation.
  28637. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  28638. v := m.condition_type
  28639. if v == nil {
  28640. return
  28641. }
  28642. return *v, true
  28643. }
  28644. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  28645. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28647. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28648. if !m.op.Is(OpUpdateOne) {
  28649. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28650. }
  28651. if m.id == nil || m.oldValue == nil {
  28652. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28653. }
  28654. oldValue, err := m.oldValue(ctx)
  28655. if err != nil {
  28656. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28657. }
  28658. return oldValue.ConditionType, nil
  28659. }
  28660. // AddConditionType adds i to the "condition_type" field.
  28661. func (m *SopNodeMutation) AddConditionType(i int) {
  28662. if m.addcondition_type != nil {
  28663. *m.addcondition_type += i
  28664. } else {
  28665. m.addcondition_type = &i
  28666. }
  28667. }
  28668. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28669. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  28670. v := m.addcondition_type
  28671. if v == nil {
  28672. return
  28673. }
  28674. return *v, true
  28675. }
  28676. // ResetConditionType resets all changes to the "condition_type" field.
  28677. func (m *SopNodeMutation) ResetConditionType() {
  28678. m.condition_type = nil
  28679. m.addcondition_type = nil
  28680. }
  28681. // SetConditionList sets the "condition_list" field.
  28682. func (m *SopNodeMutation) SetConditionList(s []string) {
  28683. m.condition_list = &s
  28684. m.appendcondition_list = nil
  28685. }
  28686. // ConditionList returns the value of the "condition_list" field in the mutation.
  28687. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  28688. v := m.condition_list
  28689. if v == nil {
  28690. return
  28691. }
  28692. return *v, true
  28693. }
  28694. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  28695. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28697. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  28698. if !m.op.Is(OpUpdateOne) {
  28699. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28700. }
  28701. if m.id == nil || m.oldValue == nil {
  28702. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28703. }
  28704. oldValue, err := m.oldValue(ctx)
  28705. if err != nil {
  28706. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28707. }
  28708. return oldValue.ConditionList, nil
  28709. }
  28710. // AppendConditionList adds s to the "condition_list" field.
  28711. func (m *SopNodeMutation) AppendConditionList(s []string) {
  28712. m.appendcondition_list = append(m.appendcondition_list, s...)
  28713. }
  28714. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28715. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  28716. if len(m.appendcondition_list) == 0 {
  28717. return nil, false
  28718. }
  28719. return m.appendcondition_list, true
  28720. }
  28721. // ClearConditionList clears the value of the "condition_list" field.
  28722. func (m *SopNodeMutation) ClearConditionList() {
  28723. m.condition_list = nil
  28724. m.appendcondition_list = nil
  28725. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  28726. }
  28727. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  28728. func (m *SopNodeMutation) ConditionListCleared() bool {
  28729. _, ok := m.clearedFields[sopnode.FieldConditionList]
  28730. return ok
  28731. }
  28732. // ResetConditionList resets all changes to the "condition_list" field.
  28733. func (m *SopNodeMutation) ResetConditionList() {
  28734. m.condition_list = nil
  28735. m.appendcondition_list = nil
  28736. delete(m.clearedFields, sopnode.FieldConditionList)
  28737. }
  28738. // SetNoReplyCondition sets the "no_reply_condition" field.
  28739. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  28740. m.no_reply_condition = &u
  28741. m.addno_reply_condition = nil
  28742. }
  28743. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  28744. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  28745. v := m.no_reply_condition
  28746. if v == nil {
  28747. return
  28748. }
  28749. return *v, true
  28750. }
  28751. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  28752. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28754. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  28755. if !m.op.Is(OpUpdateOne) {
  28756. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  28757. }
  28758. if m.id == nil || m.oldValue == nil {
  28759. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  28760. }
  28761. oldValue, err := m.oldValue(ctx)
  28762. if err != nil {
  28763. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  28764. }
  28765. return oldValue.NoReplyCondition, nil
  28766. }
  28767. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  28768. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  28769. if m.addno_reply_condition != nil {
  28770. *m.addno_reply_condition += u
  28771. } else {
  28772. m.addno_reply_condition = &u
  28773. }
  28774. }
  28775. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  28776. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  28777. v := m.addno_reply_condition
  28778. if v == nil {
  28779. return
  28780. }
  28781. return *v, true
  28782. }
  28783. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  28784. func (m *SopNodeMutation) ResetNoReplyCondition() {
  28785. m.no_reply_condition = nil
  28786. m.addno_reply_condition = nil
  28787. }
  28788. // SetNoReplyUnit sets the "no_reply_unit" field.
  28789. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  28790. m.no_reply_unit = &s
  28791. }
  28792. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  28793. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  28794. v := m.no_reply_unit
  28795. if v == nil {
  28796. return
  28797. }
  28798. return *v, true
  28799. }
  28800. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  28801. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28803. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  28804. if !m.op.Is(OpUpdateOne) {
  28805. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  28806. }
  28807. if m.id == nil || m.oldValue == nil {
  28808. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  28809. }
  28810. oldValue, err := m.oldValue(ctx)
  28811. if err != nil {
  28812. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  28813. }
  28814. return oldValue.NoReplyUnit, nil
  28815. }
  28816. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  28817. func (m *SopNodeMutation) ResetNoReplyUnit() {
  28818. m.no_reply_unit = nil
  28819. }
  28820. // SetActionMessage sets the "action_message" field.
  28821. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  28822. m.action_message = &ct
  28823. m.appendaction_message = nil
  28824. }
  28825. // ActionMessage returns the value of the "action_message" field in the mutation.
  28826. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  28827. v := m.action_message
  28828. if v == nil {
  28829. return
  28830. }
  28831. return *v, true
  28832. }
  28833. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  28834. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28836. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28837. if !m.op.Is(OpUpdateOne) {
  28838. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28839. }
  28840. if m.id == nil || m.oldValue == nil {
  28841. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28842. }
  28843. oldValue, err := m.oldValue(ctx)
  28844. if err != nil {
  28845. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28846. }
  28847. return oldValue.ActionMessage, nil
  28848. }
  28849. // AppendActionMessage adds ct to the "action_message" field.
  28850. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  28851. m.appendaction_message = append(m.appendaction_message, ct...)
  28852. }
  28853. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  28854. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  28855. if len(m.appendaction_message) == 0 {
  28856. return nil, false
  28857. }
  28858. return m.appendaction_message, true
  28859. }
  28860. // ClearActionMessage clears the value of the "action_message" field.
  28861. func (m *SopNodeMutation) ClearActionMessage() {
  28862. m.action_message = nil
  28863. m.appendaction_message = nil
  28864. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  28865. }
  28866. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  28867. func (m *SopNodeMutation) ActionMessageCleared() bool {
  28868. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  28869. return ok
  28870. }
  28871. // ResetActionMessage resets all changes to the "action_message" field.
  28872. func (m *SopNodeMutation) ResetActionMessage() {
  28873. m.action_message = nil
  28874. m.appendaction_message = nil
  28875. delete(m.clearedFields, sopnode.FieldActionMessage)
  28876. }
  28877. // SetActionLabelAdd sets the "action_label_add" field.
  28878. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  28879. m.action_label_add = &u
  28880. m.appendaction_label_add = nil
  28881. }
  28882. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  28883. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  28884. v := m.action_label_add
  28885. if v == nil {
  28886. return
  28887. }
  28888. return *v, true
  28889. }
  28890. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  28891. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28893. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  28894. if !m.op.Is(OpUpdateOne) {
  28895. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  28896. }
  28897. if m.id == nil || m.oldValue == nil {
  28898. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  28899. }
  28900. oldValue, err := m.oldValue(ctx)
  28901. if err != nil {
  28902. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  28903. }
  28904. return oldValue.ActionLabelAdd, nil
  28905. }
  28906. // AppendActionLabelAdd adds u to the "action_label_add" field.
  28907. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  28908. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  28909. }
  28910. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  28911. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  28912. if len(m.appendaction_label_add) == 0 {
  28913. return nil, false
  28914. }
  28915. return m.appendaction_label_add, true
  28916. }
  28917. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  28918. func (m *SopNodeMutation) ClearActionLabelAdd() {
  28919. m.action_label_add = nil
  28920. m.appendaction_label_add = nil
  28921. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  28922. }
  28923. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  28924. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  28925. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  28926. return ok
  28927. }
  28928. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  28929. func (m *SopNodeMutation) ResetActionLabelAdd() {
  28930. m.action_label_add = nil
  28931. m.appendaction_label_add = nil
  28932. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  28933. }
  28934. // SetActionLabelDel sets the "action_label_del" field.
  28935. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  28936. m.action_label_del = &u
  28937. m.appendaction_label_del = nil
  28938. }
  28939. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  28940. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  28941. v := m.action_label_del
  28942. if v == nil {
  28943. return
  28944. }
  28945. return *v, true
  28946. }
  28947. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  28948. // If the SopNode 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 *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  28951. if !m.op.Is(OpUpdateOne) {
  28952. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  28953. }
  28954. if m.id == nil || m.oldValue == nil {
  28955. return v, errors.New("OldActionLabelDel 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 OldActionLabelDel: %w", err)
  28960. }
  28961. return oldValue.ActionLabelDel, nil
  28962. }
  28963. // AppendActionLabelDel adds u to the "action_label_del" field.
  28964. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  28965. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  28966. }
  28967. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  28968. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  28969. if len(m.appendaction_label_del) == 0 {
  28970. return nil, false
  28971. }
  28972. return m.appendaction_label_del, true
  28973. }
  28974. // ClearActionLabelDel clears the value of the "action_label_del" field.
  28975. func (m *SopNodeMutation) ClearActionLabelDel() {
  28976. m.action_label_del = nil
  28977. m.appendaction_label_del = nil
  28978. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  28979. }
  28980. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  28981. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  28982. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  28983. return ok
  28984. }
  28985. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  28986. func (m *SopNodeMutation) ResetActionLabelDel() {
  28987. m.action_label_del = nil
  28988. m.appendaction_label_del = nil
  28989. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  28990. }
  28991. // SetActionForward sets the "action_forward" field.
  28992. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  28993. m.action_forward = &ctf
  28994. }
  28995. // ActionForward returns the value of the "action_forward" field in the mutation.
  28996. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  28997. v := m.action_forward
  28998. if v == nil {
  28999. return
  29000. }
  29001. return *v, true
  29002. }
  29003. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  29004. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29006. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  29007. if !m.op.Is(OpUpdateOne) {
  29008. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  29009. }
  29010. if m.id == nil || m.oldValue == nil {
  29011. return v, errors.New("OldActionForward requires an ID field in the mutation")
  29012. }
  29013. oldValue, err := m.oldValue(ctx)
  29014. if err != nil {
  29015. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  29016. }
  29017. return oldValue.ActionForward, nil
  29018. }
  29019. // ClearActionForward clears the value of the "action_forward" field.
  29020. func (m *SopNodeMutation) ClearActionForward() {
  29021. m.action_forward = nil
  29022. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  29023. }
  29024. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  29025. func (m *SopNodeMutation) ActionForwardCleared() bool {
  29026. _, ok := m.clearedFields[sopnode.FieldActionForward]
  29027. return ok
  29028. }
  29029. // ResetActionForward resets all changes to the "action_forward" field.
  29030. func (m *SopNodeMutation) ResetActionForward() {
  29031. m.action_forward = nil
  29032. delete(m.clearedFields, sopnode.FieldActionForward)
  29033. }
  29034. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  29035. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  29036. m.sop_stage = &id
  29037. }
  29038. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  29039. func (m *SopNodeMutation) ClearSopStage() {
  29040. m.clearedsop_stage = true
  29041. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  29042. }
  29043. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  29044. func (m *SopNodeMutation) SopStageCleared() bool {
  29045. return m.clearedsop_stage
  29046. }
  29047. // SopStageID returns the "sop_stage" edge ID in the mutation.
  29048. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  29049. if m.sop_stage != nil {
  29050. return *m.sop_stage, true
  29051. }
  29052. return
  29053. }
  29054. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  29055. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29056. // SopStageID instead. It exists only for internal usage by the builders.
  29057. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  29058. if id := m.sop_stage; id != nil {
  29059. ids = append(ids, *id)
  29060. }
  29061. return
  29062. }
  29063. // ResetSopStage resets all changes to the "sop_stage" edge.
  29064. func (m *SopNodeMutation) ResetSopStage() {
  29065. m.sop_stage = nil
  29066. m.clearedsop_stage = false
  29067. }
  29068. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  29069. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  29070. if m.node_messages == nil {
  29071. m.node_messages = make(map[uint64]struct{})
  29072. }
  29073. for i := range ids {
  29074. m.node_messages[ids[i]] = struct{}{}
  29075. }
  29076. }
  29077. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  29078. func (m *SopNodeMutation) ClearNodeMessages() {
  29079. m.clearednode_messages = true
  29080. }
  29081. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  29082. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  29083. return m.clearednode_messages
  29084. }
  29085. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  29086. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  29087. if m.removednode_messages == nil {
  29088. m.removednode_messages = make(map[uint64]struct{})
  29089. }
  29090. for i := range ids {
  29091. delete(m.node_messages, ids[i])
  29092. m.removednode_messages[ids[i]] = struct{}{}
  29093. }
  29094. }
  29095. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  29096. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  29097. for id := range m.removednode_messages {
  29098. ids = append(ids, id)
  29099. }
  29100. return
  29101. }
  29102. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  29103. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  29104. for id := range m.node_messages {
  29105. ids = append(ids, id)
  29106. }
  29107. return
  29108. }
  29109. // ResetNodeMessages resets all changes to the "node_messages" edge.
  29110. func (m *SopNodeMutation) ResetNodeMessages() {
  29111. m.node_messages = nil
  29112. m.clearednode_messages = false
  29113. m.removednode_messages = nil
  29114. }
  29115. // Where appends a list predicates to the SopNodeMutation builder.
  29116. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  29117. m.predicates = append(m.predicates, ps...)
  29118. }
  29119. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  29120. // users can use type-assertion to append predicates that do not depend on any generated package.
  29121. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  29122. p := make([]predicate.SopNode, len(ps))
  29123. for i := range ps {
  29124. p[i] = ps[i]
  29125. }
  29126. m.Where(p...)
  29127. }
  29128. // Op returns the operation name.
  29129. func (m *SopNodeMutation) Op() Op {
  29130. return m.op
  29131. }
  29132. // SetOp allows setting the mutation operation.
  29133. func (m *SopNodeMutation) SetOp(op Op) {
  29134. m.op = op
  29135. }
  29136. // Type returns the node type of this mutation (SopNode).
  29137. func (m *SopNodeMutation) Type() string {
  29138. return m.typ
  29139. }
  29140. // Fields returns all fields that were changed during this mutation. Note that in
  29141. // order to get all numeric fields that were incremented/decremented, call
  29142. // AddedFields().
  29143. func (m *SopNodeMutation) Fields() []string {
  29144. fields := make([]string, 0, 15)
  29145. if m.created_at != nil {
  29146. fields = append(fields, sopnode.FieldCreatedAt)
  29147. }
  29148. if m.updated_at != nil {
  29149. fields = append(fields, sopnode.FieldUpdatedAt)
  29150. }
  29151. if m.status != nil {
  29152. fields = append(fields, sopnode.FieldStatus)
  29153. }
  29154. if m.deleted_at != nil {
  29155. fields = append(fields, sopnode.FieldDeletedAt)
  29156. }
  29157. if m.sop_stage != nil {
  29158. fields = append(fields, sopnode.FieldStageID)
  29159. }
  29160. if m.parent_id != nil {
  29161. fields = append(fields, sopnode.FieldParentID)
  29162. }
  29163. if m.name != nil {
  29164. fields = append(fields, sopnode.FieldName)
  29165. }
  29166. if m.condition_type != nil {
  29167. fields = append(fields, sopnode.FieldConditionType)
  29168. }
  29169. if m.condition_list != nil {
  29170. fields = append(fields, sopnode.FieldConditionList)
  29171. }
  29172. if m.no_reply_condition != nil {
  29173. fields = append(fields, sopnode.FieldNoReplyCondition)
  29174. }
  29175. if m.no_reply_unit != nil {
  29176. fields = append(fields, sopnode.FieldNoReplyUnit)
  29177. }
  29178. if m.action_message != nil {
  29179. fields = append(fields, sopnode.FieldActionMessage)
  29180. }
  29181. if m.action_label_add != nil {
  29182. fields = append(fields, sopnode.FieldActionLabelAdd)
  29183. }
  29184. if m.action_label_del != nil {
  29185. fields = append(fields, sopnode.FieldActionLabelDel)
  29186. }
  29187. if m.action_forward != nil {
  29188. fields = append(fields, sopnode.FieldActionForward)
  29189. }
  29190. return fields
  29191. }
  29192. // Field returns the value of a field with the given name. The second boolean
  29193. // return value indicates that this field was not set, or was not defined in the
  29194. // schema.
  29195. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  29196. switch name {
  29197. case sopnode.FieldCreatedAt:
  29198. return m.CreatedAt()
  29199. case sopnode.FieldUpdatedAt:
  29200. return m.UpdatedAt()
  29201. case sopnode.FieldStatus:
  29202. return m.Status()
  29203. case sopnode.FieldDeletedAt:
  29204. return m.DeletedAt()
  29205. case sopnode.FieldStageID:
  29206. return m.StageID()
  29207. case sopnode.FieldParentID:
  29208. return m.ParentID()
  29209. case sopnode.FieldName:
  29210. return m.Name()
  29211. case sopnode.FieldConditionType:
  29212. return m.ConditionType()
  29213. case sopnode.FieldConditionList:
  29214. return m.ConditionList()
  29215. case sopnode.FieldNoReplyCondition:
  29216. return m.NoReplyCondition()
  29217. case sopnode.FieldNoReplyUnit:
  29218. return m.NoReplyUnit()
  29219. case sopnode.FieldActionMessage:
  29220. return m.ActionMessage()
  29221. case sopnode.FieldActionLabelAdd:
  29222. return m.ActionLabelAdd()
  29223. case sopnode.FieldActionLabelDel:
  29224. return m.ActionLabelDel()
  29225. case sopnode.FieldActionForward:
  29226. return m.ActionForward()
  29227. }
  29228. return nil, false
  29229. }
  29230. // OldField returns the old value of the field from the database. An error is
  29231. // returned if the mutation operation is not UpdateOne, or the query to the
  29232. // database failed.
  29233. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29234. switch name {
  29235. case sopnode.FieldCreatedAt:
  29236. return m.OldCreatedAt(ctx)
  29237. case sopnode.FieldUpdatedAt:
  29238. return m.OldUpdatedAt(ctx)
  29239. case sopnode.FieldStatus:
  29240. return m.OldStatus(ctx)
  29241. case sopnode.FieldDeletedAt:
  29242. return m.OldDeletedAt(ctx)
  29243. case sopnode.FieldStageID:
  29244. return m.OldStageID(ctx)
  29245. case sopnode.FieldParentID:
  29246. return m.OldParentID(ctx)
  29247. case sopnode.FieldName:
  29248. return m.OldName(ctx)
  29249. case sopnode.FieldConditionType:
  29250. return m.OldConditionType(ctx)
  29251. case sopnode.FieldConditionList:
  29252. return m.OldConditionList(ctx)
  29253. case sopnode.FieldNoReplyCondition:
  29254. return m.OldNoReplyCondition(ctx)
  29255. case sopnode.FieldNoReplyUnit:
  29256. return m.OldNoReplyUnit(ctx)
  29257. case sopnode.FieldActionMessage:
  29258. return m.OldActionMessage(ctx)
  29259. case sopnode.FieldActionLabelAdd:
  29260. return m.OldActionLabelAdd(ctx)
  29261. case sopnode.FieldActionLabelDel:
  29262. return m.OldActionLabelDel(ctx)
  29263. case sopnode.FieldActionForward:
  29264. return m.OldActionForward(ctx)
  29265. }
  29266. return nil, fmt.Errorf("unknown SopNode field %s", name)
  29267. }
  29268. // SetField sets the value of a field with the given name. It returns an error if
  29269. // the field is not defined in the schema, or if the type mismatched the field
  29270. // type.
  29271. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  29272. switch name {
  29273. case sopnode.FieldCreatedAt:
  29274. v, ok := value.(time.Time)
  29275. if !ok {
  29276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29277. }
  29278. m.SetCreatedAt(v)
  29279. return nil
  29280. case sopnode.FieldUpdatedAt:
  29281. v, ok := value.(time.Time)
  29282. if !ok {
  29283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29284. }
  29285. m.SetUpdatedAt(v)
  29286. return nil
  29287. case sopnode.FieldStatus:
  29288. v, ok := value.(uint8)
  29289. if !ok {
  29290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29291. }
  29292. m.SetStatus(v)
  29293. return nil
  29294. case sopnode.FieldDeletedAt:
  29295. v, ok := value.(time.Time)
  29296. if !ok {
  29297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29298. }
  29299. m.SetDeletedAt(v)
  29300. return nil
  29301. case sopnode.FieldStageID:
  29302. v, ok := value.(uint64)
  29303. if !ok {
  29304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29305. }
  29306. m.SetStageID(v)
  29307. return nil
  29308. case sopnode.FieldParentID:
  29309. v, ok := value.(uint64)
  29310. if !ok {
  29311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29312. }
  29313. m.SetParentID(v)
  29314. return nil
  29315. case sopnode.FieldName:
  29316. v, ok := value.(string)
  29317. if !ok {
  29318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29319. }
  29320. m.SetName(v)
  29321. return nil
  29322. case sopnode.FieldConditionType:
  29323. v, ok := value.(int)
  29324. if !ok {
  29325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29326. }
  29327. m.SetConditionType(v)
  29328. return nil
  29329. case sopnode.FieldConditionList:
  29330. v, ok := value.([]string)
  29331. if !ok {
  29332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29333. }
  29334. m.SetConditionList(v)
  29335. return nil
  29336. case sopnode.FieldNoReplyCondition:
  29337. v, ok := value.(uint64)
  29338. if !ok {
  29339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29340. }
  29341. m.SetNoReplyCondition(v)
  29342. return nil
  29343. case sopnode.FieldNoReplyUnit:
  29344. v, ok := value.(string)
  29345. if !ok {
  29346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29347. }
  29348. m.SetNoReplyUnit(v)
  29349. return nil
  29350. case sopnode.FieldActionMessage:
  29351. v, ok := value.([]custom_types.Action)
  29352. if !ok {
  29353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29354. }
  29355. m.SetActionMessage(v)
  29356. return nil
  29357. case sopnode.FieldActionLabelAdd:
  29358. v, ok := value.([]uint64)
  29359. if !ok {
  29360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29361. }
  29362. m.SetActionLabelAdd(v)
  29363. return nil
  29364. case sopnode.FieldActionLabelDel:
  29365. v, ok := value.([]uint64)
  29366. if !ok {
  29367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29368. }
  29369. m.SetActionLabelDel(v)
  29370. return nil
  29371. case sopnode.FieldActionForward:
  29372. v, ok := value.(*custom_types.ActionForward)
  29373. if !ok {
  29374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29375. }
  29376. m.SetActionForward(v)
  29377. return nil
  29378. }
  29379. return fmt.Errorf("unknown SopNode field %s", name)
  29380. }
  29381. // AddedFields returns all numeric fields that were incremented/decremented during
  29382. // this mutation.
  29383. func (m *SopNodeMutation) AddedFields() []string {
  29384. var fields []string
  29385. if m.addstatus != nil {
  29386. fields = append(fields, sopnode.FieldStatus)
  29387. }
  29388. if m.addparent_id != nil {
  29389. fields = append(fields, sopnode.FieldParentID)
  29390. }
  29391. if m.addcondition_type != nil {
  29392. fields = append(fields, sopnode.FieldConditionType)
  29393. }
  29394. if m.addno_reply_condition != nil {
  29395. fields = append(fields, sopnode.FieldNoReplyCondition)
  29396. }
  29397. return fields
  29398. }
  29399. // AddedField returns the numeric value that was incremented/decremented on a field
  29400. // with the given name. The second boolean return value indicates that this field
  29401. // was not set, or was not defined in the schema.
  29402. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  29403. switch name {
  29404. case sopnode.FieldStatus:
  29405. return m.AddedStatus()
  29406. case sopnode.FieldParentID:
  29407. return m.AddedParentID()
  29408. case sopnode.FieldConditionType:
  29409. return m.AddedConditionType()
  29410. case sopnode.FieldNoReplyCondition:
  29411. return m.AddedNoReplyCondition()
  29412. }
  29413. return nil, false
  29414. }
  29415. // AddField adds the value to the field with the given name. It returns an error if
  29416. // the field is not defined in the schema, or if the type mismatched the field
  29417. // type.
  29418. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  29419. switch name {
  29420. case sopnode.FieldStatus:
  29421. v, ok := value.(int8)
  29422. if !ok {
  29423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29424. }
  29425. m.AddStatus(v)
  29426. return nil
  29427. case sopnode.FieldParentID:
  29428. v, ok := value.(int64)
  29429. if !ok {
  29430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29431. }
  29432. m.AddParentID(v)
  29433. return nil
  29434. case sopnode.FieldConditionType:
  29435. v, ok := value.(int)
  29436. if !ok {
  29437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29438. }
  29439. m.AddConditionType(v)
  29440. return nil
  29441. case sopnode.FieldNoReplyCondition:
  29442. v, ok := value.(int64)
  29443. if !ok {
  29444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29445. }
  29446. m.AddNoReplyCondition(v)
  29447. return nil
  29448. }
  29449. return fmt.Errorf("unknown SopNode numeric field %s", name)
  29450. }
  29451. // ClearedFields returns all nullable fields that were cleared during this
  29452. // mutation.
  29453. func (m *SopNodeMutation) ClearedFields() []string {
  29454. var fields []string
  29455. if m.FieldCleared(sopnode.FieldStatus) {
  29456. fields = append(fields, sopnode.FieldStatus)
  29457. }
  29458. if m.FieldCleared(sopnode.FieldDeletedAt) {
  29459. fields = append(fields, sopnode.FieldDeletedAt)
  29460. }
  29461. if m.FieldCleared(sopnode.FieldConditionList) {
  29462. fields = append(fields, sopnode.FieldConditionList)
  29463. }
  29464. if m.FieldCleared(sopnode.FieldActionMessage) {
  29465. fields = append(fields, sopnode.FieldActionMessage)
  29466. }
  29467. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  29468. fields = append(fields, sopnode.FieldActionLabelAdd)
  29469. }
  29470. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  29471. fields = append(fields, sopnode.FieldActionLabelDel)
  29472. }
  29473. if m.FieldCleared(sopnode.FieldActionForward) {
  29474. fields = append(fields, sopnode.FieldActionForward)
  29475. }
  29476. return fields
  29477. }
  29478. // FieldCleared returns a boolean indicating if a field with the given name was
  29479. // cleared in this mutation.
  29480. func (m *SopNodeMutation) FieldCleared(name string) bool {
  29481. _, ok := m.clearedFields[name]
  29482. return ok
  29483. }
  29484. // ClearField clears the value of the field with the given name. It returns an
  29485. // error if the field is not defined in the schema.
  29486. func (m *SopNodeMutation) ClearField(name string) error {
  29487. switch name {
  29488. case sopnode.FieldStatus:
  29489. m.ClearStatus()
  29490. return nil
  29491. case sopnode.FieldDeletedAt:
  29492. m.ClearDeletedAt()
  29493. return nil
  29494. case sopnode.FieldConditionList:
  29495. m.ClearConditionList()
  29496. return nil
  29497. case sopnode.FieldActionMessage:
  29498. m.ClearActionMessage()
  29499. return nil
  29500. case sopnode.FieldActionLabelAdd:
  29501. m.ClearActionLabelAdd()
  29502. return nil
  29503. case sopnode.FieldActionLabelDel:
  29504. m.ClearActionLabelDel()
  29505. return nil
  29506. case sopnode.FieldActionForward:
  29507. m.ClearActionForward()
  29508. return nil
  29509. }
  29510. return fmt.Errorf("unknown SopNode nullable field %s", name)
  29511. }
  29512. // ResetField resets all changes in the mutation for the field with the given name.
  29513. // It returns an error if the field is not defined in the schema.
  29514. func (m *SopNodeMutation) ResetField(name string) error {
  29515. switch name {
  29516. case sopnode.FieldCreatedAt:
  29517. m.ResetCreatedAt()
  29518. return nil
  29519. case sopnode.FieldUpdatedAt:
  29520. m.ResetUpdatedAt()
  29521. return nil
  29522. case sopnode.FieldStatus:
  29523. m.ResetStatus()
  29524. return nil
  29525. case sopnode.FieldDeletedAt:
  29526. m.ResetDeletedAt()
  29527. return nil
  29528. case sopnode.FieldStageID:
  29529. m.ResetStageID()
  29530. return nil
  29531. case sopnode.FieldParentID:
  29532. m.ResetParentID()
  29533. return nil
  29534. case sopnode.FieldName:
  29535. m.ResetName()
  29536. return nil
  29537. case sopnode.FieldConditionType:
  29538. m.ResetConditionType()
  29539. return nil
  29540. case sopnode.FieldConditionList:
  29541. m.ResetConditionList()
  29542. return nil
  29543. case sopnode.FieldNoReplyCondition:
  29544. m.ResetNoReplyCondition()
  29545. return nil
  29546. case sopnode.FieldNoReplyUnit:
  29547. m.ResetNoReplyUnit()
  29548. return nil
  29549. case sopnode.FieldActionMessage:
  29550. m.ResetActionMessage()
  29551. return nil
  29552. case sopnode.FieldActionLabelAdd:
  29553. m.ResetActionLabelAdd()
  29554. return nil
  29555. case sopnode.FieldActionLabelDel:
  29556. m.ResetActionLabelDel()
  29557. return nil
  29558. case sopnode.FieldActionForward:
  29559. m.ResetActionForward()
  29560. return nil
  29561. }
  29562. return fmt.Errorf("unknown SopNode field %s", name)
  29563. }
  29564. // AddedEdges returns all edge names that were set/added in this mutation.
  29565. func (m *SopNodeMutation) AddedEdges() []string {
  29566. edges := make([]string, 0, 2)
  29567. if m.sop_stage != nil {
  29568. edges = append(edges, sopnode.EdgeSopStage)
  29569. }
  29570. if m.node_messages != nil {
  29571. edges = append(edges, sopnode.EdgeNodeMessages)
  29572. }
  29573. return edges
  29574. }
  29575. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29576. // name in this mutation.
  29577. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  29578. switch name {
  29579. case sopnode.EdgeSopStage:
  29580. if id := m.sop_stage; id != nil {
  29581. return []ent.Value{*id}
  29582. }
  29583. case sopnode.EdgeNodeMessages:
  29584. ids := make([]ent.Value, 0, len(m.node_messages))
  29585. for id := range m.node_messages {
  29586. ids = append(ids, id)
  29587. }
  29588. return ids
  29589. }
  29590. return nil
  29591. }
  29592. // RemovedEdges returns all edge names that were removed in this mutation.
  29593. func (m *SopNodeMutation) RemovedEdges() []string {
  29594. edges := make([]string, 0, 2)
  29595. if m.removednode_messages != nil {
  29596. edges = append(edges, sopnode.EdgeNodeMessages)
  29597. }
  29598. return edges
  29599. }
  29600. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29601. // the given name in this mutation.
  29602. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  29603. switch name {
  29604. case sopnode.EdgeNodeMessages:
  29605. ids := make([]ent.Value, 0, len(m.removednode_messages))
  29606. for id := range m.removednode_messages {
  29607. ids = append(ids, id)
  29608. }
  29609. return ids
  29610. }
  29611. return nil
  29612. }
  29613. // ClearedEdges returns all edge names that were cleared in this mutation.
  29614. func (m *SopNodeMutation) ClearedEdges() []string {
  29615. edges := make([]string, 0, 2)
  29616. if m.clearedsop_stage {
  29617. edges = append(edges, sopnode.EdgeSopStage)
  29618. }
  29619. if m.clearednode_messages {
  29620. edges = append(edges, sopnode.EdgeNodeMessages)
  29621. }
  29622. return edges
  29623. }
  29624. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29625. // was cleared in this mutation.
  29626. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  29627. switch name {
  29628. case sopnode.EdgeSopStage:
  29629. return m.clearedsop_stage
  29630. case sopnode.EdgeNodeMessages:
  29631. return m.clearednode_messages
  29632. }
  29633. return false
  29634. }
  29635. // ClearEdge clears the value of the edge with the given name. It returns an error
  29636. // if that edge is not defined in the schema.
  29637. func (m *SopNodeMutation) ClearEdge(name string) error {
  29638. switch name {
  29639. case sopnode.EdgeSopStage:
  29640. m.ClearSopStage()
  29641. return nil
  29642. }
  29643. return fmt.Errorf("unknown SopNode unique edge %s", name)
  29644. }
  29645. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29646. // It returns an error if the edge is not defined in the schema.
  29647. func (m *SopNodeMutation) ResetEdge(name string) error {
  29648. switch name {
  29649. case sopnode.EdgeSopStage:
  29650. m.ResetSopStage()
  29651. return nil
  29652. case sopnode.EdgeNodeMessages:
  29653. m.ResetNodeMessages()
  29654. return nil
  29655. }
  29656. return fmt.Errorf("unknown SopNode edge %s", name)
  29657. }
  29658. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  29659. type SopStageMutation struct {
  29660. config
  29661. op Op
  29662. typ string
  29663. id *uint64
  29664. created_at *time.Time
  29665. updated_at *time.Time
  29666. status *uint8
  29667. addstatus *int8
  29668. deleted_at *time.Time
  29669. name *string
  29670. condition_type *int
  29671. addcondition_type *int
  29672. condition_operator *int
  29673. addcondition_operator *int
  29674. condition_list *[]custom_types.Condition
  29675. appendcondition_list []custom_types.Condition
  29676. action_message *[]custom_types.Action
  29677. appendaction_message []custom_types.Action
  29678. action_label_add *[]uint64
  29679. appendaction_label_add []uint64
  29680. action_label_del *[]uint64
  29681. appendaction_label_del []uint64
  29682. action_forward **custom_types.ActionForward
  29683. index_sort *int
  29684. addindex_sort *int
  29685. clearedFields map[string]struct{}
  29686. sop_task *uint64
  29687. clearedsop_task bool
  29688. stage_nodes map[uint64]struct{}
  29689. removedstage_nodes map[uint64]struct{}
  29690. clearedstage_nodes bool
  29691. stage_messages map[uint64]struct{}
  29692. removedstage_messages map[uint64]struct{}
  29693. clearedstage_messages bool
  29694. done bool
  29695. oldValue func(context.Context) (*SopStage, error)
  29696. predicates []predicate.SopStage
  29697. }
  29698. var _ ent.Mutation = (*SopStageMutation)(nil)
  29699. // sopstageOption allows management of the mutation configuration using functional options.
  29700. type sopstageOption func(*SopStageMutation)
  29701. // newSopStageMutation creates new mutation for the SopStage entity.
  29702. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  29703. m := &SopStageMutation{
  29704. config: c,
  29705. op: op,
  29706. typ: TypeSopStage,
  29707. clearedFields: make(map[string]struct{}),
  29708. }
  29709. for _, opt := range opts {
  29710. opt(m)
  29711. }
  29712. return m
  29713. }
  29714. // withSopStageID sets the ID field of the mutation.
  29715. func withSopStageID(id uint64) sopstageOption {
  29716. return func(m *SopStageMutation) {
  29717. var (
  29718. err error
  29719. once sync.Once
  29720. value *SopStage
  29721. )
  29722. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  29723. once.Do(func() {
  29724. if m.done {
  29725. err = errors.New("querying old values post mutation is not allowed")
  29726. } else {
  29727. value, err = m.Client().SopStage.Get(ctx, id)
  29728. }
  29729. })
  29730. return value, err
  29731. }
  29732. m.id = &id
  29733. }
  29734. }
  29735. // withSopStage sets the old SopStage of the mutation.
  29736. func withSopStage(node *SopStage) sopstageOption {
  29737. return func(m *SopStageMutation) {
  29738. m.oldValue = func(context.Context) (*SopStage, error) {
  29739. return node, nil
  29740. }
  29741. m.id = &node.ID
  29742. }
  29743. }
  29744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29745. // executed in a transaction (ent.Tx), a transactional client is returned.
  29746. func (m SopStageMutation) Client() *Client {
  29747. client := &Client{config: m.config}
  29748. client.init()
  29749. return client
  29750. }
  29751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29752. // it returns an error otherwise.
  29753. func (m SopStageMutation) Tx() (*Tx, error) {
  29754. if _, ok := m.driver.(*txDriver); !ok {
  29755. return nil, errors.New("ent: mutation is not running in a transaction")
  29756. }
  29757. tx := &Tx{config: m.config}
  29758. tx.init()
  29759. return tx, nil
  29760. }
  29761. // SetID sets the value of the id field. Note that this
  29762. // operation is only accepted on creation of SopStage entities.
  29763. func (m *SopStageMutation) SetID(id uint64) {
  29764. m.id = &id
  29765. }
  29766. // ID returns the ID value in the mutation. Note that the ID is only available
  29767. // if it was provided to the builder or after it was returned from the database.
  29768. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  29769. if m.id == nil {
  29770. return
  29771. }
  29772. return *m.id, true
  29773. }
  29774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29775. // That means, if the mutation is applied within a transaction with an isolation level such
  29776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29777. // or updated by the mutation.
  29778. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  29779. switch {
  29780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29781. id, exists := m.ID()
  29782. if exists {
  29783. return []uint64{id}, nil
  29784. }
  29785. fallthrough
  29786. case m.op.Is(OpUpdate | OpDelete):
  29787. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  29788. default:
  29789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29790. }
  29791. }
  29792. // SetCreatedAt sets the "created_at" field.
  29793. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  29794. m.created_at = &t
  29795. }
  29796. // CreatedAt returns the value of the "created_at" field in the mutation.
  29797. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  29798. v := m.created_at
  29799. if v == nil {
  29800. return
  29801. }
  29802. return *v, true
  29803. }
  29804. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  29805. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29807. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29808. if !m.op.Is(OpUpdateOne) {
  29809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29810. }
  29811. if m.id == nil || m.oldValue == nil {
  29812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29813. }
  29814. oldValue, err := m.oldValue(ctx)
  29815. if err != nil {
  29816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29817. }
  29818. return oldValue.CreatedAt, nil
  29819. }
  29820. // ResetCreatedAt resets all changes to the "created_at" field.
  29821. func (m *SopStageMutation) ResetCreatedAt() {
  29822. m.created_at = nil
  29823. }
  29824. // SetUpdatedAt sets the "updated_at" field.
  29825. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  29826. m.updated_at = &t
  29827. }
  29828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29829. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  29830. v := m.updated_at
  29831. if v == nil {
  29832. return
  29833. }
  29834. return *v, true
  29835. }
  29836. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  29837. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29839. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29840. if !m.op.Is(OpUpdateOne) {
  29841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29842. }
  29843. if m.id == nil || m.oldValue == nil {
  29844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29845. }
  29846. oldValue, err := m.oldValue(ctx)
  29847. if err != nil {
  29848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29849. }
  29850. return oldValue.UpdatedAt, nil
  29851. }
  29852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29853. func (m *SopStageMutation) ResetUpdatedAt() {
  29854. m.updated_at = nil
  29855. }
  29856. // SetStatus sets the "status" field.
  29857. func (m *SopStageMutation) SetStatus(u uint8) {
  29858. m.status = &u
  29859. m.addstatus = nil
  29860. }
  29861. // Status returns the value of the "status" field in the mutation.
  29862. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  29863. v := m.status
  29864. if v == nil {
  29865. return
  29866. }
  29867. return *v, true
  29868. }
  29869. // OldStatus returns the old "status" field's value of the SopStage entity.
  29870. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29872. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29873. if !m.op.Is(OpUpdateOne) {
  29874. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29875. }
  29876. if m.id == nil || m.oldValue == nil {
  29877. return v, errors.New("OldStatus requires an ID field in the mutation")
  29878. }
  29879. oldValue, err := m.oldValue(ctx)
  29880. if err != nil {
  29881. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29882. }
  29883. return oldValue.Status, nil
  29884. }
  29885. // AddStatus adds u to the "status" field.
  29886. func (m *SopStageMutation) AddStatus(u int8) {
  29887. if m.addstatus != nil {
  29888. *m.addstatus += u
  29889. } else {
  29890. m.addstatus = &u
  29891. }
  29892. }
  29893. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29894. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  29895. v := m.addstatus
  29896. if v == nil {
  29897. return
  29898. }
  29899. return *v, true
  29900. }
  29901. // ClearStatus clears the value of the "status" field.
  29902. func (m *SopStageMutation) ClearStatus() {
  29903. m.status = nil
  29904. m.addstatus = nil
  29905. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  29906. }
  29907. // StatusCleared returns if the "status" field was cleared in this mutation.
  29908. func (m *SopStageMutation) StatusCleared() bool {
  29909. _, ok := m.clearedFields[sopstage.FieldStatus]
  29910. return ok
  29911. }
  29912. // ResetStatus resets all changes to the "status" field.
  29913. func (m *SopStageMutation) ResetStatus() {
  29914. m.status = nil
  29915. m.addstatus = nil
  29916. delete(m.clearedFields, sopstage.FieldStatus)
  29917. }
  29918. // SetDeletedAt sets the "deleted_at" field.
  29919. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  29920. m.deleted_at = &t
  29921. }
  29922. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29923. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  29924. v := m.deleted_at
  29925. if v == nil {
  29926. return
  29927. }
  29928. return *v, true
  29929. }
  29930. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  29931. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29933. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29934. if !m.op.Is(OpUpdateOne) {
  29935. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29936. }
  29937. if m.id == nil || m.oldValue == nil {
  29938. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29939. }
  29940. oldValue, err := m.oldValue(ctx)
  29941. if err != nil {
  29942. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29943. }
  29944. return oldValue.DeletedAt, nil
  29945. }
  29946. // ClearDeletedAt clears the value of the "deleted_at" field.
  29947. func (m *SopStageMutation) ClearDeletedAt() {
  29948. m.deleted_at = nil
  29949. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  29950. }
  29951. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29952. func (m *SopStageMutation) DeletedAtCleared() bool {
  29953. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  29954. return ok
  29955. }
  29956. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29957. func (m *SopStageMutation) ResetDeletedAt() {
  29958. m.deleted_at = nil
  29959. delete(m.clearedFields, sopstage.FieldDeletedAt)
  29960. }
  29961. // SetTaskID sets the "task_id" field.
  29962. func (m *SopStageMutation) SetTaskID(u uint64) {
  29963. m.sop_task = &u
  29964. }
  29965. // TaskID returns the value of the "task_id" field in the mutation.
  29966. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  29967. v := m.sop_task
  29968. if v == nil {
  29969. return
  29970. }
  29971. return *v, true
  29972. }
  29973. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  29974. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29976. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  29977. if !m.op.Is(OpUpdateOne) {
  29978. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  29979. }
  29980. if m.id == nil || m.oldValue == nil {
  29981. return v, errors.New("OldTaskID requires an ID field in the mutation")
  29982. }
  29983. oldValue, err := m.oldValue(ctx)
  29984. if err != nil {
  29985. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  29986. }
  29987. return oldValue.TaskID, nil
  29988. }
  29989. // ResetTaskID resets all changes to the "task_id" field.
  29990. func (m *SopStageMutation) ResetTaskID() {
  29991. m.sop_task = nil
  29992. }
  29993. // SetName sets the "name" field.
  29994. func (m *SopStageMutation) SetName(s string) {
  29995. m.name = &s
  29996. }
  29997. // Name returns the value of the "name" field in the mutation.
  29998. func (m *SopStageMutation) Name() (r string, exists bool) {
  29999. v := m.name
  30000. if v == nil {
  30001. return
  30002. }
  30003. return *v, true
  30004. }
  30005. // OldName returns the old "name" field's value of the SopStage entity.
  30006. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30008. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  30009. if !m.op.Is(OpUpdateOne) {
  30010. return v, errors.New("OldName is only allowed on UpdateOne operations")
  30011. }
  30012. if m.id == nil || m.oldValue == nil {
  30013. return v, errors.New("OldName requires an ID field in the mutation")
  30014. }
  30015. oldValue, err := m.oldValue(ctx)
  30016. if err != nil {
  30017. return v, fmt.Errorf("querying old value for OldName: %w", err)
  30018. }
  30019. return oldValue.Name, nil
  30020. }
  30021. // ResetName resets all changes to the "name" field.
  30022. func (m *SopStageMutation) ResetName() {
  30023. m.name = nil
  30024. }
  30025. // SetConditionType sets the "condition_type" field.
  30026. func (m *SopStageMutation) SetConditionType(i int) {
  30027. m.condition_type = &i
  30028. m.addcondition_type = nil
  30029. }
  30030. // ConditionType returns the value of the "condition_type" field in the mutation.
  30031. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  30032. v := m.condition_type
  30033. if v == nil {
  30034. return
  30035. }
  30036. return *v, true
  30037. }
  30038. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  30039. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30041. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  30042. if !m.op.Is(OpUpdateOne) {
  30043. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  30044. }
  30045. if m.id == nil || m.oldValue == nil {
  30046. return v, errors.New("OldConditionType requires an ID field in the mutation")
  30047. }
  30048. oldValue, err := m.oldValue(ctx)
  30049. if err != nil {
  30050. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  30051. }
  30052. return oldValue.ConditionType, nil
  30053. }
  30054. // AddConditionType adds i to the "condition_type" field.
  30055. func (m *SopStageMutation) AddConditionType(i int) {
  30056. if m.addcondition_type != nil {
  30057. *m.addcondition_type += i
  30058. } else {
  30059. m.addcondition_type = &i
  30060. }
  30061. }
  30062. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  30063. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  30064. v := m.addcondition_type
  30065. if v == nil {
  30066. return
  30067. }
  30068. return *v, true
  30069. }
  30070. // ResetConditionType resets all changes to the "condition_type" field.
  30071. func (m *SopStageMutation) ResetConditionType() {
  30072. m.condition_type = nil
  30073. m.addcondition_type = nil
  30074. }
  30075. // SetConditionOperator sets the "condition_operator" field.
  30076. func (m *SopStageMutation) SetConditionOperator(i int) {
  30077. m.condition_operator = &i
  30078. m.addcondition_operator = nil
  30079. }
  30080. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  30081. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  30082. v := m.condition_operator
  30083. if v == nil {
  30084. return
  30085. }
  30086. return *v, true
  30087. }
  30088. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  30089. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30091. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  30092. if !m.op.Is(OpUpdateOne) {
  30093. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  30094. }
  30095. if m.id == nil || m.oldValue == nil {
  30096. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  30097. }
  30098. oldValue, err := m.oldValue(ctx)
  30099. if err != nil {
  30100. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  30101. }
  30102. return oldValue.ConditionOperator, nil
  30103. }
  30104. // AddConditionOperator adds i to the "condition_operator" field.
  30105. func (m *SopStageMutation) AddConditionOperator(i int) {
  30106. if m.addcondition_operator != nil {
  30107. *m.addcondition_operator += i
  30108. } else {
  30109. m.addcondition_operator = &i
  30110. }
  30111. }
  30112. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  30113. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  30114. v := m.addcondition_operator
  30115. if v == nil {
  30116. return
  30117. }
  30118. return *v, true
  30119. }
  30120. // ResetConditionOperator resets all changes to the "condition_operator" field.
  30121. func (m *SopStageMutation) ResetConditionOperator() {
  30122. m.condition_operator = nil
  30123. m.addcondition_operator = nil
  30124. }
  30125. // SetConditionList sets the "condition_list" field.
  30126. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  30127. m.condition_list = &ct
  30128. m.appendcondition_list = nil
  30129. }
  30130. // ConditionList returns the value of the "condition_list" field in the mutation.
  30131. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  30132. v := m.condition_list
  30133. if v == nil {
  30134. return
  30135. }
  30136. return *v, true
  30137. }
  30138. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  30139. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30141. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  30142. if !m.op.Is(OpUpdateOne) {
  30143. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  30144. }
  30145. if m.id == nil || m.oldValue == nil {
  30146. return v, errors.New("OldConditionList requires an ID field in the mutation")
  30147. }
  30148. oldValue, err := m.oldValue(ctx)
  30149. if err != nil {
  30150. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  30151. }
  30152. return oldValue.ConditionList, nil
  30153. }
  30154. // AppendConditionList adds ct to the "condition_list" field.
  30155. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  30156. m.appendcondition_list = append(m.appendcondition_list, ct...)
  30157. }
  30158. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  30159. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  30160. if len(m.appendcondition_list) == 0 {
  30161. return nil, false
  30162. }
  30163. return m.appendcondition_list, true
  30164. }
  30165. // ResetConditionList resets all changes to the "condition_list" field.
  30166. func (m *SopStageMutation) ResetConditionList() {
  30167. m.condition_list = nil
  30168. m.appendcondition_list = nil
  30169. }
  30170. // SetActionMessage sets the "action_message" field.
  30171. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  30172. m.action_message = &ct
  30173. m.appendaction_message = nil
  30174. }
  30175. // ActionMessage returns the value of the "action_message" field in the mutation.
  30176. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  30177. v := m.action_message
  30178. if v == nil {
  30179. return
  30180. }
  30181. return *v, true
  30182. }
  30183. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  30184. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30186. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  30187. if !m.op.Is(OpUpdateOne) {
  30188. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  30189. }
  30190. if m.id == nil || m.oldValue == nil {
  30191. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  30192. }
  30193. oldValue, err := m.oldValue(ctx)
  30194. if err != nil {
  30195. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  30196. }
  30197. return oldValue.ActionMessage, nil
  30198. }
  30199. // AppendActionMessage adds ct to the "action_message" field.
  30200. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  30201. m.appendaction_message = append(m.appendaction_message, ct...)
  30202. }
  30203. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  30204. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  30205. if len(m.appendaction_message) == 0 {
  30206. return nil, false
  30207. }
  30208. return m.appendaction_message, true
  30209. }
  30210. // ClearActionMessage clears the value of the "action_message" field.
  30211. func (m *SopStageMutation) ClearActionMessage() {
  30212. m.action_message = nil
  30213. m.appendaction_message = nil
  30214. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  30215. }
  30216. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  30217. func (m *SopStageMutation) ActionMessageCleared() bool {
  30218. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  30219. return ok
  30220. }
  30221. // ResetActionMessage resets all changes to the "action_message" field.
  30222. func (m *SopStageMutation) ResetActionMessage() {
  30223. m.action_message = nil
  30224. m.appendaction_message = nil
  30225. delete(m.clearedFields, sopstage.FieldActionMessage)
  30226. }
  30227. // SetActionLabelAdd sets the "action_label_add" field.
  30228. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  30229. m.action_label_add = &u
  30230. m.appendaction_label_add = nil
  30231. }
  30232. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  30233. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  30234. v := m.action_label_add
  30235. if v == nil {
  30236. return
  30237. }
  30238. return *v, true
  30239. }
  30240. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  30241. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30243. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  30244. if !m.op.Is(OpUpdateOne) {
  30245. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  30246. }
  30247. if m.id == nil || m.oldValue == nil {
  30248. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  30249. }
  30250. oldValue, err := m.oldValue(ctx)
  30251. if err != nil {
  30252. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  30253. }
  30254. return oldValue.ActionLabelAdd, nil
  30255. }
  30256. // AppendActionLabelAdd adds u to the "action_label_add" field.
  30257. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  30258. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  30259. }
  30260. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  30261. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  30262. if len(m.appendaction_label_add) == 0 {
  30263. return nil, false
  30264. }
  30265. return m.appendaction_label_add, true
  30266. }
  30267. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  30268. func (m *SopStageMutation) ClearActionLabelAdd() {
  30269. m.action_label_add = nil
  30270. m.appendaction_label_add = nil
  30271. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  30272. }
  30273. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  30274. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  30275. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  30276. return ok
  30277. }
  30278. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  30279. func (m *SopStageMutation) ResetActionLabelAdd() {
  30280. m.action_label_add = nil
  30281. m.appendaction_label_add = nil
  30282. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  30283. }
  30284. // SetActionLabelDel sets the "action_label_del" field.
  30285. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  30286. m.action_label_del = &u
  30287. m.appendaction_label_del = nil
  30288. }
  30289. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  30290. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  30291. v := m.action_label_del
  30292. if v == nil {
  30293. return
  30294. }
  30295. return *v, true
  30296. }
  30297. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  30298. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30300. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  30301. if !m.op.Is(OpUpdateOne) {
  30302. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  30303. }
  30304. if m.id == nil || m.oldValue == nil {
  30305. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  30306. }
  30307. oldValue, err := m.oldValue(ctx)
  30308. if err != nil {
  30309. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  30310. }
  30311. return oldValue.ActionLabelDel, nil
  30312. }
  30313. // AppendActionLabelDel adds u to the "action_label_del" field.
  30314. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  30315. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  30316. }
  30317. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  30318. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  30319. if len(m.appendaction_label_del) == 0 {
  30320. return nil, false
  30321. }
  30322. return m.appendaction_label_del, true
  30323. }
  30324. // ClearActionLabelDel clears the value of the "action_label_del" field.
  30325. func (m *SopStageMutation) ClearActionLabelDel() {
  30326. m.action_label_del = nil
  30327. m.appendaction_label_del = nil
  30328. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  30329. }
  30330. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  30331. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  30332. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  30333. return ok
  30334. }
  30335. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  30336. func (m *SopStageMutation) ResetActionLabelDel() {
  30337. m.action_label_del = nil
  30338. m.appendaction_label_del = nil
  30339. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  30340. }
  30341. // SetActionForward sets the "action_forward" field.
  30342. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  30343. m.action_forward = &ctf
  30344. }
  30345. // ActionForward returns the value of the "action_forward" field in the mutation.
  30346. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  30347. v := m.action_forward
  30348. if v == nil {
  30349. return
  30350. }
  30351. return *v, true
  30352. }
  30353. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  30354. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30356. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  30357. if !m.op.Is(OpUpdateOne) {
  30358. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  30359. }
  30360. if m.id == nil || m.oldValue == nil {
  30361. return v, errors.New("OldActionForward requires an ID field in the mutation")
  30362. }
  30363. oldValue, err := m.oldValue(ctx)
  30364. if err != nil {
  30365. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  30366. }
  30367. return oldValue.ActionForward, nil
  30368. }
  30369. // ClearActionForward clears the value of the "action_forward" field.
  30370. func (m *SopStageMutation) ClearActionForward() {
  30371. m.action_forward = nil
  30372. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  30373. }
  30374. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  30375. func (m *SopStageMutation) ActionForwardCleared() bool {
  30376. _, ok := m.clearedFields[sopstage.FieldActionForward]
  30377. return ok
  30378. }
  30379. // ResetActionForward resets all changes to the "action_forward" field.
  30380. func (m *SopStageMutation) ResetActionForward() {
  30381. m.action_forward = nil
  30382. delete(m.clearedFields, sopstage.FieldActionForward)
  30383. }
  30384. // SetIndexSort sets the "index_sort" field.
  30385. func (m *SopStageMutation) SetIndexSort(i int) {
  30386. m.index_sort = &i
  30387. m.addindex_sort = nil
  30388. }
  30389. // IndexSort returns the value of the "index_sort" field in the mutation.
  30390. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  30391. v := m.index_sort
  30392. if v == nil {
  30393. return
  30394. }
  30395. return *v, true
  30396. }
  30397. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  30398. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30400. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  30401. if !m.op.Is(OpUpdateOne) {
  30402. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  30403. }
  30404. if m.id == nil || m.oldValue == nil {
  30405. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  30406. }
  30407. oldValue, err := m.oldValue(ctx)
  30408. if err != nil {
  30409. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  30410. }
  30411. return oldValue.IndexSort, nil
  30412. }
  30413. // AddIndexSort adds i to the "index_sort" field.
  30414. func (m *SopStageMutation) AddIndexSort(i int) {
  30415. if m.addindex_sort != nil {
  30416. *m.addindex_sort += i
  30417. } else {
  30418. m.addindex_sort = &i
  30419. }
  30420. }
  30421. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  30422. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  30423. v := m.addindex_sort
  30424. if v == nil {
  30425. return
  30426. }
  30427. return *v, true
  30428. }
  30429. // ClearIndexSort clears the value of the "index_sort" field.
  30430. func (m *SopStageMutation) ClearIndexSort() {
  30431. m.index_sort = nil
  30432. m.addindex_sort = nil
  30433. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  30434. }
  30435. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  30436. func (m *SopStageMutation) IndexSortCleared() bool {
  30437. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  30438. return ok
  30439. }
  30440. // ResetIndexSort resets all changes to the "index_sort" field.
  30441. func (m *SopStageMutation) ResetIndexSort() {
  30442. m.index_sort = nil
  30443. m.addindex_sort = nil
  30444. delete(m.clearedFields, sopstage.FieldIndexSort)
  30445. }
  30446. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  30447. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  30448. m.sop_task = &id
  30449. }
  30450. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  30451. func (m *SopStageMutation) ClearSopTask() {
  30452. m.clearedsop_task = true
  30453. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  30454. }
  30455. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  30456. func (m *SopStageMutation) SopTaskCleared() bool {
  30457. return m.clearedsop_task
  30458. }
  30459. // SopTaskID returns the "sop_task" edge ID in the mutation.
  30460. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  30461. if m.sop_task != nil {
  30462. return *m.sop_task, true
  30463. }
  30464. return
  30465. }
  30466. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  30467. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30468. // SopTaskID instead. It exists only for internal usage by the builders.
  30469. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  30470. if id := m.sop_task; id != nil {
  30471. ids = append(ids, *id)
  30472. }
  30473. return
  30474. }
  30475. // ResetSopTask resets all changes to the "sop_task" edge.
  30476. func (m *SopStageMutation) ResetSopTask() {
  30477. m.sop_task = nil
  30478. m.clearedsop_task = false
  30479. }
  30480. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  30481. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  30482. if m.stage_nodes == nil {
  30483. m.stage_nodes = make(map[uint64]struct{})
  30484. }
  30485. for i := range ids {
  30486. m.stage_nodes[ids[i]] = struct{}{}
  30487. }
  30488. }
  30489. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  30490. func (m *SopStageMutation) ClearStageNodes() {
  30491. m.clearedstage_nodes = true
  30492. }
  30493. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  30494. func (m *SopStageMutation) StageNodesCleared() bool {
  30495. return m.clearedstage_nodes
  30496. }
  30497. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  30498. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  30499. if m.removedstage_nodes == nil {
  30500. m.removedstage_nodes = make(map[uint64]struct{})
  30501. }
  30502. for i := range ids {
  30503. delete(m.stage_nodes, ids[i])
  30504. m.removedstage_nodes[ids[i]] = struct{}{}
  30505. }
  30506. }
  30507. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  30508. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  30509. for id := range m.removedstage_nodes {
  30510. ids = append(ids, id)
  30511. }
  30512. return
  30513. }
  30514. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  30515. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  30516. for id := range m.stage_nodes {
  30517. ids = append(ids, id)
  30518. }
  30519. return
  30520. }
  30521. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  30522. func (m *SopStageMutation) ResetStageNodes() {
  30523. m.stage_nodes = nil
  30524. m.clearedstage_nodes = false
  30525. m.removedstage_nodes = nil
  30526. }
  30527. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  30528. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  30529. if m.stage_messages == nil {
  30530. m.stage_messages = make(map[uint64]struct{})
  30531. }
  30532. for i := range ids {
  30533. m.stage_messages[ids[i]] = struct{}{}
  30534. }
  30535. }
  30536. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  30537. func (m *SopStageMutation) ClearStageMessages() {
  30538. m.clearedstage_messages = true
  30539. }
  30540. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  30541. func (m *SopStageMutation) StageMessagesCleared() bool {
  30542. return m.clearedstage_messages
  30543. }
  30544. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  30545. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  30546. if m.removedstage_messages == nil {
  30547. m.removedstage_messages = make(map[uint64]struct{})
  30548. }
  30549. for i := range ids {
  30550. delete(m.stage_messages, ids[i])
  30551. m.removedstage_messages[ids[i]] = struct{}{}
  30552. }
  30553. }
  30554. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  30555. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  30556. for id := range m.removedstage_messages {
  30557. ids = append(ids, id)
  30558. }
  30559. return
  30560. }
  30561. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  30562. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  30563. for id := range m.stage_messages {
  30564. ids = append(ids, id)
  30565. }
  30566. return
  30567. }
  30568. // ResetStageMessages resets all changes to the "stage_messages" edge.
  30569. func (m *SopStageMutation) ResetStageMessages() {
  30570. m.stage_messages = nil
  30571. m.clearedstage_messages = false
  30572. m.removedstage_messages = nil
  30573. }
  30574. // Where appends a list predicates to the SopStageMutation builder.
  30575. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  30576. m.predicates = append(m.predicates, ps...)
  30577. }
  30578. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  30579. // users can use type-assertion to append predicates that do not depend on any generated package.
  30580. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  30581. p := make([]predicate.SopStage, len(ps))
  30582. for i := range ps {
  30583. p[i] = ps[i]
  30584. }
  30585. m.Where(p...)
  30586. }
  30587. // Op returns the operation name.
  30588. func (m *SopStageMutation) Op() Op {
  30589. return m.op
  30590. }
  30591. // SetOp allows setting the mutation operation.
  30592. func (m *SopStageMutation) SetOp(op Op) {
  30593. m.op = op
  30594. }
  30595. // Type returns the node type of this mutation (SopStage).
  30596. func (m *SopStageMutation) Type() string {
  30597. return m.typ
  30598. }
  30599. // Fields returns all fields that were changed during this mutation. Note that in
  30600. // order to get all numeric fields that were incremented/decremented, call
  30601. // AddedFields().
  30602. func (m *SopStageMutation) Fields() []string {
  30603. fields := make([]string, 0, 14)
  30604. if m.created_at != nil {
  30605. fields = append(fields, sopstage.FieldCreatedAt)
  30606. }
  30607. if m.updated_at != nil {
  30608. fields = append(fields, sopstage.FieldUpdatedAt)
  30609. }
  30610. if m.status != nil {
  30611. fields = append(fields, sopstage.FieldStatus)
  30612. }
  30613. if m.deleted_at != nil {
  30614. fields = append(fields, sopstage.FieldDeletedAt)
  30615. }
  30616. if m.sop_task != nil {
  30617. fields = append(fields, sopstage.FieldTaskID)
  30618. }
  30619. if m.name != nil {
  30620. fields = append(fields, sopstage.FieldName)
  30621. }
  30622. if m.condition_type != nil {
  30623. fields = append(fields, sopstage.FieldConditionType)
  30624. }
  30625. if m.condition_operator != nil {
  30626. fields = append(fields, sopstage.FieldConditionOperator)
  30627. }
  30628. if m.condition_list != nil {
  30629. fields = append(fields, sopstage.FieldConditionList)
  30630. }
  30631. if m.action_message != nil {
  30632. fields = append(fields, sopstage.FieldActionMessage)
  30633. }
  30634. if m.action_label_add != nil {
  30635. fields = append(fields, sopstage.FieldActionLabelAdd)
  30636. }
  30637. if m.action_label_del != nil {
  30638. fields = append(fields, sopstage.FieldActionLabelDel)
  30639. }
  30640. if m.action_forward != nil {
  30641. fields = append(fields, sopstage.FieldActionForward)
  30642. }
  30643. if m.index_sort != nil {
  30644. fields = append(fields, sopstage.FieldIndexSort)
  30645. }
  30646. return fields
  30647. }
  30648. // Field returns the value of a field with the given name. The second boolean
  30649. // return value indicates that this field was not set, or was not defined in the
  30650. // schema.
  30651. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  30652. switch name {
  30653. case sopstage.FieldCreatedAt:
  30654. return m.CreatedAt()
  30655. case sopstage.FieldUpdatedAt:
  30656. return m.UpdatedAt()
  30657. case sopstage.FieldStatus:
  30658. return m.Status()
  30659. case sopstage.FieldDeletedAt:
  30660. return m.DeletedAt()
  30661. case sopstage.FieldTaskID:
  30662. return m.TaskID()
  30663. case sopstage.FieldName:
  30664. return m.Name()
  30665. case sopstage.FieldConditionType:
  30666. return m.ConditionType()
  30667. case sopstage.FieldConditionOperator:
  30668. return m.ConditionOperator()
  30669. case sopstage.FieldConditionList:
  30670. return m.ConditionList()
  30671. case sopstage.FieldActionMessage:
  30672. return m.ActionMessage()
  30673. case sopstage.FieldActionLabelAdd:
  30674. return m.ActionLabelAdd()
  30675. case sopstage.FieldActionLabelDel:
  30676. return m.ActionLabelDel()
  30677. case sopstage.FieldActionForward:
  30678. return m.ActionForward()
  30679. case sopstage.FieldIndexSort:
  30680. return m.IndexSort()
  30681. }
  30682. return nil, false
  30683. }
  30684. // OldField returns the old value of the field from the database. An error is
  30685. // returned if the mutation operation is not UpdateOne, or the query to the
  30686. // database failed.
  30687. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30688. switch name {
  30689. case sopstage.FieldCreatedAt:
  30690. return m.OldCreatedAt(ctx)
  30691. case sopstage.FieldUpdatedAt:
  30692. return m.OldUpdatedAt(ctx)
  30693. case sopstage.FieldStatus:
  30694. return m.OldStatus(ctx)
  30695. case sopstage.FieldDeletedAt:
  30696. return m.OldDeletedAt(ctx)
  30697. case sopstage.FieldTaskID:
  30698. return m.OldTaskID(ctx)
  30699. case sopstage.FieldName:
  30700. return m.OldName(ctx)
  30701. case sopstage.FieldConditionType:
  30702. return m.OldConditionType(ctx)
  30703. case sopstage.FieldConditionOperator:
  30704. return m.OldConditionOperator(ctx)
  30705. case sopstage.FieldConditionList:
  30706. return m.OldConditionList(ctx)
  30707. case sopstage.FieldActionMessage:
  30708. return m.OldActionMessage(ctx)
  30709. case sopstage.FieldActionLabelAdd:
  30710. return m.OldActionLabelAdd(ctx)
  30711. case sopstage.FieldActionLabelDel:
  30712. return m.OldActionLabelDel(ctx)
  30713. case sopstage.FieldActionForward:
  30714. return m.OldActionForward(ctx)
  30715. case sopstage.FieldIndexSort:
  30716. return m.OldIndexSort(ctx)
  30717. }
  30718. return nil, fmt.Errorf("unknown SopStage field %s", name)
  30719. }
  30720. // SetField sets the value of a field with the given name. It returns an error if
  30721. // the field is not defined in the schema, or if the type mismatched the field
  30722. // type.
  30723. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  30724. switch name {
  30725. case sopstage.FieldCreatedAt:
  30726. v, ok := value.(time.Time)
  30727. if !ok {
  30728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30729. }
  30730. m.SetCreatedAt(v)
  30731. return nil
  30732. case sopstage.FieldUpdatedAt:
  30733. v, ok := value.(time.Time)
  30734. if !ok {
  30735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30736. }
  30737. m.SetUpdatedAt(v)
  30738. return nil
  30739. case sopstage.FieldStatus:
  30740. v, ok := value.(uint8)
  30741. if !ok {
  30742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30743. }
  30744. m.SetStatus(v)
  30745. return nil
  30746. case sopstage.FieldDeletedAt:
  30747. v, ok := value.(time.Time)
  30748. if !ok {
  30749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30750. }
  30751. m.SetDeletedAt(v)
  30752. return nil
  30753. case sopstage.FieldTaskID:
  30754. v, ok := value.(uint64)
  30755. if !ok {
  30756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30757. }
  30758. m.SetTaskID(v)
  30759. return nil
  30760. case sopstage.FieldName:
  30761. v, ok := value.(string)
  30762. if !ok {
  30763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30764. }
  30765. m.SetName(v)
  30766. return nil
  30767. case sopstage.FieldConditionType:
  30768. v, ok := value.(int)
  30769. if !ok {
  30770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30771. }
  30772. m.SetConditionType(v)
  30773. return nil
  30774. case sopstage.FieldConditionOperator:
  30775. v, ok := value.(int)
  30776. if !ok {
  30777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30778. }
  30779. m.SetConditionOperator(v)
  30780. return nil
  30781. case sopstage.FieldConditionList:
  30782. v, ok := value.([]custom_types.Condition)
  30783. if !ok {
  30784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30785. }
  30786. m.SetConditionList(v)
  30787. return nil
  30788. case sopstage.FieldActionMessage:
  30789. v, ok := value.([]custom_types.Action)
  30790. if !ok {
  30791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30792. }
  30793. m.SetActionMessage(v)
  30794. return nil
  30795. case sopstage.FieldActionLabelAdd:
  30796. v, ok := value.([]uint64)
  30797. if !ok {
  30798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30799. }
  30800. m.SetActionLabelAdd(v)
  30801. return nil
  30802. case sopstage.FieldActionLabelDel:
  30803. v, ok := value.([]uint64)
  30804. if !ok {
  30805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30806. }
  30807. m.SetActionLabelDel(v)
  30808. return nil
  30809. case sopstage.FieldActionForward:
  30810. v, ok := value.(*custom_types.ActionForward)
  30811. if !ok {
  30812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30813. }
  30814. m.SetActionForward(v)
  30815. return nil
  30816. case sopstage.FieldIndexSort:
  30817. v, ok := value.(int)
  30818. if !ok {
  30819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30820. }
  30821. m.SetIndexSort(v)
  30822. return nil
  30823. }
  30824. return fmt.Errorf("unknown SopStage field %s", name)
  30825. }
  30826. // AddedFields returns all numeric fields that were incremented/decremented during
  30827. // this mutation.
  30828. func (m *SopStageMutation) AddedFields() []string {
  30829. var fields []string
  30830. if m.addstatus != nil {
  30831. fields = append(fields, sopstage.FieldStatus)
  30832. }
  30833. if m.addcondition_type != nil {
  30834. fields = append(fields, sopstage.FieldConditionType)
  30835. }
  30836. if m.addcondition_operator != nil {
  30837. fields = append(fields, sopstage.FieldConditionOperator)
  30838. }
  30839. if m.addindex_sort != nil {
  30840. fields = append(fields, sopstage.FieldIndexSort)
  30841. }
  30842. return fields
  30843. }
  30844. // AddedField returns the numeric value that was incremented/decremented on a field
  30845. // with the given name. The second boolean return value indicates that this field
  30846. // was not set, or was not defined in the schema.
  30847. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  30848. switch name {
  30849. case sopstage.FieldStatus:
  30850. return m.AddedStatus()
  30851. case sopstage.FieldConditionType:
  30852. return m.AddedConditionType()
  30853. case sopstage.FieldConditionOperator:
  30854. return m.AddedConditionOperator()
  30855. case sopstage.FieldIndexSort:
  30856. return m.AddedIndexSort()
  30857. }
  30858. return nil, false
  30859. }
  30860. // AddField adds the value to the field with the given name. It returns an error if
  30861. // the field is not defined in the schema, or if the type mismatched the field
  30862. // type.
  30863. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  30864. switch name {
  30865. case sopstage.FieldStatus:
  30866. v, ok := value.(int8)
  30867. if !ok {
  30868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30869. }
  30870. m.AddStatus(v)
  30871. return nil
  30872. case sopstage.FieldConditionType:
  30873. v, ok := value.(int)
  30874. if !ok {
  30875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30876. }
  30877. m.AddConditionType(v)
  30878. return nil
  30879. case sopstage.FieldConditionOperator:
  30880. v, ok := value.(int)
  30881. if !ok {
  30882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30883. }
  30884. m.AddConditionOperator(v)
  30885. return nil
  30886. case sopstage.FieldIndexSort:
  30887. v, ok := value.(int)
  30888. if !ok {
  30889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30890. }
  30891. m.AddIndexSort(v)
  30892. return nil
  30893. }
  30894. return fmt.Errorf("unknown SopStage numeric field %s", name)
  30895. }
  30896. // ClearedFields returns all nullable fields that were cleared during this
  30897. // mutation.
  30898. func (m *SopStageMutation) ClearedFields() []string {
  30899. var fields []string
  30900. if m.FieldCleared(sopstage.FieldStatus) {
  30901. fields = append(fields, sopstage.FieldStatus)
  30902. }
  30903. if m.FieldCleared(sopstage.FieldDeletedAt) {
  30904. fields = append(fields, sopstage.FieldDeletedAt)
  30905. }
  30906. if m.FieldCleared(sopstage.FieldActionMessage) {
  30907. fields = append(fields, sopstage.FieldActionMessage)
  30908. }
  30909. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  30910. fields = append(fields, sopstage.FieldActionLabelAdd)
  30911. }
  30912. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  30913. fields = append(fields, sopstage.FieldActionLabelDel)
  30914. }
  30915. if m.FieldCleared(sopstage.FieldActionForward) {
  30916. fields = append(fields, sopstage.FieldActionForward)
  30917. }
  30918. if m.FieldCleared(sopstage.FieldIndexSort) {
  30919. fields = append(fields, sopstage.FieldIndexSort)
  30920. }
  30921. return fields
  30922. }
  30923. // FieldCleared returns a boolean indicating if a field with the given name was
  30924. // cleared in this mutation.
  30925. func (m *SopStageMutation) FieldCleared(name string) bool {
  30926. _, ok := m.clearedFields[name]
  30927. return ok
  30928. }
  30929. // ClearField clears the value of the field with the given name. It returns an
  30930. // error if the field is not defined in the schema.
  30931. func (m *SopStageMutation) ClearField(name string) error {
  30932. switch name {
  30933. case sopstage.FieldStatus:
  30934. m.ClearStatus()
  30935. return nil
  30936. case sopstage.FieldDeletedAt:
  30937. m.ClearDeletedAt()
  30938. return nil
  30939. case sopstage.FieldActionMessage:
  30940. m.ClearActionMessage()
  30941. return nil
  30942. case sopstage.FieldActionLabelAdd:
  30943. m.ClearActionLabelAdd()
  30944. return nil
  30945. case sopstage.FieldActionLabelDel:
  30946. m.ClearActionLabelDel()
  30947. return nil
  30948. case sopstage.FieldActionForward:
  30949. m.ClearActionForward()
  30950. return nil
  30951. case sopstage.FieldIndexSort:
  30952. m.ClearIndexSort()
  30953. return nil
  30954. }
  30955. return fmt.Errorf("unknown SopStage nullable field %s", name)
  30956. }
  30957. // ResetField resets all changes in the mutation for the field with the given name.
  30958. // It returns an error if the field is not defined in the schema.
  30959. func (m *SopStageMutation) ResetField(name string) error {
  30960. switch name {
  30961. case sopstage.FieldCreatedAt:
  30962. m.ResetCreatedAt()
  30963. return nil
  30964. case sopstage.FieldUpdatedAt:
  30965. m.ResetUpdatedAt()
  30966. return nil
  30967. case sopstage.FieldStatus:
  30968. m.ResetStatus()
  30969. return nil
  30970. case sopstage.FieldDeletedAt:
  30971. m.ResetDeletedAt()
  30972. return nil
  30973. case sopstage.FieldTaskID:
  30974. m.ResetTaskID()
  30975. return nil
  30976. case sopstage.FieldName:
  30977. m.ResetName()
  30978. return nil
  30979. case sopstage.FieldConditionType:
  30980. m.ResetConditionType()
  30981. return nil
  30982. case sopstage.FieldConditionOperator:
  30983. m.ResetConditionOperator()
  30984. return nil
  30985. case sopstage.FieldConditionList:
  30986. m.ResetConditionList()
  30987. return nil
  30988. case sopstage.FieldActionMessage:
  30989. m.ResetActionMessage()
  30990. return nil
  30991. case sopstage.FieldActionLabelAdd:
  30992. m.ResetActionLabelAdd()
  30993. return nil
  30994. case sopstage.FieldActionLabelDel:
  30995. m.ResetActionLabelDel()
  30996. return nil
  30997. case sopstage.FieldActionForward:
  30998. m.ResetActionForward()
  30999. return nil
  31000. case sopstage.FieldIndexSort:
  31001. m.ResetIndexSort()
  31002. return nil
  31003. }
  31004. return fmt.Errorf("unknown SopStage field %s", name)
  31005. }
  31006. // AddedEdges returns all edge names that were set/added in this mutation.
  31007. func (m *SopStageMutation) AddedEdges() []string {
  31008. edges := make([]string, 0, 3)
  31009. if m.sop_task != nil {
  31010. edges = append(edges, sopstage.EdgeSopTask)
  31011. }
  31012. if m.stage_nodes != nil {
  31013. edges = append(edges, sopstage.EdgeStageNodes)
  31014. }
  31015. if m.stage_messages != nil {
  31016. edges = append(edges, sopstage.EdgeStageMessages)
  31017. }
  31018. return edges
  31019. }
  31020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31021. // name in this mutation.
  31022. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  31023. switch name {
  31024. case sopstage.EdgeSopTask:
  31025. if id := m.sop_task; id != nil {
  31026. return []ent.Value{*id}
  31027. }
  31028. case sopstage.EdgeStageNodes:
  31029. ids := make([]ent.Value, 0, len(m.stage_nodes))
  31030. for id := range m.stage_nodes {
  31031. ids = append(ids, id)
  31032. }
  31033. return ids
  31034. case sopstage.EdgeStageMessages:
  31035. ids := make([]ent.Value, 0, len(m.stage_messages))
  31036. for id := range m.stage_messages {
  31037. ids = append(ids, id)
  31038. }
  31039. return ids
  31040. }
  31041. return nil
  31042. }
  31043. // RemovedEdges returns all edge names that were removed in this mutation.
  31044. func (m *SopStageMutation) RemovedEdges() []string {
  31045. edges := make([]string, 0, 3)
  31046. if m.removedstage_nodes != nil {
  31047. edges = append(edges, sopstage.EdgeStageNodes)
  31048. }
  31049. if m.removedstage_messages != nil {
  31050. edges = append(edges, sopstage.EdgeStageMessages)
  31051. }
  31052. return edges
  31053. }
  31054. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31055. // the given name in this mutation.
  31056. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  31057. switch name {
  31058. case sopstage.EdgeStageNodes:
  31059. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  31060. for id := range m.removedstage_nodes {
  31061. ids = append(ids, id)
  31062. }
  31063. return ids
  31064. case sopstage.EdgeStageMessages:
  31065. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  31066. for id := range m.removedstage_messages {
  31067. ids = append(ids, id)
  31068. }
  31069. return ids
  31070. }
  31071. return nil
  31072. }
  31073. // ClearedEdges returns all edge names that were cleared in this mutation.
  31074. func (m *SopStageMutation) ClearedEdges() []string {
  31075. edges := make([]string, 0, 3)
  31076. if m.clearedsop_task {
  31077. edges = append(edges, sopstage.EdgeSopTask)
  31078. }
  31079. if m.clearedstage_nodes {
  31080. edges = append(edges, sopstage.EdgeStageNodes)
  31081. }
  31082. if m.clearedstage_messages {
  31083. edges = append(edges, sopstage.EdgeStageMessages)
  31084. }
  31085. return edges
  31086. }
  31087. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31088. // was cleared in this mutation.
  31089. func (m *SopStageMutation) EdgeCleared(name string) bool {
  31090. switch name {
  31091. case sopstage.EdgeSopTask:
  31092. return m.clearedsop_task
  31093. case sopstage.EdgeStageNodes:
  31094. return m.clearedstage_nodes
  31095. case sopstage.EdgeStageMessages:
  31096. return m.clearedstage_messages
  31097. }
  31098. return false
  31099. }
  31100. // ClearEdge clears the value of the edge with the given name. It returns an error
  31101. // if that edge is not defined in the schema.
  31102. func (m *SopStageMutation) ClearEdge(name string) error {
  31103. switch name {
  31104. case sopstage.EdgeSopTask:
  31105. m.ClearSopTask()
  31106. return nil
  31107. }
  31108. return fmt.Errorf("unknown SopStage unique edge %s", name)
  31109. }
  31110. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31111. // It returns an error if the edge is not defined in the schema.
  31112. func (m *SopStageMutation) ResetEdge(name string) error {
  31113. switch name {
  31114. case sopstage.EdgeSopTask:
  31115. m.ResetSopTask()
  31116. return nil
  31117. case sopstage.EdgeStageNodes:
  31118. m.ResetStageNodes()
  31119. return nil
  31120. case sopstage.EdgeStageMessages:
  31121. m.ResetStageMessages()
  31122. return nil
  31123. }
  31124. return fmt.Errorf("unknown SopStage edge %s", name)
  31125. }
  31126. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  31127. type SopTaskMutation struct {
  31128. config
  31129. op Op
  31130. typ string
  31131. id *uint64
  31132. created_at *time.Time
  31133. updated_at *time.Time
  31134. status *uint8
  31135. addstatus *int8
  31136. deleted_at *time.Time
  31137. name *string
  31138. bot_wxid_list *[]string
  31139. appendbot_wxid_list []string
  31140. _type *int
  31141. add_type *int
  31142. plan_start_time *time.Time
  31143. plan_end_time *time.Time
  31144. creator_id *string
  31145. organization_id *uint64
  31146. addorganization_id *int64
  31147. token *[]string
  31148. appendtoken []string
  31149. clearedFields map[string]struct{}
  31150. task_stages map[uint64]struct{}
  31151. removedtask_stages map[uint64]struct{}
  31152. clearedtask_stages bool
  31153. done bool
  31154. oldValue func(context.Context) (*SopTask, error)
  31155. predicates []predicate.SopTask
  31156. }
  31157. var _ ent.Mutation = (*SopTaskMutation)(nil)
  31158. // soptaskOption allows management of the mutation configuration using functional options.
  31159. type soptaskOption func(*SopTaskMutation)
  31160. // newSopTaskMutation creates new mutation for the SopTask entity.
  31161. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  31162. m := &SopTaskMutation{
  31163. config: c,
  31164. op: op,
  31165. typ: TypeSopTask,
  31166. clearedFields: make(map[string]struct{}),
  31167. }
  31168. for _, opt := range opts {
  31169. opt(m)
  31170. }
  31171. return m
  31172. }
  31173. // withSopTaskID sets the ID field of the mutation.
  31174. func withSopTaskID(id uint64) soptaskOption {
  31175. return func(m *SopTaskMutation) {
  31176. var (
  31177. err error
  31178. once sync.Once
  31179. value *SopTask
  31180. )
  31181. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  31182. once.Do(func() {
  31183. if m.done {
  31184. err = errors.New("querying old values post mutation is not allowed")
  31185. } else {
  31186. value, err = m.Client().SopTask.Get(ctx, id)
  31187. }
  31188. })
  31189. return value, err
  31190. }
  31191. m.id = &id
  31192. }
  31193. }
  31194. // withSopTask sets the old SopTask of the mutation.
  31195. func withSopTask(node *SopTask) soptaskOption {
  31196. return func(m *SopTaskMutation) {
  31197. m.oldValue = func(context.Context) (*SopTask, error) {
  31198. return node, nil
  31199. }
  31200. m.id = &node.ID
  31201. }
  31202. }
  31203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31204. // executed in a transaction (ent.Tx), a transactional client is returned.
  31205. func (m SopTaskMutation) Client() *Client {
  31206. client := &Client{config: m.config}
  31207. client.init()
  31208. return client
  31209. }
  31210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31211. // it returns an error otherwise.
  31212. func (m SopTaskMutation) Tx() (*Tx, error) {
  31213. if _, ok := m.driver.(*txDriver); !ok {
  31214. return nil, errors.New("ent: mutation is not running in a transaction")
  31215. }
  31216. tx := &Tx{config: m.config}
  31217. tx.init()
  31218. return tx, nil
  31219. }
  31220. // SetID sets the value of the id field. Note that this
  31221. // operation is only accepted on creation of SopTask entities.
  31222. func (m *SopTaskMutation) SetID(id uint64) {
  31223. m.id = &id
  31224. }
  31225. // ID returns the ID value in the mutation. Note that the ID is only available
  31226. // if it was provided to the builder or after it was returned from the database.
  31227. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  31228. if m.id == nil {
  31229. return
  31230. }
  31231. return *m.id, true
  31232. }
  31233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31234. // That means, if the mutation is applied within a transaction with an isolation level such
  31235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31236. // or updated by the mutation.
  31237. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  31238. switch {
  31239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31240. id, exists := m.ID()
  31241. if exists {
  31242. return []uint64{id}, nil
  31243. }
  31244. fallthrough
  31245. case m.op.Is(OpUpdate | OpDelete):
  31246. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  31247. default:
  31248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31249. }
  31250. }
  31251. // SetCreatedAt sets the "created_at" field.
  31252. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  31253. m.created_at = &t
  31254. }
  31255. // CreatedAt returns the value of the "created_at" field in the mutation.
  31256. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  31257. v := m.created_at
  31258. if v == nil {
  31259. return
  31260. }
  31261. return *v, true
  31262. }
  31263. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  31264. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31266. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31267. if !m.op.Is(OpUpdateOne) {
  31268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31269. }
  31270. if m.id == nil || m.oldValue == nil {
  31271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31272. }
  31273. oldValue, err := m.oldValue(ctx)
  31274. if err != nil {
  31275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31276. }
  31277. return oldValue.CreatedAt, nil
  31278. }
  31279. // ResetCreatedAt resets all changes to the "created_at" field.
  31280. func (m *SopTaskMutation) ResetCreatedAt() {
  31281. m.created_at = nil
  31282. }
  31283. // SetUpdatedAt sets the "updated_at" field.
  31284. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  31285. m.updated_at = &t
  31286. }
  31287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31288. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  31289. v := m.updated_at
  31290. if v == nil {
  31291. return
  31292. }
  31293. return *v, true
  31294. }
  31295. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  31296. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31298. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31299. if !m.op.Is(OpUpdateOne) {
  31300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31301. }
  31302. if m.id == nil || m.oldValue == nil {
  31303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31304. }
  31305. oldValue, err := m.oldValue(ctx)
  31306. if err != nil {
  31307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31308. }
  31309. return oldValue.UpdatedAt, nil
  31310. }
  31311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31312. func (m *SopTaskMutation) ResetUpdatedAt() {
  31313. m.updated_at = nil
  31314. }
  31315. // SetStatus sets the "status" field.
  31316. func (m *SopTaskMutation) SetStatus(u uint8) {
  31317. m.status = &u
  31318. m.addstatus = nil
  31319. }
  31320. // Status returns the value of the "status" field in the mutation.
  31321. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  31322. v := m.status
  31323. if v == nil {
  31324. return
  31325. }
  31326. return *v, true
  31327. }
  31328. // OldStatus returns the old "status" field's value of the SopTask entity.
  31329. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31331. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31332. if !m.op.Is(OpUpdateOne) {
  31333. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31334. }
  31335. if m.id == nil || m.oldValue == nil {
  31336. return v, errors.New("OldStatus requires an ID field in the mutation")
  31337. }
  31338. oldValue, err := m.oldValue(ctx)
  31339. if err != nil {
  31340. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31341. }
  31342. return oldValue.Status, nil
  31343. }
  31344. // AddStatus adds u to the "status" field.
  31345. func (m *SopTaskMutation) AddStatus(u int8) {
  31346. if m.addstatus != nil {
  31347. *m.addstatus += u
  31348. } else {
  31349. m.addstatus = &u
  31350. }
  31351. }
  31352. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31353. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  31354. v := m.addstatus
  31355. if v == nil {
  31356. return
  31357. }
  31358. return *v, true
  31359. }
  31360. // ClearStatus clears the value of the "status" field.
  31361. func (m *SopTaskMutation) ClearStatus() {
  31362. m.status = nil
  31363. m.addstatus = nil
  31364. m.clearedFields[soptask.FieldStatus] = struct{}{}
  31365. }
  31366. // StatusCleared returns if the "status" field was cleared in this mutation.
  31367. func (m *SopTaskMutation) StatusCleared() bool {
  31368. _, ok := m.clearedFields[soptask.FieldStatus]
  31369. return ok
  31370. }
  31371. // ResetStatus resets all changes to the "status" field.
  31372. func (m *SopTaskMutation) ResetStatus() {
  31373. m.status = nil
  31374. m.addstatus = nil
  31375. delete(m.clearedFields, soptask.FieldStatus)
  31376. }
  31377. // SetDeletedAt sets the "deleted_at" field.
  31378. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  31379. m.deleted_at = &t
  31380. }
  31381. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31382. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  31383. v := m.deleted_at
  31384. if v == nil {
  31385. return
  31386. }
  31387. return *v, true
  31388. }
  31389. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  31390. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31392. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31393. if !m.op.Is(OpUpdateOne) {
  31394. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31395. }
  31396. if m.id == nil || m.oldValue == nil {
  31397. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31398. }
  31399. oldValue, err := m.oldValue(ctx)
  31400. if err != nil {
  31401. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31402. }
  31403. return oldValue.DeletedAt, nil
  31404. }
  31405. // ClearDeletedAt clears the value of the "deleted_at" field.
  31406. func (m *SopTaskMutation) ClearDeletedAt() {
  31407. m.deleted_at = nil
  31408. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  31409. }
  31410. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31411. func (m *SopTaskMutation) DeletedAtCleared() bool {
  31412. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  31413. return ok
  31414. }
  31415. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31416. func (m *SopTaskMutation) ResetDeletedAt() {
  31417. m.deleted_at = nil
  31418. delete(m.clearedFields, soptask.FieldDeletedAt)
  31419. }
  31420. // SetName sets the "name" field.
  31421. func (m *SopTaskMutation) SetName(s string) {
  31422. m.name = &s
  31423. }
  31424. // Name returns the value of the "name" field in the mutation.
  31425. func (m *SopTaskMutation) Name() (r string, exists bool) {
  31426. v := m.name
  31427. if v == nil {
  31428. return
  31429. }
  31430. return *v, true
  31431. }
  31432. // OldName returns the old "name" field's value of the SopTask entity.
  31433. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31435. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  31436. if !m.op.Is(OpUpdateOne) {
  31437. return v, errors.New("OldName is only allowed on UpdateOne operations")
  31438. }
  31439. if m.id == nil || m.oldValue == nil {
  31440. return v, errors.New("OldName requires an ID field in the mutation")
  31441. }
  31442. oldValue, err := m.oldValue(ctx)
  31443. if err != nil {
  31444. return v, fmt.Errorf("querying old value for OldName: %w", err)
  31445. }
  31446. return oldValue.Name, nil
  31447. }
  31448. // ResetName resets all changes to the "name" field.
  31449. func (m *SopTaskMutation) ResetName() {
  31450. m.name = nil
  31451. }
  31452. // SetBotWxidList sets the "bot_wxid_list" field.
  31453. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  31454. m.bot_wxid_list = &s
  31455. m.appendbot_wxid_list = nil
  31456. }
  31457. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  31458. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  31459. v := m.bot_wxid_list
  31460. if v == nil {
  31461. return
  31462. }
  31463. return *v, true
  31464. }
  31465. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  31466. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31468. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  31469. if !m.op.Is(OpUpdateOne) {
  31470. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  31471. }
  31472. if m.id == nil || m.oldValue == nil {
  31473. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  31474. }
  31475. oldValue, err := m.oldValue(ctx)
  31476. if err != nil {
  31477. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  31478. }
  31479. return oldValue.BotWxidList, nil
  31480. }
  31481. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  31482. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  31483. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  31484. }
  31485. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  31486. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  31487. if len(m.appendbot_wxid_list) == 0 {
  31488. return nil, false
  31489. }
  31490. return m.appendbot_wxid_list, true
  31491. }
  31492. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  31493. func (m *SopTaskMutation) ClearBotWxidList() {
  31494. m.bot_wxid_list = nil
  31495. m.appendbot_wxid_list = nil
  31496. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  31497. }
  31498. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  31499. func (m *SopTaskMutation) BotWxidListCleared() bool {
  31500. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  31501. return ok
  31502. }
  31503. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  31504. func (m *SopTaskMutation) ResetBotWxidList() {
  31505. m.bot_wxid_list = nil
  31506. m.appendbot_wxid_list = nil
  31507. delete(m.clearedFields, soptask.FieldBotWxidList)
  31508. }
  31509. // SetType sets the "type" field.
  31510. func (m *SopTaskMutation) SetType(i int) {
  31511. m._type = &i
  31512. m.add_type = nil
  31513. }
  31514. // GetType returns the value of the "type" field in the mutation.
  31515. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  31516. v := m._type
  31517. if v == nil {
  31518. return
  31519. }
  31520. return *v, true
  31521. }
  31522. // OldType returns the old "type" field's value of the SopTask entity.
  31523. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31525. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  31526. if !m.op.Is(OpUpdateOne) {
  31527. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31528. }
  31529. if m.id == nil || m.oldValue == nil {
  31530. return v, errors.New("OldType requires an ID field in the mutation")
  31531. }
  31532. oldValue, err := m.oldValue(ctx)
  31533. if err != nil {
  31534. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31535. }
  31536. return oldValue.Type, nil
  31537. }
  31538. // AddType adds i to the "type" field.
  31539. func (m *SopTaskMutation) AddType(i int) {
  31540. if m.add_type != nil {
  31541. *m.add_type += i
  31542. } else {
  31543. m.add_type = &i
  31544. }
  31545. }
  31546. // AddedType returns the value that was added to the "type" field in this mutation.
  31547. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  31548. v := m.add_type
  31549. if v == nil {
  31550. return
  31551. }
  31552. return *v, true
  31553. }
  31554. // ResetType resets all changes to the "type" field.
  31555. func (m *SopTaskMutation) ResetType() {
  31556. m._type = nil
  31557. m.add_type = nil
  31558. }
  31559. // SetPlanStartTime sets the "plan_start_time" field.
  31560. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  31561. m.plan_start_time = &t
  31562. }
  31563. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  31564. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  31565. v := m.plan_start_time
  31566. if v == nil {
  31567. return
  31568. }
  31569. return *v, true
  31570. }
  31571. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  31572. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31574. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  31575. if !m.op.Is(OpUpdateOne) {
  31576. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  31577. }
  31578. if m.id == nil || m.oldValue == nil {
  31579. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  31580. }
  31581. oldValue, err := m.oldValue(ctx)
  31582. if err != nil {
  31583. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  31584. }
  31585. return oldValue.PlanStartTime, nil
  31586. }
  31587. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  31588. func (m *SopTaskMutation) ClearPlanStartTime() {
  31589. m.plan_start_time = nil
  31590. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  31591. }
  31592. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  31593. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  31594. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  31595. return ok
  31596. }
  31597. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  31598. func (m *SopTaskMutation) ResetPlanStartTime() {
  31599. m.plan_start_time = nil
  31600. delete(m.clearedFields, soptask.FieldPlanStartTime)
  31601. }
  31602. // SetPlanEndTime sets the "plan_end_time" field.
  31603. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  31604. m.plan_end_time = &t
  31605. }
  31606. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  31607. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  31608. v := m.plan_end_time
  31609. if v == nil {
  31610. return
  31611. }
  31612. return *v, true
  31613. }
  31614. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  31615. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31617. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  31618. if !m.op.Is(OpUpdateOne) {
  31619. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  31620. }
  31621. if m.id == nil || m.oldValue == nil {
  31622. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  31623. }
  31624. oldValue, err := m.oldValue(ctx)
  31625. if err != nil {
  31626. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  31627. }
  31628. return oldValue.PlanEndTime, nil
  31629. }
  31630. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  31631. func (m *SopTaskMutation) ClearPlanEndTime() {
  31632. m.plan_end_time = nil
  31633. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  31634. }
  31635. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  31636. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  31637. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  31638. return ok
  31639. }
  31640. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  31641. func (m *SopTaskMutation) ResetPlanEndTime() {
  31642. m.plan_end_time = nil
  31643. delete(m.clearedFields, soptask.FieldPlanEndTime)
  31644. }
  31645. // SetCreatorID sets the "creator_id" field.
  31646. func (m *SopTaskMutation) SetCreatorID(s string) {
  31647. m.creator_id = &s
  31648. }
  31649. // CreatorID returns the value of the "creator_id" field in the mutation.
  31650. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  31651. v := m.creator_id
  31652. if v == nil {
  31653. return
  31654. }
  31655. return *v, true
  31656. }
  31657. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  31658. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31660. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  31661. if !m.op.Is(OpUpdateOne) {
  31662. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  31663. }
  31664. if m.id == nil || m.oldValue == nil {
  31665. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  31666. }
  31667. oldValue, err := m.oldValue(ctx)
  31668. if err != nil {
  31669. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  31670. }
  31671. return oldValue.CreatorID, nil
  31672. }
  31673. // ClearCreatorID clears the value of the "creator_id" field.
  31674. func (m *SopTaskMutation) ClearCreatorID() {
  31675. m.creator_id = nil
  31676. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  31677. }
  31678. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  31679. func (m *SopTaskMutation) CreatorIDCleared() bool {
  31680. _, ok := m.clearedFields[soptask.FieldCreatorID]
  31681. return ok
  31682. }
  31683. // ResetCreatorID resets all changes to the "creator_id" field.
  31684. func (m *SopTaskMutation) ResetCreatorID() {
  31685. m.creator_id = nil
  31686. delete(m.clearedFields, soptask.FieldCreatorID)
  31687. }
  31688. // SetOrganizationID sets the "organization_id" field.
  31689. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  31690. m.organization_id = &u
  31691. m.addorganization_id = nil
  31692. }
  31693. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31694. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  31695. v := m.organization_id
  31696. if v == nil {
  31697. return
  31698. }
  31699. return *v, true
  31700. }
  31701. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  31702. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31704. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31705. if !m.op.Is(OpUpdateOne) {
  31706. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31707. }
  31708. if m.id == nil || m.oldValue == nil {
  31709. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31710. }
  31711. oldValue, err := m.oldValue(ctx)
  31712. if err != nil {
  31713. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31714. }
  31715. return oldValue.OrganizationID, nil
  31716. }
  31717. // AddOrganizationID adds u to the "organization_id" field.
  31718. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  31719. if m.addorganization_id != nil {
  31720. *m.addorganization_id += u
  31721. } else {
  31722. m.addorganization_id = &u
  31723. }
  31724. }
  31725. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31726. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  31727. v := m.addorganization_id
  31728. if v == nil {
  31729. return
  31730. }
  31731. return *v, true
  31732. }
  31733. // ClearOrganizationID clears the value of the "organization_id" field.
  31734. func (m *SopTaskMutation) ClearOrganizationID() {
  31735. m.organization_id = nil
  31736. m.addorganization_id = nil
  31737. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  31738. }
  31739. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31740. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  31741. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  31742. return ok
  31743. }
  31744. // ResetOrganizationID resets all changes to the "organization_id" field.
  31745. func (m *SopTaskMutation) ResetOrganizationID() {
  31746. m.organization_id = nil
  31747. m.addorganization_id = nil
  31748. delete(m.clearedFields, soptask.FieldOrganizationID)
  31749. }
  31750. // SetToken sets the "token" field.
  31751. func (m *SopTaskMutation) SetToken(s []string) {
  31752. m.token = &s
  31753. m.appendtoken = nil
  31754. }
  31755. // Token returns the value of the "token" field in the mutation.
  31756. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  31757. v := m.token
  31758. if v == nil {
  31759. return
  31760. }
  31761. return *v, true
  31762. }
  31763. // OldToken returns the old "token" field's value of the SopTask entity.
  31764. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31766. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  31767. if !m.op.Is(OpUpdateOne) {
  31768. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31769. }
  31770. if m.id == nil || m.oldValue == nil {
  31771. return v, errors.New("OldToken requires an ID field in the mutation")
  31772. }
  31773. oldValue, err := m.oldValue(ctx)
  31774. if err != nil {
  31775. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31776. }
  31777. return oldValue.Token, nil
  31778. }
  31779. // AppendToken adds s to the "token" field.
  31780. func (m *SopTaskMutation) AppendToken(s []string) {
  31781. m.appendtoken = append(m.appendtoken, s...)
  31782. }
  31783. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  31784. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  31785. if len(m.appendtoken) == 0 {
  31786. return nil, false
  31787. }
  31788. return m.appendtoken, true
  31789. }
  31790. // ClearToken clears the value of the "token" field.
  31791. func (m *SopTaskMutation) ClearToken() {
  31792. m.token = nil
  31793. m.appendtoken = nil
  31794. m.clearedFields[soptask.FieldToken] = struct{}{}
  31795. }
  31796. // TokenCleared returns if the "token" field was cleared in this mutation.
  31797. func (m *SopTaskMutation) TokenCleared() bool {
  31798. _, ok := m.clearedFields[soptask.FieldToken]
  31799. return ok
  31800. }
  31801. // ResetToken resets all changes to the "token" field.
  31802. func (m *SopTaskMutation) ResetToken() {
  31803. m.token = nil
  31804. m.appendtoken = nil
  31805. delete(m.clearedFields, soptask.FieldToken)
  31806. }
  31807. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  31808. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  31809. if m.task_stages == nil {
  31810. m.task_stages = make(map[uint64]struct{})
  31811. }
  31812. for i := range ids {
  31813. m.task_stages[ids[i]] = struct{}{}
  31814. }
  31815. }
  31816. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  31817. func (m *SopTaskMutation) ClearTaskStages() {
  31818. m.clearedtask_stages = true
  31819. }
  31820. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  31821. func (m *SopTaskMutation) TaskStagesCleared() bool {
  31822. return m.clearedtask_stages
  31823. }
  31824. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  31825. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  31826. if m.removedtask_stages == nil {
  31827. m.removedtask_stages = make(map[uint64]struct{})
  31828. }
  31829. for i := range ids {
  31830. delete(m.task_stages, ids[i])
  31831. m.removedtask_stages[ids[i]] = struct{}{}
  31832. }
  31833. }
  31834. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  31835. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  31836. for id := range m.removedtask_stages {
  31837. ids = append(ids, id)
  31838. }
  31839. return
  31840. }
  31841. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  31842. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  31843. for id := range m.task_stages {
  31844. ids = append(ids, id)
  31845. }
  31846. return
  31847. }
  31848. // ResetTaskStages resets all changes to the "task_stages" edge.
  31849. func (m *SopTaskMutation) ResetTaskStages() {
  31850. m.task_stages = nil
  31851. m.clearedtask_stages = false
  31852. m.removedtask_stages = nil
  31853. }
  31854. // Where appends a list predicates to the SopTaskMutation builder.
  31855. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  31856. m.predicates = append(m.predicates, ps...)
  31857. }
  31858. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  31859. // users can use type-assertion to append predicates that do not depend on any generated package.
  31860. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  31861. p := make([]predicate.SopTask, len(ps))
  31862. for i := range ps {
  31863. p[i] = ps[i]
  31864. }
  31865. m.Where(p...)
  31866. }
  31867. // Op returns the operation name.
  31868. func (m *SopTaskMutation) Op() Op {
  31869. return m.op
  31870. }
  31871. // SetOp allows setting the mutation operation.
  31872. func (m *SopTaskMutation) SetOp(op Op) {
  31873. m.op = op
  31874. }
  31875. // Type returns the node type of this mutation (SopTask).
  31876. func (m *SopTaskMutation) Type() string {
  31877. return m.typ
  31878. }
  31879. // Fields returns all fields that were changed during this mutation. Note that in
  31880. // order to get all numeric fields that were incremented/decremented, call
  31881. // AddedFields().
  31882. func (m *SopTaskMutation) Fields() []string {
  31883. fields := make([]string, 0, 12)
  31884. if m.created_at != nil {
  31885. fields = append(fields, soptask.FieldCreatedAt)
  31886. }
  31887. if m.updated_at != nil {
  31888. fields = append(fields, soptask.FieldUpdatedAt)
  31889. }
  31890. if m.status != nil {
  31891. fields = append(fields, soptask.FieldStatus)
  31892. }
  31893. if m.deleted_at != nil {
  31894. fields = append(fields, soptask.FieldDeletedAt)
  31895. }
  31896. if m.name != nil {
  31897. fields = append(fields, soptask.FieldName)
  31898. }
  31899. if m.bot_wxid_list != nil {
  31900. fields = append(fields, soptask.FieldBotWxidList)
  31901. }
  31902. if m._type != nil {
  31903. fields = append(fields, soptask.FieldType)
  31904. }
  31905. if m.plan_start_time != nil {
  31906. fields = append(fields, soptask.FieldPlanStartTime)
  31907. }
  31908. if m.plan_end_time != nil {
  31909. fields = append(fields, soptask.FieldPlanEndTime)
  31910. }
  31911. if m.creator_id != nil {
  31912. fields = append(fields, soptask.FieldCreatorID)
  31913. }
  31914. if m.organization_id != nil {
  31915. fields = append(fields, soptask.FieldOrganizationID)
  31916. }
  31917. if m.token != nil {
  31918. fields = append(fields, soptask.FieldToken)
  31919. }
  31920. return fields
  31921. }
  31922. // Field returns the value of a field with the given name. The second boolean
  31923. // return value indicates that this field was not set, or was not defined in the
  31924. // schema.
  31925. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  31926. switch name {
  31927. case soptask.FieldCreatedAt:
  31928. return m.CreatedAt()
  31929. case soptask.FieldUpdatedAt:
  31930. return m.UpdatedAt()
  31931. case soptask.FieldStatus:
  31932. return m.Status()
  31933. case soptask.FieldDeletedAt:
  31934. return m.DeletedAt()
  31935. case soptask.FieldName:
  31936. return m.Name()
  31937. case soptask.FieldBotWxidList:
  31938. return m.BotWxidList()
  31939. case soptask.FieldType:
  31940. return m.GetType()
  31941. case soptask.FieldPlanStartTime:
  31942. return m.PlanStartTime()
  31943. case soptask.FieldPlanEndTime:
  31944. return m.PlanEndTime()
  31945. case soptask.FieldCreatorID:
  31946. return m.CreatorID()
  31947. case soptask.FieldOrganizationID:
  31948. return m.OrganizationID()
  31949. case soptask.FieldToken:
  31950. return m.Token()
  31951. }
  31952. return nil, false
  31953. }
  31954. // OldField returns the old value of the field from the database. An error is
  31955. // returned if the mutation operation is not UpdateOne, or the query to the
  31956. // database failed.
  31957. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31958. switch name {
  31959. case soptask.FieldCreatedAt:
  31960. return m.OldCreatedAt(ctx)
  31961. case soptask.FieldUpdatedAt:
  31962. return m.OldUpdatedAt(ctx)
  31963. case soptask.FieldStatus:
  31964. return m.OldStatus(ctx)
  31965. case soptask.FieldDeletedAt:
  31966. return m.OldDeletedAt(ctx)
  31967. case soptask.FieldName:
  31968. return m.OldName(ctx)
  31969. case soptask.FieldBotWxidList:
  31970. return m.OldBotWxidList(ctx)
  31971. case soptask.FieldType:
  31972. return m.OldType(ctx)
  31973. case soptask.FieldPlanStartTime:
  31974. return m.OldPlanStartTime(ctx)
  31975. case soptask.FieldPlanEndTime:
  31976. return m.OldPlanEndTime(ctx)
  31977. case soptask.FieldCreatorID:
  31978. return m.OldCreatorID(ctx)
  31979. case soptask.FieldOrganizationID:
  31980. return m.OldOrganizationID(ctx)
  31981. case soptask.FieldToken:
  31982. return m.OldToken(ctx)
  31983. }
  31984. return nil, fmt.Errorf("unknown SopTask field %s", name)
  31985. }
  31986. // SetField sets the value of a field with the given name. It returns an error if
  31987. // the field is not defined in the schema, or if the type mismatched the field
  31988. // type.
  31989. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  31990. switch name {
  31991. case soptask.FieldCreatedAt:
  31992. v, ok := value.(time.Time)
  31993. if !ok {
  31994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31995. }
  31996. m.SetCreatedAt(v)
  31997. return nil
  31998. case soptask.FieldUpdatedAt:
  31999. v, ok := value.(time.Time)
  32000. if !ok {
  32001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32002. }
  32003. m.SetUpdatedAt(v)
  32004. return nil
  32005. case soptask.FieldStatus:
  32006. v, ok := value.(uint8)
  32007. if !ok {
  32008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32009. }
  32010. m.SetStatus(v)
  32011. return nil
  32012. case soptask.FieldDeletedAt:
  32013. v, ok := value.(time.Time)
  32014. if !ok {
  32015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32016. }
  32017. m.SetDeletedAt(v)
  32018. return nil
  32019. case soptask.FieldName:
  32020. v, ok := value.(string)
  32021. if !ok {
  32022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32023. }
  32024. m.SetName(v)
  32025. return nil
  32026. case soptask.FieldBotWxidList:
  32027. v, ok := value.([]string)
  32028. if !ok {
  32029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32030. }
  32031. m.SetBotWxidList(v)
  32032. return nil
  32033. case soptask.FieldType:
  32034. v, ok := value.(int)
  32035. if !ok {
  32036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32037. }
  32038. m.SetType(v)
  32039. return nil
  32040. case soptask.FieldPlanStartTime:
  32041. v, ok := value.(time.Time)
  32042. if !ok {
  32043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32044. }
  32045. m.SetPlanStartTime(v)
  32046. return nil
  32047. case soptask.FieldPlanEndTime:
  32048. v, ok := value.(time.Time)
  32049. if !ok {
  32050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32051. }
  32052. m.SetPlanEndTime(v)
  32053. return nil
  32054. case soptask.FieldCreatorID:
  32055. v, ok := value.(string)
  32056. if !ok {
  32057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32058. }
  32059. m.SetCreatorID(v)
  32060. return nil
  32061. case soptask.FieldOrganizationID:
  32062. v, ok := value.(uint64)
  32063. if !ok {
  32064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32065. }
  32066. m.SetOrganizationID(v)
  32067. return nil
  32068. case soptask.FieldToken:
  32069. v, ok := value.([]string)
  32070. if !ok {
  32071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32072. }
  32073. m.SetToken(v)
  32074. return nil
  32075. }
  32076. return fmt.Errorf("unknown SopTask field %s", name)
  32077. }
  32078. // AddedFields returns all numeric fields that were incremented/decremented during
  32079. // this mutation.
  32080. func (m *SopTaskMutation) AddedFields() []string {
  32081. var fields []string
  32082. if m.addstatus != nil {
  32083. fields = append(fields, soptask.FieldStatus)
  32084. }
  32085. if m.add_type != nil {
  32086. fields = append(fields, soptask.FieldType)
  32087. }
  32088. if m.addorganization_id != nil {
  32089. fields = append(fields, soptask.FieldOrganizationID)
  32090. }
  32091. return fields
  32092. }
  32093. // AddedField returns the numeric value that was incremented/decremented on a field
  32094. // with the given name. The second boolean return value indicates that this field
  32095. // was not set, or was not defined in the schema.
  32096. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  32097. switch name {
  32098. case soptask.FieldStatus:
  32099. return m.AddedStatus()
  32100. case soptask.FieldType:
  32101. return m.AddedType()
  32102. case soptask.FieldOrganizationID:
  32103. return m.AddedOrganizationID()
  32104. }
  32105. return nil, false
  32106. }
  32107. // AddField adds the value to the field with the given name. It returns an error if
  32108. // the field is not defined in the schema, or if the type mismatched the field
  32109. // type.
  32110. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  32111. switch name {
  32112. case soptask.FieldStatus:
  32113. v, ok := value.(int8)
  32114. if !ok {
  32115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32116. }
  32117. m.AddStatus(v)
  32118. return nil
  32119. case soptask.FieldType:
  32120. v, ok := value.(int)
  32121. if !ok {
  32122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32123. }
  32124. m.AddType(v)
  32125. return nil
  32126. case soptask.FieldOrganizationID:
  32127. v, ok := value.(int64)
  32128. if !ok {
  32129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32130. }
  32131. m.AddOrganizationID(v)
  32132. return nil
  32133. }
  32134. return fmt.Errorf("unknown SopTask numeric field %s", name)
  32135. }
  32136. // ClearedFields returns all nullable fields that were cleared during this
  32137. // mutation.
  32138. func (m *SopTaskMutation) ClearedFields() []string {
  32139. var fields []string
  32140. if m.FieldCleared(soptask.FieldStatus) {
  32141. fields = append(fields, soptask.FieldStatus)
  32142. }
  32143. if m.FieldCleared(soptask.FieldDeletedAt) {
  32144. fields = append(fields, soptask.FieldDeletedAt)
  32145. }
  32146. if m.FieldCleared(soptask.FieldBotWxidList) {
  32147. fields = append(fields, soptask.FieldBotWxidList)
  32148. }
  32149. if m.FieldCleared(soptask.FieldPlanStartTime) {
  32150. fields = append(fields, soptask.FieldPlanStartTime)
  32151. }
  32152. if m.FieldCleared(soptask.FieldPlanEndTime) {
  32153. fields = append(fields, soptask.FieldPlanEndTime)
  32154. }
  32155. if m.FieldCleared(soptask.FieldCreatorID) {
  32156. fields = append(fields, soptask.FieldCreatorID)
  32157. }
  32158. if m.FieldCleared(soptask.FieldOrganizationID) {
  32159. fields = append(fields, soptask.FieldOrganizationID)
  32160. }
  32161. if m.FieldCleared(soptask.FieldToken) {
  32162. fields = append(fields, soptask.FieldToken)
  32163. }
  32164. return fields
  32165. }
  32166. // FieldCleared returns a boolean indicating if a field with the given name was
  32167. // cleared in this mutation.
  32168. func (m *SopTaskMutation) FieldCleared(name string) bool {
  32169. _, ok := m.clearedFields[name]
  32170. return ok
  32171. }
  32172. // ClearField clears the value of the field with the given name. It returns an
  32173. // error if the field is not defined in the schema.
  32174. func (m *SopTaskMutation) ClearField(name string) error {
  32175. switch name {
  32176. case soptask.FieldStatus:
  32177. m.ClearStatus()
  32178. return nil
  32179. case soptask.FieldDeletedAt:
  32180. m.ClearDeletedAt()
  32181. return nil
  32182. case soptask.FieldBotWxidList:
  32183. m.ClearBotWxidList()
  32184. return nil
  32185. case soptask.FieldPlanStartTime:
  32186. m.ClearPlanStartTime()
  32187. return nil
  32188. case soptask.FieldPlanEndTime:
  32189. m.ClearPlanEndTime()
  32190. return nil
  32191. case soptask.FieldCreatorID:
  32192. m.ClearCreatorID()
  32193. return nil
  32194. case soptask.FieldOrganizationID:
  32195. m.ClearOrganizationID()
  32196. return nil
  32197. case soptask.FieldToken:
  32198. m.ClearToken()
  32199. return nil
  32200. }
  32201. return fmt.Errorf("unknown SopTask nullable field %s", name)
  32202. }
  32203. // ResetField resets all changes in the mutation for the field with the given name.
  32204. // It returns an error if the field is not defined in the schema.
  32205. func (m *SopTaskMutation) ResetField(name string) error {
  32206. switch name {
  32207. case soptask.FieldCreatedAt:
  32208. m.ResetCreatedAt()
  32209. return nil
  32210. case soptask.FieldUpdatedAt:
  32211. m.ResetUpdatedAt()
  32212. return nil
  32213. case soptask.FieldStatus:
  32214. m.ResetStatus()
  32215. return nil
  32216. case soptask.FieldDeletedAt:
  32217. m.ResetDeletedAt()
  32218. return nil
  32219. case soptask.FieldName:
  32220. m.ResetName()
  32221. return nil
  32222. case soptask.FieldBotWxidList:
  32223. m.ResetBotWxidList()
  32224. return nil
  32225. case soptask.FieldType:
  32226. m.ResetType()
  32227. return nil
  32228. case soptask.FieldPlanStartTime:
  32229. m.ResetPlanStartTime()
  32230. return nil
  32231. case soptask.FieldPlanEndTime:
  32232. m.ResetPlanEndTime()
  32233. return nil
  32234. case soptask.FieldCreatorID:
  32235. m.ResetCreatorID()
  32236. return nil
  32237. case soptask.FieldOrganizationID:
  32238. m.ResetOrganizationID()
  32239. return nil
  32240. case soptask.FieldToken:
  32241. m.ResetToken()
  32242. return nil
  32243. }
  32244. return fmt.Errorf("unknown SopTask field %s", name)
  32245. }
  32246. // AddedEdges returns all edge names that were set/added in this mutation.
  32247. func (m *SopTaskMutation) AddedEdges() []string {
  32248. edges := make([]string, 0, 1)
  32249. if m.task_stages != nil {
  32250. edges = append(edges, soptask.EdgeTaskStages)
  32251. }
  32252. return edges
  32253. }
  32254. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32255. // name in this mutation.
  32256. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  32257. switch name {
  32258. case soptask.EdgeTaskStages:
  32259. ids := make([]ent.Value, 0, len(m.task_stages))
  32260. for id := range m.task_stages {
  32261. ids = append(ids, id)
  32262. }
  32263. return ids
  32264. }
  32265. return nil
  32266. }
  32267. // RemovedEdges returns all edge names that were removed in this mutation.
  32268. func (m *SopTaskMutation) RemovedEdges() []string {
  32269. edges := make([]string, 0, 1)
  32270. if m.removedtask_stages != nil {
  32271. edges = append(edges, soptask.EdgeTaskStages)
  32272. }
  32273. return edges
  32274. }
  32275. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32276. // the given name in this mutation.
  32277. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  32278. switch name {
  32279. case soptask.EdgeTaskStages:
  32280. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  32281. for id := range m.removedtask_stages {
  32282. ids = append(ids, id)
  32283. }
  32284. return ids
  32285. }
  32286. return nil
  32287. }
  32288. // ClearedEdges returns all edge names that were cleared in this mutation.
  32289. func (m *SopTaskMutation) ClearedEdges() []string {
  32290. edges := make([]string, 0, 1)
  32291. if m.clearedtask_stages {
  32292. edges = append(edges, soptask.EdgeTaskStages)
  32293. }
  32294. return edges
  32295. }
  32296. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32297. // was cleared in this mutation.
  32298. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  32299. switch name {
  32300. case soptask.EdgeTaskStages:
  32301. return m.clearedtask_stages
  32302. }
  32303. return false
  32304. }
  32305. // ClearEdge clears the value of the edge with the given name. It returns an error
  32306. // if that edge is not defined in the schema.
  32307. func (m *SopTaskMutation) ClearEdge(name string) error {
  32308. switch name {
  32309. }
  32310. return fmt.Errorf("unknown SopTask unique edge %s", name)
  32311. }
  32312. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32313. // It returns an error if the edge is not defined in the schema.
  32314. func (m *SopTaskMutation) ResetEdge(name string) error {
  32315. switch name {
  32316. case soptask.EdgeTaskStages:
  32317. m.ResetTaskStages()
  32318. return nil
  32319. }
  32320. return fmt.Errorf("unknown SopTask edge %s", name)
  32321. }
  32322. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  32323. type TokenMutation struct {
  32324. config
  32325. op Op
  32326. typ string
  32327. id *uint64
  32328. created_at *time.Time
  32329. updated_at *time.Time
  32330. deleted_at *time.Time
  32331. expire_at *time.Time
  32332. token *string
  32333. mac *string
  32334. organization_id *uint64
  32335. addorganization_id *int64
  32336. custom_agent_base *string
  32337. custom_agent_key *string
  32338. openai_base *string
  32339. openai_key *string
  32340. clearedFields map[string]struct{}
  32341. agent *uint64
  32342. clearedagent bool
  32343. done bool
  32344. oldValue func(context.Context) (*Token, error)
  32345. predicates []predicate.Token
  32346. }
  32347. var _ ent.Mutation = (*TokenMutation)(nil)
  32348. // tokenOption allows management of the mutation configuration using functional options.
  32349. type tokenOption func(*TokenMutation)
  32350. // newTokenMutation creates new mutation for the Token entity.
  32351. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  32352. m := &TokenMutation{
  32353. config: c,
  32354. op: op,
  32355. typ: TypeToken,
  32356. clearedFields: make(map[string]struct{}),
  32357. }
  32358. for _, opt := range opts {
  32359. opt(m)
  32360. }
  32361. return m
  32362. }
  32363. // withTokenID sets the ID field of the mutation.
  32364. func withTokenID(id uint64) tokenOption {
  32365. return func(m *TokenMutation) {
  32366. var (
  32367. err error
  32368. once sync.Once
  32369. value *Token
  32370. )
  32371. m.oldValue = func(ctx context.Context) (*Token, error) {
  32372. once.Do(func() {
  32373. if m.done {
  32374. err = errors.New("querying old values post mutation is not allowed")
  32375. } else {
  32376. value, err = m.Client().Token.Get(ctx, id)
  32377. }
  32378. })
  32379. return value, err
  32380. }
  32381. m.id = &id
  32382. }
  32383. }
  32384. // withToken sets the old Token of the mutation.
  32385. func withToken(node *Token) tokenOption {
  32386. return func(m *TokenMutation) {
  32387. m.oldValue = func(context.Context) (*Token, error) {
  32388. return node, nil
  32389. }
  32390. m.id = &node.ID
  32391. }
  32392. }
  32393. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32394. // executed in a transaction (ent.Tx), a transactional client is returned.
  32395. func (m TokenMutation) Client() *Client {
  32396. client := &Client{config: m.config}
  32397. client.init()
  32398. return client
  32399. }
  32400. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32401. // it returns an error otherwise.
  32402. func (m TokenMutation) Tx() (*Tx, error) {
  32403. if _, ok := m.driver.(*txDriver); !ok {
  32404. return nil, errors.New("ent: mutation is not running in a transaction")
  32405. }
  32406. tx := &Tx{config: m.config}
  32407. tx.init()
  32408. return tx, nil
  32409. }
  32410. // SetID sets the value of the id field. Note that this
  32411. // operation is only accepted on creation of Token entities.
  32412. func (m *TokenMutation) SetID(id uint64) {
  32413. m.id = &id
  32414. }
  32415. // ID returns the ID value in the mutation. Note that the ID is only available
  32416. // if it was provided to the builder or after it was returned from the database.
  32417. func (m *TokenMutation) ID() (id uint64, exists bool) {
  32418. if m.id == nil {
  32419. return
  32420. }
  32421. return *m.id, true
  32422. }
  32423. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32424. // That means, if the mutation is applied within a transaction with an isolation level such
  32425. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32426. // or updated by the mutation.
  32427. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  32428. switch {
  32429. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32430. id, exists := m.ID()
  32431. if exists {
  32432. return []uint64{id}, nil
  32433. }
  32434. fallthrough
  32435. case m.op.Is(OpUpdate | OpDelete):
  32436. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  32437. default:
  32438. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32439. }
  32440. }
  32441. // SetCreatedAt sets the "created_at" field.
  32442. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  32443. m.created_at = &t
  32444. }
  32445. // CreatedAt returns the value of the "created_at" field in the mutation.
  32446. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  32447. v := m.created_at
  32448. if v == nil {
  32449. return
  32450. }
  32451. return *v, true
  32452. }
  32453. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  32454. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32456. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32457. if !m.op.Is(OpUpdateOne) {
  32458. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32459. }
  32460. if m.id == nil || m.oldValue == nil {
  32461. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32462. }
  32463. oldValue, err := m.oldValue(ctx)
  32464. if err != nil {
  32465. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32466. }
  32467. return oldValue.CreatedAt, nil
  32468. }
  32469. // ResetCreatedAt resets all changes to the "created_at" field.
  32470. func (m *TokenMutation) ResetCreatedAt() {
  32471. m.created_at = nil
  32472. }
  32473. // SetUpdatedAt sets the "updated_at" field.
  32474. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  32475. m.updated_at = &t
  32476. }
  32477. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32478. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  32479. v := m.updated_at
  32480. if v == nil {
  32481. return
  32482. }
  32483. return *v, true
  32484. }
  32485. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  32486. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32488. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32489. if !m.op.Is(OpUpdateOne) {
  32490. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32491. }
  32492. if m.id == nil || m.oldValue == nil {
  32493. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32494. }
  32495. oldValue, err := m.oldValue(ctx)
  32496. if err != nil {
  32497. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32498. }
  32499. return oldValue.UpdatedAt, nil
  32500. }
  32501. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32502. func (m *TokenMutation) ResetUpdatedAt() {
  32503. m.updated_at = nil
  32504. }
  32505. // SetDeletedAt sets the "deleted_at" field.
  32506. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  32507. m.deleted_at = &t
  32508. }
  32509. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32510. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  32511. v := m.deleted_at
  32512. if v == nil {
  32513. return
  32514. }
  32515. return *v, true
  32516. }
  32517. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  32518. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32520. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32521. if !m.op.Is(OpUpdateOne) {
  32522. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32523. }
  32524. if m.id == nil || m.oldValue == nil {
  32525. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32526. }
  32527. oldValue, err := m.oldValue(ctx)
  32528. if err != nil {
  32529. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32530. }
  32531. return oldValue.DeletedAt, nil
  32532. }
  32533. // ClearDeletedAt clears the value of the "deleted_at" field.
  32534. func (m *TokenMutation) ClearDeletedAt() {
  32535. m.deleted_at = nil
  32536. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  32537. }
  32538. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32539. func (m *TokenMutation) DeletedAtCleared() bool {
  32540. _, ok := m.clearedFields[token.FieldDeletedAt]
  32541. return ok
  32542. }
  32543. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32544. func (m *TokenMutation) ResetDeletedAt() {
  32545. m.deleted_at = nil
  32546. delete(m.clearedFields, token.FieldDeletedAt)
  32547. }
  32548. // SetExpireAt sets the "expire_at" field.
  32549. func (m *TokenMutation) SetExpireAt(t time.Time) {
  32550. m.expire_at = &t
  32551. }
  32552. // ExpireAt returns the value of the "expire_at" field in the mutation.
  32553. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  32554. v := m.expire_at
  32555. if v == nil {
  32556. return
  32557. }
  32558. return *v, true
  32559. }
  32560. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  32561. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32563. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  32564. if !m.op.Is(OpUpdateOne) {
  32565. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  32566. }
  32567. if m.id == nil || m.oldValue == nil {
  32568. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  32569. }
  32570. oldValue, err := m.oldValue(ctx)
  32571. if err != nil {
  32572. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  32573. }
  32574. return oldValue.ExpireAt, nil
  32575. }
  32576. // ClearExpireAt clears the value of the "expire_at" field.
  32577. func (m *TokenMutation) ClearExpireAt() {
  32578. m.expire_at = nil
  32579. m.clearedFields[token.FieldExpireAt] = struct{}{}
  32580. }
  32581. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  32582. func (m *TokenMutation) ExpireAtCleared() bool {
  32583. _, ok := m.clearedFields[token.FieldExpireAt]
  32584. return ok
  32585. }
  32586. // ResetExpireAt resets all changes to the "expire_at" field.
  32587. func (m *TokenMutation) ResetExpireAt() {
  32588. m.expire_at = nil
  32589. delete(m.clearedFields, token.FieldExpireAt)
  32590. }
  32591. // SetToken sets the "token" field.
  32592. func (m *TokenMutation) SetToken(s string) {
  32593. m.token = &s
  32594. }
  32595. // Token returns the value of the "token" field in the mutation.
  32596. func (m *TokenMutation) Token() (r string, exists bool) {
  32597. v := m.token
  32598. if v == nil {
  32599. return
  32600. }
  32601. return *v, true
  32602. }
  32603. // OldToken returns the old "token" field's value of the Token entity.
  32604. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32606. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  32607. if !m.op.Is(OpUpdateOne) {
  32608. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  32609. }
  32610. if m.id == nil || m.oldValue == nil {
  32611. return v, errors.New("OldToken requires an ID field in the mutation")
  32612. }
  32613. oldValue, err := m.oldValue(ctx)
  32614. if err != nil {
  32615. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  32616. }
  32617. return oldValue.Token, nil
  32618. }
  32619. // ClearToken clears the value of the "token" field.
  32620. func (m *TokenMutation) ClearToken() {
  32621. m.token = nil
  32622. m.clearedFields[token.FieldToken] = struct{}{}
  32623. }
  32624. // TokenCleared returns if the "token" field was cleared in this mutation.
  32625. func (m *TokenMutation) TokenCleared() bool {
  32626. _, ok := m.clearedFields[token.FieldToken]
  32627. return ok
  32628. }
  32629. // ResetToken resets all changes to the "token" field.
  32630. func (m *TokenMutation) ResetToken() {
  32631. m.token = nil
  32632. delete(m.clearedFields, token.FieldToken)
  32633. }
  32634. // SetMAC sets the "mac" field.
  32635. func (m *TokenMutation) SetMAC(s string) {
  32636. m.mac = &s
  32637. }
  32638. // MAC returns the value of the "mac" field in the mutation.
  32639. func (m *TokenMutation) MAC() (r string, exists bool) {
  32640. v := m.mac
  32641. if v == nil {
  32642. return
  32643. }
  32644. return *v, true
  32645. }
  32646. // OldMAC returns the old "mac" field's value of the Token entity.
  32647. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32649. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  32650. if !m.op.Is(OpUpdateOne) {
  32651. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  32652. }
  32653. if m.id == nil || m.oldValue == nil {
  32654. return v, errors.New("OldMAC requires an ID field in the mutation")
  32655. }
  32656. oldValue, err := m.oldValue(ctx)
  32657. if err != nil {
  32658. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  32659. }
  32660. return oldValue.MAC, nil
  32661. }
  32662. // ClearMAC clears the value of the "mac" field.
  32663. func (m *TokenMutation) ClearMAC() {
  32664. m.mac = nil
  32665. m.clearedFields[token.FieldMAC] = struct{}{}
  32666. }
  32667. // MACCleared returns if the "mac" field was cleared in this mutation.
  32668. func (m *TokenMutation) MACCleared() bool {
  32669. _, ok := m.clearedFields[token.FieldMAC]
  32670. return ok
  32671. }
  32672. // ResetMAC resets all changes to the "mac" field.
  32673. func (m *TokenMutation) ResetMAC() {
  32674. m.mac = nil
  32675. delete(m.clearedFields, token.FieldMAC)
  32676. }
  32677. // SetOrganizationID sets the "organization_id" field.
  32678. func (m *TokenMutation) SetOrganizationID(u uint64) {
  32679. m.organization_id = &u
  32680. m.addorganization_id = nil
  32681. }
  32682. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32683. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  32684. v := m.organization_id
  32685. if v == nil {
  32686. return
  32687. }
  32688. return *v, true
  32689. }
  32690. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  32691. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32693. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32694. if !m.op.Is(OpUpdateOne) {
  32695. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32696. }
  32697. if m.id == nil || m.oldValue == nil {
  32698. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32699. }
  32700. oldValue, err := m.oldValue(ctx)
  32701. if err != nil {
  32702. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32703. }
  32704. return oldValue.OrganizationID, nil
  32705. }
  32706. // AddOrganizationID adds u to the "organization_id" field.
  32707. func (m *TokenMutation) AddOrganizationID(u int64) {
  32708. if m.addorganization_id != nil {
  32709. *m.addorganization_id += u
  32710. } else {
  32711. m.addorganization_id = &u
  32712. }
  32713. }
  32714. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32715. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  32716. v := m.addorganization_id
  32717. if v == nil {
  32718. return
  32719. }
  32720. return *v, true
  32721. }
  32722. // ResetOrganizationID resets all changes to the "organization_id" field.
  32723. func (m *TokenMutation) ResetOrganizationID() {
  32724. m.organization_id = nil
  32725. m.addorganization_id = nil
  32726. }
  32727. // SetAgentID sets the "agent_id" field.
  32728. func (m *TokenMutation) SetAgentID(u uint64) {
  32729. m.agent = &u
  32730. }
  32731. // AgentID returns the value of the "agent_id" field in the mutation.
  32732. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  32733. v := m.agent
  32734. if v == nil {
  32735. return
  32736. }
  32737. return *v, true
  32738. }
  32739. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  32740. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32742. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32743. if !m.op.Is(OpUpdateOne) {
  32744. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32745. }
  32746. if m.id == nil || m.oldValue == nil {
  32747. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32748. }
  32749. oldValue, err := m.oldValue(ctx)
  32750. if err != nil {
  32751. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32752. }
  32753. return oldValue.AgentID, nil
  32754. }
  32755. // ResetAgentID resets all changes to the "agent_id" field.
  32756. func (m *TokenMutation) ResetAgentID() {
  32757. m.agent = nil
  32758. }
  32759. // SetCustomAgentBase sets the "custom_agent_base" field.
  32760. func (m *TokenMutation) SetCustomAgentBase(s string) {
  32761. m.custom_agent_base = &s
  32762. }
  32763. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  32764. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  32765. v := m.custom_agent_base
  32766. if v == nil {
  32767. return
  32768. }
  32769. return *v, true
  32770. }
  32771. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  32772. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32774. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  32775. if !m.op.Is(OpUpdateOne) {
  32776. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  32777. }
  32778. if m.id == nil || m.oldValue == nil {
  32779. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  32780. }
  32781. oldValue, err := m.oldValue(ctx)
  32782. if err != nil {
  32783. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  32784. }
  32785. return oldValue.CustomAgentBase, nil
  32786. }
  32787. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  32788. func (m *TokenMutation) ClearCustomAgentBase() {
  32789. m.custom_agent_base = nil
  32790. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  32791. }
  32792. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  32793. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  32794. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  32795. return ok
  32796. }
  32797. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  32798. func (m *TokenMutation) ResetCustomAgentBase() {
  32799. m.custom_agent_base = nil
  32800. delete(m.clearedFields, token.FieldCustomAgentBase)
  32801. }
  32802. // SetCustomAgentKey sets the "custom_agent_key" field.
  32803. func (m *TokenMutation) SetCustomAgentKey(s string) {
  32804. m.custom_agent_key = &s
  32805. }
  32806. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  32807. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  32808. v := m.custom_agent_key
  32809. if v == nil {
  32810. return
  32811. }
  32812. return *v, true
  32813. }
  32814. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  32815. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32817. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  32818. if !m.op.Is(OpUpdateOne) {
  32819. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  32820. }
  32821. if m.id == nil || m.oldValue == nil {
  32822. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  32823. }
  32824. oldValue, err := m.oldValue(ctx)
  32825. if err != nil {
  32826. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  32827. }
  32828. return oldValue.CustomAgentKey, nil
  32829. }
  32830. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  32831. func (m *TokenMutation) ClearCustomAgentKey() {
  32832. m.custom_agent_key = nil
  32833. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  32834. }
  32835. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  32836. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  32837. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  32838. return ok
  32839. }
  32840. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  32841. func (m *TokenMutation) ResetCustomAgentKey() {
  32842. m.custom_agent_key = nil
  32843. delete(m.clearedFields, token.FieldCustomAgentKey)
  32844. }
  32845. // SetOpenaiBase sets the "openai_base" field.
  32846. func (m *TokenMutation) SetOpenaiBase(s string) {
  32847. m.openai_base = &s
  32848. }
  32849. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  32850. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  32851. v := m.openai_base
  32852. if v == nil {
  32853. return
  32854. }
  32855. return *v, true
  32856. }
  32857. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  32858. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32860. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  32861. if !m.op.Is(OpUpdateOne) {
  32862. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  32863. }
  32864. if m.id == nil || m.oldValue == nil {
  32865. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  32866. }
  32867. oldValue, err := m.oldValue(ctx)
  32868. if err != nil {
  32869. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  32870. }
  32871. return oldValue.OpenaiBase, nil
  32872. }
  32873. // ClearOpenaiBase clears the value of the "openai_base" field.
  32874. func (m *TokenMutation) ClearOpenaiBase() {
  32875. m.openai_base = nil
  32876. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  32877. }
  32878. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  32879. func (m *TokenMutation) OpenaiBaseCleared() bool {
  32880. _, ok := m.clearedFields[token.FieldOpenaiBase]
  32881. return ok
  32882. }
  32883. // ResetOpenaiBase resets all changes to the "openai_base" field.
  32884. func (m *TokenMutation) ResetOpenaiBase() {
  32885. m.openai_base = nil
  32886. delete(m.clearedFields, token.FieldOpenaiBase)
  32887. }
  32888. // SetOpenaiKey sets the "openai_key" field.
  32889. func (m *TokenMutation) SetOpenaiKey(s string) {
  32890. m.openai_key = &s
  32891. }
  32892. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  32893. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  32894. v := m.openai_key
  32895. if v == nil {
  32896. return
  32897. }
  32898. return *v, true
  32899. }
  32900. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  32901. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32903. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  32904. if !m.op.Is(OpUpdateOne) {
  32905. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  32906. }
  32907. if m.id == nil || m.oldValue == nil {
  32908. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  32909. }
  32910. oldValue, err := m.oldValue(ctx)
  32911. if err != nil {
  32912. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  32913. }
  32914. return oldValue.OpenaiKey, nil
  32915. }
  32916. // ClearOpenaiKey clears the value of the "openai_key" field.
  32917. func (m *TokenMutation) ClearOpenaiKey() {
  32918. m.openai_key = nil
  32919. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  32920. }
  32921. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  32922. func (m *TokenMutation) OpenaiKeyCleared() bool {
  32923. _, ok := m.clearedFields[token.FieldOpenaiKey]
  32924. return ok
  32925. }
  32926. // ResetOpenaiKey resets all changes to the "openai_key" field.
  32927. func (m *TokenMutation) ResetOpenaiKey() {
  32928. m.openai_key = nil
  32929. delete(m.clearedFields, token.FieldOpenaiKey)
  32930. }
  32931. // ClearAgent clears the "agent" edge to the Agent entity.
  32932. func (m *TokenMutation) ClearAgent() {
  32933. m.clearedagent = true
  32934. m.clearedFields[token.FieldAgentID] = struct{}{}
  32935. }
  32936. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  32937. func (m *TokenMutation) AgentCleared() bool {
  32938. return m.clearedagent
  32939. }
  32940. // AgentIDs returns the "agent" edge IDs in the mutation.
  32941. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32942. // AgentID instead. It exists only for internal usage by the builders.
  32943. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  32944. if id := m.agent; id != nil {
  32945. ids = append(ids, *id)
  32946. }
  32947. return
  32948. }
  32949. // ResetAgent resets all changes to the "agent" edge.
  32950. func (m *TokenMutation) ResetAgent() {
  32951. m.agent = nil
  32952. m.clearedagent = false
  32953. }
  32954. // Where appends a list predicates to the TokenMutation builder.
  32955. func (m *TokenMutation) Where(ps ...predicate.Token) {
  32956. m.predicates = append(m.predicates, ps...)
  32957. }
  32958. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  32959. // users can use type-assertion to append predicates that do not depend on any generated package.
  32960. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  32961. p := make([]predicate.Token, len(ps))
  32962. for i := range ps {
  32963. p[i] = ps[i]
  32964. }
  32965. m.Where(p...)
  32966. }
  32967. // Op returns the operation name.
  32968. func (m *TokenMutation) Op() Op {
  32969. return m.op
  32970. }
  32971. // SetOp allows setting the mutation operation.
  32972. func (m *TokenMutation) SetOp(op Op) {
  32973. m.op = op
  32974. }
  32975. // Type returns the node type of this mutation (Token).
  32976. func (m *TokenMutation) Type() string {
  32977. return m.typ
  32978. }
  32979. // Fields returns all fields that were changed during this mutation. Note that in
  32980. // order to get all numeric fields that were incremented/decremented, call
  32981. // AddedFields().
  32982. func (m *TokenMutation) Fields() []string {
  32983. fields := make([]string, 0, 12)
  32984. if m.created_at != nil {
  32985. fields = append(fields, token.FieldCreatedAt)
  32986. }
  32987. if m.updated_at != nil {
  32988. fields = append(fields, token.FieldUpdatedAt)
  32989. }
  32990. if m.deleted_at != nil {
  32991. fields = append(fields, token.FieldDeletedAt)
  32992. }
  32993. if m.expire_at != nil {
  32994. fields = append(fields, token.FieldExpireAt)
  32995. }
  32996. if m.token != nil {
  32997. fields = append(fields, token.FieldToken)
  32998. }
  32999. if m.mac != nil {
  33000. fields = append(fields, token.FieldMAC)
  33001. }
  33002. if m.organization_id != nil {
  33003. fields = append(fields, token.FieldOrganizationID)
  33004. }
  33005. if m.agent != nil {
  33006. fields = append(fields, token.FieldAgentID)
  33007. }
  33008. if m.custom_agent_base != nil {
  33009. fields = append(fields, token.FieldCustomAgentBase)
  33010. }
  33011. if m.custom_agent_key != nil {
  33012. fields = append(fields, token.FieldCustomAgentKey)
  33013. }
  33014. if m.openai_base != nil {
  33015. fields = append(fields, token.FieldOpenaiBase)
  33016. }
  33017. if m.openai_key != nil {
  33018. fields = append(fields, token.FieldOpenaiKey)
  33019. }
  33020. return fields
  33021. }
  33022. // Field returns the value of a field with the given name. The second boolean
  33023. // return value indicates that this field was not set, or was not defined in the
  33024. // schema.
  33025. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  33026. switch name {
  33027. case token.FieldCreatedAt:
  33028. return m.CreatedAt()
  33029. case token.FieldUpdatedAt:
  33030. return m.UpdatedAt()
  33031. case token.FieldDeletedAt:
  33032. return m.DeletedAt()
  33033. case token.FieldExpireAt:
  33034. return m.ExpireAt()
  33035. case token.FieldToken:
  33036. return m.Token()
  33037. case token.FieldMAC:
  33038. return m.MAC()
  33039. case token.FieldOrganizationID:
  33040. return m.OrganizationID()
  33041. case token.FieldAgentID:
  33042. return m.AgentID()
  33043. case token.FieldCustomAgentBase:
  33044. return m.CustomAgentBase()
  33045. case token.FieldCustomAgentKey:
  33046. return m.CustomAgentKey()
  33047. case token.FieldOpenaiBase:
  33048. return m.OpenaiBase()
  33049. case token.FieldOpenaiKey:
  33050. return m.OpenaiKey()
  33051. }
  33052. return nil, false
  33053. }
  33054. // OldField returns the old value of the field from the database. An error is
  33055. // returned if the mutation operation is not UpdateOne, or the query to the
  33056. // database failed.
  33057. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33058. switch name {
  33059. case token.FieldCreatedAt:
  33060. return m.OldCreatedAt(ctx)
  33061. case token.FieldUpdatedAt:
  33062. return m.OldUpdatedAt(ctx)
  33063. case token.FieldDeletedAt:
  33064. return m.OldDeletedAt(ctx)
  33065. case token.FieldExpireAt:
  33066. return m.OldExpireAt(ctx)
  33067. case token.FieldToken:
  33068. return m.OldToken(ctx)
  33069. case token.FieldMAC:
  33070. return m.OldMAC(ctx)
  33071. case token.FieldOrganizationID:
  33072. return m.OldOrganizationID(ctx)
  33073. case token.FieldAgentID:
  33074. return m.OldAgentID(ctx)
  33075. case token.FieldCustomAgentBase:
  33076. return m.OldCustomAgentBase(ctx)
  33077. case token.FieldCustomAgentKey:
  33078. return m.OldCustomAgentKey(ctx)
  33079. case token.FieldOpenaiBase:
  33080. return m.OldOpenaiBase(ctx)
  33081. case token.FieldOpenaiKey:
  33082. return m.OldOpenaiKey(ctx)
  33083. }
  33084. return nil, fmt.Errorf("unknown Token field %s", name)
  33085. }
  33086. // SetField sets the value of a field with the given name. It returns an error if
  33087. // the field is not defined in the schema, or if the type mismatched the field
  33088. // type.
  33089. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  33090. switch name {
  33091. case token.FieldCreatedAt:
  33092. v, ok := value.(time.Time)
  33093. if !ok {
  33094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33095. }
  33096. m.SetCreatedAt(v)
  33097. return nil
  33098. case token.FieldUpdatedAt:
  33099. v, ok := value.(time.Time)
  33100. if !ok {
  33101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33102. }
  33103. m.SetUpdatedAt(v)
  33104. return nil
  33105. case token.FieldDeletedAt:
  33106. v, ok := value.(time.Time)
  33107. if !ok {
  33108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33109. }
  33110. m.SetDeletedAt(v)
  33111. return nil
  33112. case token.FieldExpireAt:
  33113. v, ok := value.(time.Time)
  33114. if !ok {
  33115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33116. }
  33117. m.SetExpireAt(v)
  33118. return nil
  33119. case token.FieldToken:
  33120. v, ok := value.(string)
  33121. if !ok {
  33122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33123. }
  33124. m.SetToken(v)
  33125. return nil
  33126. case token.FieldMAC:
  33127. v, ok := value.(string)
  33128. if !ok {
  33129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33130. }
  33131. m.SetMAC(v)
  33132. return nil
  33133. case token.FieldOrganizationID:
  33134. v, ok := value.(uint64)
  33135. if !ok {
  33136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33137. }
  33138. m.SetOrganizationID(v)
  33139. return nil
  33140. case token.FieldAgentID:
  33141. v, ok := value.(uint64)
  33142. if !ok {
  33143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33144. }
  33145. m.SetAgentID(v)
  33146. return nil
  33147. case token.FieldCustomAgentBase:
  33148. v, ok := value.(string)
  33149. if !ok {
  33150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33151. }
  33152. m.SetCustomAgentBase(v)
  33153. return nil
  33154. case token.FieldCustomAgentKey:
  33155. v, ok := value.(string)
  33156. if !ok {
  33157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33158. }
  33159. m.SetCustomAgentKey(v)
  33160. return nil
  33161. case token.FieldOpenaiBase:
  33162. v, ok := value.(string)
  33163. if !ok {
  33164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33165. }
  33166. m.SetOpenaiBase(v)
  33167. return nil
  33168. case token.FieldOpenaiKey:
  33169. v, ok := value.(string)
  33170. if !ok {
  33171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33172. }
  33173. m.SetOpenaiKey(v)
  33174. return nil
  33175. }
  33176. return fmt.Errorf("unknown Token field %s", name)
  33177. }
  33178. // AddedFields returns all numeric fields that were incremented/decremented during
  33179. // this mutation.
  33180. func (m *TokenMutation) AddedFields() []string {
  33181. var fields []string
  33182. if m.addorganization_id != nil {
  33183. fields = append(fields, token.FieldOrganizationID)
  33184. }
  33185. return fields
  33186. }
  33187. // AddedField returns the numeric value that was incremented/decremented on a field
  33188. // with the given name. The second boolean return value indicates that this field
  33189. // was not set, or was not defined in the schema.
  33190. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  33191. switch name {
  33192. case token.FieldOrganizationID:
  33193. return m.AddedOrganizationID()
  33194. }
  33195. return nil, false
  33196. }
  33197. // AddField adds the value to the field with the given name. It returns an error if
  33198. // the field is not defined in the schema, or if the type mismatched the field
  33199. // type.
  33200. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  33201. switch name {
  33202. case token.FieldOrganizationID:
  33203. v, ok := value.(int64)
  33204. if !ok {
  33205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33206. }
  33207. m.AddOrganizationID(v)
  33208. return nil
  33209. }
  33210. return fmt.Errorf("unknown Token numeric field %s", name)
  33211. }
  33212. // ClearedFields returns all nullable fields that were cleared during this
  33213. // mutation.
  33214. func (m *TokenMutation) ClearedFields() []string {
  33215. var fields []string
  33216. if m.FieldCleared(token.FieldDeletedAt) {
  33217. fields = append(fields, token.FieldDeletedAt)
  33218. }
  33219. if m.FieldCleared(token.FieldExpireAt) {
  33220. fields = append(fields, token.FieldExpireAt)
  33221. }
  33222. if m.FieldCleared(token.FieldToken) {
  33223. fields = append(fields, token.FieldToken)
  33224. }
  33225. if m.FieldCleared(token.FieldMAC) {
  33226. fields = append(fields, token.FieldMAC)
  33227. }
  33228. if m.FieldCleared(token.FieldCustomAgentBase) {
  33229. fields = append(fields, token.FieldCustomAgentBase)
  33230. }
  33231. if m.FieldCleared(token.FieldCustomAgentKey) {
  33232. fields = append(fields, token.FieldCustomAgentKey)
  33233. }
  33234. if m.FieldCleared(token.FieldOpenaiBase) {
  33235. fields = append(fields, token.FieldOpenaiBase)
  33236. }
  33237. if m.FieldCleared(token.FieldOpenaiKey) {
  33238. fields = append(fields, token.FieldOpenaiKey)
  33239. }
  33240. return fields
  33241. }
  33242. // FieldCleared returns a boolean indicating if a field with the given name was
  33243. // cleared in this mutation.
  33244. func (m *TokenMutation) FieldCleared(name string) bool {
  33245. _, ok := m.clearedFields[name]
  33246. return ok
  33247. }
  33248. // ClearField clears the value of the field with the given name. It returns an
  33249. // error if the field is not defined in the schema.
  33250. func (m *TokenMutation) ClearField(name string) error {
  33251. switch name {
  33252. case token.FieldDeletedAt:
  33253. m.ClearDeletedAt()
  33254. return nil
  33255. case token.FieldExpireAt:
  33256. m.ClearExpireAt()
  33257. return nil
  33258. case token.FieldToken:
  33259. m.ClearToken()
  33260. return nil
  33261. case token.FieldMAC:
  33262. m.ClearMAC()
  33263. return nil
  33264. case token.FieldCustomAgentBase:
  33265. m.ClearCustomAgentBase()
  33266. return nil
  33267. case token.FieldCustomAgentKey:
  33268. m.ClearCustomAgentKey()
  33269. return nil
  33270. case token.FieldOpenaiBase:
  33271. m.ClearOpenaiBase()
  33272. return nil
  33273. case token.FieldOpenaiKey:
  33274. m.ClearOpenaiKey()
  33275. return nil
  33276. }
  33277. return fmt.Errorf("unknown Token nullable field %s", name)
  33278. }
  33279. // ResetField resets all changes in the mutation for the field with the given name.
  33280. // It returns an error if the field is not defined in the schema.
  33281. func (m *TokenMutation) ResetField(name string) error {
  33282. switch name {
  33283. case token.FieldCreatedAt:
  33284. m.ResetCreatedAt()
  33285. return nil
  33286. case token.FieldUpdatedAt:
  33287. m.ResetUpdatedAt()
  33288. return nil
  33289. case token.FieldDeletedAt:
  33290. m.ResetDeletedAt()
  33291. return nil
  33292. case token.FieldExpireAt:
  33293. m.ResetExpireAt()
  33294. return nil
  33295. case token.FieldToken:
  33296. m.ResetToken()
  33297. return nil
  33298. case token.FieldMAC:
  33299. m.ResetMAC()
  33300. return nil
  33301. case token.FieldOrganizationID:
  33302. m.ResetOrganizationID()
  33303. return nil
  33304. case token.FieldAgentID:
  33305. m.ResetAgentID()
  33306. return nil
  33307. case token.FieldCustomAgentBase:
  33308. m.ResetCustomAgentBase()
  33309. return nil
  33310. case token.FieldCustomAgentKey:
  33311. m.ResetCustomAgentKey()
  33312. return nil
  33313. case token.FieldOpenaiBase:
  33314. m.ResetOpenaiBase()
  33315. return nil
  33316. case token.FieldOpenaiKey:
  33317. m.ResetOpenaiKey()
  33318. return nil
  33319. }
  33320. return fmt.Errorf("unknown Token field %s", name)
  33321. }
  33322. // AddedEdges returns all edge names that were set/added in this mutation.
  33323. func (m *TokenMutation) AddedEdges() []string {
  33324. edges := make([]string, 0, 1)
  33325. if m.agent != nil {
  33326. edges = append(edges, token.EdgeAgent)
  33327. }
  33328. return edges
  33329. }
  33330. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33331. // name in this mutation.
  33332. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  33333. switch name {
  33334. case token.EdgeAgent:
  33335. if id := m.agent; id != nil {
  33336. return []ent.Value{*id}
  33337. }
  33338. }
  33339. return nil
  33340. }
  33341. // RemovedEdges returns all edge names that were removed in this mutation.
  33342. func (m *TokenMutation) RemovedEdges() []string {
  33343. edges := make([]string, 0, 1)
  33344. return edges
  33345. }
  33346. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33347. // the given name in this mutation.
  33348. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  33349. return nil
  33350. }
  33351. // ClearedEdges returns all edge names that were cleared in this mutation.
  33352. func (m *TokenMutation) ClearedEdges() []string {
  33353. edges := make([]string, 0, 1)
  33354. if m.clearedagent {
  33355. edges = append(edges, token.EdgeAgent)
  33356. }
  33357. return edges
  33358. }
  33359. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33360. // was cleared in this mutation.
  33361. func (m *TokenMutation) EdgeCleared(name string) bool {
  33362. switch name {
  33363. case token.EdgeAgent:
  33364. return m.clearedagent
  33365. }
  33366. return false
  33367. }
  33368. // ClearEdge clears the value of the edge with the given name. It returns an error
  33369. // if that edge is not defined in the schema.
  33370. func (m *TokenMutation) ClearEdge(name string) error {
  33371. switch name {
  33372. case token.EdgeAgent:
  33373. m.ClearAgent()
  33374. return nil
  33375. }
  33376. return fmt.Errorf("unknown Token unique edge %s", name)
  33377. }
  33378. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33379. // It returns an error if the edge is not defined in the schema.
  33380. func (m *TokenMutation) ResetEdge(name string) error {
  33381. switch name {
  33382. case token.EdgeAgent:
  33383. m.ResetAgent()
  33384. return nil
  33385. }
  33386. return fmt.Errorf("unknown Token edge %s", name)
  33387. }
  33388. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  33389. type TutorialMutation struct {
  33390. config
  33391. op Op
  33392. typ string
  33393. id *uint64
  33394. created_at *time.Time
  33395. updated_at *time.Time
  33396. deleted_at *time.Time
  33397. index *int
  33398. addindex *int
  33399. title *string
  33400. content *string
  33401. organization_id *uint64
  33402. addorganization_id *int64
  33403. clearedFields map[string]struct{}
  33404. employee *uint64
  33405. clearedemployee bool
  33406. done bool
  33407. oldValue func(context.Context) (*Tutorial, error)
  33408. predicates []predicate.Tutorial
  33409. }
  33410. var _ ent.Mutation = (*TutorialMutation)(nil)
  33411. // tutorialOption allows management of the mutation configuration using functional options.
  33412. type tutorialOption func(*TutorialMutation)
  33413. // newTutorialMutation creates new mutation for the Tutorial entity.
  33414. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  33415. m := &TutorialMutation{
  33416. config: c,
  33417. op: op,
  33418. typ: TypeTutorial,
  33419. clearedFields: make(map[string]struct{}),
  33420. }
  33421. for _, opt := range opts {
  33422. opt(m)
  33423. }
  33424. return m
  33425. }
  33426. // withTutorialID sets the ID field of the mutation.
  33427. func withTutorialID(id uint64) tutorialOption {
  33428. return func(m *TutorialMutation) {
  33429. var (
  33430. err error
  33431. once sync.Once
  33432. value *Tutorial
  33433. )
  33434. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  33435. once.Do(func() {
  33436. if m.done {
  33437. err = errors.New("querying old values post mutation is not allowed")
  33438. } else {
  33439. value, err = m.Client().Tutorial.Get(ctx, id)
  33440. }
  33441. })
  33442. return value, err
  33443. }
  33444. m.id = &id
  33445. }
  33446. }
  33447. // withTutorial sets the old Tutorial of the mutation.
  33448. func withTutorial(node *Tutorial) tutorialOption {
  33449. return func(m *TutorialMutation) {
  33450. m.oldValue = func(context.Context) (*Tutorial, error) {
  33451. return node, nil
  33452. }
  33453. m.id = &node.ID
  33454. }
  33455. }
  33456. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33457. // executed in a transaction (ent.Tx), a transactional client is returned.
  33458. func (m TutorialMutation) Client() *Client {
  33459. client := &Client{config: m.config}
  33460. client.init()
  33461. return client
  33462. }
  33463. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33464. // it returns an error otherwise.
  33465. func (m TutorialMutation) Tx() (*Tx, error) {
  33466. if _, ok := m.driver.(*txDriver); !ok {
  33467. return nil, errors.New("ent: mutation is not running in a transaction")
  33468. }
  33469. tx := &Tx{config: m.config}
  33470. tx.init()
  33471. return tx, nil
  33472. }
  33473. // SetID sets the value of the id field. Note that this
  33474. // operation is only accepted on creation of Tutorial entities.
  33475. func (m *TutorialMutation) SetID(id uint64) {
  33476. m.id = &id
  33477. }
  33478. // ID returns the ID value in the mutation. Note that the ID is only available
  33479. // if it was provided to the builder or after it was returned from the database.
  33480. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  33481. if m.id == nil {
  33482. return
  33483. }
  33484. return *m.id, true
  33485. }
  33486. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33487. // That means, if the mutation is applied within a transaction with an isolation level such
  33488. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33489. // or updated by the mutation.
  33490. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  33491. switch {
  33492. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33493. id, exists := m.ID()
  33494. if exists {
  33495. return []uint64{id}, nil
  33496. }
  33497. fallthrough
  33498. case m.op.Is(OpUpdate | OpDelete):
  33499. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  33500. default:
  33501. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33502. }
  33503. }
  33504. // SetCreatedAt sets the "created_at" field.
  33505. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  33506. m.created_at = &t
  33507. }
  33508. // CreatedAt returns the value of the "created_at" field in the mutation.
  33509. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  33510. v := m.created_at
  33511. if v == nil {
  33512. return
  33513. }
  33514. return *v, true
  33515. }
  33516. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  33517. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33519. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33520. if !m.op.Is(OpUpdateOne) {
  33521. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33522. }
  33523. if m.id == nil || m.oldValue == nil {
  33524. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33525. }
  33526. oldValue, err := m.oldValue(ctx)
  33527. if err != nil {
  33528. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33529. }
  33530. return oldValue.CreatedAt, nil
  33531. }
  33532. // ResetCreatedAt resets all changes to the "created_at" field.
  33533. func (m *TutorialMutation) ResetCreatedAt() {
  33534. m.created_at = nil
  33535. }
  33536. // SetUpdatedAt sets the "updated_at" field.
  33537. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  33538. m.updated_at = &t
  33539. }
  33540. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33541. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  33542. v := m.updated_at
  33543. if v == nil {
  33544. return
  33545. }
  33546. return *v, true
  33547. }
  33548. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  33549. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33551. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33552. if !m.op.Is(OpUpdateOne) {
  33553. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33554. }
  33555. if m.id == nil || m.oldValue == nil {
  33556. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33557. }
  33558. oldValue, err := m.oldValue(ctx)
  33559. if err != nil {
  33560. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33561. }
  33562. return oldValue.UpdatedAt, nil
  33563. }
  33564. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33565. func (m *TutorialMutation) ResetUpdatedAt() {
  33566. m.updated_at = nil
  33567. }
  33568. // SetDeletedAt sets the "deleted_at" field.
  33569. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  33570. m.deleted_at = &t
  33571. }
  33572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33573. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  33574. v := m.deleted_at
  33575. if v == nil {
  33576. return
  33577. }
  33578. return *v, true
  33579. }
  33580. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  33581. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33583. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33584. if !m.op.Is(OpUpdateOne) {
  33585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33586. }
  33587. if m.id == nil || m.oldValue == nil {
  33588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33589. }
  33590. oldValue, err := m.oldValue(ctx)
  33591. if err != nil {
  33592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33593. }
  33594. return oldValue.DeletedAt, nil
  33595. }
  33596. // ClearDeletedAt clears the value of the "deleted_at" field.
  33597. func (m *TutorialMutation) ClearDeletedAt() {
  33598. m.deleted_at = nil
  33599. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  33600. }
  33601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33602. func (m *TutorialMutation) DeletedAtCleared() bool {
  33603. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  33604. return ok
  33605. }
  33606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33607. func (m *TutorialMutation) ResetDeletedAt() {
  33608. m.deleted_at = nil
  33609. delete(m.clearedFields, tutorial.FieldDeletedAt)
  33610. }
  33611. // SetEmployeeID sets the "employee_id" field.
  33612. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  33613. m.employee = &u
  33614. }
  33615. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33616. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  33617. v := m.employee
  33618. if v == nil {
  33619. return
  33620. }
  33621. return *v, true
  33622. }
  33623. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  33624. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33626. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33627. if !m.op.Is(OpUpdateOne) {
  33628. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33629. }
  33630. if m.id == nil || m.oldValue == nil {
  33631. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33632. }
  33633. oldValue, err := m.oldValue(ctx)
  33634. if err != nil {
  33635. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33636. }
  33637. return oldValue.EmployeeID, nil
  33638. }
  33639. // ResetEmployeeID resets all changes to the "employee_id" field.
  33640. func (m *TutorialMutation) ResetEmployeeID() {
  33641. m.employee = nil
  33642. }
  33643. // SetIndex sets the "index" field.
  33644. func (m *TutorialMutation) SetIndex(i int) {
  33645. m.index = &i
  33646. m.addindex = nil
  33647. }
  33648. // Index returns the value of the "index" field in the mutation.
  33649. func (m *TutorialMutation) Index() (r int, exists bool) {
  33650. v := m.index
  33651. if v == nil {
  33652. return
  33653. }
  33654. return *v, true
  33655. }
  33656. // OldIndex returns the old "index" field's value of the Tutorial entity.
  33657. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33659. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  33660. if !m.op.Is(OpUpdateOne) {
  33661. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  33662. }
  33663. if m.id == nil || m.oldValue == nil {
  33664. return v, errors.New("OldIndex requires an ID field in the mutation")
  33665. }
  33666. oldValue, err := m.oldValue(ctx)
  33667. if err != nil {
  33668. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  33669. }
  33670. return oldValue.Index, nil
  33671. }
  33672. // AddIndex adds i to the "index" field.
  33673. func (m *TutorialMutation) AddIndex(i int) {
  33674. if m.addindex != nil {
  33675. *m.addindex += i
  33676. } else {
  33677. m.addindex = &i
  33678. }
  33679. }
  33680. // AddedIndex returns the value that was added to the "index" field in this mutation.
  33681. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  33682. v := m.addindex
  33683. if v == nil {
  33684. return
  33685. }
  33686. return *v, true
  33687. }
  33688. // ResetIndex resets all changes to the "index" field.
  33689. func (m *TutorialMutation) ResetIndex() {
  33690. m.index = nil
  33691. m.addindex = nil
  33692. }
  33693. // SetTitle sets the "title" field.
  33694. func (m *TutorialMutation) SetTitle(s string) {
  33695. m.title = &s
  33696. }
  33697. // Title returns the value of the "title" field in the mutation.
  33698. func (m *TutorialMutation) Title() (r string, exists bool) {
  33699. v := m.title
  33700. if v == nil {
  33701. return
  33702. }
  33703. return *v, true
  33704. }
  33705. // OldTitle returns the old "title" field's value of the Tutorial entity.
  33706. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33708. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  33709. if !m.op.Is(OpUpdateOne) {
  33710. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  33711. }
  33712. if m.id == nil || m.oldValue == nil {
  33713. return v, errors.New("OldTitle requires an ID field in the mutation")
  33714. }
  33715. oldValue, err := m.oldValue(ctx)
  33716. if err != nil {
  33717. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  33718. }
  33719. return oldValue.Title, nil
  33720. }
  33721. // ResetTitle resets all changes to the "title" field.
  33722. func (m *TutorialMutation) ResetTitle() {
  33723. m.title = nil
  33724. }
  33725. // SetContent sets the "content" field.
  33726. func (m *TutorialMutation) SetContent(s string) {
  33727. m.content = &s
  33728. }
  33729. // Content returns the value of the "content" field in the mutation.
  33730. func (m *TutorialMutation) Content() (r string, exists bool) {
  33731. v := m.content
  33732. if v == nil {
  33733. return
  33734. }
  33735. return *v, true
  33736. }
  33737. // OldContent returns the old "content" field's value of the Tutorial entity.
  33738. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33740. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  33741. if !m.op.Is(OpUpdateOne) {
  33742. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  33743. }
  33744. if m.id == nil || m.oldValue == nil {
  33745. return v, errors.New("OldContent requires an ID field in the mutation")
  33746. }
  33747. oldValue, err := m.oldValue(ctx)
  33748. if err != nil {
  33749. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  33750. }
  33751. return oldValue.Content, nil
  33752. }
  33753. // ResetContent resets all changes to the "content" field.
  33754. func (m *TutorialMutation) ResetContent() {
  33755. m.content = nil
  33756. }
  33757. // SetOrganizationID sets the "organization_id" field.
  33758. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  33759. m.organization_id = &u
  33760. m.addorganization_id = nil
  33761. }
  33762. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33763. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  33764. v := m.organization_id
  33765. if v == nil {
  33766. return
  33767. }
  33768. return *v, true
  33769. }
  33770. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  33771. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33773. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33774. if !m.op.Is(OpUpdateOne) {
  33775. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33776. }
  33777. if m.id == nil || m.oldValue == nil {
  33778. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33779. }
  33780. oldValue, err := m.oldValue(ctx)
  33781. if err != nil {
  33782. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33783. }
  33784. return oldValue.OrganizationID, nil
  33785. }
  33786. // AddOrganizationID adds u to the "organization_id" field.
  33787. func (m *TutorialMutation) AddOrganizationID(u int64) {
  33788. if m.addorganization_id != nil {
  33789. *m.addorganization_id += u
  33790. } else {
  33791. m.addorganization_id = &u
  33792. }
  33793. }
  33794. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33795. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  33796. v := m.addorganization_id
  33797. if v == nil {
  33798. return
  33799. }
  33800. return *v, true
  33801. }
  33802. // ResetOrganizationID resets all changes to the "organization_id" field.
  33803. func (m *TutorialMutation) ResetOrganizationID() {
  33804. m.organization_id = nil
  33805. m.addorganization_id = nil
  33806. }
  33807. // ClearEmployee clears the "employee" edge to the Employee entity.
  33808. func (m *TutorialMutation) ClearEmployee() {
  33809. m.clearedemployee = true
  33810. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  33811. }
  33812. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  33813. func (m *TutorialMutation) EmployeeCleared() bool {
  33814. return m.clearedemployee
  33815. }
  33816. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  33817. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33818. // EmployeeID instead. It exists only for internal usage by the builders.
  33819. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  33820. if id := m.employee; id != nil {
  33821. ids = append(ids, *id)
  33822. }
  33823. return
  33824. }
  33825. // ResetEmployee resets all changes to the "employee" edge.
  33826. func (m *TutorialMutation) ResetEmployee() {
  33827. m.employee = nil
  33828. m.clearedemployee = false
  33829. }
  33830. // Where appends a list predicates to the TutorialMutation builder.
  33831. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  33832. m.predicates = append(m.predicates, ps...)
  33833. }
  33834. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  33835. // users can use type-assertion to append predicates that do not depend on any generated package.
  33836. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  33837. p := make([]predicate.Tutorial, len(ps))
  33838. for i := range ps {
  33839. p[i] = ps[i]
  33840. }
  33841. m.Where(p...)
  33842. }
  33843. // Op returns the operation name.
  33844. func (m *TutorialMutation) Op() Op {
  33845. return m.op
  33846. }
  33847. // SetOp allows setting the mutation operation.
  33848. func (m *TutorialMutation) SetOp(op Op) {
  33849. m.op = op
  33850. }
  33851. // Type returns the node type of this mutation (Tutorial).
  33852. func (m *TutorialMutation) Type() string {
  33853. return m.typ
  33854. }
  33855. // Fields returns all fields that were changed during this mutation. Note that in
  33856. // order to get all numeric fields that were incremented/decremented, call
  33857. // AddedFields().
  33858. func (m *TutorialMutation) Fields() []string {
  33859. fields := make([]string, 0, 8)
  33860. if m.created_at != nil {
  33861. fields = append(fields, tutorial.FieldCreatedAt)
  33862. }
  33863. if m.updated_at != nil {
  33864. fields = append(fields, tutorial.FieldUpdatedAt)
  33865. }
  33866. if m.deleted_at != nil {
  33867. fields = append(fields, tutorial.FieldDeletedAt)
  33868. }
  33869. if m.employee != nil {
  33870. fields = append(fields, tutorial.FieldEmployeeID)
  33871. }
  33872. if m.index != nil {
  33873. fields = append(fields, tutorial.FieldIndex)
  33874. }
  33875. if m.title != nil {
  33876. fields = append(fields, tutorial.FieldTitle)
  33877. }
  33878. if m.content != nil {
  33879. fields = append(fields, tutorial.FieldContent)
  33880. }
  33881. if m.organization_id != nil {
  33882. fields = append(fields, tutorial.FieldOrganizationID)
  33883. }
  33884. return fields
  33885. }
  33886. // Field returns the value of a field with the given name. The second boolean
  33887. // return value indicates that this field was not set, or was not defined in the
  33888. // schema.
  33889. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  33890. switch name {
  33891. case tutorial.FieldCreatedAt:
  33892. return m.CreatedAt()
  33893. case tutorial.FieldUpdatedAt:
  33894. return m.UpdatedAt()
  33895. case tutorial.FieldDeletedAt:
  33896. return m.DeletedAt()
  33897. case tutorial.FieldEmployeeID:
  33898. return m.EmployeeID()
  33899. case tutorial.FieldIndex:
  33900. return m.Index()
  33901. case tutorial.FieldTitle:
  33902. return m.Title()
  33903. case tutorial.FieldContent:
  33904. return m.Content()
  33905. case tutorial.FieldOrganizationID:
  33906. return m.OrganizationID()
  33907. }
  33908. return nil, false
  33909. }
  33910. // OldField returns the old value of the field from the database. An error is
  33911. // returned if the mutation operation is not UpdateOne, or the query to the
  33912. // database failed.
  33913. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33914. switch name {
  33915. case tutorial.FieldCreatedAt:
  33916. return m.OldCreatedAt(ctx)
  33917. case tutorial.FieldUpdatedAt:
  33918. return m.OldUpdatedAt(ctx)
  33919. case tutorial.FieldDeletedAt:
  33920. return m.OldDeletedAt(ctx)
  33921. case tutorial.FieldEmployeeID:
  33922. return m.OldEmployeeID(ctx)
  33923. case tutorial.FieldIndex:
  33924. return m.OldIndex(ctx)
  33925. case tutorial.FieldTitle:
  33926. return m.OldTitle(ctx)
  33927. case tutorial.FieldContent:
  33928. return m.OldContent(ctx)
  33929. case tutorial.FieldOrganizationID:
  33930. return m.OldOrganizationID(ctx)
  33931. }
  33932. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  33933. }
  33934. // SetField sets the value of a field with the given name. It returns an error if
  33935. // the field is not defined in the schema, or if the type mismatched the field
  33936. // type.
  33937. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  33938. switch name {
  33939. case tutorial.FieldCreatedAt:
  33940. v, ok := value.(time.Time)
  33941. if !ok {
  33942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33943. }
  33944. m.SetCreatedAt(v)
  33945. return nil
  33946. case tutorial.FieldUpdatedAt:
  33947. v, ok := value.(time.Time)
  33948. if !ok {
  33949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33950. }
  33951. m.SetUpdatedAt(v)
  33952. return nil
  33953. case tutorial.FieldDeletedAt:
  33954. v, ok := value.(time.Time)
  33955. if !ok {
  33956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33957. }
  33958. m.SetDeletedAt(v)
  33959. return nil
  33960. case tutorial.FieldEmployeeID:
  33961. v, ok := value.(uint64)
  33962. if !ok {
  33963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33964. }
  33965. m.SetEmployeeID(v)
  33966. return nil
  33967. case tutorial.FieldIndex:
  33968. v, ok := value.(int)
  33969. if !ok {
  33970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33971. }
  33972. m.SetIndex(v)
  33973. return nil
  33974. case tutorial.FieldTitle:
  33975. v, ok := value.(string)
  33976. if !ok {
  33977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33978. }
  33979. m.SetTitle(v)
  33980. return nil
  33981. case tutorial.FieldContent:
  33982. v, ok := value.(string)
  33983. if !ok {
  33984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33985. }
  33986. m.SetContent(v)
  33987. return nil
  33988. case tutorial.FieldOrganizationID:
  33989. v, ok := value.(uint64)
  33990. if !ok {
  33991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33992. }
  33993. m.SetOrganizationID(v)
  33994. return nil
  33995. }
  33996. return fmt.Errorf("unknown Tutorial field %s", name)
  33997. }
  33998. // AddedFields returns all numeric fields that were incremented/decremented during
  33999. // this mutation.
  34000. func (m *TutorialMutation) AddedFields() []string {
  34001. var fields []string
  34002. if m.addindex != nil {
  34003. fields = append(fields, tutorial.FieldIndex)
  34004. }
  34005. if m.addorganization_id != nil {
  34006. fields = append(fields, tutorial.FieldOrganizationID)
  34007. }
  34008. return fields
  34009. }
  34010. // AddedField returns the numeric value that was incremented/decremented on a field
  34011. // with the given name. The second boolean return value indicates that this field
  34012. // was not set, or was not defined in the schema.
  34013. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  34014. switch name {
  34015. case tutorial.FieldIndex:
  34016. return m.AddedIndex()
  34017. case tutorial.FieldOrganizationID:
  34018. return m.AddedOrganizationID()
  34019. }
  34020. return nil, false
  34021. }
  34022. // AddField adds the value to the field with the given name. It returns an error if
  34023. // the field is not defined in the schema, or if the type mismatched the field
  34024. // type.
  34025. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  34026. switch name {
  34027. case tutorial.FieldIndex:
  34028. v, ok := value.(int)
  34029. if !ok {
  34030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34031. }
  34032. m.AddIndex(v)
  34033. return nil
  34034. case tutorial.FieldOrganizationID:
  34035. v, ok := value.(int64)
  34036. if !ok {
  34037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34038. }
  34039. m.AddOrganizationID(v)
  34040. return nil
  34041. }
  34042. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  34043. }
  34044. // ClearedFields returns all nullable fields that were cleared during this
  34045. // mutation.
  34046. func (m *TutorialMutation) ClearedFields() []string {
  34047. var fields []string
  34048. if m.FieldCleared(tutorial.FieldDeletedAt) {
  34049. fields = append(fields, tutorial.FieldDeletedAt)
  34050. }
  34051. return fields
  34052. }
  34053. // FieldCleared returns a boolean indicating if a field with the given name was
  34054. // cleared in this mutation.
  34055. func (m *TutorialMutation) FieldCleared(name string) bool {
  34056. _, ok := m.clearedFields[name]
  34057. return ok
  34058. }
  34059. // ClearField clears the value of the field with the given name. It returns an
  34060. // error if the field is not defined in the schema.
  34061. func (m *TutorialMutation) ClearField(name string) error {
  34062. switch name {
  34063. case tutorial.FieldDeletedAt:
  34064. m.ClearDeletedAt()
  34065. return nil
  34066. }
  34067. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  34068. }
  34069. // ResetField resets all changes in the mutation for the field with the given name.
  34070. // It returns an error if the field is not defined in the schema.
  34071. func (m *TutorialMutation) ResetField(name string) error {
  34072. switch name {
  34073. case tutorial.FieldCreatedAt:
  34074. m.ResetCreatedAt()
  34075. return nil
  34076. case tutorial.FieldUpdatedAt:
  34077. m.ResetUpdatedAt()
  34078. return nil
  34079. case tutorial.FieldDeletedAt:
  34080. m.ResetDeletedAt()
  34081. return nil
  34082. case tutorial.FieldEmployeeID:
  34083. m.ResetEmployeeID()
  34084. return nil
  34085. case tutorial.FieldIndex:
  34086. m.ResetIndex()
  34087. return nil
  34088. case tutorial.FieldTitle:
  34089. m.ResetTitle()
  34090. return nil
  34091. case tutorial.FieldContent:
  34092. m.ResetContent()
  34093. return nil
  34094. case tutorial.FieldOrganizationID:
  34095. m.ResetOrganizationID()
  34096. return nil
  34097. }
  34098. return fmt.Errorf("unknown Tutorial field %s", name)
  34099. }
  34100. // AddedEdges returns all edge names that were set/added in this mutation.
  34101. func (m *TutorialMutation) AddedEdges() []string {
  34102. edges := make([]string, 0, 1)
  34103. if m.employee != nil {
  34104. edges = append(edges, tutorial.EdgeEmployee)
  34105. }
  34106. return edges
  34107. }
  34108. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34109. // name in this mutation.
  34110. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  34111. switch name {
  34112. case tutorial.EdgeEmployee:
  34113. if id := m.employee; id != nil {
  34114. return []ent.Value{*id}
  34115. }
  34116. }
  34117. return nil
  34118. }
  34119. // RemovedEdges returns all edge names that were removed in this mutation.
  34120. func (m *TutorialMutation) RemovedEdges() []string {
  34121. edges := make([]string, 0, 1)
  34122. return edges
  34123. }
  34124. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34125. // the given name in this mutation.
  34126. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  34127. return nil
  34128. }
  34129. // ClearedEdges returns all edge names that were cleared in this mutation.
  34130. func (m *TutorialMutation) ClearedEdges() []string {
  34131. edges := make([]string, 0, 1)
  34132. if m.clearedemployee {
  34133. edges = append(edges, tutorial.EdgeEmployee)
  34134. }
  34135. return edges
  34136. }
  34137. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34138. // was cleared in this mutation.
  34139. func (m *TutorialMutation) EdgeCleared(name string) bool {
  34140. switch name {
  34141. case tutorial.EdgeEmployee:
  34142. return m.clearedemployee
  34143. }
  34144. return false
  34145. }
  34146. // ClearEdge clears the value of the edge with the given name. It returns an error
  34147. // if that edge is not defined in the schema.
  34148. func (m *TutorialMutation) ClearEdge(name string) error {
  34149. switch name {
  34150. case tutorial.EdgeEmployee:
  34151. m.ClearEmployee()
  34152. return nil
  34153. }
  34154. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  34155. }
  34156. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34157. // It returns an error if the edge is not defined in the schema.
  34158. func (m *TutorialMutation) ResetEdge(name string) error {
  34159. switch name {
  34160. case tutorial.EdgeEmployee:
  34161. m.ResetEmployee()
  34162. return nil
  34163. }
  34164. return fmt.Errorf("unknown Tutorial edge %s", name)
  34165. }
  34166. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  34167. type UsageDetailMutation struct {
  34168. config
  34169. op Op
  34170. typ string
  34171. id *uint64
  34172. created_at *time.Time
  34173. updated_at *time.Time
  34174. status *uint8
  34175. addstatus *int8
  34176. _type *int
  34177. add_type *int
  34178. bot_id *string
  34179. receiver_id *string
  34180. app *int
  34181. addapp *int
  34182. session_id *uint64
  34183. addsession_id *int64
  34184. request *string
  34185. response *string
  34186. original_data *custom_types.OriginalData
  34187. total_tokens *uint64
  34188. addtotal_tokens *int64
  34189. prompt_tokens *uint64
  34190. addprompt_tokens *int64
  34191. completion_tokens *uint64
  34192. addcompletion_tokens *int64
  34193. organization_id *uint64
  34194. addorganization_id *int64
  34195. model *string
  34196. credits *float64
  34197. addcredits *float64
  34198. clearedFields map[string]struct{}
  34199. done bool
  34200. oldValue func(context.Context) (*UsageDetail, error)
  34201. predicates []predicate.UsageDetail
  34202. }
  34203. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  34204. // usagedetailOption allows management of the mutation configuration using functional options.
  34205. type usagedetailOption func(*UsageDetailMutation)
  34206. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  34207. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  34208. m := &UsageDetailMutation{
  34209. config: c,
  34210. op: op,
  34211. typ: TypeUsageDetail,
  34212. clearedFields: make(map[string]struct{}),
  34213. }
  34214. for _, opt := range opts {
  34215. opt(m)
  34216. }
  34217. return m
  34218. }
  34219. // withUsageDetailID sets the ID field of the mutation.
  34220. func withUsageDetailID(id uint64) usagedetailOption {
  34221. return func(m *UsageDetailMutation) {
  34222. var (
  34223. err error
  34224. once sync.Once
  34225. value *UsageDetail
  34226. )
  34227. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  34228. once.Do(func() {
  34229. if m.done {
  34230. err = errors.New("querying old values post mutation is not allowed")
  34231. } else {
  34232. value, err = m.Client().UsageDetail.Get(ctx, id)
  34233. }
  34234. })
  34235. return value, err
  34236. }
  34237. m.id = &id
  34238. }
  34239. }
  34240. // withUsageDetail sets the old UsageDetail of the mutation.
  34241. func withUsageDetail(node *UsageDetail) usagedetailOption {
  34242. return func(m *UsageDetailMutation) {
  34243. m.oldValue = func(context.Context) (*UsageDetail, error) {
  34244. return node, nil
  34245. }
  34246. m.id = &node.ID
  34247. }
  34248. }
  34249. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34250. // executed in a transaction (ent.Tx), a transactional client is returned.
  34251. func (m UsageDetailMutation) Client() *Client {
  34252. client := &Client{config: m.config}
  34253. client.init()
  34254. return client
  34255. }
  34256. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34257. // it returns an error otherwise.
  34258. func (m UsageDetailMutation) Tx() (*Tx, error) {
  34259. if _, ok := m.driver.(*txDriver); !ok {
  34260. return nil, errors.New("ent: mutation is not running in a transaction")
  34261. }
  34262. tx := &Tx{config: m.config}
  34263. tx.init()
  34264. return tx, nil
  34265. }
  34266. // SetID sets the value of the id field. Note that this
  34267. // operation is only accepted on creation of UsageDetail entities.
  34268. func (m *UsageDetailMutation) SetID(id uint64) {
  34269. m.id = &id
  34270. }
  34271. // ID returns the ID value in the mutation. Note that the ID is only available
  34272. // if it was provided to the builder or after it was returned from the database.
  34273. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  34274. if m.id == nil {
  34275. return
  34276. }
  34277. return *m.id, true
  34278. }
  34279. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34280. // That means, if the mutation is applied within a transaction with an isolation level such
  34281. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34282. // or updated by the mutation.
  34283. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  34284. switch {
  34285. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34286. id, exists := m.ID()
  34287. if exists {
  34288. return []uint64{id}, nil
  34289. }
  34290. fallthrough
  34291. case m.op.Is(OpUpdate | OpDelete):
  34292. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  34293. default:
  34294. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34295. }
  34296. }
  34297. // SetCreatedAt sets the "created_at" field.
  34298. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  34299. m.created_at = &t
  34300. }
  34301. // CreatedAt returns the value of the "created_at" field in the mutation.
  34302. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  34303. v := m.created_at
  34304. if v == nil {
  34305. return
  34306. }
  34307. return *v, true
  34308. }
  34309. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  34310. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34312. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34313. if !m.op.Is(OpUpdateOne) {
  34314. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34315. }
  34316. if m.id == nil || m.oldValue == nil {
  34317. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34318. }
  34319. oldValue, err := m.oldValue(ctx)
  34320. if err != nil {
  34321. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34322. }
  34323. return oldValue.CreatedAt, nil
  34324. }
  34325. // ResetCreatedAt resets all changes to the "created_at" field.
  34326. func (m *UsageDetailMutation) ResetCreatedAt() {
  34327. m.created_at = nil
  34328. }
  34329. // SetUpdatedAt sets the "updated_at" field.
  34330. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  34331. m.updated_at = &t
  34332. }
  34333. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34334. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  34335. v := m.updated_at
  34336. if v == nil {
  34337. return
  34338. }
  34339. return *v, true
  34340. }
  34341. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  34342. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34344. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34345. if !m.op.Is(OpUpdateOne) {
  34346. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34347. }
  34348. if m.id == nil || m.oldValue == nil {
  34349. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34350. }
  34351. oldValue, err := m.oldValue(ctx)
  34352. if err != nil {
  34353. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34354. }
  34355. return oldValue.UpdatedAt, nil
  34356. }
  34357. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34358. func (m *UsageDetailMutation) ResetUpdatedAt() {
  34359. m.updated_at = nil
  34360. }
  34361. // SetStatus sets the "status" field.
  34362. func (m *UsageDetailMutation) SetStatus(u uint8) {
  34363. m.status = &u
  34364. m.addstatus = nil
  34365. }
  34366. // Status returns the value of the "status" field in the mutation.
  34367. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  34368. v := m.status
  34369. if v == nil {
  34370. return
  34371. }
  34372. return *v, true
  34373. }
  34374. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  34375. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34377. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34378. if !m.op.Is(OpUpdateOne) {
  34379. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34380. }
  34381. if m.id == nil || m.oldValue == nil {
  34382. return v, errors.New("OldStatus requires an ID field in the mutation")
  34383. }
  34384. oldValue, err := m.oldValue(ctx)
  34385. if err != nil {
  34386. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34387. }
  34388. return oldValue.Status, nil
  34389. }
  34390. // AddStatus adds u to the "status" field.
  34391. func (m *UsageDetailMutation) AddStatus(u int8) {
  34392. if m.addstatus != nil {
  34393. *m.addstatus += u
  34394. } else {
  34395. m.addstatus = &u
  34396. }
  34397. }
  34398. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34399. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  34400. v := m.addstatus
  34401. if v == nil {
  34402. return
  34403. }
  34404. return *v, true
  34405. }
  34406. // ClearStatus clears the value of the "status" field.
  34407. func (m *UsageDetailMutation) ClearStatus() {
  34408. m.status = nil
  34409. m.addstatus = nil
  34410. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  34411. }
  34412. // StatusCleared returns if the "status" field was cleared in this mutation.
  34413. func (m *UsageDetailMutation) StatusCleared() bool {
  34414. _, ok := m.clearedFields[usagedetail.FieldStatus]
  34415. return ok
  34416. }
  34417. // ResetStatus resets all changes to the "status" field.
  34418. func (m *UsageDetailMutation) ResetStatus() {
  34419. m.status = nil
  34420. m.addstatus = nil
  34421. delete(m.clearedFields, usagedetail.FieldStatus)
  34422. }
  34423. // SetType sets the "type" field.
  34424. func (m *UsageDetailMutation) SetType(i int) {
  34425. m._type = &i
  34426. m.add_type = nil
  34427. }
  34428. // GetType returns the value of the "type" field in the mutation.
  34429. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  34430. v := m._type
  34431. if v == nil {
  34432. return
  34433. }
  34434. return *v, true
  34435. }
  34436. // OldType returns the old "type" field's value of the UsageDetail entity.
  34437. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34439. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  34440. if !m.op.Is(OpUpdateOne) {
  34441. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34442. }
  34443. if m.id == nil || m.oldValue == nil {
  34444. return v, errors.New("OldType requires an ID field in the mutation")
  34445. }
  34446. oldValue, err := m.oldValue(ctx)
  34447. if err != nil {
  34448. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34449. }
  34450. return oldValue.Type, nil
  34451. }
  34452. // AddType adds i to the "type" field.
  34453. func (m *UsageDetailMutation) AddType(i int) {
  34454. if m.add_type != nil {
  34455. *m.add_type += i
  34456. } else {
  34457. m.add_type = &i
  34458. }
  34459. }
  34460. // AddedType returns the value that was added to the "type" field in this mutation.
  34461. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  34462. v := m.add_type
  34463. if v == nil {
  34464. return
  34465. }
  34466. return *v, true
  34467. }
  34468. // ClearType clears the value of the "type" field.
  34469. func (m *UsageDetailMutation) ClearType() {
  34470. m._type = nil
  34471. m.add_type = nil
  34472. m.clearedFields[usagedetail.FieldType] = struct{}{}
  34473. }
  34474. // TypeCleared returns if the "type" field was cleared in this mutation.
  34475. func (m *UsageDetailMutation) TypeCleared() bool {
  34476. _, ok := m.clearedFields[usagedetail.FieldType]
  34477. return ok
  34478. }
  34479. // ResetType resets all changes to the "type" field.
  34480. func (m *UsageDetailMutation) ResetType() {
  34481. m._type = nil
  34482. m.add_type = nil
  34483. delete(m.clearedFields, usagedetail.FieldType)
  34484. }
  34485. // SetBotID sets the "bot_id" field.
  34486. func (m *UsageDetailMutation) SetBotID(s string) {
  34487. m.bot_id = &s
  34488. }
  34489. // BotID returns the value of the "bot_id" field in the mutation.
  34490. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  34491. v := m.bot_id
  34492. if v == nil {
  34493. return
  34494. }
  34495. return *v, true
  34496. }
  34497. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  34498. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34500. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  34501. if !m.op.Is(OpUpdateOne) {
  34502. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34503. }
  34504. if m.id == nil || m.oldValue == nil {
  34505. return v, errors.New("OldBotID requires an ID field in the mutation")
  34506. }
  34507. oldValue, err := m.oldValue(ctx)
  34508. if err != nil {
  34509. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34510. }
  34511. return oldValue.BotID, nil
  34512. }
  34513. // ResetBotID resets all changes to the "bot_id" field.
  34514. func (m *UsageDetailMutation) ResetBotID() {
  34515. m.bot_id = nil
  34516. }
  34517. // SetReceiverID sets the "receiver_id" field.
  34518. func (m *UsageDetailMutation) SetReceiverID(s string) {
  34519. m.receiver_id = &s
  34520. }
  34521. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  34522. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  34523. v := m.receiver_id
  34524. if v == nil {
  34525. return
  34526. }
  34527. return *v, true
  34528. }
  34529. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  34530. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34532. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  34533. if !m.op.Is(OpUpdateOne) {
  34534. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  34535. }
  34536. if m.id == nil || m.oldValue == nil {
  34537. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  34538. }
  34539. oldValue, err := m.oldValue(ctx)
  34540. if err != nil {
  34541. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  34542. }
  34543. return oldValue.ReceiverID, nil
  34544. }
  34545. // ResetReceiverID resets all changes to the "receiver_id" field.
  34546. func (m *UsageDetailMutation) ResetReceiverID() {
  34547. m.receiver_id = nil
  34548. }
  34549. // SetApp sets the "app" field.
  34550. func (m *UsageDetailMutation) SetApp(i int) {
  34551. m.app = &i
  34552. m.addapp = nil
  34553. }
  34554. // App returns the value of the "app" field in the mutation.
  34555. func (m *UsageDetailMutation) App() (r int, exists bool) {
  34556. v := m.app
  34557. if v == nil {
  34558. return
  34559. }
  34560. return *v, true
  34561. }
  34562. // OldApp returns the old "app" field's value of the UsageDetail entity.
  34563. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34565. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  34566. if !m.op.Is(OpUpdateOne) {
  34567. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  34568. }
  34569. if m.id == nil || m.oldValue == nil {
  34570. return v, errors.New("OldApp requires an ID field in the mutation")
  34571. }
  34572. oldValue, err := m.oldValue(ctx)
  34573. if err != nil {
  34574. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  34575. }
  34576. return oldValue.App, nil
  34577. }
  34578. // AddApp adds i to the "app" field.
  34579. func (m *UsageDetailMutation) AddApp(i int) {
  34580. if m.addapp != nil {
  34581. *m.addapp += i
  34582. } else {
  34583. m.addapp = &i
  34584. }
  34585. }
  34586. // AddedApp returns the value that was added to the "app" field in this mutation.
  34587. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  34588. v := m.addapp
  34589. if v == nil {
  34590. return
  34591. }
  34592. return *v, true
  34593. }
  34594. // ClearApp clears the value of the "app" field.
  34595. func (m *UsageDetailMutation) ClearApp() {
  34596. m.app = nil
  34597. m.addapp = nil
  34598. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  34599. }
  34600. // AppCleared returns if the "app" field was cleared in this mutation.
  34601. func (m *UsageDetailMutation) AppCleared() bool {
  34602. _, ok := m.clearedFields[usagedetail.FieldApp]
  34603. return ok
  34604. }
  34605. // ResetApp resets all changes to the "app" field.
  34606. func (m *UsageDetailMutation) ResetApp() {
  34607. m.app = nil
  34608. m.addapp = nil
  34609. delete(m.clearedFields, usagedetail.FieldApp)
  34610. }
  34611. // SetSessionID sets the "session_id" field.
  34612. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  34613. m.session_id = &u
  34614. m.addsession_id = nil
  34615. }
  34616. // SessionID returns the value of the "session_id" field in the mutation.
  34617. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  34618. v := m.session_id
  34619. if v == nil {
  34620. return
  34621. }
  34622. return *v, true
  34623. }
  34624. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  34625. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34627. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  34628. if !m.op.Is(OpUpdateOne) {
  34629. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  34630. }
  34631. if m.id == nil || m.oldValue == nil {
  34632. return v, errors.New("OldSessionID requires an ID field in the mutation")
  34633. }
  34634. oldValue, err := m.oldValue(ctx)
  34635. if err != nil {
  34636. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  34637. }
  34638. return oldValue.SessionID, nil
  34639. }
  34640. // AddSessionID adds u to the "session_id" field.
  34641. func (m *UsageDetailMutation) AddSessionID(u int64) {
  34642. if m.addsession_id != nil {
  34643. *m.addsession_id += u
  34644. } else {
  34645. m.addsession_id = &u
  34646. }
  34647. }
  34648. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  34649. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  34650. v := m.addsession_id
  34651. if v == nil {
  34652. return
  34653. }
  34654. return *v, true
  34655. }
  34656. // ClearSessionID clears the value of the "session_id" field.
  34657. func (m *UsageDetailMutation) ClearSessionID() {
  34658. m.session_id = nil
  34659. m.addsession_id = nil
  34660. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  34661. }
  34662. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  34663. func (m *UsageDetailMutation) SessionIDCleared() bool {
  34664. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  34665. return ok
  34666. }
  34667. // ResetSessionID resets all changes to the "session_id" field.
  34668. func (m *UsageDetailMutation) ResetSessionID() {
  34669. m.session_id = nil
  34670. m.addsession_id = nil
  34671. delete(m.clearedFields, usagedetail.FieldSessionID)
  34672. }
  34673. // SetRequest sets the "request" field.
  34674. func (m *UsageDetailMutation) SetRequest(s string) {
  34675. m.request = &s
  34676. }
  34677. // Request returns the value of the "request" field in the mutation.
  34678. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  34679. v := m.request
  34680. if v == nil {
  34681. return
  34682. }
  34683. return *v, true
  34684. }
  34685. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  34686. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34688. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  34689. if !m.op.Is(OpUpdateOne) {
  34690. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  34691. }
  34692. if m.id == nil || m.oldValue == nil {
  34693. return v, errors.New("OldRequest requires an ID field in the mutation")
  34694. }
  34695. oldValue, err := m.oldValue(ctx)
  34696. if err != nil {
  34697. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  34698. }
  34699. return oldValue.Request, nil
  34700. }
  34701. // ResetRequest resets all changes to the "request" field.
  34702. func (m *UsageDetailMutation) ResetRequest() {
  34703. m.request = nil
  34704. }
  34705. // SetResponse sets the "response" field.
  34706. func (m *UsageDetailMutation) SetResponse(s string) {
  34707. m.response = &s
  34708. }
  34709. // Response returns the value of the "response" field in the mutation.
  34710. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  34711. v := m.response
  34712. if v == nil {
  34713. return
  34714. }
  34715. return *v, true
  34716. }
  34717. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  34718. // If the UsageDetail 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 *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  34721. if !m.op.Is(OpUpdateOne) {
  34722. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  34723. }
  34724. if m.id == nil || m.oldValue == nil {
  34725. return v, errors.New("OldResponse 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 OldResponse: %w", err)
  34730. }
  34731. return oldValue.Response, nil
  34732. }
  34733. // ResetResponse resets all changes to the "response" field.
  34734. func (m *UsageDetailMutation) ResetResponse() {
  34735. m.response = nil
  34736. }
  34737. // SetOriginalData sets the "original_data" field.
  34738. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  34739. m.original_data = &ctd
  34740. }
  34741. // OriginalData returns the value of the "original_data" field in the mutation.
  34742. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  34743. v := m.original_data
  34744. if v == nil {
  34745. return
  34746. }
  34747. return *v, true
  34748. }
  34749. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  34750. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34752. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  34753. if !m.op.Is(OpUpdateOne) {
  34754. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  34755. }
  34756. if m.id == nil || m.oldValue == nil {
  34757. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  34758. }
  34759. oldValue, err := m.oldValue(ctx)
  34760. if err != nil {
  34761. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  34762. }
  34763. return oldValue.OriginalData, nil
  34764. }
  34765. // ResetOriginalData resets all changes to the "original_data" field.
  34766. func (m *UsageDetailMutation) ResetOriginalData() {
  34767. m.original_data = nil
  34768. }
  34769. // SetTotalTokens sets the "total_tokens" field.
  34770. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  34771. m.total_tokens = &u
  34772. m.addtotal_tokens = nil
  34773. }
  34774. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34775. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  34776. v := m.total_tokens
  34777. if v == nil {
  34778. return
  34779. }
  34780. return *v, true
  34781. }
  34782. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  34783. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34785. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34786. if !m.op.Is(OpUpdateOne) {
  34787. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34788. }
  34789. if m.id == nil || m.oldValue == nil {
  34790. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34791. }
  34792. oldValue, err := m.oldValue(ctx)
  34793. if err != nil {
  34794. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34795. }
  34796. return oldValue.TotalTokens, nil
  34797. }
  34798. // AddTotalTokens adds u to the "total_tokens" field.
  34799. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  34800. if m.addtotal_tokens != nil {
  34801. *m.addtotal_tokens += u
  34802. } else {
  34803. m.addtotal_tokens = &u
  34804. }
  34805. }
  34806. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34807. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  34808. v := m.addtotal_tokens
  34809. if v == nil {
  34810. return
  34811. }
  34812. return *v, true
  34813. }
  34814. // ClearTotalTokens clears the value of the "total_tokens" field.
  34815. func (m *UsageDetailMutation) ClearTotalTokens() {
  34816. m.total_tokens = nil
  34817. m.addtotal_tokens = nil
  34818. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  34819. }
  34820. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34821. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  34822. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  34823. return ok
  34824. }
  34825. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34826. func (m *UsageDetailMutation) ResetTotalTokens() {
  34827. m.total_tokens = nil
  34828. m.addtotal_tokens = nil
  34829. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  34830. }
  34831. // SetPromptTokens sets the "prompt_tokens" field.
  34832. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  34833. m.prompt_tokens = &u
  34834. m.addprompt_tokens = nil
  34835. }
  34836. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  34837. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  34838. v := m.prompt_tokens
  34839. if v == nil {
  34840. return
  34841. }
  34842. return *v, true
  34843. }
  34844. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  34845. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34847. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  34848. if !m.op.Is(OpUpdateOne) {
  34849. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  34850. }
  34851. if m.id == nil || m.oldValue == nil {
  34852. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  34853. }
  34854. oldValue, err := m.oldValue(ctx)
  34855. if err != nil {
  34856. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  34857. }
  34858. return oldValue.PromptTokens, nil
  34859. }
  34860. // AddPromptTokens adds u to the "prompt_tokens" field.
  34861. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  34862. if m.addprompt_tokens != nil {
  34863. *m.addprompt_tokens += u
  34864. } else {
  34865. m.addprompt_tokens = &u
  34866. }
  34867. }
  34868. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  34869. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  34870. v := m.addprompt_tokens
  34871. if v == nil {
  34872. return
  34873. }
  34874. return *v, true
  34875. }
  34876. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  34877. func (m *UsageDetailMutation) ClearPromptTokens() {
  34878. m.prompt_tokens = nil
  34879. m.addprompt_tokens = nil
  34880. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  34881. }
  34882. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  34883. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  34884. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  34885. return ok
  34886. }
  34887. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  34888. func (m *UsageDetailMutation) ResetPromptTokens() {
  34889. m.prompt_tokens = nil
  34890. m.addprompt_tokens = nil
  34891. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  34892. }
  34893. // SetCompletionTokens sets the "completion_tokens" field.
  34894. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  34895. m.completion_tokens = &u
  34896. m.addcompletion_tokens = nil
  34897. }
  34898. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  34899. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  34900. v := m.completion_tokens
  34901. if v == nil {
  34902. return
  34903. }
  34904. return *v, true
  34905. }
  34906. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  34907. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34909. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  34910. if !m.op.Is(OpUpdateOne) {
  34911. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  34912. }
  34913. if m.id == nil || m.oldValue == nil {
  34914. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  34915. }
  34916. oldValue, err := m.oldValue(ctx)
  34917. if err != nil {
  34918. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  34919. }
  34920. return oldValue.CompletionTokens, nil
  34921. }
  34922. // AddCompletionTokens adds u to the "completion_tokens" field.
  34923. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  34924. if m.addcompletion_tokens != nil {
  34925. *m.addcompletion_tokens += u
  34926. } else {
  34927. m.addcompletion_tokens = &u
  34928. }
  34929. }
  34930. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  34931. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  34932. v := m.addcompletion_tokens
  34933. if v == nil {
  34934. return
  34935. }
  34936. return *v, true
  34937. }
  34938. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  34939. func (m *UsageDetailMutation) ClearCompletionTokens() {
  34940. m.completion_tokens = nil
  34941. m.addcompletion_tokens = nil
  34942. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  34943. }
  34944. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  34945. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  34946. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  34947. return ok
  34948. }
  34949. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  34950. func (m *UsageDetailMutation) ResetCompletionTokens() {
  34951. m.completion_tokens = nil
  34952. m.addcompletion_tokens = nil
  34953. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  34954. }
  34955. // SetOrganizationID sets the "organization_id" field.
  34956. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  34957. m.organization_id = &u
  34958. m.addorganization_id = nil
  34959. }
  34960. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34961. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  34962. v := m.organization_id
  34963. if v == nil {
  34964. return
  34965. }
  34966. return *v, true
  34967. }
  34968. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  34969. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34971. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34972. if !m.op.Is(OpUpdateOne) {
  34973. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34974. }
  34975. if m.id == nil || m.oldValue == nil {
  34976. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34977. }
  34978. oldValue, err := m.oldValue(ctx)
  34979. if err != nil {
  34980. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34981. }
  34982. return oldValue.OrganizationID, nil
  34983. }
  34984. // AddOrganizationID adds u to the "organization_id" field.
  34985. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  34986. if m.addorganization_id != nil {
  34987. *m.addorganization_id += u
  34988. } else {
  34989. m.addorganization_id = &u
  34990. }
  34991. }
  34992. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34993. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  34994. v := m.addorganization_id
  34995. if v == nil {
  34996. return
  34997. }
  34998. return *v, true
  34999. }
  35000. // ClearOrganizationID clears the value of the "organization_id" field.
  35001. func (m *UsageDetailMutation) ClearOrganizationID() {
  35002. m.organization_id = nil
  35003. m.addorganization_id = nil
  35004. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  35005. }
  35006. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35007. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  35008. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  35009. return ok
  35010. }
  35011. // ResetOrganizationID resets all changes to the "organization_id" field.
  35012. func (m *UsageDetailMutation) ResetOrganizationID() {
  35013. m.organization_id = nil
  35014. m.addorganization_id = nil
  35015. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  35016. }
  35017. // SetModel sets the "model" field.
  35018. func (m *UsageDetailMutation) SetModel(s string) {
  35019. m.model = &s
  35020. }
  35021. // Model returns the value of the "model" field in the mutation.
  35022. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  35023. v := m.model
  35024. if v == nil {
  35025. return
  35026. }
  35027. return *v, true
  35028. }
  35029. // OldModel returns the old "model" field's value of the UsageDetail entity.
  35030. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35032. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  35033. if !m.op.Is(OpUpdateOne) {
  35034. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  35035. }
  35036. if m.id == nil || m.oldValue == nil {
  35037. return v, errors.New("OldModel requires an ID field in the mutation")
  35038. }
  35039. oldValue, err := m.oldValue(ctx)
  35040. if err != nil {
  35041. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  35042. }
  35043. return oldValue.Model, nil
  35044. }
  35045. // ClearModel clears the value of the "model" field.
  35046. func (m *UsageDetailMutation) ClearModel() {
  35047. m.model = nil
  35048. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  35049. }
  35050. // ModelCleared returns if the "model" field was cleared in this mutation.
  35051. func (m *UsageDetailMutation) ModelCleared() bool {
  35052. _, ok := m.clearedFields[usagedetail.FieldModel]
  35053. return ok
  35054. }
  35055. // ResetModel resets all changes to the "model" field.
  35056. func (m *UsageDetailMutation) ResetModel() {
  35057. m.model = nil
  35058. delete(m.clearedFields, usagedetail.FieldModel)
  35059. }
  35060. // SetCredits sets the "credits" field.
  35061. func (m *UsageDetailMutation) SetCredits(f float64) {
  35062. m.credits = &f
  35063. m.addcredits = nil
  35064. }
  35065. // Credits returns the value of the "credits" field in the mutation.
  35066. func (m *UsageDetailMutation) Credits() (r float64, exists bool) {
  35067. v := m.credits
  35068. if v == nil {
  35069. return
  35070. }
  35071. return *v, true
  35072. }
  35073. // OldCredits returns the old "credits" field's value of the UsageDetail entity.
  35074. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35076. func (m *UsageDetailMutation) OldCredits(ctx context.Context) (v float64, err error) {
  35077. if !m.op.Is(OpUpdateOne) {
  35078. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  35079. }
  35080. if m.id == nil || m.oldValue == nil {
  35081. return v, errors.New("OldCredits requires an ID field in the mutation")
  35082. }
  35083. oldValue, err := m.oldValue(ctx)
  35084. if err != nil {
  35085. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  35086. }
  35087. return oldValue.Credits, nil
  35088. }
  35089. // AddCredits adds f to the "credits" field.
  35090. func (m *UsageDetailMutation) AddCredits(f float64) {
  35091. if m.addcredits != nil {
  35092. *m.addcredits += f
  35093. } else {
  35094. m.addcredits = &f
  35095. }
  35096. }
  35097. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  35098. func (m *UsageDetailMutation) AddedCredits() (r float64, exists bool) {
  35099. v := m.addcredits
  35100. if v == nil {
  35101. return
  35102. }
  35103. return *v, true
  35104. }
  35105. // ClearCredits clears the value of the "credits" field.
  35106. func (m *UsageDetailMutation) ClearCredits() {
  35107. m.credits = nil
  35108. m.addcredits = nil
  35109. m.clearedFields[usagedetail.FieldCredits] = struct{}{}
  35110. }
  35111. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  35112. func (m *UsageDetailMutation) CreditsCleared() bool {
  35113. _, ok := m.clearedFields[usagedetail.FieldCredits]
  35114. return ok
  35115. }
  35116. // ResetCredits resets all changes to the "credits" field.
  35117. func (m *UsageDetailMutation) ResetCredits() {
  35118. m.credits = nil
  35119. m.addcredits = nil
  35120. delete(m.clearedFields, usagedetail.FieldCredits)
  35121. }
  35122. // Where appends a list predicates to the UsageDetailMutation builder.
  35123. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  35124. m.predicates = append(m.predicates, ps...)
  35125. }
  35126. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  35127. // users can use type-assertion to append predicates that do not depend on any generated package.
  35128. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  35129. p := make([]predicate.UsageDetail, len(ps))
  35130. for i := range ps {
  35131. p[i] = ps[i]
  35132. }
  35133. m.Where(p...)
  35134. }
  35135. // Op returns the operation name.
  35136. func (m *UsageDetailMutation) Op() Op {
  35137. return m.op
  35138. }
  35139. // SetOp allows setting the mutation operation.
  35140. func (m *UsageDetailMutation) SetOp(op Op) {
  35141. m.op = op
  35142. }
  35143. // Type returns the node type of this mutation (UsageDetail).
  35144. func (m *UsageDetailMutation) Type() string {
  35145. return m.typ
  35146. }
  35147. // Fields returns all fields that were changed during this mutation. Note that in
  35148. // order to get all numeric fields that were incremented/decremented, call
  35149. // AddedFields().
  35150. func (m *UsageDetailMutation) Fields() []string {
  35151. fields := make([]string, 0, 17)
  35152. if m.created_at != nil {
  35153. fields = append(fields, usagedetail.FieldCreatedAt)
  35154. }
  35155. if m.updated_at != nil {
  35156. fields = append(fields, usagedetail.FieldUpdatedAt)
  35157. }
  35158. if m.status != nil {
  35159. fields = append(fields, usagedetail.FieldStatus)
  35160. }
  35161. if m._type != nil {
  35162. fields = append(fields, usagedetail.FieldType)
  35163. }
  35164. if m.bot_id != nil {
  35165. fields = append(fields, usagedetail.FieldBotID)
  35166. }
  35167. if m.receiver_id != nil {
  35168. fields = append(fields, usagedetail.FieldReceiverID)
  35169. }
  35170. if m.app != nil {
  35171. fields = append(fields, usagedetail.FieldApp)
  35172. }
  35173. if m.session_id != nil {
  35174. fields = append(fields, usagedetail.FieldSessionID)
  35175. }
  35176. if m.request != nil {
  35177. fields = append(fields, usagedetail.FieldRequest)
  35178. }
  35179. if m.response != nil {
  35180. fields = append(fields, usagedetail.FieldResponse)
  35181. }
  35182. if m.original_data != nil {
  35183. fields = append(fields, usagedetail.FieldOriginalData)
  35184. }
  35185. if m.total_tokens != nil {
  35186. fields = append(fields, usagedetail.FieldTotalTokens)
  35187. }
  35188. if m.prompt_tokens != nil {
  35189. fields = append(fields, usagedetail.FieldPromptTokens)
  35190. }
  35191. if m.completion_tokens != nil {
  35192. fields = append(fields, usagedetail.FieldCompletionTokens)
  35193. }
  35194. if m.organization_id != nil {
  35195. fields = append(fields, usagedetail.FieldOrganizationID)
  35196. }
  35197. if m.model != nil {
  35198. fields = append(fields, usagedetail.FieldModel)
  35199. }
  35200. if m.credits != nil {
  35201. fields = append(fields, usagedetail.FieldCredits)
  35202. }
  35203. return fields
  35204. }
  35205. // Field returns the value of a field with the given name. The second boolean
  35206. // return value indicates that this field was not set, or was not defined in the
  35207. // schema.
  35208. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  35209. switch name {
  35210. case usagedetail.FieldCreatedAt:
  35211. return m.CreatedAt()
  35212. case usagedetail.FieldUpdatedAt:
  35213. return m.UpdatedAt()
  35214. case usagedetail.FieldStatus:
  35215. return m.Status()
  35216. case usagedetail.FieldType:
  35217. return m.GetType()
  35218. case usagedetail.FieldBotID:
  35219. return m.BotID()
  35220. case usagedetail.FieldReceiverID:
  35221. return m.ReceiverID()
  35222. case usagedetail.FieldApp:
  35223. return m.App()
  35224. case usagedetail.FieldSessionID:
  35225. return m.SessionID()
  35226. case usagedetail.FieldRequest:
  35227. return m.Request()
  35228. case usagedetail.FieldResponse:
  35229. return m.Response()
  35230. case usagedetail.FieldOriginalData:
  35231. return m.OriginalData()
  35232. case usagedetail.FieldTotalTokens:
  35233. return m.TotalTokens()
  35234. case usagedetail.FieldPromptTokens:
  35235. return m.PromptTokens()
  35236. case usagedetail.FieldCompletionTokens:
  35237. return m.CompletionTokens()
  35238. case usagedetail.FieldOrganizationID:
  35239. return m.OrganizationID()
  35240. case usagedetail.FieldModel:
  35241. return m.Model()
  35242. case usagedetail.FieldCredits:
  35243. return m.Credits()
  35244. }
  35245. return nil, false
  35246. }
  35247. // OldField returns the old value of the field from the database. An error is
  35248. // returned if the mutation operation is not UpdateOne, or the query to the
  35249. // database failed.
  35250. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35251. switch name {
  35252. case usagedetail.FieldCreatedAt:
  35253. return m.OldCreatedAt(ctx)
  35254. case usagedetail.FieldUpdatedAt:
  35255. return m.OldUpdatedAt(ctx)
  35256. case usagedetail.FieldStatus:
  35257. return m.OldStatus(ctx)
  35258. case usagedetail.FieldType:
  35259. return m.OldType(ctx)
  35260. case usagedetail.FieldBotID:
  35261. return m.OldBotID(ctx)
  35262. case usagedetail.FieldReceiverID:
  35263. return m.OldReceiverID(ctx)
  35264. case usagedetail.FieldApp:
  35265. return m.OldApp(ctx)
  35266. case usagedetail.FieldSessionID:
  35267. return m.OldSessionID(ctx)
  35268. case usagedetail.FieldRequest:
  35269. return m.OldRequest(ctx)
  35270. case usagedetail.FieldResponse:
  35271. return m.OldResponse(ctx)
  35272. case usagedetail.FieldOriginalData:
  35273. return m.OldOriginalData(ctx)
  35274. case usagedetail.FieldTotalTokens:
  35275. return m.OldTotalTokens(ctx)
  35276. case usagedetail.FieldPromptTokens:
  35277. return m.OldPromptTokens(ctx)
  35278. case usagedetail.FieldCompletionTokens:
  35279. return m.OldCompletionTokens(ctx)
  35280. case usagedetail.FieldOrganizationID:
  35281. return m.OldOrganizationID(ctx)
  35282. case usagedetail.FieldModel:
  35283. return m.OldModel(ctx)
  35284. case usagedetail.FieldCredits:
  35285. return m.OldCredits(ctx)
  35286. }
  35287. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  35288. }
  35289. // SetField sets the value of a field with the given name. It returns an error if
  35290. // the field is not defined in the schema, or if the type mismatched the field
  35291. // type.
  35292. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  35293. switch name {
  35294. case usagedetail.FieldCreatedAt:
  35295. v, ok := value.(time.Time)
  35296. if !ok {
  35297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35298. }
  35299. m.SetCreatedAt(v)
  35300. return nil
  35301. case usagedetail.FieldUpdatedAt:
  35302. v, ok := value.(time.Time)
  35303. if !ok {
  35304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35305. }
  35306. m.SetUpdatedAt(v)
  35307. return nil
  35308. case usagedetail.FieldStatus:
  35309. v, ok := value.(uint8)
  35310. if !ok {
  35311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35312. }
  35313. m.SetStatus(v)
  35314. return nil
  35315. case usagedetail.FieldType:
  35316. v, ok := value.(int)
  35317. if !ok {
  35318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35319. }
  35320. m.SetType(v)
  35321. return nil
  35322. case usagedetail.FieldBotID:
  35323. v, ok := value.(string)
  35324. if !ok {
  35325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35326. }
  35327. m.SetBotID(v)
  35328. return nil
  35329. case usagedetail.FieldReceiverID:
  35330. v, ok := value.(string)
  35331. if !ok {
  35332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35333. }
  35334. m.SetReceiverID(v)
  35335. return nil
  35336. case usagedetail.FieldApp:
  35337. v, ok := value.(int)
  35338. if !ok {
  35339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35340. }
  35341. m.SetApp(v)
  35342. return nil
  35343. case usagedetail.FieldSessionID:
  35344. v, ok := value.(uint64)
  35345. if !ok {
  35346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35347. }
  35348. m.SetSessionID(v)
  35349. return nil
  35350. case usagedetail.FieldRequest:
  35351. v, ok := value.(string)
  35352. if !ok {
  35353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35354. }
  35355. m.SetRequest(v)
  35356. return nil
  35357. case usagedetail.FieldResponse:
  35358. v, ok := value.(string)
  35359. if !ok {
  35360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35361. }
  35362. m.SetResponse(v)
  35363. return nil
  35364. case usagedetail.FieldOriginalData:
  35365. v, ok := value.(custom_types.OriginalData)
  35366. if !ok {
  35367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35368. }
  35369. m.SetOriginalData(v)
  35370. return nil
  35371. case usagedetail.FieldTotalTokens:
  35372. v, ok := value.(uint64)
  35373. if !ok {
  35374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35375. }
  35376. m.SetTotalTokens(v)
  35377. return nil
  35378. case usagedetail.FieldPromptTokens:
  35379. v, ok := value.(uint64)
  35380. if !ok {
  35381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35382. }
  35383. m.SetPromptTokens(v)
  35384. return nil
  35385. case usagedetail.FieldCompletionTokens:
  35386. v, ok := value.(uint64)
  35387. if !ok {
  35388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35389. }
  35390. m.SetCompletionTokens(v)
  35391. return nil
  35392. case usagedetail.FieldOrganizationID:
  35393. v, ok := value.(uint64)
  35394. if !ok {
  35395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35396. }
  35397. m.SetOrganizationID(v)
  35398. return nil
  35399. case usagedetail.FieldModel:
  35400. v, ok := value.(string)
  35401. if !ok {
  35402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35403. }
  35404. m.SetModel(v)
  35405. return nil
  35406. case usagedetail.FieldCredits:
  35407. v, ok := value.(float64)
  35408. if !ok {
  35409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35410. }
  35411. m.SetCredits(v)
  35412. return nil
  35413. }
  35414. return fmt.Errorf("unknown UsageDetail field %s", name)
  35415. }
  35416. // AddedFields returns all numeric fields that were incremented/decremented during
  35417. // this mutation.
  35418. func (m *UsageDetailMutation) AddedFields() []string {
  35419. var fields []string
  35420. if m.addstatus != nil {
  35421. fields = append(fields, usagedetail.FieldStatus)
  35422. }
  35423. if m.add_type != nil {
  35424. fields = append(fields, usagedetail.FieldType)
  35425. }
  35426. if m.addapp != nil {
  35427. fields = append(fields, usagedetail.FieldApp)
  35428. }
  35429. if m.addsession_id != nil {
  35430. fields = append(fields, usagedetail.FieldSessionID)
  35431. }
  35432. if m.addtotal_tokens != nil {
  35433. fields = append(fields, usagedetail.FieldTotalTokens)
  35434. }
  35435. if m.addprompt_tokens != nil {
  35436. fields = append(fields, usagedetail.FieldPromptTokens)
  35437. }
  35438. if m.addcompletion_tokens != nil {
  35439. fields = append(fields, usagedetail.FieldCompletionTokens)
  35440. }
  35441. if m.addorganization_id != nil {
  35442. fields = append(fields, usagedetail.FieldOrganizationID)
  35443. }
  35444. if m.addcredits != nil {
  35445. fields = append(fields, usagedetail.FieldCredits)
  35446. }
  35447. return fields
  35448. }
  35449. // AddedField returns the numeric value that was incremented/decremented on a field
  35450. // with the given name. The second boolean return value indicates that this field
  35451. // was not set, or was not defined in the schema.
  35452. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  35453. switch name {
  35454. case usagedetail.FieldStatus:
  35455. return m.AddedStatus()
  35456. case usagedetail.FieldType:
  35457. return m.AddedType()
  35458. case usagedetail.FieldApp:
  35459. return m.AddedApp()
  35460. case usagedetail.FieldSessionID:
  35461. return m.AddedSessionID()
  35462. case usagedetail.FieldTotalTokens:
  35463. return m.AddedTotalTokens()
  35464. case usagedetail.FieldPromptTokens:
  35465. return m.AddedPromptTokens()
  35466. case usagedetail.FieldCompletionTokens:
  35467. return m.AddedCompletionTokens()
  35468. case usagedetail.FieldOrganizationID:
  35469. return m.AddedOrganizationID()
  35470. case usagedetail.FieldCredits:
  35471. return m.AddedCredits()
  35472. }
  35473. return nil, false
  35474. }
  35475. // AddField adds the value to the field with the given name. It returns an error if
  35476. // the field is not defined in the schema, or if the type mismatched the field
  35477. // type.
  35478. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  35479. switch name {
  35480. case usagedetail.FieldStatus:
  35481. v, ok := value.(int8)
  35482. if !ok {
  35483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35484. }
  35485. m.AddStatus(v)
  35486. return nil
  35487. case usagedetail.FieldType:
  35488. v, ok := value.(int)
  35489. if !ok {
  35490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35491. }
  35492. m.AddType(v)
  35493. return nil
  35494. case usagedetail.FieldApp:
  35495. v, ok := value.(int)
  35496. if !ok {
  35497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35498. }
  35499. m.AddApp(v)
  35500. return nil
  35501. case usagedetail.FieldSessionID:
  35502. v, ok := value.(int64)
  35503. if !ok {
  35504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35505. }
  35506. m.AddSessionID(v)
  35507. return nil
  35508. case usagedetail.FieldTotalTokens:
  35509. v, ok := value.(int64)
  35510. if !ok {
  35511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35512. }
  35513. m.AddTotalTokens(v)
  35514. return nil
  35515. case usagedetail.FieldPromptTokens:
  35516. v, ok := value.(int64)
  35517. if !ok {
  35518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35519. }
  35520. m.AddPromptTokens(v)
  35521. return nil
  35522. case usagedetail.FieldCompletionTokens:
  35523. v, ok := value.(int64)
  35524. if !ok {
  35525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35526. }
  35527. m.AddCompletionTokens(v)
  35528. return nil
  35529. case usagedetail.FieldOrganizationID:
  35530. v, ok := value.(int64)
  35531. if !ok {
  35532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35533. }
  35534. m.AddOrganizationID(v)
  35535. return nil
  35536. case usagedetail.FieldCredits:
  35537. v, ok := value.(float64)
  35538. if !ok {
  35539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35540. }
  35541. m.AddCredits(v)
  35542. return nil
  35543. }
  35544. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  35545. }
  35546. // ClearedFields returns all nullable fields that were cleared during this
  35547. // mutation.
  35548. func (m *UsageDetailMutation) ClearedFields() []string {
  35549. var fields []string
  35550. if m.FieldCleared(usagedetail.FieldStatus) {
  35551. fields = append(fields, usagedetail.FieldStatus)
  35552. }
  35553. if m.FieldCleared(usagedetail.FieldType) {
  35554. fields = append(fields, usagedetail.FieldType)
  35555. }
  35556. if m.FieldCleared(usagedetail.FieldApp) {
  35557. fields = append(fields, usagedetail.FieldApp)
  35558. }
  35559. if m.FieldCleared(usagedetail.FieldSessionID) {
  35560. fields = append(fields, usagedetail.FieldSessionID)
  35561. }
  35562. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  35563. fields = append(fields, usagedetail.FieldTotalTokens)
  35564. }
  35565. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  35566. fields = append(fields, usagedetail.FieldPromptTokens)
  35567. }
  35568. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  35569. fields = append(fields, usagedetail.FieldCompletionTokens)
  35570. }
  35571. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  35572. fields = append(fields, usagedetail.FieldOrganizationID)
  35573. }
  35574. if m.FieldCleared(usagedetail.FieldModel) {
  35575. fields = append(fields, usagedetail.FieldModel)
  35576. }
  35577. if m.FieldCleared(usagedetail.FieldCredits) {
  35578. fields = append(fields, usagedetail.FieldCredits)
  35579. }
  35580. return fields
  35581. }
  35582. // FieldCleared returns a boolean indicating if a field with the given name was
  35583. // cleared in this mutation.
  35584. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  35585. _, ok := m.clearedFields[name]
  35586. return ok
  35587. }
  35588. // ClearField clears the value of the field with the given name. It returns an
  35589. // error if the field is not defined in the schema.
  35590. func (m *UsageDetailMutation) ClearField(name string) error {
  35591. switch name {
  35592. case usagedetail.FieldStatus:
  35593. m.ClearStatus()
  35594. return nil
  35595. case usagedetail.FieldType:
  35596. m.ClearType()
  35597. return nil
  35598. case usagedetail.FieldApp:
  35599. m.ClearApp()
  35600. return nil
  35601. case usagedetail.FieldSessionID:
  35602. m.ClearSessionID()
  35603. return nil
  35604. case usagedetail.FieldTotalTokens:
  35605. m.ClearTotalTokens()
  35606. return nil
  35607. case usagedetail.FieldPromptTokens:
  35608. m.ClearPromptTokens()
  35609. return nil
  35610. case usagedetail.FieldCompletionTokens:
  35611. m.ClearCompletionTokens()
  35612. return nil
  35613. case usagedetail.FieldOrganizationID:
  35614. m.ClearOrganizationID()
  35615. return nil
  35616. case usagedetail.FieldModel:
  35617. m.ClearModel()
  35618. return nil
  35619. case usagedetail.FieldCredits:
  35620. m.ClearCredits()
  35621. return nil
  35622. }
  35623. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  35624. }
  35625. // ResetField resets all changes in the mutation for the field with the given name.
  35626. // It returns an error if the field is not defined in the schema.
  35627. func (m *UsageDetailMutation) ResetField(name string) error {
  35628. switch name {
  35629. case usagedetail.FieldCreatedAt:
  35630. m.ResetCreatedAt()
  35631. return nil
  35632. case usagedetail.FieldUpdatedAt:
  35633. m.ResetUpdatedAt()
  35634. return nil
  35635. case usagedetail.FieldStatus:
  35636. m.ResetStatus()
  35637. return nil
  35638. case usagedetail.FieldType:
  35639. m.ResetType()
  35640. return nil
  35641. case usagedetail.FieldBotID:
  35642. m.ResetBotID()
  35643. return nil
  35644. case usagedetail.FieldReceiverID:
  35645. m.ResetReceiverID()
  35646. return nil
  35647. case usagedetail.FieldApp:
  35648. m.ResetApp()
  35649. return nil
  35650. case usagedetail.FieldSessionID:
  35651. m.ResetSessionID()
  35652. return nil
  35653. case usagedetail.FieldRequest:
  35654. m.ResetRequest()
  35655. return nil
  35656. case usagedetail.FieldResponse:
  35657. m.ResetResponse()
  35658. return nil
  35659. case usagedetail.FieldOriginalData:
  35660. m.ResetOriginalData()
  35661. return nil
  35662. case usagedetail.FieldTotalTokens:
  35663. m.ResetTotalTokens()
  35664. return nil
  35665. case usagedetail.FieldPromptTokens:
  35666. m.ResetPromptTokens()
  35667. return nil
  35668. case usagedetail.FieldCompletionTokens:
  35669. m.ResetCompletionTokens()
  35670. return nil
  35671. case usagedetail.FieldOrganizationID:
  35672. m.ResetOrganizationID()
  35673. return nil
  35674. case usagedetail.FieldModel:
  35675. m.ResetModel()
  35676. return nil
  35677. case usagedetail.FieldCredits:
  35678. m.ResetCredits()
  35679. return nil
  35680. }
  35681. return fmt.Errorf("unknown UsageDetail field %s", name)
  35682. }
  35683. // AddedEdges returns all edge names that were set/added in this mutation.
  35684. func (m *UsageDetailMutation) AddedEdges() []string {
  35685. edges := make([]string, 0, 0)
  35686. return edges
  35687. }
  35688. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35689. // name in this mutation.
  35690. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  35691. return nil
  35692. }
  35693. // RemovedEdges returns all edge names that were removed in this mutation.
  35694. func (m *UsageDetailMutation) RemovedEdges() []string {
  35695. edges := make([]string, 0, 0)
  35696. return edges
  35697. }
  35698. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35699. // the given name in this mutation.
  35700. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  35701. return nil
  35702. }
  35703. // ClearedEdges returns all edge names that were cleared in this mutation.
  35704. func (m *UsageDetailMutation) ClearedEdges() []string {
  35705. edges := make([]string, 0, 0)
  35706. return edges
  35707. }
  35708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35709. // was cleared in this mutation.
  35710. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  35711. return false
  35712. }
  35713. // ClearEdge clears the value of the edge with the given name. It returns an error
  35714. // if that edge is not defined in the schema.
  35715. func (m *UsageDetailMutation) ClearEdge(name string) error {
  35716. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  35717. }
  35718. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35719. // It returns an error if the edge is not defined in the schema.
  35720. func (m *UsageDetailMutation) ResetEdge(name string) error {
  35721. return fmt.Errorf("unknown UsageDetail edge %s", name)
  35722. }
  35723. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  35724. type UsageStatisticDayMutation struct {
  35725. config
  35726. op Op
  35727. typ string
  35728. id *uint64
  35729. created_at *time.Time
  35730. updated_at *time.Time
  35731. status *uint8
  35732. addstatus *int8
  35733. deleted_at *time.Time
  35734. addtime *uint64
  35735. addaddtime *int64
  35736. _type *int
  35737. add_type *int
  35738. bot_id *string
  35739. organization_id *uint64
  35740. addorganization_id *int64
  35741. ai_response *uint64
  35742. addai_response *int64
  35743. sop_run *uint64
  35744. addsop_run *int64
  35745. total_friend *uint64
  35746. addtotal_friend *int64
  35747. total_group *uint64
  35748. addtotal_group *int64
  35749. account_balance *uint64
  35750. addaccount_balance *int64
  35751. consume_token *uint64
  35752. addconsume_token *int64
  35753. active_user *uint64
  35754. addactive_user *int64
  35755. new_user *int64
  35756. addnew_user *int64
  35757. label_dist *[]custom_types.LabelDist
  35758. appendlabel_dist []custom_types.LabelDist
  35759. consume_coin *float64
  35760. addconsume_coin *float64
  35761. clearedFields map[string]struct{}
  35762. done bool
  35763. oldValue func(context.Context) (*UsageStatisticDay, error)
  35764. predicates []predicate.UsageStatisticDay
  35765. }
  35766. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  35767. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  35768. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  35769. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  35770. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  35771. m := &UsageStatisticDayMutation{
  35772. config: c,
  35773. op: op,
  35774. typ: TypeUsageStatisticDay,
  35775. clearedFields: make(map[string]struct{}),
  35776. }
  35777. for _, opt := range opts {
  35778. opt(m)
  35779. }
  35780. return m
  35781. }
  35782. // withUsageStatisticDayID sets the ID field of the mutation.
  35783. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  35784. return func(m *UsageStatisticDayMutation) {
  35785. var (
  35786. err error
  35787. once sync.Once
  35788. value *UsageStatisticDay
  35789. )
  35790. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  35791. once.Do(func() {
  35792. if m.done {
  35793. err = errors.New("querying old values post mutation is not allowed")
  35794. } else {
  35795. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  35796. }
  35797. })
  35798. return value, err
  35799. }
  35800. m.id = &id
  35801. }
  35802. }
  35803. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  35804. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  35805. return func(m *UsageStatisticDayMutation) {
  35806. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  35807. return node, nil
  35808. }
  35809. m.id = &node.ID
  35810. }
  35811. }
  35812. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35813. // executed in a transaction (ent.Tx), a transactional client is returned.
  35814. func (m UsageStatisticDayMutation) Client() *Client {
  35815. client := &Client{config: m.config}
  35816. client.init()
  35817. return client
  35818. }
  35819. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35820. // it returns an error otherwise.
  35821. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  35822. if _, ok := m.driver.(*txDriver); !ok {
  35823. return nil, errors.New("ent: mutation is not running in a transaction")
  35824. }
  35825. tx := &Tx{config: m.config}
  35826. tx.init()
  35827. return tx, nil
  35828. }
  35829. // SetID sets the value of the id field. Note that this
  35830. // operation is only accepted on creation of UsageStatisticDay entities.
  35831. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  35832. m.id = &id
  35833. }
  35834. // ID returns the ID value in the mutation. Note that the ID is only available
  35835. // if it was provided to the builder or after it was returned from the database.
  35836. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  35837. if m.id == nil {
  35838. return
  35839. }
  35840. return *m.id, true
  35841. }
  35842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35843. // That means, if the mutation is applied within a transaction with an isolation level such
  35844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35845. // or updated by the mutation.
  35846. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  35847. switch {
  35848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35849. id, exists := m.ID()
  35850. if exists {
  35851. return []uint64{id}, nil
  35852. }
  35853. fallthrough
  35854. case m.op.Is(OpUpdate | OpDelete):
  35855. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  35856. default:
  35857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35858. }
  35859. }
  35860. // SetCreatedAt sets the "created_at" field.
  35861. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  35862. m.created_at = &t
  35863. }
  35864. // CreatedAt returns the value of the "created_at" field in the mutation.
  35865. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  35866. v := m.created_at
  35867. if v == nil {
  35868. return
  35869. }
  35870. return *v, true
  35871. }
  35872. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  35873. // If the UsageStatisticDay 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 *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35876. if !m.op.Is(OpUpdateOne) {
  35877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35878. }
  35879. if m.id == nil || m.oldValue == nil {
  35880. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  35885. }
  35886. return oldValue.CreatedAt, nil
  35887. }
  35888. // ResetCreatedAt resets all changes to the "created_at" field.
  35889. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  35890. m.created_at = nil
  35891. }
  35892. // SetUpdatedAt sets the "updated_at" field.
  35893. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  35894. m.updated_at = &t
  35895. }
  35896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35897. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  35898. v := m.updated_at
  35899. if v == nil {
  35900. return
  35901. }
  35902. return *v, true
  35903. }
  35904. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  35905. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35907. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35908. if !m.op.Is(OpUpdateOne) {
  35909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35910. }
  35911. if m.id == nil || m.oldValue == nil {
  35912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35913. }
  35914. oldValue, err := m.oldValue(ctx)
  35915. if err != nil {
  35916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35917. }
  35918. return oldValue.UpdatedAt, nil
  35919. }
  35920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35921. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  35922. m.updated_at = nil
  35923. }
  35924. // SetStatus sets the "status" field.
  35925. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  35926. m.status = &u
  35927. m.addstatus = nil
  35928. }
  35929. // Status returns the value of the "status" field in the mutation.
  35930. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  35931. v := m.status
  35932. if v == nil {
  35933. return
  35934. }
  35935. return *v, true
  35936. }
  35937. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  35938. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35940. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35941. if !m.op.Is(OpUpdateOne) {
  35942. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35943. }
  35944. if m.id == nil || m.oldValue == nil {
  35945. return v, errors.New("OldStatus requires an ID field in the mutation")
  35946. }
  35947. oldValue, err := m.oldValue(ctx)
  35948. if err != nil {
  35949. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35950. }
  35951. return oldValue.Status, nil
  35952. }
  35953. // AddStatus adds u to the "status" field.
  35954. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  35955. if m.addstatus != nil {
  35956. *m.addstatus += u
  35957. } else {
  35958. m.addstatus = &u
  35959. }
  35960. }
  35961. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35962. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  35963. v := m.addstatus
  35964. if v == nil {
  35965. return
  35966. }
  35967. return *v, true
  35968. }
  35969. // ClearStatus clears the value of the "status" field.
  35970. func (m *UsageStatisticDayMutation) ClearStatus() {
  35971. m.status = nil
  35972. m.addstatus = nil
  35973. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  35974. }
  35975. // StatusCleared returns if the "status" field was cleared in this mutation.
  35976. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  35977. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  35978. return ok
  35979. }
  35980. // ResetStatus resets all changes to the "status" field.
  35981. func (m *UsageStatisticDayMutation) ResetStatus() {
  35982. m.status = nil
  35983. m.addstatus = nil
  35984. delete(m.clearedFields, usagestatisticday.FieldStatus)
  35985. }
  35986. // SetDeletedAt sets the "deleted_at" field.
  35987. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  35988. m.deleted_at = &t
  35989. }
  35990. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35991. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  35992. v := m.deleted_at
  35993. if v == nil {
  35994. return
  35995. }
  35996. return *v, true
  35997. }
  35998. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  35999. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36001. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36002. if !m.op.Is(OpUpdateOne) {
  36003. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36004. }
  36005. if m.id == nil || m.oldValue == nil {
  36006. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36007. }
  36008. oldValue, err := m.oldValue(ctx)
  36009. if err != nil {
  36010. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36011. }
  36012. return oldValue.DeletedAt, nil
  36013. }
  36014. // ClearDeletedAt clears the value of the "deleted_at" field.
  36015. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  36016. m.deleted_at = nil
  36017. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  36018. }
  36019. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36020. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  36021. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  36022. return ok
  36023. }
  36024. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36025. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  36026. m.deleted_at = nil
  36027. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  36028. }
  36029. // SetAddtime sets the "addtime" field.
  36030. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  36031. m.addtime = &u
  36032. m.addaddtime = nil
  36033. }
  36034. // Addtime returns the value of the "addtime" field in the mutation.
  36035. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  36036. v := m.addtime
  36037. if v == nil {
  36038. return
  36039. }
  36040. return *v, true
  36041. }
  36042. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  36043. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36045. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  36046. if !m.op.Is(OpUpdateOne) {
  36047. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  36048. }
  36049. if m.id == nil || m.oldValue == nil {
  36050. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36051. }
  36052. oldValue, err := m.oldValue(ctx)
  36053. if err != nil {
  36054. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36055. }
  36056. return oldValue.Addtime, nil
  36057. }
  36058. // AddAddtime adds u to the "addtime" field.
  36059. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  36060. if m.addaddtime != nil {
  36061. *m.addaddtime += u
  36062. } else {
  36063. m.addaddtime = &u
  36064. }
  36065. }
  36066. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36067. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  36068. v := m.addaddtime
  36069. if v == nil {
  36070. return
  36071. }
  36072. return *v, true
  36073. }
  36074. // ResetAddtime resets all changes to the "addtime" field.
  36075. func (m *UsageStatisticDayMutation) ResetAddtime() {
  36076. m.addtime = nil
  36077. m.addaddtime = nil
  36078. }
  36079. // SetType sets the "type" field.
  36080. func (m *UsageStatisticDayMutation) SetType(i int) {
  36081. m._type = &i
  36082. m.add_type = nil
  36083. }
  36084. // GetType returns the value of the "type" field in the mutation.
  36085. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  36086. v := m._type
  36087. if v == nil {
  36088. return
  36089. }
  36090. return *v, true
  36091. }
  36092. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  36093. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36095. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  36096. if !m.op.Is(OpUpdateOne) {
  36097. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36098. }
  36099. if m.id == nil || m.oldValue == nil {
  36100. return v, errors.New("OldType requires an ID field in the mutation")
  36101. }
  36102. oldValue, err := m.oldValue(ctx)
  36103. if err != nil {
  36104. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36105. }
  36106. return oldValue.Type, nil
  36107. }
  36108. // AddType adds i to the "type" field.
  36109. func (m *UsageStatisticDayMutation) AddType(i int) {
  36110. if m.add_type != nil {
  36111. *m.add_type += i
  36112. } else {
  36113. m.add_type = &i
  36114. }
  36115. }
  36116. // AddedType returns the value that was added to the "type" field in this mutation.
  36117. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  36118. v := m.add_type
  36119. if v == nil {
  36120. return
  36121. }
  36122. return *v, true
  36123. }
  36124. // ResetType resets all changes to the "type" field.
  36125. func (m *UsageStatisticDayMutation) ResetType() {
  36126. m._type = nil
  36127. m.add_type = nil
  36128. }
  36129. // SetBotID sets the "bot_id" field.
  36130. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  36131. m.bot_id = &s
  36132. }
  36133. // BotID returns the value of the "bot_id" field in the mutation.
  36134. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  36135. v := m.bot_id
  36136. if v == nil {
  36137. return
  36138. }
  36139. return *v, true
  36140. }
  36141. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  36142. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36144. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  36145. if !m.op.Is(OpUpdateOne) {
  36146. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36147. }
  36148. if m.id == nil || m.oldValue == nil {
  36149. return v, errors.New("OldBotID requires an ID field in the mutation")
  36150. }
  36151. oldValue, err := m.oldValue(ctx)
  36152. if err != nil {
  36153. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36154. }
  36155. return oldValue.BotID, nil
  36156. }
  36157. // ClearBotID clears the value of the "bot_id" field.
  36158. func (m *UsageStatisticDayMutation) ClearBotID() {
  36159. m.bot_id = nil
  36160. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  36161. }
  36162. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36163. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  36164. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  36165. return ok
  36166. }
  36167. // ResetBotID resets all changes to the "bot_id" field.
  36168. func (m *UsageStatisticDayMutation) ResetBotID() {
  36169. m.bot_id = nil
  36170. delete(m.clearedFields, usagestatisticday.FieldBotID)
  36171. }
  36172. // SetOrganizationID sets the "organization_id" field.
  36173. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  36174. m.organization_id = &u
  36175. m.addorganization_id = nil
  36176. }
  36177. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36178. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  36179. v := m.organization_id
  36180. if v == nil {
  36181. return
  36182. }
  36183. return *v, true
  36184. }
  36185. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  36186. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36188. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36189. if !m.op.Is(OpUpdateOne) {
  36190. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36191. }
  36192. if m.id == nil || m.oldValue == nil {
  36193. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36194. }
  36195. oldValue, err := m.oldValue(ctx)
  36196. if err != nil {
  36197. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36198. }
  36199. return oldValue.OrganizationID, nil
  36200. }
  36201. // AddOrganizationID adds u to the "organization_id" field.
  36202. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  36203. if m.addorganization_id != nil {
  36204. *m.addorganization_id += u
  36205. } else {
  36206. m.addorganization_id = &u
  36207. }
  36208. }
  36209. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36210. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  36211. v := m.addorganization_id
  36212. if v == nil {
  36213. return
  36214. }
  36215. return *v, true
  36216. }
  36217. // ClearOrganizationID clears the value of the "organization_id" field.
  36218. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  36219. m.organization_id = nil
  36220. m.addorganization_id = nil
  36221. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  36222. }
  36223. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36224. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  36225. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  36226. return ok
  36227. }
  36228. // ResetOrganizationID resets all changes to the "organization_id" field.
  36229. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  36230. m.organization_id = nil
  36231. m.addorganization_id = nil
  36232. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  36233. }
  36234. // SetAiResponse sets the "ai_response" field.
  36235. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  36236. m.ai_response = &u
  36237. m.addai_response = nil
  36238. }
  36239. // AiResponse returns the value of the "ai_response" field in the mutation.
  36240. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  36241. v := m.ai_response
  36242. if v == nil {
  36243. return
  36244. }
  36245. return *v, true
  36246. }
  36247. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  36248. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36250. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36251. if !m.op.Is(OpUpdateOne) {
  36252. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36253. }
  36254. if m.id == nil || m.oldValue == nil {
  36255. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36256. }
  36257. oldValue, err := m.oldValue(ctx)
  36258. if err != nil {
  36259. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36260. }
  36261. return oldValue.AiResponse, nil
  36262. }
  36263. // AddAiResponse adds u to the "ai_response" field.
  36264. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  36265. if m.addai_response != nil {
  36266. *m.addai_response += u
  36267. } else {
  36268. m.addai_response = &u
  36269. }
  36270. }
  36271. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36272. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  36273. v := m.addai_response
  36274. if v == nil {
  36275. return
  36276. }
  36277. return *v, true
  36278. }
  36279. // ResetAiResponse resets all changes to the "ai_response" field.
  36280. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  36281. m.ai_response = nil
  36282. m.addai_response = nil
  36283. }
  36284. // SetSopRun sets the "sop_run" field.
  36285. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  36286. m.sop_run = &u
  36287. m.addsop_run = nil
  36288. }
  36289. // SopRun returns the value of the "sop_run" field in the mutation.
  36290. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  36291. v := m.sop_run
  36292. if v == nil {
  36293. return
  36294. }
  36295. return *v, true
  36296. }
  36297. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  36298. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36300. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36301. if !m.op.Is(OpUpdateOne) {
  36302. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36303. }
  36304. if m.id == nil || m.oldValue == nil {
  36305. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36306. }
  36307. oldValue, err := m.oldValue(ctx)
  36308. if err != nil {
  36309. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36310. }
  36311. return oldValue.SopRun, nil
  36312. }
  36313. // AddSopRun adds u to the "sop_run" field.
  36314. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  36315. if m.addsop_run != nil {
  36316. *m.addsop_run += u
  36317. } else {
  36318. m.addsop_run = &u
  36319. }
  36320. }
  36321. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36322. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  36323. v := m.addsop_run
  36324. if v == nil {
  36325. return
  36326. }
  36327. return *v, true
  36328. }
  36329. // ResetSopRun resets all changes to the "sop_run" field.
  36330. func (m *UsageStatisticDayMutation) ResetSopRun() {
  36331. m.sop_run = nil
  36332. m.addsop_run = nil
  36333. }
  36334. // SetTotalFriend sets the "total_friend" field.
  36335. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  36336. m.total_friend = &u
  36337. m.addtotal_friend = nil
  36338. }
  36339. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36340. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  36341. v := m.total_friend
  36342. if v == nil {
  36343. return
  36344. }
  36345. return *v, true
  36346. }
  36347. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  36348. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36350. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36351. if !m.op.Is(OpUpdateOne) {
  36352. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36353. }
  36354. if m.id == nil || m.oldValue == nil {
  36355. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36356. }
  36357. oldValue, err := m.oldValue(ctx)
  36358. if err != nil {
  36359. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36360. }
  36361. return oldValue.TotalFriend, nil
  36362. }
  36363. // AddTotalFriend adds u to the "total_friend" field.
  36364. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  36365. if m.addtotal_friend != nil {
  36366. *m.addtotal_friend += u
  36367. } else {
  36368. m.addtotal_friend = &u
  36369. }
  36370. }
  36371. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36372. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  36373. v := m.addtotal_friend
  36374. if v == nil {
  36375. return
  36376. }
  36377. return *v, true
  36378. }
  36379. // ResetTotalFriend resets all changes to the "total_friend" field.
  36380. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  36381. m.total_friend = nil
  36382. m.addtotal_friend = nil
  36383. }
  36384. // SetTotalGroup sets the "total_group" field.
  36385. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  36386. m.total_group = &u
  36387. m.addtotal_group = nil
  36388. }
  36389. // TotalGroup returns the value of the "total_group" field in the mutation.
  36390. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  36391. v := m.total_group
  36392. if v == nil {
  36393. return
  36394. }
  36395. return *v, true
  36396. }
  36397. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  36398. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36400. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36401. if !m.op.Is(OpUpdateOne) {
  36402. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36403. }
  36404. if m.id == nil || m.oldValue == nil {
  36405. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36406. }
  36407. oldValue, err := m.oldValue(ctx)
  36408. if err != nil {
  36409. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36410. }
  36411. return oldValue.TotalGroup, nil
  36412. }
  36413. // AddTotalGroup adds u to the "total_group" field.
  36414. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  36415. if m.addtotal_group != nil {
  36416. *m.addtotal_group += u
  36417. } else {
  36418. m.addtotal_group = &u
  36419. }
  36420. }
  36421. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36422. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  36423. v := m.addtotal_group
  36424. if v == nil {
  36425. return
  36426. }
  36427. return *v, true
  36428. }
  36429. // ResetTotalGroup resets all changes to the "total_group" field.
  36430. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  36431. m.total_group = nil
  36432. m.addtotal_group = nil
  36433. }
  36434. // SetAccountBalance sets the "account_balance" field.
  36435. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  36436. m.account_balance = &u
  36437. m.addaccount_balance = nil
  36438. }
  36439. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36440. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  36441. v := m.account_balance
  36442. if v == nil {
  36443. return
  36444. }
  36445. return *v, true
  36446. }
  36447. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  36448. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36450. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36451. if !m.op.Is(OpUpdateOne) {
  36452. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36453. }
  36454. if m.id == nil || m.oldValue == nil {
  36455. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36456. }
  36457. oldValue, err := m.oldValue(ctx)
  36458. if err != nil {
  36459. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36460. }
  36461. return oldValue.AccountBalance, nil
  36462. }
  36463. // AddAccountBalance adds u to the "account_balance" field.
  36464. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  36465. if m.addaccount_balance != nil {
  36466. *m.addaccount_balance += u
  36467. } else {
  36468. m.addaccount_balance = &u
  36469. }
  36470. }
  36471. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36472. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  36473. v := m.addaccount_balance
  36474. if v == nil {
  36475. return
  36476. }
  36477. return *v, true
  36478. }
  36479. // ResetAccountBalance resets all changes to the "account_balance" field.
  36480. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  36481. m.account_balance = nil
  36482. m.addaccount_balance = nil
  36483. }
  36484. // SetConsumeToken sets the "consume_token" field.
  36485. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  36486. m.consume_token = &u
  36487. m.addconsume_token = nil
  36488. }
  36489. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36490. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  36491. v := m.consume_token
  36492. if v == nil {
  36493. return
  36494. }
  36495. return *v, true
  36496. }
  36497. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  36498. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36500. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36501. if !m.op.Is(OpUpdateOne) {
  36502. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36503. }
  36504. if m.id == nil || m.oldValue == nil {
  36505. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36506. }
  36507. oldValue, err := m.oldValue(ctx)
  36508. if err != nil {
  36509. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36510. }
  36511. return oldValue.ConsumeToken, nil
  36512. }
  36513. // AddConsumeToken adds u to the "consume_token" field.
  36514. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  36515. if m.addconsume_token != nil {
  36516. *m.addconsume_token += u
  36517. } else {
  36518. m.addconsume_token = &u
  36519. }
  36520. }
  36521. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36522. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  36523. v := m.addconsume_token
  36524. if v == nil {
  36525. return
  36526. }
  36527. return *v, true
  36528. }
  36529. // ResetConsumeToken resets all changes to the "consume_token" field.
  36530. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  36531. m.consume_token = nil
  36532. m.addconsume_token = nil
  36533. }
  36534. // SetActiveUser sets the "active_user" field.
  36535. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  36536. m.active_user = &u
  36537. m.addactive_user = nil
  36538. }
  36539. // ActiveUser returns the value of the "active_user" field in the mutation.
  36540. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  36541. v := m.active_user
  36542. if v == nil {
  36543. return
  36544. }
  36545. return *v, true
  36546. }
  36547. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  36548. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36550. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36551. if !m.op.Is(OpUpdateOne) {
  36552. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36553. }
  36554. if m.id == nil || m.oldValue == nil {
  36555. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36556. }
  36557. oldValue, err := m.oldValue(ctx)
  36558. if err != nil {
  36559. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36560. }
  36561. return oldValue.ActiveUser, nil
  36562. }
  36563. // AddActiveUser adds u to the "active_user" field.
  36564. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  36565. if m.addactive_user != nil {
  36566. *m.addactive_user += u
  36567. } else {
  36568. m.addactive_user = &u
  36569. }
  36570. }
  36571. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36572. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  36573. v := m.addactive_user
  36574. if v == nil {
  36575. return
  36576. }
  36577. return *v, true
  36578. }
  36579. // ResetActiveUser resets all changes to the "active_user" field.
  36580. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  36581. m.active_user = nil
  36582. m.addactive_user = nil
  36583. }
  36584. // SetNewUser sets the "new_user" field.
  36585. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  36586. m.new_user = &i
  36587. m.addnew_user = nil
  36588. }
  36589. // NewUser returns the value of the "new_user" field in the mutation.
  36590. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  36591. v := m.new_user
  36592. if v == nil {
  36593. return
  36594. }
  36595. return *v, true
  36596. }
  36597. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  36598. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36600. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36601. if !m.op.Is(OpUpdateOne) {
  36602. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36603. }
  36604. if m.id == nil || m.oldValue == nil {
  36605. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36606. }
  36607. oldValue, err := m.oldValue(ctx)
  36608. if err != nil {
  36609. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36610. }
  36611. return oldValue.NewUser, nil
  36612. }
  36613. // AddNewUser adds i to the "new_user" field.
  36614. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  36615. if m.addnew_user != nil {
  36616. *m.addnew_user += i
  36617. } else {
  36618. m.addnew_user = &i
  36619. }
  36620. }
  36621. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36622. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  36623. v := m.addnew_user
  36624. if v == nil {
  36625. return
  36626. }
  36627. return *v, true
  36628. }
  36629. // ResetNewUser resets all changes to the "new_user" field.
  36630. func (m *UsageStatisticDayMutation) ResetNewUser() {
  36631. m.new_user = nil
  36632. m.addnew_user = nil
  36633. }
  36634. // SetLabelDist sets the "label_dist" field.
  36635. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36636. m.label_dist = &ctd
  36637. m.appendlabel_dist = nil
  36638. }
  36639. // LabelDist returns the value of the "label_dist" field in the mutation.
  36640. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36641. v := m.label_dist
  36642. if v == nil {
  36643. return
  36644. }
  36645. return *v, true
  36646. }
  36647. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  36648. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36650. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36651. if !m.op.Is(OpUpdateOne) {
  36652. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36653. }
  36654. if m.id == nil || m.oldValue == nil {
  36655. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36656. }
  36657. oldValue, err := m.oldValue(ctx)
  36658. if err != nil {
  36659. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36660. }
  36661. return oldValue.LabelDist, nil
  36662. }
  36663. // AppendLabelDist adds ctd to the "label_dist" field.
  36664. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36665. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36666. }
  36667. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36668. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36669. if len(m.appendlabel_dist) == 0 {
  36670. return nil, false
  36671. }
  36672. return m.appendlabel_dist, true
  36673. }
  36674. // ResetLabelDist resets all changes to the "label_dist" field.
  36675. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  36676. m.label_dist = nil
  36677. m.appendlabel_dist = nil
  36678. }
  36679. // SetConsumeCoin sets the "consume_coin" field.
  36680. func (m *UsageStatisticDayMutation) SetConsumeCoin(f float64) {
  36681. m.consume_coin = &f
  36682. m.addconsume_coin = nil
  36683. }
  36684. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  36685. func (m *UsageStatisticDayMutation) ConsumeCoin() (r float64, exists bool) {
  36686. v := m.consume_coin
  36687. if v == nil {
  36688. return
  36689. }
  36690. return *v, true
  36691. }
  36692. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  36693. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36695. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  36696. if !m.op.Is(OpUpdateOne) {
  36697. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  36698. }
  36699. if m.id == nil || m.oldValue == nil {
  36700. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  36701. }
  36702. oldValue, err := m.oldValue(ctx)
  36703. if err != nil {
  36704. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  36705. }
  36706. return oldValue.ConsumeCoin, nil
  36707. }
  36708. // AddConsumeCoin adds f to the "consume_coin" field.
  36709. func (m *UsageStatisticDayMutation) AddConsumeCoin(f float64) {
  36710. if m.addconsume_coin != nil {
  36711. *m.addconsume_coin += f
  36712. } else {
  36713. m.addconsume_coin = &f
  36714. }
  36715. }
  36716. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  36717. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r float64, exists bool) {
  36718. v := m.addconsume_coin
  36719. if v == nil {
  36720. return
  36721. }
  36722. return *v, true
  36723. }
  36724. // ClearConsumeCoin clears the value of the "consume_coin" field.
  36725. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  36726. m.consume_coin = nil
  36727. m.addconsume_coin = nil
  36728. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  36729. }
  36730. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  36731. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  36732. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  36733. return ok
  36734. }
  36735. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  36736. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  36737. m.consume_coin = nil
  36738. m.addconsume_coin = nil
  36739. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  36740. }
  36741. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  36742. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  36743. m.predicates = append(m.predicates, ps...)
  36744. }
  36745. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  36746. // users can use type-assertion to append predicates that do not depend on any generated package.
  36747. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  36748. p := make([]predicate.UsageStatisticDay, len(ps))
  36749. for i := range ps {
  36750. p[i] = ps[i]
  36751. }
  36752. m.Where(p...)
  36753. }
  36754. // Op returns the operation name.
  36755. func (m *UsageStatisticDayMutation) Op() Op {
  36756. return m.op
  36757. }
  36758. // SetOp allows setting the mutation operation.
  36759. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  36760. m.op = op
  36761. }
  36762. // Type returns the node type of this mutation (UsageStatisticDay).
  36763. func (m *UsageStatisticDayMutation) Type() string {
  36764. return m.typ
  36765. }
  36766. // Fields returns all fields that were changed during this mutation. Note that in
  36767. // order to get all numeric fields that were incremented/decremented, call
  36768. // AddedFields().
  36769. func (m *UsageStatisticDayMutation) Fields() []string {
  36770. fields := make([]string, 0, 18)
  36771. if m.created_at != nil {
  36772. fields = append(fields, usagestatisticday.FieldCreatedAt)
  36773. }
  36774. if m.updated_at != nil {
  36775. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  36776. }
  36777. if m.status != nil {
  36778. fields = append(fields, usagestatisticday.FieldStatus)
  36779. }
  36780. if m.deleted_at != nil {
  36781. fields = append(fields, usagestatisticday.FieldDeletedAt)
  36782. }
  36783. if m.addtime != nil {
  36784. fields = append(fields, usagestatisticday.FieldAddtime)
  36785. }
  36786. if m._type != nil {
  36787. fields = append(fields, usagestatisticday.FieldType)
  36788. }
  36789. if m.bot_id != nil {
  36790. fields = append(fields, usagestatisticday.FieldBotID)
  36791. }
  36792. if m.organization_id != nil {
  36793. fields = append(fields, usagestatisticday.FieldOrganizationID)
  36794. }
  36795. if m.ai_response != nil {
  36796. fields = append(fields, usagestatisticday.FieldAiResponse)
  36797. }
  36798. if m.sop_run != nil {
  36799. fields = append(fields, usagestatisticday.FieldSopRun)
  36800. }
  36801. if m.total_friend != nil {
  36802. fields = append(fields, usagestatisticday.FieldTotalFriend)
  36803. }
  36804. if m.total_group != nil {
  36805. fields = append(fields, usagestatisticday.FieldTotalGroup)
  36806. }
  36807. if m.account_balance != nil {
  36808. fields = append(fields, usagestatisticday.FieldAccountBalance)
  36809. }
  36810. if m.consume_token != nil {
  36811. fields = append(fields, usagestatisticday.FieldConsumeToken)
  36812. }
  36813. if m.active_user != nil {
  36814. fields = append(fields, usagestatisticday.FieldActiveUser)
  36815. }
  36816. if m.new_user != nil {
  36817. fields = append(fields, usagestatisticday.FieldNewUser)
  36818. }
  36819. if m.label_dist != nil {
  36820. fields = append(fields, usagestatisticday.FieldLabelDist)
  36821. }
  36822. if m.consume_coin != nil {
  36823. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36824. }
  36825. return fields
  36826. }
  36827. // Field returns the value of a field with the given name. The second boolean
  36828. // return value indicates that this field was not set, or was not defined in the
  36829. // schema.
  36830. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  36831. switch name {
  36832. case usagestatisticday.FieldCreatedAt:
  36833. return m.CreatedAt()
  36834. case usagestatisticday.FieldUpdatedAt:
  36835. return m.UpdatedAt()
  36836. case usagestatisticday.FieldStatus:
  36837. return m.Status()
  36838. case usagestatisticday.FieldDeletedAt:
  36839. return m.DeletedAt()
  36840. case usagestatisticday.FieldAddtime:
  36841. return m.Addtime()
  36842. case usagestatisticday.FieldType:
  36843. return m.GetType()
  36844. case usagestatisticday.FieldBotID:
  36845. return m.BotID()
  36846. case usagestatisticday.FieldOrganizationID:
  36847. return m.OrganizationID()
  36848. case usagestatisticday.FieldAiResponse:
  36849. return m.AiResponse()
  36850. case usagestatisticday.FieldSopRun:
  36851. return m.SopRun()
  36852. case usagestatisticday.FieldTotalFriend:
  36853. return m.TotalFriend()
  36854. case usagestatisticday.FieldTotalGroup:
  36855. return m.TotalGroup()
  36856. case usagestatisticday.FieldAccountBalance:
  36857. return m.AccountBalance()
  36858. case usagestatisticday.FieldConsumeToken:
  36859. return m.ConsumeToken()
  36860. case usagestatisticday.FieldActiveUser:
  36861. return m.ActiveUser()
  36862. case usagestatisticday.FieldNewUser:
  36863. return m.NewUser()
  36864. case usagestatisticday.FieldLabelDist:
  36865. return m.LabelDist()
  36866. case usagestatisticday.FieldConsumeCoin:
  36867. return m.ConsumeCoin()
  36868. }
  36869. return nil, false
  36870. }
  36871. // OldField returns the old value of the field from the database. An error is
  36872. // returned if the mutation operation is not UpdateOne, or the query to the
  36873. // database failed.
  36874. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36875. switch name {
  36876. case usagestatisticday.FieldCreatedAt:
  36877. return m.OldCreatedAt(ctx)
  36878. case usagestatisticday.FieldUpdatedAt:
  36879. return m.OldUpdatedAt(ctx)
  36880. case usagestatisticday.FieldStatus:
  36881. return m.OldStatus(ctx)
  36882. case usagestatisticday.FieldDeletedAt:
  36883. return m.OldDeletedAt(ctx)
  36884. case usagestatisticday.FieldAddtime:
  36885. return m.OldAddtime(ctx)
  36886. case usagestatisticday.FieldType:
  36887. return m.OldType(ctx)
  36888. case usagestatisticday.FieldBotID:
  36889. return m.OldBotID(ctx)
  36890. case usagestatisticday.FieldOrganizationID:
  36891. return m.OldOrganizationID(ctx)
  36892. case usagestatisticday.FieldAiResponse:
  36893. return m.OldAiResponse(ctx)
  36894. case usagestatisticday.FieldSopRun:
  36895. return m.OldSopRun(ctx)
  36896. case usagestatisticday.FieldTotalFriend:
  36897. return m.OldTotalFriend(ctx)
  36898. case usagestatisticday.FieldTotalGroup:
  36899. return m.OldTotalGroup(ctx)
  36900. case usagestatisticday.FieldAccountBalance:
  36901. return m.OldAccountBalance(ctx)
  36902. case usagestatisticday.FieldConsumeToken:
  36903. return m.OldConsumeToken(ctx)
  36904. case usagestatisticday.FieldActiveUser:
  36905. return m.OldActiveUser(ctx)
  36906. case usagestatisticday.FieldNewUser:
  36907. return m.OldNewUser(ctx)
  36908. case usagestatisticday.FieldLabelDist:
  36909. return m.OldLabelDist(ctx)
  36910. case usagestatisticday.FieldConsumeCoin:
  36911. return m.OldConsumeCoin(ctx)
  36912. }
  36913. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  36914. }
  36915. // SetField sets the value of a field with the given name. It returns an error if
  36916. // the field is not defined in the schema, or if the type mismatched the field
  36917. // type.
  36918. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  36919. switch name {
  36920. case usagestatisticday.FieldCreatedAt:
  36921. v, ok := value.(time.Time)
  36922. if !ok {
  36923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36924. }
  36925. m.SetCreatedAt(v)
  36926. return nil
  36927. case usagestatisticday.FieldUpdatedAt:
  36928. v, ok := value.(time.Time)
  36929. if !ok {
  36930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36931. }
  36932. m.SetUpdatedAt(v)
  36933. return nil
  36934. case usagestatisticday.FieldStatus:
  36935. v, ok := value.(uint8)
  36936. if !ok {
  36937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36938. }
  36939. m.SetStatus(v)
  36940. return nil
  36941. case usagestatisticday.FieldDeletedAt:
  36942. v, ok := value.(time.Time)
  36943. if !ok {
  36944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36945. }
  36946. m.SetDeletedAt(v)
  36947. return nil
  36948. case usagestatisticday.FieldAddtime:
  36949. v, ok := value.(uint64)
  36950. if !ok {
  36951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36952. }
  36953. m.SetAddtime(v)
  36954. return nil
  36955. case usagestatisticday.FieldType:
  36956. v, ok := value.(int)
  36957. if !ok {
  36958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36959. }
  36960. m.SetType(v)
  36961. return nil
  36962. case usagestatisticday.FieldBotID:
  36963. v, ok := value.(string)
  36964. if !ok {
  36965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36966. }
  36967. m.SetBotID(v)
  36968. return nil
  36969. case usagestatisticday.FieldOrganizationID:
  36970. v, ok := value.(uint64)
  36971. if !ok {
  36972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36973. }
  36974. m.SetOrganizationID(v)
  36975. return nil
  36976. case usagestatisticday.FieldAiResponse:
  36977. v, ok := value.(uint64)
  36978. if !ok {
  36979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36980. }
  36981. m.SetAiResponse(v)
  36982. return nil
  36983. case usagestatisticday.FieldSopRun:
  36984. v, ok := value.(uint64)
  36985. if !ok {
  36986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36987. }
  36988. m.SetSopRun(v)
  36989. return nil
  36990. case usagestatisticday.FieldTotalFriend:
  36991. v, ok := value.(uint64)
  36992. if !ok {
  36993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36994. }
  36995. m.SetTotalFriend(v)
  36996. return nil
  36997. case usagestatisticday.FieldTotalGroup:
  36998. v, ok := value.(uint64)
  36999. if !ok {
  37000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37001. }
  37002. m.SetTotalGroup(v)
  37003. return nil
  37004. case usagestatisticday.FieldAccountBalance:
  37005. v, ok := value.(uint64)
  37006. if !ok {
  37007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37008. }
  37009. m.SetAccountBalance(v)
  37010. return nil
  37011. case usagestatisticday.FieldConsumeToken:
  37012. v, ok := value.(uint64)
  37013. if !ok {
  37014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37015. }
  37016. m.SetConsumeToken(v)
  37017. return nil
  37018. case usagestatisticday.FieldActiveUser:
  37019. v, ok := value.(uint64)
  37020. if !ok {
  37021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37022. }
  37023. m.SetActiveUser(v)
  37024. return nil
  37025. case usagestatisticday.FieldNewUser:
  37026. v, ok := value.(int64)
  37027. if !ok {
  37028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37029. }
  37030. m.SetNewUser(v)
  37031. return nil
  37032. case usagestatisticday.FieldLabelDist:
  37033. v, ok := value.([]custom_types.LabelDist)
  37034. if !ok {
  37035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37036. }
  37037. m.SetLabelDist(v)
  37038. return nil
  37039. case usagestatisticday.FieldConsumeCoin:
  37040. v, ok := value.(float64)
  37041. if !ok {
  37042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37043. }
  37044. m.SetConsumeCoin(v)
  37045. return nil
  37046. }
  37047. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37048. }
  37049. // AddedFields returns all numeric fields that were incremented/decremented during
  37050. // this mutation.
  37051. func (m *UsageStatisticDayMutation) AddedFields() []string {
  37052. var fields []string
  37053. if m.addstatus != nil {
  37054. fields = append(fields, usagestatisticday.FieldStatus)
  37055. }
  37056. if m.addaddtime != nil {
  37057. fields = append(fields, usagestatisticday.FieldAddtime)
  37058. }
  37059. if m.add_type != nil {
  37060. fields = append(fields, usagestatisticday.FieldType)
  37061. }
  37062. if m.addorganization_id != nil {
  37063. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37064. }
  37065. if m.addai_response != nil {
  37066. fields = append(fields, usagestatisticday.FieldAiResponse)
  37067. }
  37068. if m.addsop_run != nil {
  37069. fields = append(fields, usagestatisticday.FieldSopRun)
  37070. }
  37071. if m.addtotal_friend != nil {
  37072. fields = append(fields, usagestatisticday.FieldTotalFriend)
  37073. }
  37074. if m.addtotal_group != nil {
  37075. fields = append(fields, usagestatisticday.FieldTotalGroup)
  37076. }
  37077. if m.addaccount_balance != nil {
  37078. fields = append(fields, usagestatisticday.FieldAccountBalance)
  37079. }
  37080. if m.addconsume_token != nil {
  37081. fields = append(fields, usagestatisticday.FieldConsumeToken)
  37082. }
  37083. if m.addactive_user != nil {
  37084. fields = append(fields, usagestatisticday.FieldActiveUser)
  37085. }
  37086. if m.addnew_user != nil {
  37087. fields = append(fields, usagestatisticday.FieldNewUser)
  37088. }
  37089. if m.addconsume_coin != nil {
  37090. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37091. }
  37092. return fields
  37093. }
  37094. // AddedField returns the numeric value that was incremented/decremented on a field
  37095. // with the given name. The second boolean return value indicates that this field
  37096. // was not set, or was not defined in the schema.
  37097. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  37098. switch name {
  37099. case usagestatisticday.FieldStatus:
  37100. return m.AddedStatus()
  37101. case usagestatisticday.FieldAddtime:
  37102. return m.AddedAddtime()
  37103. case usagestatisticday.FieldType:
  37104. return m.AddedType()
  37105. case usagestatisticday.FieldOrganizationID:
  37106. return m.AddedOrganizationID()
  37107. case usagestatisticday.FieldAiResponse:
  37108. return m.AddedAiResponse()
  37109. case usagestatisticday.FieldSopRun:
  37110. return m.AddedSopRun()
  37111. case usagestatisticday.FieldTotalFriend:
  37112. return m.AddedTotalFriend()
  37113. case usagestatisticday.FieldTotalGroup:
  37114. return m.AddedTotalGroup()
  37115. case usagestatisticday.FieldAccountBalance:
  37116. return m.AddedAccountBalance()
  37117. case usagestatisticday.FieldConsumeToken:
  37118. return m.AddedConsumeToken()
  37119. case usagestatisticday.FieldActiveUser:
  37120. return m.AddedActiveUser()
  37121. case usagestatisticday.FieldNewUser:
  37122. return m.AddedNewUser()
  37123. case usagestatisticday.FieldConsumeCoin:
  37124. return m.AddedConsumeCoin()
  37125. }
  37126. return nil, false
  37127. }
  37128. // AddField adds the value to the field with the given name. It returns an error if
  37129. // the field is not defined in the schema, or if the type mismatched the field
  37130. // type.
  37131. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  37132. switch name {
  37133. case usagestatisticday.FieldStatus:
  37134. v, ok := value.(int8)
  37135. if !ok {
  37136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37137. }
  37138. m.AddStatus(v)
  37139. return nil
  37140. case usagestatisticday.FieldAddtime:
  37141. v, ok := value.(int64)
  37142. if !ok {
  37143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37144. }
  37145. m.AddAddtime(v)
  37146. return nil
  37147. case usagestatisticday.FieldType:
  37148. v, ok := value.(int)
  37149. if !ok {
  37150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37151. }
  37152. m.AddType(v)
  37153. return nil
  37154. case usagestatisticday.FieldOrganizationID:
  37155. v, ok := value.(int64)
  37156. if !ok {
  37157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37158. }
  37159. m.AddOrganizationID(v)
  37160. return nil
  37161. case usagestatisticday.FieldAiResponse:
  37162. v, ok := value.(int64)
  37163. if !ok {
  37164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37165. }
  37166. m.AddAiResponse(v)
  37167. return nil
  37168. case usagestatisticday.FieldSopRun:
  37169. v, ok := value.(int64)
  37170. if !ok {
  37171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37172. }
  37173. m.AddSopRun(v)
  37174. return nil
  37175. case usagestatisticday.FieldTotalFriend:
  37176. v, ok := value.(int64)
  37177. if !ok {
  37178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37179. }
  37180. m.AddTotalFriend(v)
  37181. return nil
  37182. case usagestatisticday.FieldTotalGroup:
  37183. v, ok := value.(int64)
  37184. if !ok {
  37185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37186. }
  37187. m.AddTotalGroup(v)
  37188. return nil
  37189. case usagestatisticday.FieldAccountBalance:
  37190. v, ok := value.(int64)
  37191. if !ok {
  37192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37193. }
  37194. m.AddAccountBalance(v)
  37195. return nil
  37196. case usagestatisticday.FieldConsumeToken:
  37197. v, ok := value.(int64)
  37198. if !ok {
  37199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37200. }
  37201. m.AddConsumeToken(v)
  37202. return nil
  37203. case usagestatisticday.FieldActiveUser:
  37204. v, ok := value.(int64)
  37205. if !ok {
  37206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37207. }
  37208. m.AddActiveUser(v)
  37209. return nil
  37210. case usagestatisticday.FieldNewUser:
  37211. v, ok := value.(int64)
  37212. if !ok {
  37213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37214. }
  37215. m.AddNewUser(v)
  37216. return nil
  37217. case usagestatisticday.FieldConsumeCoin:
  37218. v, ok := value.(float64)
  37219. if !ok {
  37220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37221. }
  37222. m.AddConsumeCoin(v)
  37223. return nil
  37224. }
  37225. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  37226. }
  37227. // ClearedFields returns all nullable fields that were cleared during this
  37228. // mutation.
  37229. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  37230. var fields []string
  37231. if m.FieldCleared(usagestatisticday.FieldStatus) {
  37232. fields = append(fields, usagestatisticday.FieldStatus)
  37233. }
  37234. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  37235. fields = append(fields, usagestatisticday.FieldDeletedAt)
  37236. }
  37237. if m.FieldCleared(usagestatisticday.FieldBotID) {
  37238. fields = append(fields, usagestatisticday.FieldBotID)
  37239. }
  37240. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  37241. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37242. }
  37243. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  37244. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37245. }
  37246. return fields
  37247. }
  37248. // FieldCleared returns a boolean indicating if a field with the given name was
  37249. // cleared in this mutation.
  37250. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  37251. _, ok := m.clearedFields[name]
  37252. return ok
  37253. }
  37254. // ClearField clears the value of the field with the given name. It returns an
  37255. // error if the field is not defined in the schema.
  37256. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  37257. switch name {
  37258. case usagestatisticday.FieldStatus:
  37259. m.ClearStatus()
  37260. return nil
  37261. case usagestatisticday.FieldDeletedAt:
  37262. m.ClearDeletedAt()
  37263. return nil
  37264. case usagestatisticday.FieldBotID:
  37265. m.ClearBotID()
  37266. return nil
  37267. case usagestatisticday.FieldOrganizationID:
  37268. m.ClearOrganizationID()
  37269. return nil
  37270. case usagestatisticday.FieldConsumeCoin:
  37271. m.ClearConsumeCoin()
  37272. return nil
  37273. }
  37274. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  37275. }
  37276. // ResetField resets all changes in the mutation for the field with the given name.
  37277. // It returns an error if the field is not defined in the schema.
  37278. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  37279. switch name {
  37280. case usagestatisticday.FieldCreatedAt:
  37281. m.ResetCreatedAt()
  37282. return nil
  37283. case usagestatisticday.FieldUpdatedAt:
  37284. m.ResetUpdatedAt()
  37285. return nil
  37286. case usagestatisticday.FieldStatus:
  37287. m.ResetStatus()
  37288. return nil
  37289. case usagestatisticday.FieldDeletedAt:
  37290. m.ResetDeletedAt()
  37291. return nil
  37292. case usagestatisticday.FieldAddtime:
  37293. m.ResetAddtime()
  37294. return nil
  37295. case usagestatisticday.FieldType:
  37296. m.ResetType()
  37297. return nil
  37298. case usagestatisticday.FieldBotID:
  37299. m.ResetBotID()
  37300. return nil
  37301. case usagestatisticday.FieldOrganizationID:
  37302. m.ResetOrganizationID()
  37303. return nil
  37304. case usagestatisticday.FieldAiResponse:
  37305. m.ResetAiResponse()
  37306. return nil
  37307. case usagestatisticday.FieldSopRun:
  37308. m.ResetSopRun()
  37309. return nil
  37310. case usagestatisticday.FieldTotalFriend:
  37311. m.ResetTotalFriend()
  37312. return nil
  37313. case usagestatisticday.FieldTotalGroup:
  37314. m.ResetTotalGroup()
  37315. return nil
  37316. case usagestatisticday.FieldAccountBalance:
  37317. m.ResetAccountBalance()
  37318. return nil
  37319. case usagestatisticday.FieldConsumeToken:
  37320. m.ResetConsumeToken()
  37321. return nil
  37322. case usagestatisticday.FieldActiveUser:
  37323. m.ResetActiveUser()
  37324. return nil
  37325. case usagestatisticday.FieldNewUser:
  37326. m.ResetNewUser()
  37327. return nil
  37328. case usagestatisticday.FieldLabelDist:
  37329. m.ResetLabelDist()
  37330. return nil
  37331. case usagestatisticday.FieldConsumeCoin:
  37332. m.ResetConsumeCoin()
  37333. return nil
  37334. }
  37335. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37336. }
  37337. // AddedEdges returns all edge names that were set/added in this mutation.
  37338. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  37339. edges := make([]string, 0, 0)
  37340. return edges
  37341. }
  37342. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37343. // name in this mutation.
  37344. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  37345. return nil
  37346. }
  37347. // RemovedEdges returns all edge names that were removed in this mutation.
  37348. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  37349. edges := make([]string, 0, 0)
  37350. return edges
  37351. }
  37352. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37353. // the given name in this mutation.
  37354. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  37355. return nil
  37356. }
  37357. // ClearedEdges returns all edge names that were cleared in this mutation.
  37358. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  37359. edges := make([]string, 0, 0)
  37360. return edges
  37361. }
  37362. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37363. // was cleared in this mutation.
  37364. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  37365. return false
  37366. }
  37367. // ClearEdge clears the value of the edge with the given name. It returns an error
  37368. // if that edge is not defined in the schema.
  37369. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  37370. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  37371. }
  37372. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37373. // It returns an error if the edge is not defined in the schema.
  37374. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  37375. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  37376. }
  37377. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  37378. type UsageStatisticHourMutation struct {
  37379. config
  37380. op Op
  37381. typ string
  37382. id *uint64
  37383. created_at *time.Time
  37384. updated_at *time.Time
  37385. status *uint8
  37386. addstatus *int8
  37387. deleted_at *time.Time
  37388. addtime *uint64
  37389. addaddtime *int64
  37390. _type *int
  37391. add_type *int
  37392. bot_id *string
  37393. organization_id *uint64
  37394. addorganization_id *int64
  37395. ai_response *uint64
  37396. addai_response *int64
  37397. sop_run *uint64
  37398. addsop_run *int64
  37399. total_friend *uint64
  37400. addtotal_friend *int64
  37401. total_group *uint64
  37402. addtotal_group *int64
  37403. account_balance *uint64
  37404. addaccount_balance *int64
  37405. consume_token *uint64
  37406. addconsume_token *int64
  37407. active_user *uint64
  37408. addactive_user *int64
  37409. new_user *int64
  37410. addnew_user *int64
  37411. label_dist *[]custom_types.LabelDist
  37412. appendlabel_dist []custom_types.LabelDist
  37413. consume_coin *float64
  37414. addconsume_coin *float64
  37415. clearedFields map[string]struct{}
  37416. done bool
  37417. oldValue func(context.Context) (*UsageStatisticHour, error)
  37418. predicates []predicate.UsageStatisticHour
  37419. }
  37420. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  37421. // usagestatistichourOption allows management of the mutation configuration using functional options.
  37422. type usagestatistichourOption func(*UsageStatisticHourMutation)
  37423. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  37424. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  37425. m := &UsageStatisticHourMutation{
  37426. config: c,
  37427. op: op,
  37428. typ: TypeUsageStatisticHour,
  37429. clearedFields: make(map[string]struct{}),
  37430. }
  37431. for _, opt := range opts {
  37432. opt(m)
  37433. }
  37434. return m
  37435. }
  37436. // withUsageStatisticHourID sets the ID field of the mutation.
  37437. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  37438. return func(m *UsageStatisticHourMutation) {
  37439. var (
  37440. err error
  37441. once sync.Once
  37442. value *UsageStatisticHour
  37443. )
  37444. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  37445. once.Do(func() {
  37446. if m.done {
  37447. err = errors.New("querying old values post mutation is not allowed")
  37448. } else {
  37449. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  37450. }
  37451. })
  37452. return value, err
  37453. }
  37454. m.id = &id
  37455. }
  37456. }
  37457. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  37458. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  37459. return func(m *UsageStatisticHourMutation) {
  37460. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  37461. return node, nil
  37462. }
  37463. m.id = &node.ID
  37464. }
  37465. }
  37466. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37467. // executed in a transaction (ent.Tx), a transactional client is returned.
  37468. func (m UsageStatisticHourMutation) Client() *Client {
  37469. client := &Client{config: m.config}
  37470. client.init()
  37471. return client
  37472. }
  37473. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37474. // it returns an error otherwise.
  37475. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  37476. if _, ok := m.driver.(*txDriver); !ok {
  37477. return nil, errors.New("ent: mutation is not running in a transaction")
  37478. }
  37479. tx := &Tx{config: m.config}
  37480. tx.init()
  37481. return tx, nil
  37482. }
  37483. // SetID sets the value of the id field. Note that this
  37484. // operation is only accepted on creation of UsageStatisticHour entities.
  37485. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  37486. m.id = &id
  37487. }
  37488. // ID returns the ID value in the mutation. Note that the ID is only available
  37489. // if it was provided to the builder or after it was returned from the database.
  37490. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  37491. if m.id == nil {
  37492. return
  37493. }
  37494. return *m.id, true
  37495. }
  37496. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37497. // That means, if the mutation is applied within a transaction with an isolation level such
  37498. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37499. // or updated by the mutation.
  37500. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  37501. switch {
  37502. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37503. id, exists := m.ID()
  37504. if exists {
  37505. return []uint64{id}, nil
  37506. }
  37507. fallthrough
  37508. case m.op.Is(OpUpdate | OpDelete):
  37509. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  37510. default:
  37511. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37512. }
  37513. }
  37514. // SetCreatedAt sets the "created_at" field.
  37515. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  37516. m.created_at = &t
  37517. }
  37518. // CreatedAt returns the value of the "created_at" field in the mutation.
  37519. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  37520. v := m.created_at
  37521. if v == nil {
  37522. return
  37523. }
  37524. return *v, true
  37525. }
  37526. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  37527. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37529. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37530. if !m.op.Is(OpUpdateOne) {
  37531. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37532. }
  37533. if m.id == nil || m.oldValue == nil {
  37534. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37535. }
  37536. oldValue, err := m.oldValue(ctx)
  37537. if err != nil {
  37538. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37539. }
  37540. return oldValue.CreatedAt, nil
  37541. }
  37542. // ResetCreatedAt resets all changes to the "created_at" field.
  37543. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  37544. m.created_at = nil
  37545. }
  37546. // SetUpdatedAt sets the "updated_at" field.
  37547. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  37548. m.updated_at = &t
  37549. }
  37550. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37551. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  37552. v := m.updated_at
  37553. if v == nil {
  37554. return
  37555. }
  37556. return *v, true
  37557. }
  37558. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  37559. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37561. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37562. if !m.op.Is(OpUpdateOne) {
  37563. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37564. }
  37565. if m.id == nil || m.oldValue == nil {
  37566. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37567. }
  37568. oldValue, err := m.oldValue(ctx)
  37569. if err != nil {
  37570. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37571. }
  37572. return oldValue.UpdatedAt, nil
  37573. }
  37574. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37575. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  37576. m.updated_at = nil
  37577. }
  37578. // SetStatus sets the "status" field.
  37579. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  37580. m.status = &u
  37581. m.addstatus = nil
  37582. }
  37583. // Status returns the value of the "status" field in the mutation.
  37584. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  37585. v := m.status
  37586. if v == nil {
  37587. return
  37588. }
  37589. return *v, true
  37590. }
  37591. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  37592. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37594. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37595. if !m.op.Is(OpUpdateOne) {
  37596. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37597. }
  37598. if m.id == nil || m.oldValue == nil {
  37599. return v, errors.New("OldStatus requires an ID field in the mutation")
  37600. }
  37601. oldValue, err := m.oldValue(ctx)
  37602. if err != nil {
  37603. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37604. }
  37605. return oldValue.Status, nil
  37606. }
  37607. // AddStatus adds u to the "status" field.
  37608. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  37609. if m.addstatus != nil {
  37610. *m.addstatus += u
  37611. } else {
  37612. m.addstatus = &u
  37613. }
  37614. }
  37615. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37616. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  37617. v := m.addstatus
  37618. if v == nil {
  37619. return
  37620. }
  37621. return *v, true
  37622. }
  37623. // ClearStatus clears the value of the "status" field.
  37624. func (m *UsageStatisticHourMutation) ClearStatus() {
  37625. m.status = nil
  37626. m.addstatus = nil
  37627. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  37628. }
  37629. // StatusCleared returns if the "status" field was cleared in this mutation.
  37630. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  37631. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  37632. return ok
  37633. }
  37634. // ResetStatus resets all changes to the "status" field.
  37635. func (m *UsageStatisticHourMutation) ResetStatus() {
  37636. m.status = nil
  37637. m.addstatus = nil
  37638. delete(m.clearedFields, usagestatistichour.FieldStatus)
  37639. }
  37640. // SetDeletedAt sets the "deleted_at" field.
  37641. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  37642. m.deleted_at = &t
  37643. }
  37644. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37645. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  37646. v := m.deleted_at
  37647. if v == nil {
  37648. return
  37649. }
  37650. return *v, true
  37651. }
  37652. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  37653. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37655. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37656. if !m.op.Is(OpUpdateOne) {
  37657. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37658. }
  37659. if m.id == nil || m.oldValue == nil {
  37660. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37661. }
  37662. oldValue, err := m.oldValue(ctx)
  37663. if err != nil {
  37664. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37665. }
  37666. return oldValue.DeletedAt, nil
  37667. }
  37668. // ClearDeletedAt clears the value of the "deleted_at" field.
  37669. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  37670. m.deleted_at = nil
  37671. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  37672. }
  37673. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37674. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  37675. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  37676. return ok
  37677. }
  37678. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37679. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  37680. m.deleted_at = nil
  37681. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  37682. }
  37683. // SetAddtime sets the "addtime" field.
  37684. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  37685. m.addtime = &u
  37686. m.addaddtime = nil
  37687. }
  37688. // Addtime returns the value of the "addtime" field in the mutation.
  37689. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  37690. v := m.addtime
  37691. if v == nil {
  37692. return
  37693. }
  37694. return *v, true
  37695. }
  37696. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  37697. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37699. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37700. if !m.op.Is(OpUpdateOne) {
  37701. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37702. }
  37703. if m.id == nil || m.oldValue == nil {
  37704. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37705. }
  37706. oldValue, err := m.oldValue(ctx)
  37707. if err != nil {
  37708. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37709. }
  37710. return oldValue.Addtime, nil
  37711. }
  37712. // AddAddtime adds u to the "addtime" field.
  37713. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  37714. if m.addaddtime != nil {
  37715. *m.addaddtime += u
  37716. } else {
  37717. m.addaddtime = &u
  37718. }
  37719. }
  37720. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37721. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  37722. v := m.addaddtime
  37723. if v == nil {
  37724. return
  37725. }
  37726. return *v, true
  37727. }
  37728. // ResetAddtime resets all changes to the "addtime" field.
  37729. func (m *UsageStatisticHourMutation) ResetAddtime() {
  37730. m.addtime = nil
  37731. m.addaddtime = nil
  37732. }
  37733. // SetType sets the "type" field.
  37734. func (m *UsageStatisticHourMutation) SetType(i int) {
  37735. m._type = &i
  37736. m.add_type = nil
  37737. }
  37738. // GetType returns the value of the "type" field in the mutation.
  37739. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  37740. v := m._type
  37741. if v == nil {
  37742. return
  37743. }
  37744. return *v, true
  37745. }
  37746. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  37747. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37749. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  37750. if !m.op.Is(OpUpdateOne) {
  37751. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37752. }
  37753. if m.id == nil || m.oldValue == nil {
  37754. return v, errors.New("OldType requires an ID field in the mutation")
  37755. }
  37756. oldValue, err := m.oldValue(ctx)
  37757. if err != nil {
  37758. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37759. }
  37760. return oldValue.Type, nil
  37761. }
  37762. // AddType adds i to the "type" field.
  37763. func (m *UsageStatisticHourMutation) AddType(i int) {
  37764. if m.add_type != nil {
  37765. *m.add_type += i
  37766. } else {
  37767. m.add_type = &i
  37768. }
  37769. }
  37770. // AddedType returns the value that was added to the "type" field in this mutation.
  37771. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  37772. v := m.add_type
  37773. if v == nil {
  37774. return
  37775. }
  37776. return *v, true
  37777. }
  37778. // ResetType resets all changes to the "type" field.
  37779. func (m *UsageStatisticHourMutation) ResetType() {
  37780. m._type = nil
  37781. m.add_type = nil
  37782. }
  37783. // SetBotID sets the "bot_id" field.
  37784. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  37785. m.bot_id = &s
  37786. }
  37787. // BotID returns the value of the "bot_id" field in the mutation.
  37788. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  37789. v := m.bot_id
  37790. if v == nil {
  37791. return
  37792. }
  37793. return *v, true
  37794. }
  37795. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  37796. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37798. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  37799. if !m.op.Is(OpUpdateOne) {
  37800. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37801. }
  37802. if m.id == nil || m.oldValue == nil {
  37803. return v, errors.New("OldBotID requires an ID field in the mutation")
  37804. }
  37805. oldValue, err := m.oldValue(ctx)
  37806. if err != nil {
  37807. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37808. }
  37809. return oldValue.BotID, nil
  37810. }
  37811. // ClearBotID clears the value of the "bot_id" field.
  37812. func (m *UsageStatisticHourMutation) ClearBotID() {
  37813. m.bot_id = nil
  37814. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  37815. }
  37816. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  37817. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  37818. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  37819. return ok
  37820. }
  37821. // ResetBotID resets all changes to the "bot_id" field.
  37822. func (m *UsageStatisticHourMutation) ResetBotID() {
  37823. m.bot_id = nil
  37824. delete(m.clearedFields, usagestatistichour.FieldBotID)
  37825. }
  37826. // SetOrganizationID sets the "organization_id" field.
  37827. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  37828. m.organization_id = &u
  37829. m.addorganization_id = nil
  37830. }
  37831. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37832. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  37833. v := m.organization_id
  37834. if v == nil {
  37835. return
  37836. }
  37837. return *v, true
  37838. }
  37839. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  37840. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37842. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37843. if !m.op.Is(OpUpdateOne) {
  37844. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37845. }
  37846. if m.id == nil || m.oldValue == nil {
  37847. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37848. }
  37849. oldValue, err := m.oldValue(ctx)
  37850. if err != nil {
  37851. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37852. }
  37853. return oldValue.OrganizationID, nil
  37854. }
  37855. // AddOrganizationID adds u to the "organization_id" field.
  37856. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  37857. if m.addorganization_id != nil {
  37858. *m.addorganization_id += u
  37859. } else {
  37860. m.addorganization_id = &u
  37861. }
  37862. }
  37863. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37864. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  37865. v := m.addorganization_id
  37866. if v == nil {
  37867. return
  37868. }
  37869. return *v, true
  37870. }
  37871. // ClearOrganizationID clears the value of the "organization_id" field.
  37872. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  37873. m.organization_id = nil
  37874. m.addorganization_id = nil
  37875. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  37876. }
  37877. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37878. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  37879. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  37880. return ok
  37881. }
  37882. // ResetOrganizationID resets all changes to the "organization_id" field.
  37883. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  37884. m.organization_id = nil
  37885. m.addorganization_id = nil
  37886. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  37887. }
  37888. // SetAiResponse sets the "ai_response" field.
  37889. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  37890. m.ai_response = &u
  37891. m.addai_response = nil
  37892. }
  37893. // AiResponse returns the value of the "ai_response" field in the mutation.
  37894. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  37895. v := m.ai_response
  37896. if v == nil {
  37897. return
  37898. }
  37899. return *v, true
  37900. }
  37901. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  37902. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37904. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  37905. if !m.op.Is(OpUpdateOne) {
  37906. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  37907. }
  37908. if m.id == nil || m.oldValue == nil {
  37909. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  37910. }
  37911. oldValue, err := m.oldValue(ctx)
  37912. if err != nil {
  37913. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  37914. }
  37915. return oldValue.AiResponse, nil
  37916. }
  37917. // AddAiResponse adds u to the "ai_response" field.
  37918. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  37919. if m.addai_response != nil {
  37920. *m.addai_response += u
  37921. } else {
  37922. m.addai_response = &u
  37923. }
  37924. }
  37925. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  37926. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  37927. v := m.addai_response
  37928. if v == nil {
  37929. return
  37930. }
  37931. return *v, true
  37932. }
  37933. // ResetAiResponse resets all changes to the "ai_response" field.
  37934. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  37935. m.ai_response = nil
  37936. m.addai_response = nil
  37937. }
  37938. // SetSopRun sets the "sop_run" field.
  37939. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  37940. m.sop_run = &u
  37941. m.addsop_run = nil
  37942. }
  37943. // SopRun returns the value of the "sop_run" field in the mutation.
  37944. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  37945. v := m.sop_run
  37946. if v == nil {
  37947. return
  37948. }
  37949. return *v, true
  37950. }
  37951. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  37952. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37954. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  37955. if !m.op.Is(OpUpdateOne) {
  37956. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  37957. }
  37958. if m.id == nil || m.oldValue == nil {
  37959. return v, errors.New("OldSopRun requires an ID field in the mutation")
  37960. }
  37961. oldValue, err := m.oldValue(ctx)
  37962. if err != nil {
  37963. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  37964. }
  37965. return oldValue.SopRun, nil
  37966. }
  37967. // AddSopRun adds u to the "sop_run" field.
  37968. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  37969. if m.addsop_run != nil {
  37970. *m.addsop_run += u
  37971. } else {
  37972. m.addsop_run = &u
  37973. }
  37974. }
  37975. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  37976. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  37977. v := m.addsop_run
  37978. if v == nil {
  37979. return
  37980. }
  37981. return *v, true
  37982. }
  37983. // ResetSopRun resets all changes to the "sop_run" field.
  37984. func (m *UsageStatisticHourMutation) ResetSopRun() {
  37985. m.sop_run = nil
  37986. m.addsop_run = nil
  37987. }
  37988. // SetTotalFriend sets the "total_friend" field.
  37989. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  37990. m.total_friend = &u
  37991. m.addtotal_friend = nil
  37992. }
  37993. // TotalFriend returns the value of the "total_friend" field in the mutation.
  37994. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  37995. v := m.total_friend
  37996. if v == nil {
  37997. return
  37998. }
  37999. return *v, true
  38000. }
  38001. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  38002. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38004. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  38005. if !m.op.Is(OpUpdateOne) {
  38006. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  38007. }
  38008. if m.id == nil || m.oldValue == nil {
  38009. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  38010. }
  38011. oldValue, err := m.oldValue(ctx)
  38012. if err != nil {
  38013. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  38014. }
  38015. return oldValue.TotalFriend, nil
  38016. }
  38017. // AddTotalFriend adds u to the "total_friend" field.
  38018. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  38019. if m.addtotal_friend != nil {
  38020. *m.addtotal_friend += u
  38021. } else {
  38022. m.addtotal_friend = &u
  38023. }
  38024. }
  38025. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  38026. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  38027. v := m.addtotal_friend
  38028. if v == nil {
  38029. return
  38030. }
  38031. return *v, true
  38032. }
  38033. // ResetTotalFriend resets all changes to the "total_friend" field.
  38034. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  38035. m.total_friend = nil
  38036. m.addtotal_friend = nil
  38037. }
  38038. // SetTotalGroup sets the "total_group" field.
  38039. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  38040. m.total_group = &u
  38041. m.addtotal_group = nil
  38042. }
  38043. // TotalGroup returns the value of the "total_group" field in the mutation.
  38044. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  38045. v := m.total_group
  38046. if v == nil {
  38047. return
  38048. }
  38049. return *v, true
  38050. }
  38051. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  38052. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38054. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  38055. if !m.op.Is(OpUpdateOne) {
  38056. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  38057. }
  38058. if m.id == nil || m.oldValue == nil {
  38059. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  38060. }
  38061. oldValue, err := m.oldValue(ctx)
  38062. if err != nil {
  38063. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  38064. }
  38065. return oldValue.TotalGroup, nil
  38066. }
  38067. // AddTotalGroup adds u to the "total_group" field.
  38068. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  38069. if m.addtotal_group != nil {
  38070. *m.addtotal_group += u
  38071. } else {
  38072. m.addtotal_group = &u
  38073. }
  38074. }
  38075. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  38076. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  38077. v := m.addtotal_group
  38078. if v == nil {
  38079. return
  38080. }
  38081. return *v, true
  38082. }
  38083. // ResetTotalGroup resets all changes to the "total_group" field.
  38084. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  38085. m.total_group = nil
  38086. m.addtotal_group = nil
  38087. }
  38088. // SetAccountBalance sets the "account_balance" field.
  38089. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  38090. m.account_balance = &u
  38091. m.addaccount_balance = nil
  38092. }
  38093. // AccountBalance returns the value of the "account_balance" field in the mutation.
  38094. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  38095. v := m.account_balance
  38096. if v == nil {
  38097. return
  38098. }
  38099. return *v, true
  38100. }
  38101. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  38102. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38104. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  38105. if !m.op.Is(OpUpdateOne) {
  38106. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  38107. }
  38108. if m.id == nil || m.oldValue == nil {
  38109. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  38110. }
  38111. oldValue, err := m.oldValue(ctx)
  38112. if err != nil {
  38113. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  38114. }
  38115. return oldValue.AccountBalance, nil
  38116. }
  38117. // AddAccountBalance adds u to the "account_balance" field.
  38118. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  38119. if m.addaccount_balance != nil {
  38120. *m.addaccount_balance += u
  38121. } else {
  38122. m.addaccount_balance = &u
  38123. }
  38124. }
  38125. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  38126. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  38127. v := m.addaccount_balance
  38128. if v == nil {
  38129. return
  38130. }
  38131. return *v, true
  38132. }
  38133. // ResetAccountBalance resets all changes to the "account_balance" field.
  38134. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  38135. m.account_balance = nil
  38136. m.addaccount_balance = nil
  38137. }
  38138. // SetConsumeToken sets the "consume_token" field.
  38139. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  38140. m.consume_token = &u
  38141. m.addconsume_token = nil
  38142. }
  38143. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  38144. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  38145. v := m.consume_token
  38146. if v == nil {
  38147. return
  38148. }
  38149. return *v, true
  38150. }
  38151. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  38152. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38154. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38155. if !m.op.Is(OpUpdateOne) {
  38156. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38157. }
  38158. if m.id == nil || m.oldValue == nil {
  38159. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38160. }
  38161. oldValue, err := m.oldValue(ctx)
  38162. if err != nil {
  38163. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38164. }
  38165. return oldValue.ConsumeToken, nil
  38166. }
  38167. // AddConsumeToken adds u to the "consume_token" field.
  38168. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  38169. if m.addconsume_token != nil {
  38170. *m.addconsume_token += u
  38171. } else {
  38172. m.addconsume_token = &u
  38173. }
  38174. }
  38175. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38176. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  38177. v := m.addconsume_token
  38178. if v == nil {
  38179. return
  38180. }
  38181. return *v, true
  38182. }
  38183. // ResetConsumeToken resets all changes to the "consume_token" field.
  38184. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  38185. m.consume_token = nil
  38186. m.addconsume_token = nil
  38187. }
  38188. // SetActiveUser sets the "active_user" field.
  38189. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  38190. m.active_user = &u
  38191. m.addactive_user = nil
  38192. }
  38193. // ActiveUser returns the value of the "active_user" field in the mutation.
  38194. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  38195. v := m.active_user
  38196. if v == nil {
  38197. return
  38198. }
  38199. return *v, true
  38200. }
  38201. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  38202. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38205. if !m.op.Is(OpUpdateOne) {
  38206. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38207. }
  38208. if m.id == nil || m.oldValue == nil {
  38209. return v, errors.New("OldActiveUser 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 OldActiveUser: %w", err)
  38214. }
  38215. return oldValue.ActiveUser, nil
  38216. }
  38217. // AddActiveUser adds u to the "active_user" field.
  38218. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  38219. if m.addactive_user != nil {
  38220. *m.addactive_user += u
  38221. } else {
  38222. m.addactive_user = &u
  38223. }
  38224. }
  38225. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38226. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  38227. v := m.addactive_user
  38228. if v == nil {
  38229. return
  38230. }
  38231. return *v, true
  38232. }
  38233. // ResetActiveUser resets all changes to the "active_user" field.
  38234. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  38235. m.active_user = nil
  38236. m.addactive_user = nil
  38237. }
  38238. // SetNewUser sets the "new_user" field.
  38239. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  38240. m.new_user = &i
  38241. m.addnew_user = nil
  38242. }
  38243. // NewUser returns the value of the "new_user" field in the mutation.
  38244. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  38245. v := m.new_user
  38246. if v == nil {
  38247. return
  38248. }
  38249. return *v, true
  38250. }
  38251. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  38252. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38254. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38255. if !m.op.Is(OpUpdateOne) {
  38256. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38257. }
  38258. if m.id == nil || m.oldValue == nil {
  38259. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38260. }
  38261. oldValue, err := m.oldValue(ctx)
  38262. if err != nil {
  38263. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38264. }
  38265. return oldValue.NewUser, nil
  38266. }
  38267. // AddNewUser adds i to the "new_user" field.
  38268. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  38269. if m.addnew_user != nil {
  38270. *m.addnew_user += i
  38271. } else {
  38272. m.addnew_user = &i
  38273. }
  38274. }
  38275. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38276. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  38277. v := m.addnew_user
  38278. if v == nil {
  38279. return
  38280. }
  38281. return *v, true
  38282. }
  38283. // ResetNewUser resets all changes to the "new_user" field.
  38284. func (m *UsageStatisticHourMutation) ResetNewUser() {
  38285. m.new_user = nil
  38286. m.addnew_user = nil
  38287. }
  38288. // SetLabelDist sets the "label_dist" field.
  38289. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38290. m.label_dist = &ctd
  38291. m.appendlabel_dist = nil
  38292. }
  38293. // LabelDist returns the value of the "label_dist" field in the mutation.
  38294. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38295. v := m.label_dist
  38296. if v == nil {
  38297. return
  38298. }
  38299. return *v, true
  38300. }
  38301. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  38302. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38304. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38305. if !m.op.Is(OpUpdateOne) {
  38306. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38307. }
  38308. if m.id == nil || m.oldValue == nil {
  38309. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38310. }
  38311. oldValue, err := m.oldValue(ctx)
  38312. if err != nil {
  38313. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38314. }
  38315. return oldValue.LabelDist, nil
  38316. }
  38317. // AppendLabelDist adds ctd to the "label_dist" field.
  38318. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38319. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38320. }
  38321. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38322. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38323. if len(m.appendlabel_dist) == 0 {
  38324. return nil, false
  38325. }
  38326. return m.appendlabel_dist, true
  38327. }
  38328. // ResetLabelDist resets all changes to the "label_dist" field.
  38329. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  38330. m.label_dist = nil
  38331. m.appendlabel_dist = nil
  38332. }
  38333. // SetConsumeCoin sets the "consume_coin" field.
  38334. func (m *UsageStatisticHourMutation) SetConsumeCoin(f float64) {
  38335. m.consume_coin = &f
  38336. m.addconsume_coin = nil
  38337. }
  38338. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  38339. func (m *UsageStatisticHourMutation) ConsumeCoin() (r float64, exists bool) {
  38340. v := m.consume_coin
  38341. if v == nil {
  38342. return
  38343. }
  38344. return *v, true
  38345. }
  38346. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  38347. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38349. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  38350. if !m.op.Is(OpUpdateOne) {
  38351. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  38352. }
  38353. if m.id == nil || m.oldValue == nil {
  38354. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  38355. }
  38356. oldValue, err := m.oldValue(ctx)
  38357. if err != nil {
  38358. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  38359. }
  38360. return oldValue.ConsumeCoin, nil
  38361. }
  38362. // AddConsumeCoin adds f to the "consume_coin" field.
  38363. func (m *UsageStatisticHourMutation) AddConsumeCoin(f float64) {
  38364. if m.addconsume_coin != nil {
  38365. *m.addconsume_coin += f
  38366. } else {
  38367. m.addconsume_coin = &f
  38368. }
  38369. }
  38370. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  38371. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r float64, exists bool) {
  38372. v := m.addconsume_coin
  38373. if v == nil {
  38374. return
  38375. }
  38376. return *v, true
  38377. }
  38378. // ClearConsumeCoin clears the value of the "consume_coin" field.
  38379. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  38380. m.consume_coin = nil
  38381. m.addconsume_coin = nil
  38382. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  38383. }
  38384. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  38385. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  38386. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  38387. return ok
  38388. }
  38389. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  38390. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  38391. m.consume_coin = nil
  38392. m.addconsume_coin = nil
  38393. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  38394. }
  38395. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  38396. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  38397. m.predicates = append(m.predicates, ps...)
  38398. }
  38399. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  38400. // users can use type-assertion to append predicates that do not depend on any generated package.
  38401. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  38402. p := make([]predicate.UsageStatisticHour, len(ps))
  38403. for i := range ps {
  38404. p[i] = ps[i]
  38405. }
  38406. m.Where(p...)
  38407. }
  38408. // Op returns the operation name.
  38409. func (m *UsageStatisticHourMutation) Op() Op {
  38410. return m.op
  38411. }
  38412. // SetOp allows setting the mutation operation.
  38413. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  38414. m.op = op
  38415. }
  38416. // Type returns the node type of this mutation (UsageStatisticHour).
  38417. func (m *UsageStatisticHourMutation) Type() string {
  38418. return m.typ
  38419. }
  38420. // Fields returns all fields that were changed during this mutation. Note that in
  38421. // order to get all numeric fields that were incremented/decremented, call
  38422. // AddedFields().
  38423. func (m *UsageStatisticHourMutation) Fields() []string {
  38424. fields := make([]string, 0, 18)
  38425. if m.created_at != nil {
  38426. fields = append(fields, usagestatistichour.FieldCreatedAt)
  38427. }
  38428. if m.updated_at != nil {
  38429. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  38430. }
  38431. if m.status != nil {
  38432. fields = append(fields, usagestatistichour.FieldStatus)
  38433. }
  38434. if m.deleted_at != nil {
  38435. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38436. }
  38437. if m.addtime != nil {
  38438. fields = append(fields, usagestatistichour.FieldAddtime)
  38439. }
  38440. if m._type != nil {
  38441. fields = append(fields, usagestatistichour.FieldType)
  38442. }
  38443. if m.bot_id != nil {
  38444. fields = append(fields, usagestatistichour.FieldBotID)
  38445. }
  38446. if m.organization_id != nil {
  38447. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38448. }
  38449. if m.ai_response != nil {
  38450. fields = append(fields, usagestatistichour.FieldAiResponse)
  38451. }
  38452. if m.sop_run != nil {
  38453. fields = append(fields, usagestatistichour.FieldSopRun)
  38454. }
  38455. if m.total_friend != nil {
  38456. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38457. }
  38458. if m.total_group != nil {
  38459. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38460. }
  38461. if m.account_balance != nil {
  38462. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38463. }
  38464. if m.consume_token != nil {
  38465. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38466. }
  38467. if m.active_user != nil {
  38468. fields = append(fields, usagestatistichour.FieldActiveUser)
  38469. }
  38470. if m.new_user != nil {
  38471. fields = append(fields, usagestatistichour.FieldNewUser)
  38472. }
  38473. if m.label_dist != nil {
  38474. fields = append(fields, usagestatistichour.FieldLabelDist)
  38475. }
  38476. if m.consume_coin != nil {
  38477. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38478. }
  38479. return fields
  38480. }
  38481. // Field returns the value of a field with the given name. The second boolean
  38482. // return value indicates that this field was not set, or was not defined in the
  38483. // schema.
  38484. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  38485. switch name {
  38486. case usagestatistichour.FieldCreatedAt:
  38487. return m.CreatedAt()
  38488. case usagestatistichour.FieldUpdatedAt:
  38489. return m.UpdatedAt()
  38490. case usagestatistichour.FieldStatus:
  38491. return m.Status()
  38492. case usagestatistichour.FieldDeletedAt:
  38493. return m.DeletedAt()
  38494. case usagestatistichour.FieldAddtime:
  38495. return m.Addtime()
  38496. case usagestatistichour.FieldType:
  38497. return m.GetType()
  38498. case usagestatistichour.FieldBotID:
  38499. return m.BotID()
  38500. case usagestatistichour.FieldOrganizationID:
  38501. return m.OrganizationID()
  38502. case usagestatistichour.FieldAiResponse:
  38503. return m.AiResponse()
  38504. case usagestatistichour.FieldSopRun:
  38505. return m.SopRun()
  38506. case usagestatistichour.FieldTotalFriend:
  38507. return m.TotalFriend()
  38508. case usagestatistichour.FieldTotalGroup:
  38509. return m.TotalGroup()
  38510. case usagestatistichour.FieldAccountBalance:
  38511. return m.AccountBalance()
  38512. case usagestatistichour.FieldConsumeToken:
  38513. return m.ConsumeToken()
  38514. case usagestatistichour.FieldActiveUser:
  38515. return m.ActiveUser()
  38516. case usagestatistichour.FieldNewUser:
  38517. return m.NewUser()
  38518. case usagestatistichour.FieldLabelDist:
  38519. return m.LabelDist()
  38520. case usagestatistichour.FieldConsumeCoin:
  38521. return m.ConsumeCoin()
  38522. }
  38523. return nil, false
  38524. }
  38525. // OldField returns the old value of the field from the database. An error is
  38526. // returned if the mutation operation is not UpdateOne, or the query to the
  38527. // database failed.
  38528. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38529. switch name {
  38530. case usagestatistichour.FieldCreatedAt:
  38531. return m.OldCreatedAt(ctx)
  38532. case usagestatistichour.FieldUpdatedAt:
  38533. return m.OldUpdatedAt(ctx)
  38534. case usagestatistichour.FieldStatus:
  38535. return m.OldStatus(ctx)
  38536. case usagestatistichour.FieldDeletedAt:
  38537. return m.OldDeletedAt(ctx)
  38538. case usagestatistichour.FieldAddtime:
  38539. return m.OldAddtime(ctx)
  38540. case usagestatistichour.FieldType:
  38541. return m.OldType(ctx)
  38542. case usagestatistichour.FieldBotID:
  38543. return m.OldBotID(ctx)
  38544. case usagestatistichour.FieldOrganizationID:
  38545. return m.OldOrganizationID(ctx)
  38546. case usagestatistichour.FieldAiResponse:
  38547. return m.OldAiResponse(ctx)
  38548. case usagestatistichour.FieldSopRun:
  38549. return m.OldSopRun(ctx)
  38550. case usagestatistichour.FieldTotalFriend:
  38551. return m.OldTotalFriend(ctx)
  38552. case usagestatistichour.FieldTotalGroup:
  38553. return m.OldTotalGroup(ctx)
  38554. case usagestatistichour.FieldAccountBalance:
  38555. return m.OldAccountBalance(ctx)
  38556. case usagestatistichour.FieldConsumeToken:
  38557. return m.OldConsumeToken(ctx)
  38558. case usagestatistichour.FieldActiveUser:
  38559. return m.OldActiveUser(ctx)
  38560. case usagestatistichour.FieldNewUser:
  38561. return m.OldNewUser(ctx)
  38562. case usagestatistichour.FieldLabelDist:
  38563. return m.OldLabelDist(ctx)
  38564. case usagestatistichour.FieldConsumeCoin:
  38565. return m.OldConsumeCoin(ctx)
  38566. }
  38567. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38568. }
  38569. // SetField sets the value of a field with the given name. It returns an error if
  38570. // the field is not defined in the schema, or if the type mismatched the field
  38571. // type.
  38572. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  38573. switch name {
  38574. case usagestatistichour.FieldCreatedAt:
  38575. v, ok := value.(time.Time)
  38576. if !ok {
  38577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38578. }
  38579. m.SetCreatedAt(v)
  38580. return nil
  38581. case usagestatistichour.FieldUpdatedAt:
  38582. v, ok := value.(time.Time)
  38583. if !ok {
  38584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38585. }
  38586. m.SetUpdatedAt(v)
  38587. return nil
  38588. case usagestatistichour.FieldStatus:
  38589. v, ok := value.(uint8)
  38590. if !ok {
  38591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38592. }
  38593. m.SetStatus(v)
  38594. return nil
  38595. case usagestatistichour.FieldDeletedAt:
  38596. v, ok := value.(time.Time)
  38597. if !ok {
  38598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38599. }
  38600. m.SetDeletedAt(v)
  38601. return nil
  38602. case usagestatistichour.FieldAddtime:
  38603. v, ok := value.(uint64)
  38604. if !ok {
  38605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38606. }
  38607. m.SetAddtime(v)
  38608. return nil
  38609. case usagestatistichour.FieldType:
  38610. v, ok := value.(int)
  38611. if !ok {
  38612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38613. }
  38614. m.SetType(v)
  38615. return nil
  38616. case usagestatistichour.FieldBotID:
  38617. v, ok := value.(string)
  38618. if !ok {
  38619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38620. }
  38621. m.SetBotID(v)
  38622. return nil
  38623. case usagestatistichour.FieldOrganizationID:
  38624. v, ok := value.(uint64)
  38625. if !ok {
  38626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38627. }
  38628. m.SetOrganizationID(v)
  38629. return nil
  38630. case usagestatistichour.FieldAiResponse:
  38631. v, ok := value.(uint64)
  38632. if !ok {
  38633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38634. }
  38635. m.SetAiResponse(v)
  38636. return nil
  38637. case usagestatistichour.FieldSopRun:
  38638. v, ok := value.(uint64)
  38639. if !ok {
  38640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38641. }
  38642. m.SetSopRun(v)
  38643. return nil
  38644. case usagestatistichour.FieldTotalFriend:
  38645. v, ok := value.(uint64)
  38646. if !ok {
  38647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38648. }
  38649. m.SetTotalFriend(v)
  38650. return nil
  38651. case usagestatistichour.FieldTotalGroup:
  38652. v, ok := value.(uint64)
  38653. if !ok {
  38654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38655. }
  38656. m.SetTotalGroup(v)
  38657. return nil
  38658. case usagestatistichour.FieldAccountBalance:
  38659. v, ok := value.(uint64)
  38660. if !ok {
  38661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38662. }
  38663. m.SetAccountBalance(v)
  38664. return nil
  38665. case usagestatistichour.FieldConsumeToken:
  38666. v, ok := value.(uint64)
  38667. if !ok {
  38668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38669. }
  38670. m.SetConsumeToken(v)
  38671. return nil
  38672. case usagestatistichour.FieldActiveUser:
  38673. v, ok := value.(uint64)
  38674. if !ok {
  38675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38676. }
  38677. m.SetActiveUser(v)
  38678. return nil
  38679. case usagestatistichour.FieldNewUser:
  38680. v, ok := value.(int64)
  38681. if !ok {
  38682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38683. }
  38684. m.SetNewUser(v)
  38685. return nil
  38686. case usagestatistichour.FieldLabelDist:
  38687. v, ok := value.([]custom_types.LabelDist)
  38688. if !ok {
  38689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38690. }
  38691. m.SetLabelDist(v)
  38692. return nil
  38693. case usagestatistichour.FieldConsumeCoin:
  38694. v, ok := value.(float64)
  38695. if !ok {
  38696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38697. }
  38698. m.SetConsumeCoin(v)
  38699. return nil
  38700. }
  38701. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38702. }
  38703. // AddedFields returns all numeric fields that were incremented/decremented during
  38704. // this mutation.
  38705. func (m *UsageStatisticHourMutation) AddedFields() []string {
  38706. var fields []string
  38707. if m.addstatus != nil {
  38708. fields = append(fields, usagestatistichour.FieldStatus)
  38709. }
  38710. if m.addaddtime != nil {
  38711. fields = append(fields, usagestatistichour.FieldAddtime)
  38712. }
  38713. if m.add_type != nil {
  38714. fields = append(fields, usagestatistichour.FieldType)
  38715. }
  38716. if m.addorganization_id != nil {
  38717. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38718. }
  38719. if m.addai_response != nil {
  38720. fields = append(fields, usagestatistichour.FieldAiResponse)
  38721. }
  38722. if m.addsop_run != nil {
  38723. fields = append(fields, usagestatistichour.FieldSopRun)
  38724. }
  38725. if m.addtotal_friend != nil {
  38726. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38727. }
  38728. if m.addtotal_group != nil {
  38729. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38730. }
  38731. if m.addaccount_balance != nil {
  38732. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38733. }
  38734. if m.addconsume_token != nil {
  38735. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38736. }
  38737. if m.addactive_user != nil {
  38738. fields = append(fields, usagestatistichour.FieldActiveUser)
  38739. }
  38740. if m.addnew_user != nil {
  38741. fields = append(fields, usagestatistichour.FieldNewUser)
  38742. }
  38743. if m.addconsume_coin != nil {
  38744. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38745. }
  38746. return fields
  38747. }
  38748. // AddedField returns the numeric value that was incremented/decremented on a field
  38749. // with the given name. The second boolean return value indicates that this field
  38750. // was not set, or was not defined in the schema.
  38751. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  38752. switch name {
  38753. case usagestatistichour.FieldStatus:
  38754. return m.AddedStatus()
  38755. case usagestatistichour.FieldAddtime:
  38756. return m.AddedAddtime()
  38757. case usagestatistichour.FieldType:
  38758. return m.AddedType()
  38759. case usagestatistichour.FieldOrganizationID:
  38760. return m.AddedOrganizationID()
  38761. case usagestatistichour.FieldAiResponse:
  38762. return m.AddedAiResponse()
  38763. case usagestatistichour.FieldSopRun:
  38764. return m.AddedSopRun()
  38765. case usagestatistichour.FieldTotalFriend:
  38766. return m.AddedTotalFriend()
  38767. case usagestatistichour.FieldTotalGroup:
  38768. return m.AddedTotalGroup()
  38769. case usagestatistichour.FieldAccountBalance:
  38770. return m.AddedAccountBalance()
  38771. case usagestatistichour.FieldConsumeToken:
  38772. return m.AddedConsumeToken()
  38773. case usagestatistichour.FieldActiveUser:
  38774. return m.AddedActiveUser()
  38775. case usagestatistichour.FieldNewUser:
  38776. return m.AddedNewUser()
  38777. case usagestatistichour.FieldConsumeCoin:
  38778. return m.AddedConsumeCoin()
  38779. }
  38780. return nil, false
  38781. }
  38782. // AddField adds the value to the field with the given name. It returns an error if
  38783. // the field is not defined in the schema, or if the type mismatched the field
  38784. // type.
  38785. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  38786. switch name {
  38787. case usagestatistichour.FieldStatus:
  38788. v, ok := value.(int8)
  38789. if !ok {
  38790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38791. }
  38792. m.AddStatus(v)
  38793. return nil
  38794. case usagestatistichour.FieldAddtime:
  38795. v, ok := value.(int64)
  38796. if !ok {
  38797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38798. }
  38799. m.AddAddtime(v)
  38800. return nil
  38801. case usagestatistichour.FieldType:
  38802. v, ok := value.(int)
  38803. if !ok {
  38804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38805. }
  38806. m.AddType(v)
  38807. return nil
  38808. case usagestatistichour.FieldOrganizationID:
  38809. v, ok := value.(int64)
  38810. if !ok {
  38811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38812. }
  38813. m.AddOrganizationID(v)
  38814. return nil
  38815. case usagestatistichour.FieldAiResponse:
  38816. v, ok := value.(int64)
  38817. if !ok {
  38818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38819. }
  38820. m.AddAiResponse(v)
  38821. return nil
  38822. case usagestatistichour.FieldSopRun:
  38823. v, ok := value.(int64)
  38824. if !ok {
  38825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38826. }
  38827. m.AddSopRun(v)
  38828. return nil
  38829. case usagestatistichour.FieldTotalFriend:
  38830. v, ok := value.(int64)
  38831. if !ok {
  38832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38833. }
  38834. m.AddTotalFriend(v)
  38835. return nil
  38836. case usagestatistichour.FieldTotalGroup:
  38837. v, ok := value.(int64)
  38838. if !ok {
  38839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38840. }
  38841. m.AddTotalGroup(v)
  38842. return nil
  38843. case usagestatistichour.FieldAccountBalance:
  38844. v, ok := value.(int64)
  38845. if !ok {
  38846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38847. }
  38848. m.AddAccountBalance(v)
  38849. return nil
  38850. case usagestatistichour.FieldConsumeToken:
  38851. v, ok := value.(int64)
  38852. if !ok {
  38853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38854. }
  38855. m.AddConsumeToken(v)
  38856. return nil
  38857. case usagestatistichour.FieldActiveUser:
  38858. v, ok := value.(int64)
  38859. if !ok {
  38860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38861. }
  38862. m.AddActiveUser(v)
  38863. return nil
  38864. case usagestatistichour.FieldNewUser:
  38865. v, ok := value.(int64)
  38866. if !ok {
  38867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38868. }
  38869. m.AddNewUser(v)
  38870. return nil
  38871. case usagestatistichour.FieldConsumeCoin:
  38872. v, ok := value.(float64)
  38873. if !ok {
  38874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38875. }
  38876. m.AddConsumeCoin(v)
  38877. return nil
  38878. }
  38879. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  38880. }
  38881. // ClearedFields returns all nullable fields that were cleared during this
  38882. // mutation.
  38883. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  38884. var fields []string
  38885. if m.FieldCleared(usagestatistichour.FieldStatus) {
  38886. fields = append(fields, usagestatistichour.FieldStatus)
  38887. }
  38888. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  38889. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38890. }
  38891. if m.FieldCleared(usagestatistichour.FieldBotID) {
  38892. fields = append(fields, usagestatistichour.FieldBotID)
  38893. }
  38894. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  38895. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38896. }
  38897. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  38898. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38899. }
  38900. return fields
  38901. }
  38902. // FieldCleared returns a boolean indicating if a field with the given name was
  38903. // cleared in this mutation.
  38904. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  38905. _, ok := m.clearedFields[name]
  38906. return ok
  38907. }
  38908. // ClearField clears the value of the field with the given name. It returns an
  38909. // error if the field is not defined in the schema.
  38910. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  38911. switch name {
  38912. case usagestatistichour.FieldStatus:
  38913. m.ClearStatus()
  38914. return nil
  38915. case usagestatistichour.FieldDeletedAt:
  38916. m.ClearDeletedAt()
  38917. return nil
  38918. case usagestatistichour.FieldBotID:
  38919. m.ClearBotID()
  38920. return nil
  38921. case usagestatistichour.FieldOrganizationID:
  38922. m.ClearOrganizationID()
  38923. return nil
  38924. case usagestatistichour.FieldConsumeCoin:
  38925. m.ClearConsumeCoin()
  38926. return nil
  38927. }
  38928. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  38929. }
  38930. // ResetField resets all changes in the mutation for the field with the given name.
  38931. // It returns an error if the field is not defined in the schema.
  38932. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  38933. switch name {
  38934. case usagestatistichour.FieldCreatedAt:
  38935. m.ResetCreatedAt()
  38936. return nil
  38937. case usagestatistichour.FieldUpdatedAt:
  38938. m.ResetUpdatedAt()
  38939. return nil
  38940. case usagestatistichour.FieldStatus:
  38941. m.ResetStatus()
  38942. return nil
  38943. case usagestatistichour.FieldDeletedAt:
  38944. m.ResetDeletedAt()
  38945. return nil
  38946. case usagestatistichour.FieldAddtime:
  38947. m.ResetAddtime()
  38948. return nil
  38949. case usagestatistichour.FieldType:
  38950. m.ResetType()
  38951. return nil
  38952. case usagestatistichour.FieldBotID:
  38953. m.ResetBotID()
  38954. return nil
  38955. case usagestatistichour.FieldOrganizationID:
  38956. m.ResetOrganizationID()
  38957. return nil
  38958. case usagestatistichour.FieldAiResponse:
  38959. m.ResetAiResponse()
  38960. return nil
  38961. case usagestatistichour.FieldSopRun:
  38962. m.ResetSopRun()
  38963. return nil
  38964. case usagestatistichour.FieldTotalFriend:
  38965. m.ResetTotalFriend()
  38966. return nil
  38967. case usagestatistichour.FieldTotalGroup:
  38968. m.ResetTotalGroup()
  38969. return nil
  38970. case usagestatistichour.FieldAccountBalance:
  38971. m.ResetAccountBalance()
  38972. return nil
  38973. case usagestatistichour.FieldConsumeToken:
  38974. m.ResetConsumeToken()
  38975. return nil
  38976. case usagestatistichour.FieldActiveUser:
  38977. m.ResetActiveUser()
  38978. return nil
  38979. case usagestatistichour.FieldNewUser:
  38980. m.ResetNewUser()
  38981. return nil
  38982. case usagestatistichour.FieldLabelDist:
  38983. m.ResetLabelDist()
  38984. return nil
  38985. case usagestatistichour.FieldConsumeCoin:
  38986. m.ResetConsumeCoin()
  38987. return nil
  38988. }
  38989. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38990. }
  38991. // AddedEdges returns all edge names that were set/added in this mutation.
  38992. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  38993. edges := make([]string, 0, 0)
  38994. return edges
  38995. }
  38996. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38997. // name in this mutation.
  38998. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  38999. return nil
  39000. }
  39001. // RemovedEdges returns all edge names that were removed in this mutation.
  39002. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  39003. edges := make([]string, 0, 0)
  39004. return edges
  39005. }
  39006. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39007. // the given name in this mutation.
  39008. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  39009. return nil
  39010. }
  39011. // ClearedEdges returns all edge names that were cleared in this mutation.
  39012. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  39013. edges := make([]string, 0, 0)
  39014. return edges
  39015. }
  39016. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39017. // was cleared in this mutation.
  39018. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  39019. return false
  39020. }
  39021. // ClearEdge clears the value of the edge with the given name. It returns an error
  39022. // if that edge is not defined in the schema.
  39023. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  39024. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  39025. }
  39026. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39027. // It returns an error if the edge is not defined in the schema.
  39028. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  39029. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  39030. }
  39031. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  39032. type UsageStatisticMonthMutation struct {
  39033. config
  39034. op Op
  39035. typ string
  39036. id *uint64
  39037. created_at *time.Time
  39038. updated_at *time.Time
  39039. status *uint8
  39040. addstatus *int8
  39041. deleted_at *time.Time
  39042. addtime *uint64
  39043. addaddtime *int64
  39044. _type *int
  39045. add_type *int
  39046. bot_id *string
  39047. organization_id *uint64
  39048. addorganization_id *int64
  39049. ai_response *uint64
  39050. addai_response *int64
  39051. sop_run *uint64
  39052. addsop_run *int64
  39053. total_friend *uint64
  39054. addtotal_friend *int64
  39055. total_group *uint64
  39056. addtotal_group *int64
  39057. account_balance *uint64
  39058. addaccount_balance *int64
  39059. consume_token *uint64
  39060. addconsume_token *int64
  39061. active_user *uint64
  39062. addactive_user *int64
  39063. new_user *int64
  39064. addnew_user *int64
  39065. label_dist *[]custom_types.LabelDist
  39066. appendlabel_dist []custom_types.LabelDist
  39067. consume_coin *float64
  39068. addconsume_coin *float64
  39069. clearedFields map[string]struct{}
  39070. done bool
  39071. oldValue func(context.Context) (*UsageStatisticMonth, error)
  39072. predicates []predicate.UsageStatisticMonth
  39073. }
  39074. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  39075. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  39076. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  39077. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  39078. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  39079. m := &UsageStatisticMonthMutation{
  39080. config: c,
  39081. op: op,
  39082. typ: TypeUsageStatisticMonth,
  39083. clearedFields: make(map[string]struct{}),
  39084. }
  39085. for _, opt := range opts {
  39086. opt(m)
  39087. }
  39088. return m
  39089. }
  39090. // withUsageStatisticMonthID sets the ID field of the mutation.
  39091. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  39092. return func(m *UsageStatisticMonthMutation) {
  39093. var (
  39094. err error
  39095. once sync.Once
  39096. value *UsageStatisticMonth
  39097. )
  39098. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  39099. once.Do(func() {
  39100. if m.done {
  39101. err = errors.New("querying old values post mutation is not allowed")
  39102. } else {
  39103. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  39104. }
  39105. })
  39106. return value, err
  39107. }
  39108. m.id = &id
  39109. }
  39110. }
  39111. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  39112. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  39113. return func(m *UsageStatisticMonthMutation) {
  39114. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  39115. return node, nil
  39116. }
  39117. m.id = &node.ID
  39118. }
  39119. }
  39120. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39121. // executed in a transaction (ent.Tx), a transactional client is returned.
  39122. func (m UsageStatisticMonthMutation) Client() *Client {
  39123. client := &Client{config: m.config}
  39124. client.init()
  39125. return client
  39126. }
  39127. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39128. // it returns an error otherwise.
  39129. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  39130. if _, ok := m.driver.(*txDriver); !ok {
  39131. return nil, errors.New("ent: mutation is not running in a transaction")
  39132. }
  39133. tx := &Tx{config: m.config}
  39134. tx.init()
  39135. return tx, nil
  39136. }
  39137. // SetID sets the value of the id field. Note that this
  39138. // operation is only accepted on creation of UsageStatisticMonth entities.
  39139. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  39140. m.id = &id
  39141. }
  39142. // ID returns the ID value in the mutation. Note that the ID is only available
  39143. // if it was provided to the builder or after it was returned from the database.
  39144. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  39145. if m.id == nil {
  39146. return
  39147. }
  39148. return *m.id, true
  39149. }
  39150. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39151. // That means, if the mutation is applied within a transaction with an isolation level such
  39152. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39153. // or updated by the mutation.
  39154. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  39155. switch {
  39156. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39157. id, exists := m.ID()
  39158. if exists {
  39159. return []uint64{id}, nil
  39160. }
  39161. fallthrough
  39162. case m.op.Is(OpUpdate | OpDelete):
  39163. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  39164. default:
  39165. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39166. }
  39167. }
  39168. // SetCreatedAt sets the "created_at" field.
  39169. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  39170. m.created_at = &t
  39171. }
  39172. // CreatedAt returns the value of the "created_at" field in the mutation.
  39173. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  39174. v := m.created_at
  39175. if v == nil {
  39176. return
  39177. }
  39178. return *v, true
  39179. }
  39180. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  39181. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39183. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39184. if !m.op.Is(OpUpdateOne) {
  39185. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39186. }
  39187. if m.id == nil || m.oldValue == nil {
  39188. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39189. }
  39190. oldValue, err := m.oldValue(ctx)
  39191. if err != nil {
  39192. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39193. }
  39194. return oldValue.CreatedAt, nil
  39195. }
  39196. // ResetCreatedAt resets all changes to the "created_at" field.
  39197. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  39198. m.created_at = nil
  39199. }
  39200. // SetUpdatedAt sets the "updated_at" field.
  39201. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  39202. m.updated_at = &t
  39203. }
  39204. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39205. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  39206. v := m.updated_at
  39207. if v == nil {
  39208. return
  39209. }
  39210. return *v, true
  39211. }
  39212. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  39213. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39215. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39216. if !m.op.Is(OpUpdateOne) {
  39217. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39218. }
  39219. if m.id == nil || m.oldValue == nil {
  39220. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39221. }
  39222. oldValue, err := m.oldValue(ctx)
  39223. if err != nil {
  39224. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39225. }
  39226. return oldValue.UpdatedAt, nil
  39227. }
  39228. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39229. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  39230. m.updated_at = nil
  39231. }
  39232. // SetStatus sets the "status" field.
  39233. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  39234. m.status = &u
  39235. m.addstatus = nil
  39236. }
  39237. // Status returns the value of the "status" field in the mutation.
  39238. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  39239. v := m.status
  39240. if v == nil {
  39241. return
  39242. }
  39243. return *v, true
  39244. }
  39245. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  39246. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39248. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39249. if !m.op.Is(OpUpdateOne) {
  39250. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39251. }
  39252. if m.id == nil || m.oldValue == nil {
  39253. return v, errors.New("OldStatus requires an ID field in the mutation")
  39254. }
  39255. oldValue, err := m.oldValue(ctx)
  39256. if err != nil {
  39257. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39258. }
  39259. return oldValue.Status, nil
  39260. }
  39261. // AddStatus adds u to the "status" field.
  39262. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  39263. if m.addstatus != nil {
  39264. *m.addstatus += u
  39265. } else {
  39266. m.addstatus = &u
  39267. }
  39268. }
  39269. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39270. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  39271. v := m.addstatus
  39272. if v == nil {
  39273. return
  39274. }
  39275. return *v, true
  39276. }
  39277. // ClearStatus clears the value of the "status" field.
  39278. func (m *UsageStatisticMonthMutation) ClearStatus() {
  39279. m.status = nil
  39280. m.addstatus = nil
  39281. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  39282. }
  39283. // StatusCleared returns if the "status" field was cleared in this mutation.
  39284. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  39285. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  39286. return ok
  39287. }
  39288. // ResetStatus resets all changes to the "status" field.
  39289. func (m *UsageStatisticMonthMutation) ResetStatus() {
  39290. m.status = nil
  39291. m.addstatus = nil
  39292. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  39293. }
  39294. // SetDeletedAt sets the "deleted_at" field.
  39295. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  39296. m.deleted_at = &t
  39297. }
  39298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39299. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  39300. v := m.deleted_at
  39301. if v == nil {
  39302. return
  39303. }
  39304. return *v, true
  39305. }
  39306. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  39307. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39309. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39310. if !m.op.Is(OpUpdateOne) {
  39311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39312. }
  39313. if m.id == nil || m.oldValue == nil {
  39314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39315. }
  39316. oldValue, err := m.oldValue(ctx)
  39317. if err != nil {
  39318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39319. }
  39320. return oldValue.DeletedAt, nil
  39321. }
  39322. // ClearDeletedAt clears the value of the "deleted_at" field.
  39323. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  39324. m.deleted_at = nil
  39325. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  39326. }
  39327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39328. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  39329. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  39330. return ok
  39331. }
  39332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39333. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  39334. m.deleted_at = nil
  39335. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  39336. }
  39337. // SetAddtime sets the "addtime" field.
  39338. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  39339. m.addtime = &u
  39340. m.addaddtime = nil
  39341. }
  39342. // Addtime returns the value of the "addtime" field in the mutation.
  39343. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  39344. v := m.addtime
  39345. if v == nil {
  39346. return
  39347. }
  39348. return *v, true
  39349. }
  39350. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  39351. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39353. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  39354. if !m.op.Is(OpUpdateOne) {
  39355. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  39356. }
  39357. if m.id == nil || m.oldValue == nil {
  39358. return v, errors.New("OldAddtime requires an ID field in the mutation")
  39359. }
  39360. oldValue, err := m.oldValue(ctx)
  39361. if err != nil {
  39362. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  39363. }
  39364. return oldValue.Addtime, nil
  39365. }
  39366. // AddAddtime adds u to the "addtime" field.
  39367. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  39368. if m.addaddtime != nil {
  39369. *m.addaddtime += u
  39370. } else {
  39371. m.addaddtime = &u
  39372. }
  39373. }
  39374. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  39375. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  39376. v := m.addaddtime
  39377. if v == nil {
  39378. return
  39379. }
  39380. return *v, true
  39381. }
  39382. // ResetAddtime resets all changes to the "addtime" field.
  39383. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  39384. m.addtime = nil
  39385. m.addaddtime = nil
  39386. }
  39387. // SetType sets the "type" field.
  39388. func (m *UsageStatisticMonthMutation) SetType(i int) {
  39389. m._type = &i
  39390. m.add_type = nil
  39391. }
  39392. // GetType returns the value of the "type" field in the mutation.
  39393. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  39394. v := m._type
  39395. if v == nil {
  39396. return
  39397. }
  39398. return *v, true
  39399. }
  39400. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  39401. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  39404. if !m.op.Is(OpUpdateOne) {
  39405. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39406. }
  39407. if m.id == nil || m.oldValue == nil {
  39408. return v, errors.New("OldType 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 OldType: %w", err)
  39413. }
  39414. return oldValue.Type, nil
  39415. }
  39416. // AddType adds i to the "type" field.
  39417. func (m *UsageStatisticMonthMutation) AddType(i int) {
  39418. if m.add_type != nil {
  39419. *m.add_type += i
  39420. } else {
  39421. m.add_type = &i
  39422. }
  39423. }
  39424. // AddedType returns the value that was added to the "type" field in this mutation.
  39425. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  39426. v := m.add_type
  39427. if v == nil {
  39428. return
  39429. }
  39430. return *v, true
  39431. }
  39432. // ResetType resets all changes to the "type" field.
  39433. func (m *UsageStatisticMonthMutation) ResetType() {
  39434. m._type = nil
  39435. m.add_type = nil
  39436. }
  39437. // SetBotID sets the "bot_id" field.
  39438. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  39439. m.bot_id = &s
  39440. }
  39441. // BotID returns the value of the "bot_id" field in the mutation.
  39442. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  39443. v := m.bot_id
  39444. if v == nil {
  39445. return
  39446. }
  39447. return *v, true
  39448. }
  39449. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  39450. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39452. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  39453. if !m.op.Is(OpUpdateOne) {
  39454. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39455. }
  39456. if m.id == nil || m.oldValue == nil {
  39457. return v, errors.New("OldBotID requires an ID field in the mutation")
  39458. }
  39459. oldValue, err := m.oldValue(ctx)
  39460. if err != nil {
  39461. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39462. }
  39463. return oldValue.BotID, nil
  39464. }
  39465. // ClearBotID clears the value of the "bot_id" field.
  39466. func (m *UsageStatisticMonthMutation) ClearBotID() {
  39467. m.bot_id = nil
  39468. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  39469. }
  39470. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  39471. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  39472. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  39473. return ok
  39474. }
  39475. // ResetBotID resets all changes to the "bot_id" field.
  39476. func (m *UsageStatisticMonthMutation) ResetBotID() {
  39477. m.bot_id = nil
  39478. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  39479. }
  39480. // SetOrganizationID sets the "organization_id" field.
  39481. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  39482. m.organization_id = &u
  39483. m.addorganization_id = nil
  39484. }
  39485. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39486. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  39487. v := m.organization_id
  39488. if v == nil {
  39489. return
  39490. }
  39491. return *v, true
  39492. }
  39493. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  39494. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39496. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39497. if !m.op.Is(OpUpdateOne) {
  39498. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39499. }
  39500. if m.id == nil || m.oldValue == nil {
  39501. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39502. }
  39503. oldValue, err := m.oldValue(ctx)
  39504. if err != nil {
  39505. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39506. }
  39507. return oldValue.OrganizationID, nil
  39508. }
  39509. // AddOrganizationID adds u to the "organization_id" field.
  39510. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  39511. if m.addorganization_id != nil {
  39512. *m.addorganization_id += u
  39513. } else {
  39514. m.addorganization_id = &u
  39515. }
  39516. }
  39517. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39518. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  39519. v := m.addorganization_id
  39520. if v == nil {
  39521. return
  39522. }
  39523. return *v, true
  39524. }
  39525. // ClearOrganizationID clears the value of the "organization_id" field.
  39526. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  39527. m.organization_id = nil
  39528. m.addorganization_id = nil
  39529. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  39530. }
  39531. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39532. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  39533. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  39534. return ok
  39535. }
  39536. // ResetOrganizationID resets all changes to the "organization_id" field.
  39537. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  39538. m.organization_id = nil
  39539. m.addorganization_id = nil
  39540. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  39541. }
  39542. // SetAiResponse sets the "ai_response" field.
  39543. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  39544. m.ai_response = &u
  39545. m.addai_response = nil
  39546. }
  39547. // AiResponse returns the value of the "ai_response" field in the mutation.
  39548. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  39549. v := m.ai_response
  39550. if v == nil {
  39551. return
  39552. }
  39553. return *v, true
  39554. }
  39555. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  39556. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39558. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  39559. if !m.op.Is(OpUpdateOne) {
  39560. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  39561. }
  39562. if m.id == nil || m.oldValue == nil {
  39563. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  39564. }
  39565. oldValue, err := m.oldValue(ctx)
  39566. if err != nil {
  39567. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  39568. }
  39569. return oldValue.AiResponse, nil
  39570. }
  39571. // AddAiResponse adds u to the "ai_response" field.
  39572. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  39573. if m.addai_response != nil {
  39574. *m.addai_response += u
  39575. } else {
  39576. m.addai_response = &u
  39577. }
  39578. }
  39579. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  39580. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  39581. v := m.addai_response
  39582. if v == nil {
  39583. return
  39584. }
  39585. return *v, true
  39586. }
  39587. // ResetAiResponse resets all changes to the "ai_response" field.
  39588. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  39589. m.ai_response = nil
  39590. m.addai_response = nil
  39591. }
  39592. // SetSopRun sets the "sop_run" field.
  39593. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  39594. m.sop_run = &u
  39595. m.addsop_run = nil
  39596. }
  39597. // SopRun returns the value of the "sop_run" field in the mutation.
  39598. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  39599. v := m.sop_run
  39600. if v == nil {
  39601. return
  39602. }
  39603. return *v, true
  39604. }
  39605. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  39606. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39608. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  39609. if !m.op.Is(OpUpdateOne) {
  39610. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  39611. }
  39612. if m.id == nil || m.oldValue == nil {
  39613. return v, errors.New("OldSopRun requires an ID field in the mutation")
  39614. }
  39615. oldValue, err := m.oldValue(ctx)
  39616. if err != nil {
  39617. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  39618. }
  39619. return oldValue.SopRun, nil
  39620. }
  39621. // AddSopRun adds u to the "sop_run" field.
  39622. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  39623. if m.addsop_run != nil {
  39624. *m.addsop_run += u
  39625. } else {
  39626. m.addsop_run = &u
  39627. }
  39628. }
  39629. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  39630. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  39631. v := m.addsop_run
  39632. if v == nil {
  39633. return
  39634. }
  39635. return *v, true
  39636. }
  39637. // ResetSopRun resets all changes to the "sop_run" field.
  39638. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  39639. m.sop_run = nil
  39640. m.addsop_run = nil
  39641. }
  39642. // SetTotalFriend sets the "total_friend" field.
  39643. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  39644. m.total_friend = &u
  39645. m.addtotal_friend = nil
  39646. }
  39647. // TotalFriend returns the value of the "total_friend" field in the mutation.
  39648. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  39649. v := m.total_friend
  39650. if v == nil {
  39651. return
  39652. }
  39653. return *v, true
  39654. }
  39655. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  39656. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39658. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  39659. if !m.op.Is(OpUpdateOne) {
  39660. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  39661. }
  39662. if m.id == nil || m.oldValue == nil {
  39663. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  39664. }
  39665. oldValue, err := m.oldValue(ctx)
  39666. if err != nil {
  39667. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  39668. }
  39669. return oldValue.TotalFriend, nil
  39670. }
  39671. // AddTotalFriend adds u to the "total_friend" field.
  39672. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  39673. if m.addtotal_friend != nil {
  39674. *m.addtotal_friend += u
  39675. } else {
  39676. m.addtotal_friend = &u
  39677. }
  39678. }
  39679. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  39680. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  39681. v := m.addtotal_friend
  39682. if v == nil {
  39683. return
  39684. }
  39685. return *v, true
  39686. }
  39687. // ResetTotalFriend resets all changes to the "total_friend" field.
  39688. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  39689. m.total_friend = nil
  39690. m.addtotal_friend = nil
  39691. }
  39692. // SetTotalGroup sets the "total_group" field.
  39693. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  39694. m.total_group = &u
  39695. m.addtotal_group = nil
  39696. }
  39697. // TotalGroup returns the value of the "total_group" field in the mutation.
  39698. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  39699. v := m.total_group
  39700. if v == nil {
  39701. return
  39702. }
  39703. return *v, true
  39704. }
  39705. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  39706. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39708. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  39709. if !m.op.Is(OpUpdateOne) {
  39710. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  39711. }
  39712. if m.id == nil || m.oldValue == nil {
  39713. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  39714. }
  39715. oldValue, err := m.oldValue(ctx)
  39716. if err != nil {
  39717. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  39718. }
  39719. return oldValue.TotalGroup, nil
  39720. }
  39721. // AddTotalGroup adds u to the "total_group" field.
  39722. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  39723. if m.addtotal_group != nil {
  39724. *m.addtotal_group += u
  39725. } else {
  39726. m.addtotal_group = &u
  39727. }
  39728. }
  39729. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  39730. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  39731. v := m.addtotal_group
  39732. if v == nil {
  39733. return
  39734. }
  39735. return *v, true
  39736. }
  39737. // ResetTotalGroup resets all changes to the "total_group" field.
  39738. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  39739. m.total_group = nil
  39740. m.addtotal_group = nil
  39741. }
  39742. // SetAccountBalance sets the "account_balance" field.
  39743. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  39744. m.account_balance = &u
  39745. m.addaccount_balance = nil
  39746. }
  39747. // AccountBalance returns the value of the "account_balance" field in the mutation.
  39748. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  39749. v := m.account_balance
  39750. if v == nil {
  39751. return
  39752. }
  39753. return *v, true
  39754. }
  39755. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  39756. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39758. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  39759. if !m.op.Is(OpUpdateOne) {
  39760. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  39761. }
  39762. if m.id == nil || m.oldValue == nil {
  39763. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  39764. }
  39765. oldValue, err := m.oldValue(ctx)
  39766. if err != nil {
  39767. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  39768. }
  39769. return oldValue.AccountBalance, nil
  39770. }
  39771. // AddAccountBalance adds u to the "account_balance" field.
  39772. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  39773. if m.addaccount_balance != nil {
  39774. *m.addaccount_balance += u
  39775. } else {
  39776. m.addaccount_balance = &u
  39777. }
  39778. }
  39779. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  39780. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  39781. v := m.addaccount_balance
  39782. if v == nil {
  39783. return
  39784. }
  39785. return *v, true
  39786. }
  39787. // ResetAccountBalance resets all changes to the "account_balance" field.
  39788. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  39789. m.account_balance = nil
  39790. m.addaccount_balance = nil
  39791. }
  39792. // SetConsumeToken sets the "consume_token" field.
  39793. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  39794. m.consume_token = &u
  39795. m.addconsume_token = nil
  39796. }
  39797. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  39798. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  39799. v := m.consume_token
  39800. if v == nil {
  39801. return
  39802. }
  39803. return *v, true
  39804. }
  39805. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  39806. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39808. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  39809. if !m.op.Is(OpUpdateOne) {
  39810. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  39811. }
  39812. if m.id == nil || m.oldValue == nil {
  39813. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  39814. }
  39815. oldValue, err := m.oldValue(ctx)
  39816. if err != nil {
  39817. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  39818. }
  39819. return oldValue.ConsumeToken, nil
  39820. }
  39821. // AddConsumeToken adds u to the "consume_token" field.
  39822. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  39823. if m.addconsume_token != nil {
  39824. *m.addconsume_token += u
  39825. } else {
  39826. m.addconsume_token = &u
  39827. }
  39828. }
  39829. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  39830. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  39831. v := m.addconsume_token
  39832. if v == nil {
  39833. return
  39834. }
  39835. return *v, true
  39836. }
  39837. // ResetConsumeToken resets all changes to the "consume_token" field.
  39838. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  39839. m.consume_token = nil
  39840. m.addconsume_token = nil
  39841. }
  39842. // SetActiveUser sets the "active_user" field.
  39843. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  39844. m.active_user = &u
  39845. m.addactive_user = nil
  39846. }
  39847. // ActiveUser returns the value of the "active_user" field in the mutation.
  39848. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  39849. v := m.active_user
  39850. if v == nil {
  39851. return
  39852. }
  39853. return *v, true
  39854. }
  39855. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  39856. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39858. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  39859. if !m.op.Is(OpUpdateOne) {
  39860. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  39861. }
  39862. if m.id == nil || m.oldValue == nil {
  39863. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  39864. }
  39865. oldValue, err := m.oldValue(ctx)
  39866. if err != nil {
  39867. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  39868. }
  39869. return oldValue.ActiveUser, nil
  39870. }
  39871. // AddActiveUser adds u to the "active_user" field.
  39872. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  39873. if m.addactive_user != nil {
  39874. *m.addactive_user += u
  39875. } else {
  39876. m.addactive_user = &u
  39877. }
  39878. }
  39879. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  39880. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  39881. v := m.addactive_user
  39882. if v == nil {
  39883. return
  39884. }
  39885. return *v, true
  39886. }
  39887. // ResetActiveUser resets all changes to the "active_user" field.
  39888. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  39889. m.active_user = nil
  39890. m.addactive_user = nil
  39891. }
  39892. // SetNewUser sets the "new_user" field.
  39893. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  39894. m.new_user = &i
  39895. m.addnew_user = nil
  39896. }
  39897. // NewUser returns the value of the "new_user" field in the mutation.
  39898. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  39899. v := m.new_user
  39900. if v == nil {
  39901. return
  39902. }
  39903. return *v, true
  39904. }
  39905. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  39906. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39908. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  39909. if !m.op.Is(OpUpdateOne) {
  39910. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  39911. }
  39912. if m.id == nil || m.oldValue == nil {
  39913. return v, errors.New("OldNewUser requires an ID field in the mutation")
  39914. }
  39915. oldValue, err := m.oldValue(ctx)
  39916. if err != nil {
  39917. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  39918. }
  39919. return oldValue.NewUser, nil
  39920. }
  39921. // AddNewUser adds i to the "new_user" field.
  39922. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  39923. if m.addnew_user != nil {
  39924. *m.addnew_user += i
  39925. } else {
  39926. m.addnew_user = &i
  39927. }
  39928. }
  39929. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  39930. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  39931. v := m.addnew_user
  39932. if v == nil {
  39933. return
  39934. }
  39935. return *v, true
  39936. }
  39937. // ResetNewUser resets all changes to the "new_user" field.
  39938. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  39939. m.new_user = nil
  39940. m.addnew_user = nil
  39941. }
  39942. // SetLabelDist sets the "label_dist" field.
  39943. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  39944. m.label_dist = &ctd
  39945. m.appendlabel_dist = nil
  39946. }
  39947. // LabelDist returns the value of the "label_dist" field in the mutation.
  39948. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  39949. v := m.label_dist
  39950. if v == nil {
  39951. return
  39952. }
  39953. return *v, true
  39954. }
  39955. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  39956. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39958. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  39959. if !m.op.Is(OpUpdateOne) {
  39960. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  39961. }
  39962. if m.id == nil || m.oldValue == nil {
  39963. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  39964. }
  39965. oldValue, err := m.oldValue(ctx)
  39966. if err != nil {
  39967. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  39968. }
  39969. return oldValue.LabelDist, nil
  39970. }
  39971. // AppendLabelDist adds ctd to the "label_dist" field.
  39972. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  39973. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  39974. }
  39975. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  39976. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  39977. if len(m.appendlabel_dist) == 0 {
  39978. return nil, false
  39979. }
  39980. return m.appendlabel_dist, true
  39981. }
  39982. // ResetLabelDist resets all changes to the "label_dist" field.
  39983. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  39984. m.label_dist = nil
  39985. m.appendlabel_dist = nil
  39986. }
  39987. // SetConsumeCoin sets the "consume_coin" field.
  39988. func (m *UsageStatisticMonthMutation) SetConsumeCoin(f float64) {
  39989. m.consume_coin = &f
  39990. m.addconsume_coin = nil
  39991. }
  39992. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  39993. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r float64, exists bool) {
  39994. v := m.consume_coin
  39995. if v == nil {
  39996. return
  39997. }
  39998. return *v, true
  39999. }
  40000. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  40001. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40003. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  40004. if !m.op.Is(OpUpdateOne) {
  40005. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  40006. }
  40007. if m.id == nil || m.oldValue == nil {
  40008. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  40009. }
  40010. oldValue, err := m.oldValue(ctx)
  40011. if err != nil {
  40012. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  40013. }
  40014. return oldValue.ConsumeCoin, nil
  40015. }
  40016. // AddConsumeCoin adds f to the "consume_coin" field.
  40017. func (m *UsageStatisticMonthMutation) AddConsumeCoin(f float64) {
  40018. if m.addconsume_coin != nil {
  40019. *m.addconsume_coin += f
  40020. } else {
  40021. m.addconsume_coin = &f
  40022. }
  40023. }
  40024. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  40025. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r float64, exists bool) {
  40026. v := m.addconsume_coin
  40027. if v == nil {
  40028. return
  40029. }
  40030. return *v, true
  40031. }
  40032. // ClearConsumeCoin clears the value of the "consume_coin" field.
  40033. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  40034. m.consume_coin = nil
  40035. m.addconsume_coin = nil
  40036. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  40037. }
  40038. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  40039. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  40040. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  40041. return ok
  40042. }
  40043. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  40044. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  40045. m.consume_coin = nil
  40046. m.addconsume_coin = nil
  40047. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  40048. }
  40049. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  40050. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  40051. m.predicates = append(m.predicates, ps...)
  40052. }
  40053. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  40054. // users can use type-assertion to append predicates that do not depend on any generated package.
  40055. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  40056. p := make([]predicate.UsageStatisticMonth, len(ps))
  40057. for i := range ps {
  40058. p[i] = ps[i]
  40059. }
  40060. m.Where(p...)
  40061. }
  40062. // Op returns the operation name.
  40063. func (m *UsageStatisticMonthMutation) Op() Op {
  40064. return m.op
  40065. }
  40066. // SetOp allows setting the mutation operation.
  40067. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  40068. m.op = op
  40069. }
  40070. // Type returns the node type of this mutation (UsageStatisticMonth).
  40071. func (m *UsageStatisticMonthMutation) Type() string {
  40072. return m.typ
  40073. }
  40074. // Fields returns all fields that were changed during this mutation. Note that in
  40075. // order to get all numeric fields that were incremented/decremented, call
  40076. // AddedFields().
  40077. func (m *UsageStatisticMonthMutation) Fields() []string {
  40078. fields := make([]string, 0, 18)
  40079. if m.created_at != nil {
  40080. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  40081. }
  40082. if m.updated_at != nil {
  40083. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  40084. }
  40085. if m.status != nil {
  40086. fields = append(fields, usagestatisticmonth.FieldStatus)
  40087. }
  40088. if m.deleted_at != nil {
  40089. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40090. }
  40091. if m.addtime != nil {
  40092. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40093. }
  40094. if m._type != nil {
  40095. fields = append(fields, usagestatisticmonth.FieldType)
  40096. }
  40097. if m.bot_id != nil {
  40098. fields = append(fields, usagestatisticmonth.FieldBotID)
  40099. }
  40100. if m.organization_id != nil {
  40101. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40102. }
  40103. if m.ai_response != nil {
  40104. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40105. }
  40106. if m.sop_run != nil {
  40107. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40108. }
  40109. if m.total_friend != nil {
  40110. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40111. }
  40112. if m.total_group != nil {
  40113. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40114. }
  40115. if m.account_balance != nil {
  40116. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40117. }
  40118. if m.consume_token != nil {
  40119. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40120. }
  40121. if m.active_user != nil {
  40122. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40123. }
  40124. if m.new_user != nil {
  40125. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40126. }
  40127. if m.label_dist != nil {
  40128. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  40129. }
  40130. if m.consume_coin != nil {
  40131. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40132. }
  40133. return fields
  40134. }
  40135. // Field returns the value of a field with the given name. The second boolean
  40136. // return value indicates that this field was not set, or was not defined in the
  40137. // schema.
  40138. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  40139. switch name {
  40140. case usagestatisticmonth.FieldCreatedAt:
  40141. return m.CreatedAt()
  40142. case usagestatisticmonth.FieldUpdatedAt:
  40143. return m.UpdatedAt()
  40144. case usagestatisticmonth.FieldStatus:
  40145. return m.Status()
  40146. case usagestatisticmonth.FieldDeletedAt:
  40147. return m.DeletedAt()
  40148. case usagestatisticmonth.FieldAddtime:
  40149. return m.Addtime()
  40150. case usagestatisticmonth.FieldType:
  40151. return m.GetType()
  40152. case usagestatisticmonth.FieldBotID:
  40153. return m.BotID()
  40154. case usagestatisticmonth.FieldOrganizationID:
  40155. return m.OrganizationID()
  40156. case usagestatisticmonth.FieldAiResponse:
  40157. return m.AiResponse()
  40158. case usagestatisticmonth.FieldSopRun:
  40159. return m.SopRun()
  40160. case usagestatisticmonth.FieldTotalFriend:
  40161. return m.TotalFriend()
  40162. case usagestatisticmonth.FieldTotalGroup:
  40163. return m.TotalGroup()
  40164. case usagestatisticmonth.FieldAccountBalance:
  40165. return m.AccountBalance()
  40166. case usagestatisticmonth.FieldConsumeToken:
  40167. return m.ConsumeToken()
  40168. case usagestatisticmonth.FieldActiveUser:
  40169. return m.ActiveUser()
  40170. case usagestatisticmonth.FieldNewUser:
  40171. return m.NewUser()
  40172. case usagestatisticmonth.FieldLabelDist:
  40173. return m.LabelDist()
  40174. case usagestatisticmonth.FieldConsumeCoin:
  40175. return m.ConsumeCoin()
  40176. }
  40177. return nil, false
  40178. }
  40179. // OldField returns the old value of the field from the database. An error is
  40180. // returned if the mutation operation is not UpdateOne, or the query to the
  40181. // database failed.
  40182. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40183. switch name {
  40184. case usagestatisticmonth.FieldCreatedAt:
  40185. return m.OldCreatedAt(ctx)
  40186. case usagestatisticmonth.FieldUpdatedAt:
  40187. return m.OldUpdatedAt(ctx)
  40188. case usagestatisticmonth.FieldStatus:
  40189. return m.OldStatus(ctx)
  40190. case usagestatisticmonth.FieldDeletedAt:
  40191. return m.OldDeletedAt(ctx)
  40192. case usagestatisticmonth.FieldAddtime:
  40193. return m.OldAddtime(ctx)
  40194. case usagestatisticmonth.FieldType:
  40195. return m.OldType(ctx)
  40196. case usagestatisticmonth.FieldBotID:
  40197. return m.OldBotID(ctx)
  40198. case usagestatisticmonth.FieldOrganizationID:
  40199. return m.OldOrganizationID(ctx)
  40200. case usagestatisticmonth.FieldAiResponse:
  40201. return m.OldAiResponse(ctx)
  40202. case usagestatisticmonth.FieldSopRun:
  40203. return m.OldSopRun(ctx)
  40204. case usagestatisticmonth.FieldTotalFriend:
  40205. return m.OldTotalFriend(ctx)
  40206. case usagestatisticmonth.FieldTotalGroup:
  40207. return m.OldTotalGroup(ctx)
  40208. case usagestatisticmonth.FieldAccountBalance:
  40209. return m.OldAccountBalance(ctx)
  40210. case usagestatisticmonth.FieldConsumeToken:
  40211. return m.OldConsumeToken(ctx)
  40212. case usagestatisticmonth.FieldActiveUser:
  40213. return m.OldActiveUser(ctx)
  40214. case usagestatisticmonth.FieldNewUser:
  40215. return m.OldNewUser(ctx)
  40216. case usagestatisticmonth.FieldLabelDist:
  40217. return m.OldLabelDist(ctx)
  40218. case usagestatisticmonth.FieldConsumeCoin:
  40219. return m.OldConsumeCoin(ctx)
  40220. }
  40221. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40222. }
  40223. // SetField sets the value of a field with the given name. It returns an error if
  40224. // the field is not defined in the schema, or if the type mismatched the field
  40225. // type.
  40226. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  40227. switch name {
  40228. case usagestatisticmonth.FieldCreatedAt:
  40229. v, ok := value.(time.Time)
  40230. if !ok {
  40231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40232. }
  40233. m.SetCreatedAt(v)
  40234. return nil
  40235. case usagestatisticmonth.FieldUpdatedAt:
  40236. v, ok := value.(time.Time)
  40237. if !ok {
  40238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40239. }
  40240. m.SetUpdatedAt(v)
  40241. return nil
  40242. case usagestatisticmonth.FieldStatus:
  40243. v, ok := value.(uint8)
  40244. if !ok {
  40245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40246. }
  40247. m.SetStatus(v)
  40248. return nil
  40249. case usagestatisticmonth.FieldDeletedAt:
  40250. v, ok := value.(time.Time)
  40251. if !ok {
  40252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40253. }
  40254. m.SetDeletedAt(v)
  40255. return nil
  40256. case usagestatisticmonth.FieldAddtime:
  40257. v, ok := value.(uint64)
  40258. if !ok {
  40259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40260. }
  40261. m.SetAddtime(v)
  40262. return nil
  40263. case usagestatisticmonth.FieldType:
  40264. v, ok := value.(int)
  40265. if !ok {
  40266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40267. }
  40268. m.SetType(v)
  40269. return nil
  40270. case usagestatisticmonth.FieldBotID:
  40271. v, ok := value.(string)
  40272. if !ok {
  40273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40274. }
  40275. m.SetBotID(v)
  40276. return nil
  40277. case usagestatisticmonth.FieldOrganizationID:
  40278. v, ok := value.(uint64)
  40279. if !ok {
  40280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40281. }
  40282. m.SetOrganizationID(v)
  40283. return nil
  40284. case usagestatisticmonth.FieldAiResponse:
  40285. v, ok := value.(uint64)
  40286. if !ok {
  40287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40288. }
  40289. m.SetAiResponse(v)
  40290. return nil
  40291. case usagestatisticmonth.FieldSopRun:
  40292. v, ok := value.(uint64)
  40293. if !ok {
  40294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40295. }
  40296. m.SetSopRun(v)
  40297. return nil
  40298. case usagestatisticmonth.FieldTotalFriend:
  40299. v, ok := value.(uint64)
  40300. if !ok {
  40301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40302. }
  40303. m.SetTotalFriend(v)
  40304. return nil
  40305. case usagestatisticmonth.FieldTotalGroup:
  40306. v, ok := value.(uint64)
  40307. if !ok {
  40308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40309. }
  40310. m.SetTotalGroup(v)
  40311. return nil
  40312. case usagestatisticmonth.FieldAccountBalance:
  40313. v, ok := value.(uint64)
  40314. if !ok {
  40315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40316. }
  40317. m.SetAccountBalance(v)
  40318. return nil
  40319. case usagestatisticmonth.FieldConsumeToken:
  40320. v, ok := value.(uint64)
  40321. if !ok {
  40322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40323. }
  40324. m.SetConsumeToken(v)
  40325. return nil
  40326. case usagestatisticmonth.FieldActiveUser:
  40327. v, ok := value.(uint64)
  40328. if !ok {
  40329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40330. }
  40331. m.SetActiveUser(v)
  40332. return nil
  40333. case usagestatisticmonth.FieldNewUser:
  40334. v, ok := value.(int64)
  40335. if !ok {
  40336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40337. }
  40338. m.SetNewUser(v)
  40339. return nil
  40340. case usagestatisticmonth.FieldLabelDist:
  40341. v, ok := value.([]custom_types.LabelDist)
  40342. if !ok {
  40343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40344. }
  40345. m.SetLabelDist(v)
  40346. return nil
  40347. case usagestatisticmonth.FieldConsumeCoin:
  40348. v, ok := value.(float64)
  40349. if !ok {
  40350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40351. }
  40352. m.SetConsumeCoin(v)
  40353. return nil
  40354. }
  40355. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40356. }
  40357. // AddedFields returns all numeric fields that were incremented/decremented during
  40358. // this mutation.
  40359. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  40360. var fields []string
  40361. if m.addstatus != nil {
  40362. fields = append(fields, usagestatisticmonth.FieldStatus)
  40363. }
  40364. if m.addaddtime != nil {
  40365. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40366. }
  40367. if m.add_type != nil {
  40368. fields = append(fields, usagestatisticmonth.FieldType)
  40369. }
  40370. if m.addorganization_id != nil {
  40371. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40372. }
  40373. if m.addai_response != nil {
  40374. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40375. }
  40376. if m.addsop_run != nil {
  40377. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40378. }
  40379. if m.addtotal_friend != nil {
  40380. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40381. }
  40382. if m.addtotal_group != nil {
  40383. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40384. }
  40385. if m.addaccount_balance != nil {
  40386. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40387. }
  40388. if m.addconsume_token != nil {
  40389. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40390. }
  40391. if m.addactive_user != nil {
  40392. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40393. }
  40394. if m.addnew_user != nil {
  40395. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40396. }
  40397. if m.addconsume_coin != nil {
  40398. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40399. }
  40400. return fields
  40401. }
  40402. // AddedField returns the numeric value that was incremented/decremented on a field
  40403. // with the given name. The second boolean return value indicates that this field
  40404. // was not set, or was not defined in the schema.
  40405. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  40406. switch name {
  40407. case usagestatisticmonth.FieldStatus:
  40408. return m.AddedStatus()
  40409. case usagestatisticmonth.FieldAddtime:
  40410. return m.AddedAddtime()
  40411. case usagestatisticmonth.FieldType:
  40412. return m.AddedType()
  40413. case usagestatisticmonth.FieldOrganizationID:
  40414. return m.AddedOrganizationID()
  40415. case usagestatisticmonth.FieldAiResponse:
  40416. return m.AddedAiResponse()
  40417. case usagestatisticmonth.FieldSopRun:
  40418. return m.AddedSopRun()
  40419. case usagestatisticmonth.FieldTotalFriend:
  40420. return m.AddedTotalFriend()
  40421. case usagestatisticmonth.FieldTotalGroup:
  40422. return m.AddedTotalGroup()
  40423. case usagestatisticmonth.FieldAccountBalance:
  40424. return m.AddedAccountBalance()
  40425. case usagestatisticmonth.FieldConsumeToken:
  40426. return m.AddedConsumeToken()
  40427. case usagestatisticmonth.FieldActiveUser:
  40428. return m.AddedActiveUser()
  40429. case usagestatisticmonth.FieldNewUser:
  40430. return m.AddedNewUser()
  40431. case usagestatisticmonth.FieldConsumeCoin:
  40432. return m.AddedConsumeCoin()
  40433. }
  40434. return nil, false
  40435. }
  40436. // AddField adds the value to the field with the given name. It returns an error if
  40437. // the field is not defined in the schema, or if the type mismatched the field
  40438. // type.
  40439. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  40440. switch name {
  40441. case usagestatisticmonth.FieldStatus:
  40442. v, ok := value.(int8)
  40443. if !ok {
  40444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40445. }
  40446. m.AddStatus(v)
  40447. return nil
  40448. case usagestatisticmonth.FieldAddtime:
  40449. v, ok := value.(int64)
  40450. if !ok {
  40451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40452. }
  40453. m.AddAddtime(v)
  40454. return nil
  40455. case usagestatisticmonth.FieldType:
  40456. v, ok := value.(int)
  40457. if !ok {
  40458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40459. }
  40460. m.AddType(v)
  40461. return nil
  40462. case usagestatisticmonth.FieldOrganizationID:
  40463. v, ok := value.(int64)
  40464. if !ok {
  40465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40466. }
  40467. m.AddOrganizationID(v)
  40468. return nil
  40469. case usagestatisticmonth.FieldAiResponse:
  40470. v, ok := value.(int64)
  40471. if !ok {
  40472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40473. }
  40474. m.AddAiResponse(v)
  40475. return nil
  40476. case usagestatisticmonth.FieldSopRun:
  40477. v, ok := value.(int64)
  40478. if !ok {
  40479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40480. }
  40481. m.AddSopRun(v)
  40482. return nil
  40483. case usagestatisticmonth.FieldTotalFriend:
  40484. v, ok := value.(int64)
  40485. if !ok {
  40486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40487. }
  40488. m.AddTotalFriend(v)
  40489. return nil
  40490. case usagestatisticmonth.FieldTotalGroup:
  40491. v, ok := value.(int64)
  40492. if !ok {
  40493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40494. }
  40495. m.AddTotalGroup(v)
  40496. return nil
  40497. case usagestatisticmonth.FieldAccountBalance:
  40498. v, ok := value.(int64)
  40499. if !ok {
  40500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40501. }
  40502. m.AddAccountBalance(v)
  40503. return nil
  40504. case usagestatisticmonth.FieldConsumeToken:
  40505. v, ok := value.(int64)
  40506. if !ok {
  40507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40508. }
  40509. m.AddConsumeToken(v)
  40510. return nil
  40511. case usagestatisticmonth.FieldActiveUser:
  40512. v, ok := value.(int64)
  40513. if !ok {
  40514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40515. }
  40516. m.AddActiveUser(v)
  40517. return nil
  40518. case usagestatisticmonth.FieldNewUser:
  40519. v, ok := value.(int64)
  40520. if !ok {
  40521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40522. }
  40523. m.AddNewUser(v)
  40524. return nil
  40525. case usagestatisticmonth.FieldConsumeCoin:
  40526. v, ok := value.(float64)
  40527. if !ok {
  40528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40529. }
  40530. m.AddConsumeCoin(v)
  40531. return nil
  40532. }
  40533. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  40534. }
  40535. // ClearedFields returns all nullable fields that were cleared during this
  40536. // mutation.
  40537. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  40538. var fields []string
  40539. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  40540. fields = append(fields, usagestatisticmonth.FieldStatus)
  40541. }
  40542. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  40543. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40544. }
  40545. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  40546. fields = append(fields, usagestatisticmonth.FieldBotID)
  40547. }
  40548. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  40549. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40550. }
  40551. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  40552. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40553. }
  40554. return fields
  40555. }
  40556. // FieldCleared returns a boolean indicating if a field with the given name was
  40557. // cleared in this mutation.
  40558. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  40559. _, ok := m.clearedFields[name]
  40560. return ok
  40561. }
  40562. // ClearField clears the value of the field with the given name. It returns an
  40563. // error if the field is not defined in the schema.
  40564. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  40565. switch name {
  40566. case usagestatisticmonth.FieldStatus:
  40567. m.ClearStatus()
  40568. return nil
  40569. case usagestatisticmonth.FieldDeletedAt:
  40570. m.ClearDeletedAt()
  40571. return nil
  40572. case usagestatisticmonth.FieldBotID:
  40573. m.ClearBotID()
  40574. return nil
  40575. case usagestatisticmonth.FieldOrganizationID:
  40576. m.ClearOrganizationID()
  40577. return nil
  40578. case usagestatisticmonth.FieldConsumeCoin:
  40579. m.ClearConsumeCoin()
  40580. return nil
  40581. }
  40582. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  40583. }
  40584. // ResetField resets all changes in the mutation for the field with the given name.
  40585. // It returns an error if the field is not defined in the schema.
  40586. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  40587. switch name {
  40588. case usagestatisticmonth.FieldCreatedAt:
  40589. m.ResetCreatedAt()
  40590. return nil
  40591. case usagestatisticmonth.FieldUpdatedAt:
  40592. m.ResetUpdatedAt()
  40593. return nil
  40594. case usagestatisticmonth.FieldStatus:
  40595. m.ResetStatus()
  40596. return nil
  40597. case usagestatisticmonth.FieldDeletedAt:
  40598. m.ResetDeletedAt()
  40599. return nil
  40600. case usagestatisticmonth.FieldAddtime:
  40601. m.ResetAddtime()
  40602. return nil
  40603. case usagestatisticmonth.FieldType:
  40604. m.ResetType()
  40605. return nil
  40606. case usagestatisticmonth.FieldBotID:
  40607. m.ResetBotID()
  40608. return nil
  40609. case usagestatisticmonth.FieldOrganizationID:
  40610. m.ResetOrganizationID()
  40611. return nil
  40612. case usagestatisticmonth.FieldAiResponse:
  40613. m.ResetAiResponse()
  40614. return nil
  40615. case usagestatisticmonth.FieldSopRun:
  40616. m.ResetSopRun()
  40617. return nil
  40618. case usagestatisticmonth.FieldTotalFriend:
  40619. m.ResetTotalFriend()
  40620. return nil
  40621. case usagestatisticmonth.FieldTotalGroup:
  40622. m.ResetTotalGroup()
  40623. return nil
  40624. case usagestatisticmonth.FieldAccountBalance:
  40625. m.ResetAccountBalance()
  40626. return nil
  40627. case usagestatisticmonth.FieldConsumeToken:
  40628. m.ResetConsumeToken()
  40629. return nil
  40630. case usagestatisticmonth.FieldActiveUser:
  40631. m.ResetActiveUser()
  40632. return nil
  40633. case usagestatisticmonth.FieldNewUser:
  40634. m.ResetNewUser()
  40635. return nil
  40636. case usagestatisticmonth.FieldLabelDist:
  40637. m.ResetLabelDist()
  40638. return nil
  40639. case usagestatisticmonth.FieldConsumeCoin:
  40640. m.ResetConsumeCoin()
  40641. return nil
  40642. }
  40643. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40644. }
  40645. // AddedEdges returns all edge names that were set/added in this mutation.
  40646. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  40647. edges := make([]string, 0, 0)
  40648. return edges
  40649. }
  40650. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40651. // name in this mutation.
  40652. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  40653. return nil
  40654. }
  40655. // RemovedEdges returns all edge names that were removed in this mutation.
  40656. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  40657. edges := make([]string, 0, 0)
  40658. return edges
  40659. }
  40660. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40661. // the given name in this mutation.
  40662. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  40663. return nil
  40664. }
  40665. // ClearedEdges returns all edge names that were cleared in this mutation.
  40666. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  40667. edges := make([]string, 0, 0)
  40668. return edges
  40669. }
  40670. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40671. // was cleared in this mutation.
  40672. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  40673. return false
  40674. }
  40675. // ClearEdge clears the value of the edge with the given name. It returns an error
  40676. // if that edge is not defined in the schema.
  40677. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  40678. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  40679. }
  40680. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40681. // It returns an error if the edge is not defined in the schema.
  40682. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  40683. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  40684. }
  40685. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  40686. type UsageTotalMutation struct {
  40687. config
  40688. op Op
  40689. typ string
  40690. id *uint64
  40691. created_at *time.Time
  40692. updated_at *time.Time
  40693. status *uint8
  40694. addstatus *int8
  40695. _type *int
  40696. add_type *int
  40697. bot_id *string
  40698. total_tokens *uint64
  40699. addtotal_tokens *int64
  40700. start_index *uint64
  40701. addstart_index *int64
  40702. end_index *uint64
  40703. addend_index *int64
  40704. organization_id *uint64
  40705. addorganization_id *int64
  40706. clearedFields map[string]struct{}
  40707. done bool
  40708. oldValue func(context.Context) (*UsageTotal, error)
  40709. predicates []predicate.UsageTotal
  40710. }
  40711. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  40712. // usagetotalOption allows management of the mutation configuration using functional options.
  40713. type usagetotalOption func(*UsageTotalMutation)
  40714. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  40715. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  40716. m := &UsageTotalMutation{
  40717. config: c,
  40718. op: op,
  40719. typ: TypeUsageTotal,
  40720. clearedFields: make(map[string]struct{}),
  40721. }
  40722. for _, opt := range opts {
  40723. opt(m)
  40724. }
  40725. return m
  40726. }
  40727. // withUsageTotalID sets the ID field of the mutation.
  40728. func withUsageTotalID(id uint64) usagetotalOption {
  40729. return func(m *UsageTotalMutation) {
  40730. var (
  40731. err error
  40732. once sync.Once
  40733. value *UsageTotal
  40734. )
  40735. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  40736. once.Do(func() {
  40737. if m.done {
  40738. err = errors.New("querying old values post mutation is not allowed")
  40739. } else {
  40740. value, err = m.Client().UsageTotal.Get(ctx, id)
  40741. }
  40742. })
  40743. return value, err
  40744. }
  40745. m.id = &id
  40746. }
  40747. }
  40748. // withUsageTotal sets the old UsageTotal of the mutation.
  40749. func withUsageTotal(node *UsageTotal) usagetotalOption {
  40750. return func(m *UsageTotalMutation) {
  40751. m.oldValue = func(context.Context) (*UsageTotal, error) {
  40752. return node, nil
  40753. }
  40754. m.id = &node.ID
  40755. }
  40756. }
  40757. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40758. // executed in a transaction (ent.Tx), a transactional client is returned.
  40759. func (m UsageTotalMutation) Client() *Client {
  40760. client := &Client{config: m.config}
  40761. client.init()
  40762. return client
  40763. }
  40764. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40765. // it returns an error otherwise.
  40766. func (m UsageTotalMutation) Tx() (*Tx, error) {
  40767. if _, ok := m.driver.(*txDriver); !ok {
  40768. return nil, errors.New("ent: mutation is not running in a transaction")
  40769. }
  40770. tx := &Tx{config: m.config}
  40771. tx.init()
  40772. return tx, nil
  40773. }
  40774. // SetID sets the value of the id field. Note that this
  40775. // operation is only accepted on creation of UsageTotal entities.
  40776. func (m *UsageTotalMutation) SetID(id uint64) {
  40777. m.id = &id
  40778. }
  40779. // ID returns the ID value in the mutation. Note that the ID is only available
  40780. // if it was provided to the builder or after it was returned from the database.
  40781. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  40782. if m.id == nil {
  40783. return
  40784. }
  40785. return *m.id, true
  40786. }
  40787. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40788. // That means, if the mutation is applied within a transaction with an isolation level such
  40789. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40790. // or updated by the mutation.
  40791. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  40792. switch {
  40793. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40794. id, exists := m.ID()
  40795. if exists {
  40796. return []uint64{id}, nil
  40797. }
  40798. fallthrough
  40799. case m.op.Is(OpUpdate | OpDelete):
  40800. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  40801. default:
  40802. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40803. }
  40804. }
  40805. // SetCreatedAt sets the "created_at" field.
  40806. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  40807. m.created_at = &t
  40808. }
  40809. // CreatedAt returns the value of the "created_at" field in the mutation.
  40810. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  40811. v := m.created_at
  40812. if v == nil {
  40813. return
  40814. }
  40815. return *v, true
  40816. }
  40817. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  40818. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40820. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40821. if !m.op.Is(OpUpdateOne) {
  40822. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40823. }
  40824. if m.id == nil || m.oldValue == nil {
  40825. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40826. }
  40827. oldValue, err := m.oldValue(ctx)
  40828. if err != nil {
  40829. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40830. }
  40831. return oldValue.CreatedAt, nil
  40832. }
  40833. // ResetCreatedAt resets all changes to the "created_at" field.
  40834. func (m *UsageTotalMutation) ResetCreatedAt() {
  40835. m.created_at = nil
  40836. }
  40837. // SetUpdatedAt sets the "updated_at" field.
  40838. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  40839. m.updated_at = &t
  40840. }
  40841. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40842. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  40843. v := m.updated_at
  40844. if v == nil {
  40845. return
  40846. }
  40847. return *v, true
  40848. }
  40849. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  40850. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40852. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40853. if !m.op.Is(OpUpdateOne) {
  40854. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40855. }
  40856. if m.id == nil || m.oldValue == nil {
  40857. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40858. }
  40859. oldValue, err := m.oldValue(ctx)
  40860. if err != nil {
  40861. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40862. }
  40863. return oldValue.UpdatedAt, nil
  40864. }
  40865. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40866. func (m *UsageTotalMutation) ResetUpdatedAt() {
  40867. m.updated_at = nil
  40868. }
  40869. // SetStatus sets the "status" field.
  40870. func (m *UsageTotalMutation) SetStatus(u uint8) {
  40871. m.status = &u
  40872. m.addstatus = nil
  40873. }
  40874. // Status returns the value of the "status" field in the mutation.
  40875. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  40876. v := m.status
  40877. if v == nil {
  40878. return
  40879. }
  40880. return *v, true
  40881. }
  40882. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  40883. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40885. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40886. if !m.op.Is(OpUpdateOne) {
  40887. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40888. }
  40889. if m.id == nil || m.oldValue == nil {
  40890. return v, errors.New("OldStatus requires an ID field in the mutation")
  40891. }
  40892. oldValue, err := m.oldValue(ctx)
  40893. if err != nil {
  40894. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40895. }
  40896. return oldValue.Status, nil
  40897. }
  40898. // AddStatus adds u to the "status" field.
  40899. func (m *UsageTotalMutation) AddStatus(u int8) {
  40900. if m.addstatus != nil {
  40901. *m.addstatus += u
  40902. } else {
  40903. m.addstatus = &u
  40904. }
  40905. }
  40906. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40907. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  40908. v := m.addstatus
  40909. if v == nil {
  40910. return
  40911. }
  40912. return *v, true
  40913. }
  40914. // ClearStatus clears the value of the "status" field.
  40915. func (m *UsageTotalMutation) ClearStatus() {
  40916. m.status = nil
  40917. m.addstatus = nil
  40918. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  40919. }
  40920. // StatusCleared returns if the "status" field was cleared in this mutation.
  40921. func (m *UsageTotalMutation) StatusCleared() bool {
  40922. _, ok := m.clearedFields[usagetotal.FieldStatus]
  40923. return ok
  40924. }
  40925. // ResetStatus resets all changes to the "status" field.
  40926. func (m *UsageTotalMutation) ResetStatus() {
  40927. m.status = nil
  40928. m.addstatus = nil
  40929. delete(m.clearedFields, usagetotal.FieldStatus)
  40930. }
  40931. // SetType sets the "type" field.
  40932. func (m *UsageTotalMutation) SetType(i int) {
  40933. m._type = &i
  40934. m.add_type = nil
  40935. }
  40936. // GetType returns the value of the "type" field in the mutation.
  40937. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  40938. v := m._type
  40939. if v == nil {
  40940. return
  40941. }
  40942. return *v, true
  40943. }
  40944. // OldType returns the old "type" field's value of the UsageTotal entity.
  40945. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40947. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  40948. if !m.op.Is(OpUpdateOne) {
  40949. return v, errors.New("OldType is only allowed on UpdateOne operations")
  40950. }
  40951. if m.id == nil || m.oldValue == nil {
  40952. return v, errors.New("OldType requires an ID field in the mutation")
  40953. }
  40954. oldValue, err := m.oldValue(ctx)
  40955. if err != nil {
  40956. return v, fmt.Errorf("querying old value for OldType: %w", err)
  40957. }
  40958. return oldValue.Type, nil
  40959. }
  40960. // AddType adds i to the "type" field.
  40961. func (m *UsageTotalMutation) AddType(i int) {
  40962. if m.add_type != nil {
  40963. *m.add_type += i
  40964. } else {
  40965. m.add_type = &i
  40966. }
  40967. }
  40968. // AddedType returns the value that was added to the "type" field in this mutation.
  40969. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  40970. v := m.add_type
  40971. if v == nil {
  40972. return
  40973. }
  40974. return *v, true
  40975. }
  40976. // ClearType clears the value of the "type" field.
  40977. func (m *UsageTotalMutation) ClearType() {
  40978. m._type = nil
  40979. m.add_type = nil
  40980. m.clearedFields[usagetotal.FieldType] = struct{}{}
  40981. }
  40982. // TypeCleared returns if the "type" field was cleared in this mutation.
  40983. func (m *UsageTotalMutation) TypeCleared() bool {
  40984. _, ok := m.clearedFields[usagetotal.FieldType]
  40985. return ok
  40986. }
  40987. // ResetType resets all changes to the "type" field.
  40988. func (m *UsageTotalMutation) ResetType() {
  40989. m._type = nil
  40990. m.add_type = nil
  40991. delete(m.clearedFields, usagetotal.FieldType)
  40992. }
  40993. // SetBotID sets the "bot_id" field.
  40994. func (m *UsageTotalMutation) SetBotID(s string) {
  40995. m.bot_id = &s
  40996. }
  40997. // BotID returns the value of the "bot_id" field in the mutation.
  40998. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  40999. v := m.bot_id
  41000. if v == nil {
  41001. return
  41002. }
  41003. return *v, true
  41004. }
  41005. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  41006. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41008. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  41009. if !m.op.Is(OpUpdateOne) {
  41010. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41011. }
  41012. if m.id == nil || m.oldValue == nil {
  41013. return v, errors.New("OldBotID requires an ID field in the mutation")
  41014. }
  41015. oldValue, err := m.oldValue(ctx)
  41016. if err != nil {
  41017. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41018. }
  41019. return oldValue.BotID, nil
  41020. }
  41021. // ResetBotID resets all changes to the "bot_id" field.
  41022. func (m *UsageTotalMutation) ResetBotID() {
  41023. m.bot_id = nil
  41024. }
  41025. // SetTotalTokens sets the "total_tokens" field.
  41026. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  41027. m.total_tokens = &u
  41028. m.addtotal_tokens = nil
  41029. }
  41030. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  41031. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  41032. v := m.total_tokens
  41033. if v == nil {
  41034. return
  41035. }
  41036. return *v, true
  41037. }
  41038. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  41039. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41041. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  41042. if !m.op.Is(OpUpdateOne) {
  41043. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  41044. }
  41045. if m.id == nil || m.oldValue == nil {
  41046. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  41047. }
  41048. oldValue, err := m.oldValue(ctx)
  41049. if err != nil {
  41050. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  41051. }
  41052. return oldValue.TotalTokens, nil
  41053. }
  41054. // AddTotalTokens adds u to the "total_tokens" field.
  41055. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  41056. if m.addtotal_tokens != nil {
  41057. *m.addtotal_tokens += u
  41058. } else {
  41059. m.addtotal_tokens = &u
  41060. }
  41061. }
  41062. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  41063. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  41064. v := m.addtotal_tokens
  41065. if v == nil {
  41066. return
  41067. }
  41068. return *v, true
  41069. }
  41070. // ClearTotalTokens clears the value of the "total_tokens" field.
  41071. func (m *UsageTotalMutation) ClearTotalTokens() {
  41072. m.total_tokens = nil
  41073. m.addtotal_tokens = nil
  41074. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  41075. }
  41076. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  41077. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  41078. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  41079. return ok
  41080. }
  41081. // ResetTotalTokens resets all changes to the "total_tokens" field.
  41082. func (m *UsageTotalMutation) ResetTotalTokens() {
  41083. m.total_tokens = nil
  41084. m.addtotal_tokens = nil
  41085. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  41086. }
  41087. // SetStartIndex sets the "start_index" field.
  41088. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  41089. m.start_index = &u
  41090. m.addstart_index = nil
  41091. }
  41092. // StartIndex returns the value of the "start_index" field in the mutation.
  41093. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  41094. v := m.start_index
  41095. if v == nil {
  41096. return
  41097. }
  41098. return *v, true
  41099. }
  41100. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  41101. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41103. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  41104. if !m.op.Is(OpUpdateOne) {
  41105. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  41106. }
  41107. if m.id == nil || m.oldValue == nil {
  41108. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  41109. }
  41110. oldValue, err := m.oldValue(ctx)
  41111. if err != nil {
  41112. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  41113. }
  41114. return oldValue.StartIndex, nil
  41115. }
  41116. // AddStartIndex adds u to the "start_index" field.
  41117. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  41118. if m.addstart_index != nil {
  41119. *m.addstart_index += u
  41120. } else {
  41121. m.addstart_index = &u
  41122. }
  41123. }
  41124. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  41125. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  41126. v := m.addstart_index
  41127. if v == nil {
  41128. return
  41129. }
  41130. return *v, true
  41131. }
  41132. // ClearStartIndex clears the value of the "start_index" field.
  41133. func (m *UsageTotalMutation) ClearStartIndex() {
  41134. m.start_index = nil
  41135. m.addstart_index = nil
  41136. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  41137. }
  41138. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  41139. func (m *UsageTotalMutation) StartIndexCleared() bool {
  41140. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  41141. return ok
  41142. }
  41143. // ResetStartIndex resets all changes to the "start_index" field.
  41144. func (m *UsageTotalMutation) ResetStartIndex() {
  41145. m.start_index = nil
  41146. m.addstart_index = nil
  41147. delete(m.clearedFields, usagetotal.FieldStartIndex)
  41148. }
  41149. // SetEndIndex sets the "end_index" field.
  41150. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  41151. m.end_index = &u
  41152. m.addend_index = nil
  41153. }
  41154. // EndIndex returns the value of the "end_index" field in the mutation.
  41155. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  41156. v := m.end_index
  41157. if v == nil {
  41158. return
  41159. }
  41160. return *v, true
  41161. }
  41162. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  41163. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41165. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  41166. if !m.op.Is(OpUpdateOne) {
  41167. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  41168. }
  41169. if m.id == nil || m.oldValue == nil {
  41170. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  41171. }
  41172. oldValue, err := m.oldValue(ctx)
  41173. if err != nil {
  41174. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  41175. }
  41176. return oldValue.EndIndex, nil
  41177. }
  41178. // AddEndIndex adds u to the "end_index" field.
  41179. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  41180. if m.addend_index != nil {
  41181. *m.addend_index += u
  41182. } else {
  41183. m.addend_index = &u
  41184. }
  41185. }
  41186. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  41187. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  41188. v := m.addend_index
  41189. if v == nil {
  41190. return
  41191. }
  41192. return *v, true
  41193. }
  41194. // ClearEndIndex clears the value of the "end_index" field.
  41195. func (m *UsageTotalMutation) ClearEndIndex() {
  41196. m.end_index = nil
  41197. m.addend_index = nil
  41198. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  41199. }
  41200. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  41201. func (m *UsageTotalMutation) EndIndexCleared() bool {
  41202. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  41203. return ok
  41204. }
  41205. // ResetEndIndex resets all changes to the "end_index" field.
  41206. func (m *UsageTotalMutation) ResetEndIndex() {
  41207. m.end_index = nil
  41208. m.addend_index = nil
  41209. delete(m.clearedFields, usagetotal.FieldEndIndex)
  41210. }
  41211. // SetOrganizationID sets the "organization_id" field.
  41212. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  41213. m.organization_id = &u
  41214. m.addorganization_id = nil
  41215. }
  41216. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41217. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  41218. v := m.organization_id
  41219. if v == nil {
  41220. return
  41221. }
  41222. return *v, true
  41223. }
  41224. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  41225. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41227. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41228. if !m.op.Is(OpUpdateOne) {
  41229. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41230. }
  41231. if m.id == nil || m.oldValue == nil {
  41232. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41233. }
  41234. oldValue, err := m.oldValue(ctx)
  41235. if err != nil {
  41236. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41237. }
  41238. return oldValue.OrganizationID, nil
  41239. }
  41240. // AddOrganizationID adds u to the "organization_id" field.
  41241. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  41242. if m.addorganization_id != nil {
  41243. *m.addorganization_id += u
  41244. } else {
  41245. m.addorganization_id = &u
  41246. }
  41247. }
  41248. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41249. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  41250. v := m.addorganization_id
  41251. if v == nil {
  41252. return
  41253. }
  41254. return *v, true
  41255. }
  41256. // ClearOrganizationID clears the value of the "organization_id" field.
  41257. func (m *UsageTotalMutation) ClearOrganizationID() {
  41258. m.organization_id = nil
  41259. m.addorganization_id = nil
  41260. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  41261. }
  41262. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41263. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  41264. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  41265. return ok
  41266. }
  41267. // ResetOrganizationID resets all changes to the "organization_id" field.
  41268. func (m *UsageTotalMutation) ResetOrganizationID() {
  41269. m.organization_id = nil
  41270. m.addorganization_id = nil
  41271. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  41272. }
  41273. // Where appends a list predicates to the UsageTotalMutation builder.
  41274. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  41275. m.predicates = append(m.predicates, ps...)
  41276. }
  41277. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  41278. // users can use type-assertion to append predicates that do not depend on any generated package.
  41279. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  41280. p := make([]predicate.UsageTotal, len(ps))
  41281. for i := range ps {
  41282. p[i] = ps[i]
  41283. }
  41284. m.Where(p...)
  41285. }
  41286. // Op returns the operation name.
  41287. func (m *UsageTotalMutation) Op() Op {
  41288. return m.op
  41289. }
  41290. // SetOp allows setting the mutation operation.
  41291. func (m *UsageTotalMutation) SetOp(op Op) {
  41292. m.op = op
  41293. }
  41294. // Type returns the node type of this mutation (UsageTotal).
  41295. func (m *UsageTotalMutation) Type() string {
  41296. return m.typ
  41297. }
  41298. // Fields returns all fields that were changed during this mutation. Note that in
  41299. // order to get all numeric fields that were incremented/decremented, call
  41300. // AddedFields().
  41301. func (m *UsageTotalMutation) Fields() []string {
  41302. fields := make([]string, 0, 9)
  41303. if m.created_at != nil {
  41304. fields = append(fields, usagetotal.FieldCreatedAt)
  41305. }
  41306. if m.updated_at != nil {
  41307. fields = append(fields, usagetotal.FieldUpdatedAt)
  41308. }
  41309. if m.status != nil {
  41310. fields = append(fields, usagetotal.FieldStatus)
  41311. }
  41312. if m._type != nil {
  41313. fields = append(fields, usagetotal.FieldType)
  41314. }
  41315. if m.bot_id != nil {
  41316. fields = append(fields, usagetotal.FieldBotID)
  41317. }
  41318. if m.total_tokens != nil {
  41319. fields = append(fields, usagetotal.FieldTotalTokens)
  41320. }
  41321. if m.start_index != nil {
  41322. fields = append(fields, usagetotal.FieldStartIndex)
  41323. }
  41324. if m.end_index != nil {
  41325. fields = append(fields, usagetotal.FieldEndIndex)
  41326. }
  41327. if m.organization_id != nil {
  41328. fields = append(fields, usagetotal.FieldOrganizationID)
  41329. }
  41330. return fields
  41331. }
  41332. // Field returns the value of a field with the given name. The second boolean
  41333. // return value indicates that this field was not set, or was not defined in the
  41334. // schema.
  41335. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  41336. switch name {
  41337. case usagetotal.FieldCreatedAt:
  41338. return m.CreatedAt()
  41339. case usagetotal.FieldUpdatedAt:
  41340. return m.UpdatedAt()
  41341. case usagetotal.FieldStatus:
  41342. return m.Status()
  41343. case usagetotal.FieldType:
  41344. return m.GetType()
  41345. case usagetotal.FieldBotID:
  41346. return m.BotID()
  41347. case usagetotal.FieldTotalTokens:
  41348. return m.TotalTokens()
  41349. case usagetotal.FieldStartIndex:
  41350. return m.StartIndex()
  41351. case usagetotal.FieldEndIndex:
  41352. return m.EndIndex()
  41353. case usagetotal.FieldOrganizationID:
  41354. return m.OrganizationID()
  41355. }
  41356. return nil, false
  41357. }
  41358. // OldField returns the old value of the field from the database. An error is
  41359. // returned if the mutation operation is not UpdateOne, or the query to the
  41360. // database failed.
  41361. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41362. switch name {
  41363. case usagetotal.FieldCreatedAt:
  41364. return m.OldCreatedAt(ctx)
  41365. case usagetotal.FieldUpdatedAt:
  41366. return m.OldUpdatedAt(ctx)
  41367. case usagetotal.FieldStatus:
  41368. return m.OldStatus(ctx)
  41369. case usagetotal.FieldType:
  41370. return m.OldType(ctx)
  41371. case usagetotal.FieldBotID:
  41372. return m.OldBotID(ctx)
  41373. case usagetotal.FieldTotalTokens:
  41374. return m.OldTotalTokens(ctx)
  41375. case usagetotal.FieldStartIndex:
  41376. return m.OldStartIndex(ctx)
  41377. case usagetotal.FieldEndIndex:
  41378. return m.OldEndIndex(ctx)
  41379. case usagetotal.FieldOrganizationID:
  41380. return m.OldOrganizationID(ctx)
  41381. }
  41382. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  41383. }
  41384. // SetField sets the value of a field with the given name. It returns an error if
  41385. // the field is not defined in the schema, or if the type mismatched the field
  41386. // type.
  41387. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  41388. switch name {
  41389. case usagetotal.FieldCreatedAt:
  41390. v, ok := value.(time.Time)
  41391. if !ok {
  41392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41393. }
  41394. m.SetCreatedAt(v)
  41395. return nil
  41396. case usagetotal.FieldUpdatedAt:
  41397. v, ok := value.(time.Time)
  41398. if !ok {
  41399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41400. }
  41401. m.SetUpdatedAt(v)
  41402. return nil
  41403. case usagetotal.FieldStatus:
  41404. v, ok := value.(uint8)
  41405. if !ok {
  41406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41407. }
  41408. m.SetStatus(v)
  41409. return nil
  41410. case usagetotal.FieldType:
  41411. v, ok := value.(int)
  41412. if !ok {
  41413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41414. }
  41415. m.SetType(v)
  41416. return nil
  41417. case usagetotal.FieldBotID:
  41418. v, ok := value.(string)
  41419. if !ok {
  41420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41421. }
  41422. m.SetBotID(v)
  41423. return nil
  41424. case usagetotal.FieldTotalTokens:
  41425. v, ok := value.(uint64)
  41426. if !ok {
  41427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41428. }
  41429. m.SetTotalTokens(v)
  41430. return nil
  41431. case usagetotal.FieldStartIndex:
  41432. v, ok := value.(uint64)
  41433. if !ok {
  41434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41435. }
  41436. m.SetStartIndex(v)
  41437. return nil
  41438. case usagetotal.FieldEndIndex:
  41439. v, ok := value.(uint64)
  41440. if !ok {
  41441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41442. }
  41443. m.SetEndIndex(v)
  41444. return nil
  41445. case usagetotal.FieldOrganizationID:
  41446. v, ok := value.(uint64)
  41447. if !ok {
  41448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41449. }
  41450. m.SetOrganizationID(v)
  41451. return nil
  41452. }
  41453. return fmt.Errorf("unknown UsageTotal field %s", name)
  41454. }
  41455. // AddedFields returns all numeric fields that were incremented/decremented during
  41456. // this mutation.
  41457. func (m *UsageTotalMutation) AddedFields() []string {
  41458. var fields []string
  41459. if m.addstatus != nil {
  41460. fields = append(fields, usagetotal.FieldStatus)
  41461. }
  41462. if m.add_type != nil {
  41463. fields = append(fields, usagetotal.FieldType)
  41464. }
  41465. if m.addtotal_tokens != nil {
  41466. fields = append(fields, usagetotal.FieldTotalTokens)
  41467. }
  41468. if m.addstart_index != nil {
  41469. fields = append(fields, usagetotal.FieldStartIndex)
  41470. }
  41471. if m.addend_index != nil {
  41472. fields = append(fields, usagetotal.FieldEndIndex)
  41473. }
  41474. if m.addorganization_id != nil {
  41475. fields = append(fields, usagetotal.FieldOrganizationID)
  41476. }
  41477. return fields
  41478. }
  41479. // AddedField returns the numeric value that was incremented/decremented on a field
  41480. // with the given name. The second boolean return value indicates that this field
  41481. // was not set, or was not defined in the schema.
  41482. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  41483. switch name {
  41484. case usagetotal.FieldStatus:
  41485. return m.AddedStatus()
  41486. case usagetotal.FieldType:
  41487. return m.AddedType()
  41488. case usagetotal.FieldTotalTokens:
  41489. return m.AddedTotalTokens()
  41490. case usagetotal.FieldStartIndex:
  41491. return m.AddedStartIndex()
  41492. case usagetotal.FieldEndIndex:
  41493. return m.AddedEndIndex()
  41494. case usagetotal.FieldOrganizationID:
  41495. return m.AddedOrganizationID()
  41496. }
  41497. return nil, false
  41498. }
  41499. // AddField adds the value to the field with the given name. It returns an error if
  41500. // the field is not defined in the schema, or if the type mismatched the field
  41501. // type.
  41502. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  41503. switch name {
  41504. case usagetotal.FieldStatus:
  41505. v, ok := value.(int8)
  41506. if !ok {
  41507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41508. }
  41509. m.AddStatus(v)
  41510. return nil
  41511. case usagetotal.FieldType:
  41512. v, ok := value.(int)
  41513. if !ok {
  41514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41515. }
  41516. m.AddType(v)
  41517. return nil
  41518. case usagetotal.FieldTotalTokens:
  41519. v, ok := value.(int64)
  41520. if !ok {
  41521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41522. }
  41523. m.AddTotalTokens(v)
  41524. return nil
  41525. case usagetotal.FieldStartIndex:
  41526. v, ok := value.(int64)
  41527. if !ok {
  41528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41529. }
  41530. m.AddStartIndex(v)
  41531. return nil
  41532. case usagetotal.FieldEndIndex:
  41533. v, ok := value.(int64)
  41534. if !ok {
  41535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41536. }
  41537. m.AddEndIndex(v)
  41538. return nil
  41539. case usagetotal.FieldOrganizationID:
  41540. v, ok := value.(int64)
  41541. if !ok {
  41542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41543. }
  41544. m.AddOrganizationID(v)
  41545. return nil
  41546. }
  41547. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  41548. }
  41549. // ClearedFields returns all nullable fields that were cleared during this
  41550. // mutation.
  41551. func (m *UsageTotalMutation) ClearedFields() []string {
  41552. var fields []string
  41553. if m.FieldCleared(usagetotal.FieldStatus) {
  41554. fields = append(fields, usagetotal.FieldStatus)
  41555. }
  41556. if m.FieldCleared(usagetotal.FieldType) {
  41557. fields = append(fields, usagetotal.FieldType)
  41558. }
  41559. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  41560. fields = append(fields, usagetotal.FieldTotalTokens)
  41561. }
  41562. if m.FieldCleared(usagetotal.FieldStartIndex) {
  41563. fields = append(fields, usagetotal.FieldStartIndex)
  41564. }
  41565. if m.FieldCleared(usagetotal.FieldEndIndex) {
  41566. fields = append(fields, usagetotal.FieldEndIndex)
  41567. }
  41568. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  41569. fields = append(fields, usagetotal.FieldOrganizationID)
  41570. }
  41571. return fields
  41572. }
  41573. // FieldCleared returns a boolean indicating if a field with the given name was
  41574. // cleared in this mutation.
  41575. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  41576. _, ok := m.clearedFields[name]
  41577. return ok
  41578. }
  41579. // ClearField clears the value of the field with the given name. It returns an
  41580. // error if the field is not defined in the schema.
  41581. func (m *UsageTotalMutation) ClearField(name string) error {
  41582. switch name {
  41583. case usagetotal.FieldStatus:
  41584. m.ClearStatus()
  41585. return nil
  41586. case usagetotal.FieldType:
  41587. m.ClearType()
  41588. return nil
  41589. case usagetotal.FieldTotalTokens:
  41590. m.ClearTotalTokens()
  41591. return nil
  41592. case usagetotal.FieldStartIndex:
  41593. m.ClearStartIndex()
  41594. return nil
  41595. case usagetotal.FieldEndIndex:
  41596. m.ClearEndIndex()
  41597. return nil
  41598. case usagetotal.FieldOrganizationID:
  41599. m.ClearOrganizationID()
  41600. return nil
  41601. }
  41602. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  41603. }
  41604. // ResetField resets all changes in the mutation for the field with the given name.
  41605. // It returns an error if the field is not defined in the schema.
  41606. func (m *UsageTotalMutation) ResetField(name string) error {
  41607. switch name {
  41608. case usagetotal.FieldCreatedAt:
  41609. m.ResetCreatedAt()
  41610. return nil
  41611. case usagetotal.FieldUpdatedAt:
  41612. m.ResetUpdatedAt()
  41613. return nil
  41614. case usagetotal.FieldStatus:
  41615. m.ResetStatus()
  41616. return nil
  41617. case usagetotal.FieldType:
  41618. m.ResetType()
  41619. return nil
  41620. case usagetotal.FieldBotID:
  41621. m.ResetBotID()
  41622. return nil
  41623. case usagetotal.FieldTotalTokens:
  41624. m.ResetTotalTokens()
  41625. return nil
  41626. case usagetotal.FieldStartIndex:
  41627. m.ResetStartIndex()
  41628. return nil
  41629. case usagetotal.FieldEndIndex:
  41630. m.ResetEndIndex()
  41631. return nil
  41632. case usagetotal.FieldOrganizationID:
  41633. m.ResetOrganizationID()
  41634. return nil
  41635. }
  41636. return fmt.Errorf("unknown UsageTotal field %s", name)
  41637. }
  41638. // AddedEdges returns all edge names that were set/added in this mutation.
  41639. func (m *UsageTotalMutation) AddedEdges() []string {
  41640. edges := make([]string, 0, 0)
  41641. return edges
  41642. }
  41643. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41644. // name in this mutation.
  41645. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  41646. return nil
  41647. }
  41648. // RemovedEdges returns all edge names that were removed in this mutation.
  41649. func (m *UsageTotalMutation) RemovedEdges() []string {
  41650. edges := make([]string, 0, 0)
  41651. return edges
  41652. }
  41653. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41654. // the given name in this mutation.
  41655. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  41656. return nil
  41657. }
  41658. // ClearedEdges returns all edge names that were cleared in this mutation.
  41659. func (m *UsageTotalMutation) ClearedEdges() []string {
  41660. edges := make([]string, 0, 0)
  41661. return edges
  41662. }
  41663. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41664. // was cleared in this mutation.
  41665. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  41666. return false
  41667. }
  41668. // ClearEdge clears the value of the edge with the given name. It returns an error
  41669. // if that edge is not defined in the schema.
  41670. func (m *UsageTotalMutation) ClearEdge(name string) error {
  41671. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  41672. }
  41673. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41674. // It returns an error if the edge is not defined in the schema.
  41675. func (m *UsageTotalMutation) ResetEdge(name string) error {
  41676. return fmt.Errorf("unknown UsageTotal edge %s", name)
  41677. }
  41678. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  41679. type WhatsappMutation struct {
  41680. config
  41681. op Op
  41682. typ string
  41683. id *uint64
  41684. created_at *time.Time
  41685. updated_at *time.Time
  41686. status *uint8
  41687. addstatus *int8
  41688. deleted_at *time.Time
  41689. wa_id *string
  41690. wa_name *string
  41691. callback *string
  41692. account *string
  41693. cc *string
  41694. phone *string
  41695. cc_phone *string
  41696. phone_name *string
  41697. phone_status *int8
  41698. addphone_status *int8
  41699. organization_id *uint64
  41700. addorganization_id *int64
  41701. api_base *string
  41702. api_key *string
  41703. allow_list *[]string
  41704. appendallow_list []string
  41705. group_allow_list *[]string
  41706. appendgroup_allow_list []string
  41707. block_list *[]string
  41708. appendblock_list []string
  41709. group_block_list *[]string
  41710. appendgroup_block_list []string
  41711. clearedFields map[string]struct{}
  41712. agent *uint64
  41713. clearedagent bool
  41714. done bool
  41715. oldValue func(context.Context) (*Whatsapp, error)
  41716. predicates []predicate.Whatsapp
  41717. }
  41718. var _ ent.Mutation = (*WhatsappMutation)(nil)
  41719. // whatsappOption allows management of the mutation configuration using functional options.
  41720. type whatsappOption func(*WhatsappMutation)
  41721. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  41722. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  41723. m := &WhatsappMutation{
  41724. config: c,
  41725. op: op,
  41726. typ: TypeWhatsapp,
  41727. clearedFields: make(map[string]struct{}),
  41728. }
  41729. for _, opt := range opts {
  41730. opt(m)
  41731. }
  41732. return m
  41733. }
  41734. // withWhatsappID sets the ID field of the mutation.
  41735. func withWhatsappID(id uint64) whatsappOption {
  41736. return func(m *WhatsappMutation) {
  41737. var (
  41738. err error
  41739. once sync.Once
  41740. value *Whatsapp
  41741. )
  41742. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  41743. once.Do(func() {
  41744. if m.done {
  41745. err = errors.New("querying old values post mutation is not allowed")
  41746. } else {
  41747. value, err = m.Client().Whatsapp.Get(ctx, id)
  41748. }
  41749. })
  41750. return value, err
  41751. }
  41752. m.id = &id
  41753. }
  41754. }
  41755. // withWhatsapp sets the old Whatsapp of the mutation.
  41756. func withWhatsapp(node *Whatsapp) whatsappOption {
  41757. return func(m *WhatsappMutation) {
  41758. m.oldValue = func(context.Context) (*Whatsapp, error) {
  41759. return node, nil
  41760. }
  41761. m.id = &node.ID
  41762. }
  41763. }
  41764. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41765. // executed in a transaction (ent.Tx), a transactional client is returned.
  41766. func (m WhatsappMutation) Client() *Client {
  41767. client := &Client{config: m.config}
  41768. client.init()
  41769. return client
  41770. }
  41771. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41772. // it returns an error otherwise.
  41773. func (m WhatsappMutation) Tx() (*Tx, error) {
  41774. if _, ok := m.driver.(*txDriver); !ok {
  41775. return nil, errors.New("ent: mutation is not running in a transaction")
  41776. }
  41777. tx := &Tx{config: m.config}
  41778. tx.init()
  41779. return tx, nil
  41780. }
  41781. // SetID sets the value of the id field. Note that this
  41782. // operation is only accepted on creation of Whatsapp entities.
  41783. func (m *WhatsappMutation) SetID(id uint64) {
  41784. m.id = &id
  41785. }
  41786. // ID returns the ID value in the mutation. Note that the ID is only available
  41787. // if it was provided to the builder or after it was returned from the database.
  41788. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  41789. if m.id == nil {
  41790. return
  41791. }
  41792. return *m.id, true
  41793. }
  41794. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41795. // That means, if the mutation is applied within a transaction with an isolation level such
  41796. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41797. // or updated by the mutation.
  41798. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  41799. switch {
  41800. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41801. id, exists := m.ID()
  41802. if exists {
  41803. return []uint64{id}, nil
  41804. }
  41805. fallthrough
  41806. case m.op.Is(OpUpdate | OpDelete):
  41807. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  41808. default:
  41809. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41810. }
  41811. }
  41812. // SetCreatedAt sets the "created_at" field.
  41813. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  41814. m.created_at = &t
  41815. }
  41816. // CreatedAt returns the value of the "created_at" field in the mutation.
  41817. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  41818. v := m.created_at
  41819. if v == nil {
  41820. return
  41821. }
  41822. return *v, true
  41823. }
  41824. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  41825. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41827. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41828. if !m.op.Is(OpUpdateOne) {
  41829. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41830. }
  41831. if m.id == nil || m.oldValue == nil {
  41832. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41833. }
  41834. oldValue, err := m.oldValue(ctx)
  41835. if err != nil {
  41836. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41837. }
  41838. return oldValue.CreatedAt, nil
  41839. }
  41840. // ResetCreatedAt resets all changes to the "created_at" field.
  41841. func (m *WhatsappMutation) ResetCreatedAt() {
  41842. m.created_at = nil
  41843. }
  41844. // SetUpdatedAt sets the "updated_at" field.
  41845. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  41846. m.updated_at = &t
  41847. }
  41848. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41849. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  41850. v := m.updated_at
  41851. if v == nil {
  41852. return
  41853. }
  41854. return *v, true
  41855. }
  41856. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  41857. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41859. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41860. if !m.op.Is(OpUpdateOne) {
  41861. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41862. }
  41863. if m.id == nil || m.oldValue == nil {
  41864. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41865. }
  41866. oldValue, err := m.oldValue(ctx)
  41867. if err != nil {
  41868. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41869. }
  41870. return oldValue.UpdatedAt, nil
  41871. }
  41872. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41873. func (m *WhatsappMutation) ResetUpdatedAt() {
  41874. m.updated_at = nil
  41875. }
  41876. // SetStatus sets the "status" field.
  41877. func (m *WhatsappMutation) SetStatus(u uint8) {
  41878. m.status = &u
  41879. m.addstatus = nil
  41880. }
  41881. // Status returns the value of the "status" field in the mutation.
  41882. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  41883. v := m.status
  41884. if v == nil {
  41885. return
  41886. }
  41887. return *v, true
  41888. }
  41889. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  41890. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41892. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41893. if !m.op.Is(OpUpdateOne) {
  41894. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41895. }
  41896. if m.id == nil || m.oldValue == nil {
  41897. return v, errors.New("OldStatus requires an ID field in the mutation")
  41898. }
  41899. oldValue, err := m.oldValue(ctx)
  41900. if err != nil {
  41901. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41902. }
  41903. return oldValue.Status, nil
  41904. }
  41905. // AddStatus adds u to the "status" field.
  41906. func (m *WhatsappMutation) AddStatus(u int8) {
  41907. if m.addstatus != nil {
  41908. *m.addstatus += u
  41909. } else {
  41910. m.addstatus = &u
  41911. }
  41912. }
  41913. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41914. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  41915. v := m.addstatus
  41916. if v == nil {
  41917. return
  41918. }
  41919. return *v, true
  41920. }
  41921. // ClearStatus clears the value of the "status" field.
  41922. func (m *WhatsappMutation) ClearStatus() {
  41923. m.status = nil
  41924. m.addstatus = nil
  41925. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  41926. }
  41927. // StatusCleared returns if the "status" field was cleared in this mutation.
  41928. func (m *WhatsappMutation) StatusCleared() bool {
  41929. _, ok := m.clearedFields[whatsapp.FieldStatus]
  41930. return ok
  41931. }
  41932. // ResetStatus resets all changes to the "status" field.
  41933. func (m *WhatsappMutation) ResetStatus() {
  41934. m.status = nil
  41935. m.addstatus = nil
  41936. delete(m.clearedFields, whatsapp.FieldStatus)
  41937. }
  41938. // SetDeletedAt sets the "deleted_at" field.
  41939. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  41940. m.deleted_at = &t
  41941. }
  41942. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41943. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  41944. v := m.deleted_at
  41945. if v == nil {
  41946. return
  41947. }
  41948. return *v, true
  41949. }
  41950. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  41951. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41953. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41954. if !m.op.Is(OpUpdateOne) {
  41955. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41956. }
  41957. if m.id == nil || m.oldValue == nil {
  41958. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41959. }
  41960. oldValue, err := m.oldValue(ctx)
  41961. if err != nil {
  41962. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41963. }
  41964. return oldValue.DeletedAt, nil
  41965. }
  41966. // ClearDeletedAt clears the value of the "deleted_at" field.
  41967. func (m *WhatsappMutation) ClearDeletedAt() {
  41968. m.deleted_at = nil
  41969. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  41970. }
  41971. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41972. func (m *WhatsappMutation) DeletedAtCleared() bool {
  41973. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  41974. return ok
  41975. }
  41976. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41977. func (m *WhatsappMutation) ResetDeletedAt() {
  41978. m.deleted_at = nil
  41979. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  41980. }
  41981. // SetWaID sets the "wa_id" field.
  41982. func (m *WhatsappMutation) SetWaID(s string) {
  41983. m.wa_id = &s
  41984. }
  41985. // WaID returns the value of the "wa_id" field in the mutation.
  41986. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  41987. v := m.wa_id
  41988. if v == nil {
  41989. return
  41990. }
  41991. return *v, true
  41992. }
  41993. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  41994. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41996. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  41997. if !m.op.Is(OpUpdateOne) {
  41998. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41999. }
  42000. if m.id == nil || m.oldValue == nil {
  42001. return v, errors.New("OldWaID requires an ID field in the mutation")
  42002. }
  42003. oldValue, err := m.oldValue(ctx)
  42004. if err != nil {
  42005. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42006. }
  42007. return oldValue.WaID, nil
  42008. }
  42009. // ClearWaID clears the value of the "wa_id" field.
  42010. func (m *WhatsappMutation) ClearWaID() {
  42011. m.wa_id = nil
  42012. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  42013. }
  42014. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42015. func (m *WhatsappMutation) WaIDCleared() bool {
  42016. _, ok := m.clearedFields[whatsapp.FieldWaID]
  42017. return ok
  42018. }
  42019. // ResetWaID resets all changes to the "wa_id" field.
  42020. func (m *WhatsappMutation) ResetWaID() {
  42021. m.wa_id = nil
  42022. delete(m.clearedFields, whatsapp.FieldWaID)
  42023. }
  42024. // SetWaName sets the "wa_name" field.
  42025. func (m *WhatsappMutation) SetWaName(s string) {
  42026. m.wa_name = &s
  42027. }
  42028. // WaName returns the value of the "wa_name" field in the mutation.
  42029. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  42030. v := m.wa_name
  42031. if v == nil {
  42032. return
  42033. }
  42034. return *v, true
  42035. }
  42036. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  42037. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42039. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  42040. if !m.op.Is(OpUpdateOne) {
  42041. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42042. }
  42043. if m.id == nil || m.oldValue == nil {
  42044. return v, errors.New("OldWaName requires an ID field in the mutation")
  42045. }
  42046. oldValue, err := m.oldValue(ctx)
  42047. if err != nil {
  42048. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42049. }
  42050. return oldValue.WaName, nil
  42051. }
  42052. // ClearWaName clears the value of the "wa_name" field.
  42053. func (m *WhatsappMutation) ClearWaName() {
  42054. m.wa_name = nil
  42055. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  42056. }
  42057. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42058. func (m *WhatsappMutation) WaNameCleared() bool {
  42059. _, ok := m.clearedFields[whatsapp.FieldWaName]
  42060. return ok
  42061. }
  42062. // ResetWaName resets all changes to the "wa_name" field.
  42063. func (m *WhatsappMutation) ResetWaName() {
  42064. m.wa_name = nil
  42065. delete(m.clearedFields, whatsapp.FieldWaName)
  42066. }
  42067. // SetCallback sets the "callback" field.
  42068. func (m *WhatsappMutation) SetCallback(s string) {
  42069. m.callback = &s
  42070. }
  42071. // Callback returns the value of the "callback" field in the mutation.
  42072. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  42073. v := m.callback
  42074. if v == nil {
  42075. return
  42076. }
  42077. return *v, true
  42078. }
  42079. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  42080. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42082. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  42083. if !m.op.Is(OpUpdateOne) {
  42084. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42085. }
  42086. if m.id == nil || m.oldValue == nil {
  42087. return v, errors.New("OldCallback requires an ID field in the mutation")
  42088. }
  42089. oldValue, err := m.oldValue(ctx)
  42090. if err != nil {
  42091. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42092. }
  42093. return oldValue.Callback, nil
  42094. }
  42095. // ClearCallback clears the value of the "callback" field.
  42096. func (m *WhatsappMutation) ClearCallback() {
  42097. m.callback = nil
  42098. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  42099. }
  42100. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  42101. func (m *WhatsappMutation) CallbackCleared() bool {
  42102. _, ok := m.clearedFields[whatsapp.FieldCallback]
  42103. return ok
  42104. }
  42105. // ResetCallback resets all changes to the "callback" field.
  42106. func (m *WhatsappMutation) ResetCallback() {
  42107. m.callback = nil
  42108. delete(m.clearedFields, whatsapp.FieldCallback)
  42109. }
  42110. // SetAgentID sets the "agent_id" field.
  42111. func (m *WhatsappMutation) SetAgentID(u uint64) {
  42112. m.agent = &u
  42113. }
  42114. // AgentID returns the value of the "agent_id" field in the mutation.
  42115. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  42116. v := m.agent
  42117. if v == nil {
  42118. return
  42119. }
  42120. return *v, true
  42121. }
  42122. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  42123. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42125. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42126. if !m.op.Is(OpUpdateOne) {
  42127. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42128. }
  42129. if m.id == nil || m.oldValue == nil {
  42130. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42131. }
  42132. oldValue, err := m.oldValue(ctx)
  42133. if err != nil {
  42134. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42135. }
  42136. return oldValue.AgentID, nil
  42137. }
  42138. // ResetAgentID resets all changes to the "agent_id" field.
  42139. func (m *WhatsappMutation) ResetAgentID() {
  42140. m.agent = nil
  42141. }
  42142. // SetAccount sets the "account" field.
  42143. func (m *WhatsappMutation) SetAccount(s string) {
  42144. m.account = &s
  42145. }
  42146. // Account returns the value of the "account" field in the mutation.
  42147. func (m *WhatsappMutation) Account() (r string, exists bool) {
  42148. v := m.account
  42149. if v == nil {
  42150. return
  42151. }
  42152. return *v, true
  42153. }
  42154. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  42155. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42157. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  42158. if !m.op.Is(OpUpdateOne) {
  42159. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42160. }
  42161. if m.id == nil || m.oldValue == nil {
  42162. return v, errors.New("OldAccount requires an ID field in the mutation")
  42163. }
  42164. oldValue, err := m.oldValue(ctx)
  42165. if err != nil {
  42166. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42167. }
  42168. return oldValue.Account, nil
  42169. }
  42170. // ClearAccount clears the value of the "account" field.
  42171. func (m *WhatsappMutation) ClearAccount() {
  42172. m.account = nil
  42173. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  42174. }
  42175. // AccountCleared returns if the "account" field was cleared in this mutation.
  42176. func (m *WhatsappMutation) AccountCleared() bool {
  42177. _, ok := m.clearedFields[whatsapp.FieldAccount]
  42178. return ok
  42179. }
  42180. // ResetAccount resets all changes to the "account" field.
  42181. func (m *WhatsappMutation) ResetAccount() {
  42182. m.account = nil
  42183. delete(m.clearedFields, whatsapp.FieldAccount)
  42184. }
  42185. // SetCc sets the "cc" field.
  42186. func (m *WhatsappMutation) SetCc(s string) {
  42187. m.cc = &s
  42188. }
  42189. // Cc returns the value of the "cc" field in the mutation.
  42190. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  42191. v := m.cc
  42192. if v == nil {
  42193. return
  42194. }
  42195. return *v, true
  42196. }
  42197. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  42198. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42200. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  42201. if !m.op.Is(OpUpdateOne) {
  42202. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  42203. }
  42204. if m.id == nil || m.oldValue == nil {
  42205. return v, errors.New("OldCc requires an ID field in the mutation")
  42206. }
  42207. oldValue, err := m.oldValue(ctx)
  42208. if err != nil {
  42209. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  42210. }
  42211. return oldValue.Cc, nil
  42212. }
  42213. // ResetCc resets all changes to the "cc" field.
  42214. func (m *WhatsappMutation) ResetCc() {
  42215. m.cc = nil
  42216. }
  42217. // SetPhone sets the "phone" field.
  42218. func (m *WhatsappMutation) SetPhone(s string) {
  42219. m.phone = &s
  42220. }
  42221. // Phone returns the value of the "phone" field in the mutation.
  42222. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  42223. v := m.phone
  42224. if v == nil {
  42225. return
  42226. }
  42227. return *v, true
  42228. }
  42229. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  42230. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42232. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  42233. if !m.op.Is(OpUpdateOne) {
  42234. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42235. }
  42236. if m.id == nil || m.oldValue == nil {
  42237. return v, errors.New("OldPhone requires an ID field in the mutation")
  42238. }
  42239. oldValue, err := m.oldValue(ctx)
  42240. if err != nil {
  42241. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42242. }
  42243. return oldValue.Phone, nil
  42244. }
  42245. // ResetPhone resets all changes to the "phone" field.
  42246. func (m *WhatsappMutation) ResetPhone() {
  42247. m.phone = nil
  42248. }
  42249. // SetCcPhone sets the "cc_phone" field.
  42250. func (m *WhatsappMutation) SetCcPhone(s string) {
  42251. m.cc_phone = &s
  42252. }
  42253. // CcPhone returns the value of the "cc_phone" field in the mutation.
  42254. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  42255. v := m.cc_phone
  42256. if v == nil {
  42257. return
  42258. }
  42259. return *v, true
  42260. }
  42261. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  42262. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42264. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  42265. if !m.op.Is(OpUpdateOne) {
  42266. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  42267. }
  42268. if m.id == nil || m.oldValue == nil {
  42269. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  42270. }
  42271. oldValue, err := m.oldValue(ctx)
  42272. if err != nil {
  42273. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  42274. }
  42275. return oldValue.CcPhone, nil
  42276. }
  42277. // ResetCcPhone resets all changes to the "cc_phone" field.
  42278. func (m *WhatsappMutation) ResetCcPhone() {
  42279. m.cc_phone = nil
  42280. }
  42281. // SetPhoneName sets the "phone_name" field.
  42282. func (m *WhatsappMutation) SetPhoneName(s string) {
  42283. m.phone_name = &s
  42284. }
  42285. // PhoneName returns the value of the "phone_name" field in the mutation.
  42286. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  42287. v := m.phone_name
  42288. if v == nil {
  42289. return
  42290. }
  42291. return *v, true
  42292. }
  42293. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  42294. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42296. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  42297. if !m.op.Is(OpUpdateOne) {
  42298. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  42299. }
  42300. if m.id == nil || m.oldValue == nil {
  42301. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  42302. }
  42303. oldValue, err := m.oldValue(ctx)
  42304. if err != nil {
  42305. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  42306. }
  42307. return oldValue.PhoneName, nil
  42308. }
  42309. // ResetPhoneName resets all changes to the "phone_name" field.
  42310. func (m *WhatsappMutation) ResetPhoneName() {
  42311. m.phone_name = nil
  42312. }
  42313. // SetPhoneStatus sets the "phone_status" field.
  42314. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  42315. m.phone_status = &i
  42316. m.addphone_status = nil
  42317. }
  42318. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  42319. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  42320. v := m.phone_status
  42321. if v == nil {
  42322. return
  42323. }
  42324. return *v, true
  42325. }
  42326. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  42327. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42329. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  42330. if !m.op.Is(OpUpdateOne) {
  42331. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  42332. }
  42333. if m.id == nil || m.oldValue == nil {
  42334. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  42335. }
  42336. oldValue, err := m.oldValue(ctx)
  42337. if err != nil {
  42338. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  42339. }
  42340. return oldValue.PhoneStatus, nil
  42341. }
  42342. // AddPhoneStatus adds i to the "phone_status" field.
  42343. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  42344. if m.addphone_status != nil {
  42345. *m.addphone_status += i
  42346. } else {
  42347. m.addphone_status = &i
  42348. }
  42349. }
  42350. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  42351. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  42352. v := m.addphone_status
  42353. if v == nil {
  42354. return
  42355. }
  42356. return *v, true
  42357. }
  42358. // ResetPhoneStatus resets all changes to the "phone_status" field.
  42359. func (m *WhatsappMutation) ResetPhoneStatus() {
  42360. m.phone_status = nil
  42361. m.addphone_status = nil
  42362. }
  42363. // SetOrganizationID sets the "organization_id" field.
  42364. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  42365. m.organization_id = &u
  42366. m.addorganization_id = nil
  42367. }
  42368. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42369. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  42370. v := m.organization_id
  42371. if v == nil {
  42372. return
  42373. }
  42374. return *v, true
  42375. }
  42376. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  42377. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42379. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42380. if !m.op.Is(OpUpdateOne) {
  42381. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42382. }
  42383. if m.id == nil || m.oldValue == nil {
  42384. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42385. }
  42386. oldValue, err := m.oldValue(ctx)
  42387. if err != nil {
  42388. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42389. }
  42390. return oldValue.OrganizationID, nil
  42391. }
  42392. // AddOrganizationID adds u to the "organization_id" field.
  42393. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  42394. if m.addorganization_id != nil {
  42395. *m.addorganization_id += u
  42396. } else {
  42397. m.addorganization_id = &u
  42398. }
  42399. }
  42400. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42401. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  42402. v := m.addorganization_id
  42403. if v == nil {
  42404. return
  42405. }
  42406. return *v, true
  42407. }
  42408. // ClearOrganizationID clears the value of the "organization_id" field.
  42409. func (m *WhatsappMutation) ClearOrganizationID() {
  42410. m.organization_id = nil
  42411. m.addorganization_id = nil
  42412. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  42413. }
  42414. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42415. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  42416. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  42417. return ok
  42418. }
  42419. // ResetOrganizationID resets all changes to the "organization_id" field.
  42420. func (m *WhatsappMutation) ResetOrganizationID() {
  42421. m.organization_id = nil
  42422. m.addorganization_id = nil
  42423. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  42424. }
  42425. // SetAPIBase sets the "api_base" field.
  42426. func (m *WhatsappMutation) SetAPIBase(s string) {
  42427. m.api_base = &s
  42428. }
  42429. // APIBase returns the value of the "api_base" field in the mutation.
  42430. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  42431. v := m.api_base
  42432. if v == nil {
  42433. return
  42434. }
  42435. return *v, true
  42436. }
  42437. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  42438. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42440. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42441. if !m.op.Is(OpUpdateOne) {
  42442. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42443. }
  42444. if m.id == nil || m.oldValue == nil {
  42445. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42446. }
  42447. oldValue, err := m.oldValue(ctx)
  42448. if err != nil {
  42449. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42450. }
  42451. return oldValue.APIBase, nil
  42452. }
  42453. // ClearAPIBase clears the value of the "api_base" field.
  42454. func (m *WhatsappMutation) ClearAPIBase() {
  42455. m.api_base = nil
  42456. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  42457. }
  42458. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42459. func (m *WhatsappMutation) APIBaseCleared() bool {
  42460. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  42461. return ok
  42462. }
  42463. // ResetAPIBase resets all changes to the "api_base" field.
  42464. func (m *WhatsappMutation) ResetAPIBase() {
  42465. m.api_base = nil
  42466. delete(m.clearedFields, whatsapp.FieldAPIBase)
  42467. }
  42468. // SetAPIKey sets the "api_key" field.
  42469. func (m *WhatsappMutation) SetAPIKey(s string) {
  42470. m.api_key = &s
  42471. }
  42472. // APIKey returns the value of the "api_key" field in the mutation.
  42473. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  42474. v := m.api_key
  42475. if v == nil {
  42476. return
  42477. }
  42478. return *v, true
  42479. }
  42480. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  42481. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42483. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42484. if !m.op.Is(OpUpdateOne) {
  42485. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42486. }
  42487. if m.id == nil || m.oldValue == nil {
  42488. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42489. }
  42490. oldValue, err := m.oldValue(ctx)
  42491. if err != nil {
  42492. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42493. }
  42494. return oldValue.APIKey, nil
  42495. }
  42496. // ClearAPIKey clears the value of the "api_key" field.
  42497. func (m *WhatsappMutation) ClearAPIKey() {
  42498. m.api_key = nil
  42499. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  42500. }
  42501. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42502. func (m *WhatsappMutation) APIKeyCleared() bool {
  42503. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  42504. return ok
  42505. }
  42506. // ResetAPIKey resets all changes to the "api_key" field.
  42507. func (m *WhatsappMutation) ResetAPIKey() {
  42508. m.api_key = nil
  42509. delete(m.clearedFields, whatsapp.FieldAPIKey)
  42510. }
  42511. // SetAllowList sets the "allow_list" field.
  42512. func (m *WhatsappMutation) SetAllowList(s []string) {
  42513. m.allow_list = &s
  42514. m.appendallow_list = nil
  42515. }
  42516. // AllowList returns the value of the "allow_list" field in the mutation.
  42517. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  42518. v := m.allow_list
  42519. if v == nil {
  42520. return
  42521. }
  42522. return *v, true
  42523. }
  42524. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  42525. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42527. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42528. if !m.op.Is(OpUpdateOne) {
  42529. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42530. }
  42531. if m.id == nil || m.oldValue == nil {
  42532. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42533. }
  42534. oldValue, err := m.oldValue(ctx)
  42535. if err != nil {
  42536. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42537. }
  42538. return oldValue.AllowList, nil
  42539. }
  42540. // AppendAllowList adds s to the "allow_list" field.
  42541. func (m *WhatsappMutation) AppendAllowList(s []string) {
  42542. m.appendallow_list = append(m.appendallow_list, s...)
  42543. }
  42544. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42545. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  42546. if len(m.appendallow_list) == 0 {
  42547. return nil, false
  42548. }
  42549. return m.appendallow_list, true
  42550. }
  42551. // ClearAllowList clears the value of the "allow_list" field.
  42552. func (m *WhatsappMutation) ClearAllowList() {
  42553. m.allow_list = nil
  42554. m.appendallow_list = nil
  42555. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  42556. }
  42557. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  42558. func (m *WhatsappMutation) AllowListCleared() bool {
  42559. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  42560. return ok
  42561. }
  42562. // ResetAllowList resets all changes to the "allow_list" field.
  42563. func (m *WhatsappMutation) ResetAllowList() {
  42564. m.allow_list = nil
  42565. m.appendallow_list = nil
  42566. delete(m.clearedFields, whatsapp.FieldAllowList)
  42567. }
  42568. // SetGroupAllowList sets the "group_allow_list" field.
  42569. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  42570. m.group_allow_list = &s
  42571. m.appendgroup_allow_list = nil
  42572. }
  42573. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42574. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  42575. v := m.group_allow_list
  42576. if v == nil {
  42577. return
  42578. }
  42579. return *v, true
  42580. }
  42581. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  42582. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42584. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42585. if !m.op.Is(OpUpdateOne) {
  42586. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42587. }
  42588. if m.id == nil || m.oldValue == nil {
  42589. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42590. }
  42591. oldValue, err := m.oldValue(ctx)
  42592. if err != nil {
  42593. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42594. }
  42595. return oldValue.GroupAllowList, nil
  42596. }
  42597. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42598. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  42599. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42600. }
  42601. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42602. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  42603. if len(m.appendgroup_allow_list) == 0 {
  42604. return nil, false
  42605. }
  42606. return m.appendgroup_allow_list, true
  42607. }
  42608. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  42609. func (m *WhatsappMutation) ClearGroupAllowList() {
  42610. m.group_allow_list = nil
  42611. m.appendgroup_allow_list = nil
  42612. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  42613. }
  42614. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  42615. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  42616. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  42617. return ok
  42618. }
  42619. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42620. func (m *WhatsappMutation) ResetGroupAllowList() {
  42621. m.group_allow_list = nil
  42622. m.appendgroup_allow_list = nil
  42623. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  42624. }
  42625. // SetBlockList sets the "block_list" field.
  42626. func (m *WhatsappMutation) SetBlockList(s []string) {
  42627. m.block_list = &s
  42628. m.appendblock_list = nil
  42629. }
  42630. // BlockList returns the value of the "block_list" field in the mutation.
  42631. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  42632. v := m.block_list
  42633. if v == nil {
  42634. return
  42635. }
  42636. return *v, true
  42637. }
  42638. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  42639. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42641. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42642. if !m.op.Is(OpUpdateOne) {
  42643. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42644. }
  42645. if m.id == nil || m.oldValue == nil {
  42646. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42647. }
  42648. oldValue, err := m.oldValue(ctx)
  42649. if err != nil {
  42650. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42651. }
  42652. return oldValue.BlockList, nil
  42653. }
  42654. // AppendBlockList adds s to the "block_list" field.
  42655. func (m *WhatsappMutation) AppendBlockList(s []string) {
  42656. m.appendblock_list = append(m.appendblock_list, s...)
  42657. }
  42658. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42659. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  42660. if len(m.appendblock_list) == 0 {
  42661. return nil, false
  42662. }
  42663. return m.appendblock_list, true
  42664. }
  42665. // ClearBlockList clears the value of the "block_list" field.
  42666. func (m *WhatsappMutation) ClearBlockList() {
  42667. m.block_list = nil
  42668. m.appendblock_list = nil
  42669. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  42670. }
  42671. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  42672. func (m *WhatsappMutation) BlockListCleared() bool {
  42673. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  42674. return ok
  42675. }
  42676. // ResetBlockList resets all changes to the "block_list" field.
  42677. func (m *WhatsappMutation) ResetBlockList() {
  42678. m.block_list = nil
  42679. m.appendblock_list = nil
  42680. delete(m.clearedFields, whatsapp.FieldBlockList)
  42681. }
  42682. // SetGroupBlockList sets the "group_block_list" field.
  42683. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  42684. m.group_block_list = &s
  42685. m.appendgroup_block_list = nil
  42686. }
  42687. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42688. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  42689. v := m.group_block_list
  42690. if v == nil {
  42691. return
  42692. }
  42693. return *v, true
  42694. }
  42695. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  42696. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42698. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42699. if !m.op.Is(OpUpdateOne) {
  42700. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42701. }
  42702. if m.id == nil || m.oldValue == nil {
  42703. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42704. }
  42705. oldValue, err := m.oldValue(ctx)
  42706. if err != nil {
  42707. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42708. }
  42709. return oldValue.GroupBlockList, nil
  42710. }
  42711. // AppendGroupBlockList adds s to the "group_block_list" field.
  42712. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  42713. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42714. }
  42715. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42716. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  42717. if len(m.appendgroup_block_list) == 0 {
  42718. return nil, false
  42719. }
  42720. return m.appendgroup_block_list, true
  42721. }
  42722. // ClearGroupBlockList clears the value of the "group_block_list" field.
  42723. func (m *WhatsappMutation) ClearGroupBlockList() {
  42724. m.group_block_list = nil
  42725. m.appendgroup_block_list = nil
  42726. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  42727. }
  42728. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  42729. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  42730. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  42731. return ok
  42732. }
  42733. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42734. func (m *WhatsappMutation) ResetGroupBlockList() {
  42735. m.group_block_list = nil
  42736. m.appendgroup_block_list = nil
  42737. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  42738. }
  42739. // ClearAgent clears the "agent" edge to the Agent entity.
  42740. func (m *WhatsappMutation) ClearAgent() {
  42741. m.clearedagent = true
  42742. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  42743. }
  42744. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42745. func (m *WhatsappMutation) AgentCleared() bool {
  42746. return m.clearedagent
  42747. }
  42748. // AgentIDs returns the "agent" edge IDs in the mutation.
  42749. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42750. // AgentID instead. It exists only for internal usage by the builders.
  42751. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  42752. if id := m.agent; id != nil {
  42753. ids = append(ids, *id)
  42754. }
  42755. return
  42756. }
  42757. // ResetAgent resets all changes to the "agent" edge.
  42758. func (m *WhatsappMutation) ResetAgent() {
  42759. m.agent = nil
  42760. m.clearedagent = false
  42761. }
  42762. // Where appends a list predicates to the WhatsappMutation builder.
  42763. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  42764. m.predicates = append(m.predicates, ps...)
  42765. }
  42766. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  42767. // users can use type-assertion to append predicates that do not depend on any generated package.
  42768. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  42769. p := make([]predicate.Whatsapp, len(ps))
  42770. for i := range ps {
  42771. p[i] = ps[i]
  42772. }
  42773. m.Where(p...)
  42774. }
  42775. // Op returns the operation name.
  42776. func (m *WhatsappMutation) Op() Op {
  42777. return m.op
  42778. }
  42779. // SetOp allows setting the mutation operation.
  42780. func (m *WhatsappMutation) SetOp(op Op) {
  42781. m.op = op
  42782. }
  42783. // Type returns the node type of this mutation (Whatsapp).
  42784. func (m *WhatsappMutation) Type() string {
  42785. return m.typ
  42786. }
  42787. // Fields returns all fields that were changed during this mutation. Note that in
  42788. // order to get all numeric fields that were incremented/decremented, call
  42789. // AddedFields().
  42790. func (m *WhatsappMutation) Fields() []string {
  42791. fields := make([]string, 0, 21)
  42792. if m.created_at != nil {
  42793. fields = append(fields, whatsapp.FieldCreatedAt)
  42794. }
  42795. if m.updated_at != nil {
  42796. fields = append(fields, whatsapp.FieldUpdatedAt)
  42797. }
  42798. if m.status != nil {
  42799. fields = append(fields, whatsapp.FieldStatus)
  42800. }
  42801. if m.deleted_at != nil {
  42802. fields = append(fields, whatsapp.FieldDeletedAt)
  42803. }
  42804. if m.wa_id != nil {
  42805. fields = append(fields, whatsapp.FieldWaID)
  42806. }
  42807. if m.wa_name != nil {
  42808. fields = append(fields, whatsapp.FieldWaName)
  42809. }
  42810. if m.callback != nil {
  42811. fields = append(fields, whatsapp.FieldCallback)
  42812. }
  42813. if m.agent != nil {
  42814. fields = append(fields, whatsapp.FieldAgentID)
  42815. }
  42816. if m.account != nil {
  42817. fields = append(fields, whatsapp.FieldAccount)
  42818. }
  42819. if m.cc != nil {
  42820. fields = append(fields, whatsapp.FieldCc)
  42821. }
  42822. if m.phone != nil {
  42823. fields = append(fields, whatsapp.FieldPhone)
  42824. }
  42825. if m.cc_phone != nil {
  42826. fields = append(fields, whatsapp.FieldCcPhone)
  42827. }
  42828. if m.phone_name != nil {
  42829. fields = append(fields, whatsapp.FieldPhoneName)
  42830. }
  42831. if m.phone_status != nil {
  42832. fields = append(fields, whatsapp.FieldPhoneStatus)
  42833. }
  42834. if m.organization_id != nil {
  42835. fields = append(fields, whatsapp.FieldOrganizationID)
  42836. }
  42837. if m.api_base != nil {
  42838. fields = append(fields, whatsapp.FieldAPIBase)
  42839. }
  42840. if m.api_key != nil {
  42841. fields = append(fields, whatsapp.FieldAPIKey)
  42842. }
  42843. if m.allow_list != nil {
  42844. fields = append(fields, whatsapp.FieldAllowList)
  42845. }
  42846. if m.group_allow_list != nil {
  42847. fields = append(fields, whatsapp.FieldGroupAllowList)
  42848. }
  42849. if m.block_list != nil {
  42850. fields = append(fields, whatsapp.FieldBlockList)
  42851. }
  42852. if m.group_block_list != nil {
  42853. fields = append(fields, whatsapp.FieldGroupBlockList)
  42854. }
  42855. return fields
  42856. }
  42857. // Field returns the value of a field with the given name. The second boolean
  42858. // return value indicates that this field was not set, or was not defined in the
  42859. // schema.
  42860. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  42861. switch name {
  42862. case whatsapp.FieldCreatedAt:
  42863. return m.CreatedAt()
  42864. case whatsapp.FieldUpdatedAt:
  42865. return m.UpdatedAt()
  42866. case whatsapp.FieldStatus:
  42867. return m.Status()
  42868. case whatsapp.FieldDeletedAt:
  42869. return m.DeletedAt()
  42870. case whatsapp.FieldWaID:
  42871. return m.WaID()
  42872. case whatsapp.FieldWaName:
  42873. return m.WaName()
  42874. case whatsapp.FieldCallback:
  42875. return m.Callback()
  42876. case whatsapp.FieldAgentID:
  42877. return m.AgentID()
  42878. case whatsapp.FieldAccount:
  42879. return m.Account()
  42880. case whatsapp.FieldCc:
  42881. return m.Cc()
  42882. case whatsapp.FieldPhone:
  42883. return m.Phone()
  42884. case whatsapp.FieldCcPhone:
  42885. return m.CcPhone()
  42886. case whatsapp.FieldPhoneName:
  42887. return m.PhoneName()
  42888. case whatsapp.FieldPhoneStatus:
  42889. return m.PhoneStatus()
  42890. case whatsapp.FieldOrganizationID:
  42891. return m.OrganizationID()
  42892. case whatsapp.FieldAPIBase:
  42893. return m.APIBase()
  42894. case whatsapp.FieldAPIKey:
  42895. return m.APIKey()
  42896. case whatsapp.FieldAllowList:
  42897. return m.AllowList()
  42898. case whatsapp.FieldGroupAllowList:
  42899. return m.GroupAllowList()
  42900. case whatsapp.FieldBlockList:
  42901. return m.BlockList()
  42902. case whatsapp.FieldGroupBlockList:
  42903. return m.GroupBlockList()
  42904. }
  42905. return nil, false
  42906. }
  42907. // OldField returns the old value of the field from the database. An error is
  42908. // returned if the mutation operation is not UpdateOne, or the query to the
  42909. // database failed.
  42910. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42911. switch name {
  42912. case whatsapp.FieldCreatedAt:
  42913. return m.OldCreatedAt(ctx)
  42914. case whatsapp.FieldUpdatedAt:
  42915. return m.OldUpdatedAt(ctx)
  42916. case whatsapp.FieldStatus:
  42917. return m.OldStatus(ctx)
  42918. case whatsapp.FieldDeletedAt:
  42919. return m.OldDeletedAt(ctx)
  42920. case whatsapp.FieldWaID:
  42921. return m.OldWaID(ctx)
  42922. case whatsapp.FieldWaName:
  42923. return m.OldWaName(ctx)
  42924. case whatsapp.FieldCallback:
  42925. return m.OldCallback(ctx)
  42926. case whatsapp.FieldAgentID:
  42927. return m.OldAgentID(ctx)
  42928. case whatsapp.FieldAccount:
  42929. return m.OldAccount(ctx)
  42930. case whatsapp.FieldCc:
  42931. return m.OldCc(ctx)
  42932. case whatsapp.FieldPhone:
  42933. return m.OldPhone(ctx)
  42934. case whatsapp.FieldCcPhone:
  42935. return m.OldCcPhone(ctx)
  42936. case whatsapp.FieldPhoneName:
  42937. return m.OldPhoneName(ctx)
  42938. case whatsapp.FieldPhoneStatus:
  42939. return m.OldPhoneStatus(ctx)
  42940. case whatsapp.FieldOrganizationID:
  42941. return m.OldOrganizationID(ctx)
  42942. case whatsapp.FieldAPIBase:
  42943. return m.OldAPIBase(ctx)
  42944. case whatsapp.FieldAPIKey:
  42945. return m.OldAPIKey(ctx)
  42946. case whatsapp.FieldAllowList:
  42947. return m.OldAllowList(ctx)
  42948. case whatsapp.FieldGroupAllowList:
  42949. return m.OldGroupAllowList(ctx)
  42950. case whatsapp.FieldBlockList:
  42951. return m.OldBlockList(ctx)
  42952. case whatsapp.FieldGroupBlockList:
  42953. return m.OldGroupBlockList(ctx)
  42954. }
  42955. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  42956. }
  42957. // SetField sets the value of a field with the given name. It returns an error if
  42958. // the field is not defined in the schema, or if the type mismatched the field
  42959. // type.
  42960. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  42961. switch name {
  42962. case whatsapp.FieldCreatedAt:
  42963. v, ok := value.(time.Time)
  42964. if !ok {
  42965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42966. }
  42967. m.SetCreatedAt(v)
  42968. return nil
  42969. case whatsapp.FieldUpdatedAt:
  42970. v, ok := value.(time.Time)
  42971. if !ok {
  42972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42973. }
  42974. m.SetUpdatedAt(v)
  42975. return nil
  42976. case whatsapp.FieldStatus:
  42977. v, ok := value.(uint8)
  42978. if !ok {
  42979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42980. }
  42981. m.SetStatus(v)
  42982. return nil
  42983. case whatsapp.FieldDeletedAt:
  42984. v, ok := value.(time.Time)
  42985. if !ok {
  42986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42987. }
  42988. m.SetDeletedAt(v)
  42989. return nil
  42990. case whatsapp.FieldWaID:
  42991. v, ok := value.(string)
  42992. if !ok {
  42993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42994. }
  42995. m.SetWaID(v)
  42996. return nil
  42997. case whatsapp.FieldWaName:
  42998. v, ok := value.(string)
  42999. if !ok {
  43000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43001. }
  43002. m.SetWaName(v)
  43003. return nil
  43004. case whatsapp.FieldCallback:
  43005. v, ok := value.(string)
  43006. if !ok {
  43007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43008. }
  43009. m.SetCallback(v)
  43010. return nil
  43011. case whatsapp.FieldAgentID:
  43012. v, ok := value.(uint64)
  43013. if !ok {
  43014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43015. }
  43016. m.SetAgentID(v)
  43017. return nil
  43018. case whatsapp.FieldAccount:
  43019. v, ok := value.(string)
  43020. if !ok {
  43021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43022. }
  43023. m.SetAccount(v)
  43024. return nil
  43025. case whatsapp.FieldCc:
  43026. v, ok := value.(string)
  43027. if !ok {
  43028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43029. }
  43030. m.SetCc(v)
  43031. return nil
  43032. case whatsapp.FieldPhone:
  43033. v, ok := value.(string)
  43034. if !ok {
  43035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43036. }
  43037. m.SetPhone(v)
  43038. return nil
  43039. case whatsapp.FieldCcPhone:
  43040. v, ok := value.(string)
  43041. if !ok {
  43042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43043. }
  43044. m.SetCcPhone(v)
  43045. return nil
  43046. case whatsapp.FieldPhoneName:
  43047. v, ok := value.(string)
  43048. if !ok {
  43049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43050. }
  43051. m.SetPhoneName(v)
  43052. return nil
  43053. case whatsapp.FieldPhoneStatus:
  43054. v, ok := value.(int8)
  43055. if !ok {
  43056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43057. }
  43058. m.SetPhoneStatus(v)
  43059. return nil
  43060. case whatsapp.FieldOrganizationID:
  43061. v, ok := value.(uint64)
  43062. if !ok {
  43063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43064. }
  43065. m.SetOrganizationID(v)
  43066. return nil
  43067. case whatsapp.FieldAPIBase:
  43068. v, ok := value.(string)
  43069. if !ok {
  43070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43071. }
  43072. m.SetAPIBase(v)
  43073. return nil
  43074. case whatsapp.FieldAPIKey:
  43075. v, ok := value.(string)
  43076. if !ok {
  43077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43078. }
  43079. m.SetAPIKey(v)
  43080. return nil
  43081. case whatsapp.FieldAllowList:
  43082. v, ok := value.([]string)
  43083. if !ok {
  43084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43085. }
  43086. m.SetAllowList(v)
  43087. return nil
  43088. case whatsapp.FieldGroupAllowList:
  43089. v, ok := value.([]string)
  43090. if !ok {
  43091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43092. }
  43093. m.SetGroupAllowList(v)
  43094. return nil
  43095. case whatsapp.FieldBlockList:
  43096. v, ok := value.([]string)
  43097. if !ok {
  43098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43099. }
  43100. m.SetBlockList(v)
  43101. return nil
  43102. case whatsapp.FieldGroupBlockList:
  43103. v, ok := value.([]string)
  43104. if !ok {
  43105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43106. }
  43107. m.SetGroupBlockList(v)
  43108. return nil
  43109. }
  43110. return fmt.Errorf("unknown Whatsapp field %s", name)
  43111. }
  43112. // AddedFields returns all numeric fields that were incremented/decremented during
  43113. // this mutation.
  43114. func (m *WhatsappMutation) AddedFields() []string {
  43115. var fields []string
  43116. if m.addstatus != nil {
  43117. fields = append(fields, whatsapp.FieldStatus)
  43118. }
  43119. if m.addphone_status != nil {
  43120. fields = append(fields, whatsapp.FieldPhoneStatus)
  43121. }
  43122. if m.addorganization_id != nil {
  43123. fields = append(fields, whatsapp.FieldOrganizationID)
  43124. }
  43125. return fields
  43126. }
  43127. // AddedField returns the numeric value that was incremented/decremented on a field
  43128. // with the given name. The second boolean return value indicates that this field
  43129. // was not set, or was not defined in the schema.
  43130. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  43131. switch name {
  43132. case whatsapp.FieldStatus:
  43133. return m.AddedStatus()
  43134. case whatsapp.FieldPhoneStatus:
  43135. return m.AddedPhoneStatus()
  43136. case whatsapp.FieldOrganizationID:
  43137. return m.AddedOrganizationID()
  43138. }
  43139. return nil, false
  43140. }
  43141. // AddField adds the value to the field with the given name. It returns an error if
  43142. // the field is not defined in the schema, or if the type mismatched the field
  43143. // type.
  43144. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  43145. switch name {
  43146. case whatsapp.FieldStatus:
  43147. v, ok := value.(int8)
  43148. if !ok {
  43149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43150. }
  43151. m.AddStatus(v)
  43152. return nil
  43153. case whatsapp.FieldPhoneStatus:
  43154. v, ok := value.(int8)
  43155. if !ok {
  43156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43157. }
  43158. m.AddPhoneStatus(v)
  43159. return nil
  43160. case whatsapp.FieldOrganizationID:
  43161. v, ok := value.(int64)
  43162. if !ok {
  43163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43164. }
  43165. m.AddOrganizationID(v)
  43166. return nil
  43167. }
  43168. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  43169. }
  43170. // ClearedFields returns all nullable fields that were cleared during this
  43171. // mutation.
  43172. func (m *WhatsappMutation) ClearedFields() []string {
  43173. var fields []string
  43174. if m.FieldCleared(whatsapp.FieldStatus) {
  43175. fields = append(fields, whatsapp.FieldStatus)
  43176. }
  43177. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  43178. fields = append(fields, whatsapp.FieldDeletedAt)
  43179. }
  43180. if m.FieldCleared(whatsapp.FieldWaID) {
  43181. fields = append(fields, whatsapp.FieldWaID)
  43182. }
  43183. if m.FieldCleared(whatsapp.FieldWaName) {
  43184. fields = append(fields, whatsapp.FieldWaName)
  43185. }
  43186. if m.FieldCleared(whatsapp.FieldCallback) {
  43187. fields = append(fields, whatsapp.FieldCallback)
  43188. }
  43189. if m.FieldCleared(whatsapp.FieldAccount) {
  43190. fields = append(fields, whatsapp.FieldAccount)
  43191. }
  43192. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  43193. fields = append(fields, whatsapp.FieldOrganizationID)
  43194. }
  43195. if m.FieldCleared(whatsapp.FieldAPIBase) {
  43196. fields = append(fields, whatsapp.FieldAPIBase)
  43197. }
  43198. if m.FieldCleared(whatsapp.FieldAPIKey) {
  43199. fields = append(fields, whatsapp.FieldAPIKey)
  43200. }
  43201. if m.FieldCleared(whatsapp.FieldAllowList) {
  43202. fields = append(fields, whatsapp.FieldAllowList)
  43203. }
  43204. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  43205. fields = append(fields, whatsapp.FieldGroupAllowList)
  43206. }
  43207. if m.FieldCleared(whatsapp.FieldBlockList) {
  43208. fields = append(fields, whatsapp.FieldBlockList)
  43209. }
  43210. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  43211. fields = append(fields, whatsapp.FieldGroupBlockList)
  43212. }
  43213. return fields
  43214. }
  43215. // FieldCleared returns a boolean indicating if a field with the given name was
  43216. // cleared in this mutation.
  43217. func (m *WhatsappMutation) FieldCleared(name string) bool {
  43218. _, ok := m.clearedFields[name]
  43219. return ok
  43220. }
  43221. // ClearField clears the value of the field with the given name. It returns an
  43222. // error if the field is not defined in the schema.
  43223. func (m *WhatsappMutation) ClearField(name string) error {
  43224. switch name {
  43225. case whatsapp.FieldStatus:
  43226. m.ClearStatus()
  43227. return nil
  43228. case whatsapp.FieldDeletedAt:
  43229. m.ClearDeletedAt()
  43230. return nil
  43231. case whatsapp.FieldWaID:
  43232. m.ClearWaID()
  43233. return nil
  43234. case whatsapp.FieldWaName:
  43235. m.ClearWaName()
  43236. return nil
  43237. case whatsapp.FieldCallback:
  43238. m.ClearCallback()
  43239. return nil
  43240. case whatsapp.FieldAccount:
  43241. m.ClearAccount()
  43242. return nil
  43243. case whatsapp.FieldOrganizationID:
  43244. m.ClearOrganizationID()
  43245. return nil
  43246. case whatsapp.FieldAPIBase:
  43247. m.ClearAPIBase()
  43248. return nil
  43249. case whatsapp.FieldAPIKey:
  43250. m.ClearAPIKey()
  43251. return nil
  43252. case whatsapp.FieldAllowList:
  43253. m.ClearAllowList()
  43254. return nil
  43255. case whatsapp.FieldGroupAllowList:
  43256. m.ClearGroupAllowList()
  43257. return nil
  43258. case whatsapp.FieldBlockList:
  43259. m.ClearBlockList()
  43260. return nil
  43261. case whatsapp.FieldGroupBlockList:
  43262. m.ClearGroupBlockList()
  43263. return nil
  43264. }
  43265. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  43266. }
  43267. // ResetField resets all changes in the mutation for the field with the given name.
  43268. // It returns an error if the field is not defined in the schema.
  43269. func (m *WhatsappMutation) ResetField(name string) error {
  43270. switch name {
  43271. case whatsapp.FieldCreatedAt:
  43272. m.ResetCreatedAt()
  43273. return nil
  43274. case whatsapp.FieldUpdatedAt:
  43275. m.ResetUpdatedAt()
  43276. return nil
  43277. case whatsapp.FieldStatus:
  43278. m.ResetStatus()
  43279. return nil
  43280. case whatsapp.FieldDeletedAt:
  43281. m.ResetDeletedAt()
  43282. return nil
  43283. case whatsapp.FieldWaID:
  43284. m.ResetWaID()
  43285. return nil
  43286. case whatsapp.FieldWaName:
  43287. m.ResetWaName()
  43288. return nil
  43289. case whatsapp.FieldCallback:
  43290. m.ResetCallback()
  43291. return nil
  43292. case whatsapp.FieldAgentID:
  43293. m.ResetAgentID()
  43294. return nil
  43295. case whatsapp.FieldAccount:
  43296. m.ResetAccount()
  43297. return nil
  43298. case whatsapp.FieldCc:
  43299. m.ResetCc()
  43300. return nil
  43301. case whatsapp.FieldPhone:
  43302. m.ResetPhone()
  43303. return nil
  43304. case whatsapp.FieldCcPhone:
  43305. m.ResetCcPhone()
  43306. return nil
  43307. case whatsapp.FieldPhoneName:
  43308. m.ResetPhoneName()
  43309. return nil
  43310. case whatsapp.FieldPhoneStatus:
  43311. m.ResetPhoneStatus()
  43312. return nil
  43313. case whatsapp.FieldOrganizationID:
  43314. m.ResetOrganizationID()
  43315. return nil
  43316. case whatsapp.FieldAPIBase:
  43317. m.ResetAPIBase()
  43318. return nil
  43319. case whatsapp.FieldAPIKey:
  43320. m.ResetAPIKey()
  43321. return nil
  43322. case whatsapp.FieldAllowList:
  43323. m.ResetAllowList()
  43324. return nil
  43325. case whatsapp.FieldGroupAllowList:
  43326. m.ResetGroupAllowList()
  43327. return nil
  43328. case whatsapp.FieldBlockList:
  43329. m.ResetBlockList()
  43330. return nil
  43331. case whatsapp.FieldGroupBlockList:
  43332. m.ResetGroupBlockList()
  43333. return nil
  43334. }
  43335. return fmt.Errorf("unknown Whatsapp field %s", name)
  43336. }
  43337. // AddedEdges returns all edge names that were set/added in this mutation.
  43338. func (m *WhatsappMutation) AddedEdges() []string {
  43339. edges := make([]string, 0, 1)
  43340. if m.agent != nil {
  43341. edges = append(edges, whatsapp.EdgeAgent)
  43342. }
  43343. return edges
  43344. }
  43345. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43346. // name in this mutation.
  43347. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  43348. switch name {
  43349. case whatsapp.EdgeAgent:
  43350. if id := m.agent; id != nil {
  43351. return []ent.Value{*id}
  43352. }
  43353. }
  43354. return nil
  43355. }
  43356. // RemovedEdges returns all edge names that were removed in this mutation.
  43357. func (m *WhatsappMutation) RemovedEdges() []string {
  43358. edges := make([]string, 0, 1)
  43359. return edges
  43360. }
  43361. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43362. // the given name in this mutation.
  43363. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  43364. return nil
  43365. }
  43366. // ClearedEdges returns all edge names that were cleared in this mutation.
  43367. func (m *WhatsappMutation) ClearedEdges() []string {
  43368. edges := make([]string, 0, 1)
  43369. if m.clearedagent {
  43370. edges = append(edges, whatsapp.EdgeAgent)
  43371. }
  43372. return edges
  43373. }
  43374. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43375. // was cleared in this mutation.
  43376. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  43377. switch name {
  43378. case whatsapp.EdgeAgent:
  43379. return m.clearedagent
  43380. }
  43381. return false
  43382. }
  43383. // ClearEdge clears the value of the edge with the given name. It returns an error
  43384. // if that edge is not defined in the schema.
  43385. func (m *WhatsappMutation) ClearEdge(name string) error {
  43386. switch name {
  43387. case whatsapp.EdgeAgent:
  43388. m.ClearAgent()
  43389. return nil
  43390. }
  43391. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  43392. }
  43393. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43394. // It returns an error if the edge is not defined in the schema.
  43395. func (m *WhatsappMutation) ResetEdge(name string) error {
  43396. switch name {
  43397. case whatsapp.EdgeAgent:
  43398. m.ResetAgent()
  43399. return nil
  43400. }
  43401. return fmt.Errorf("unknown Whatsapp edge %s", name)
  43402. }
  43403. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  43404. type WhatsappChannelMutation struct {
  43405. config
  43406. op Op
  43407. typ string
  43408. id *uint64
  43409. created_at *time.Time
  43410. updated_at *time.Time
  43411. status *uint8
  43412. addstatus *int8
  43413. deleted_at *time.Time
  43414. ak *string
  43415. sk *string
  43416. wa_id *string
  43417. wa_name *string
  43418. waba_id *uint64
  43419. addwaba_id *int64
  43420. business_id *uint64
  43421. addbusiness_id *int64
  43422. organization_id *uint64
  43423. addorganization_id *int64
  43424. verify_account *string
  43425. clearedFields map[string]struct{}
  43426. done bool
  43427. oldValue func(context.Context) (*WhatsappChannel, error)
  43428. predicates []predicate.WhatsappChannel
  43429. }
  43430. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  43431. // whatsappchannelOption allows management of the mutation configuration using functional options.
  43432. type whatsappchannelOption func(*WhatsappChannelMutation)
  43433. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  43434. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  43435. m := &WhatsappChannelMutation{
  43436. config: c,
  43437. op: op,
  43438. typ: TypeWhatsappChannel,
  43439. clearedFields: make(map[string]struct{}),
  43440. }
  43441. for _, opt := range opts {
  43442. opt(m)
  43443. }
  43444. return m
  43445. }
  43446. // withWhatsappChannelID sets the ID field of the mutation.
  43447. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  43448. return func(m *WhatsappChannelMutation) {
  43449. var (
  43450. err error
  43451. once sync.Once
  43452. value *WhatsappChannel
  43453. )
  43454. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  43455. once.Do(func() {
  43456. if m.done {
  43457. err = errors.New("querying old values post mutation is not allowed")
  43458. } else {
  43459. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  43460. }
  43461. })
  43462. return value, err
  43463. }
  43464. m.id = &id
  43465. }
  43466. }
  43467. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  43468. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  43469. return func(m *WhatsappChannelMutation) {
  43470. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  43471. return node, nil
  43472. }
  43473. m.id = &node.ID
  43474. }
  43475. }
  43476. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43477. // executed in a transaction (ent.Tx), a transactional client is returned.
  43478. func (m WhatsappChannelMutation) Client() *Client {
  43479. client := &Client{config: m.config}
  43480. client.init()
  43481. return client
  43482. }
  43483. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43484. // it returns an error otherwise.
  43485. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  43486. if _, ok := m.driver.(*txDriver); !ok {
  43487. return nil, errors.New("ent: mutation is not running in a transaction")
  43488. }
  43489. tx := &Tx{config: m.config}
  43490. tx.init()
  43491. return tx, nil
  43492. }
  43493. // SetID sets the value of the id field. Note that this
  43494. // operation is only accepted on creation of WhatsappChannel entities.
  43495. func (m *WhatsappChannelMutation) SetID(id uint64) {
  43496. m.id = &id
  43497. }
  43498. // ID returns the ID value in the mutation. Note that the ID is only available
  43499. // if it was provided to the builder or after it was returned from the database.
  43500. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  43501. if m.id == nil {
  43502. return
  43503. }
  43504. return *m.id, true
  43505. }
  43506. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43507. // That means, if the mutation is applied within a transaction with an isolation level such
  43508. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43509. // or updated by the mutation.
  43510. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  43511. switch {
  43512. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43513. id, exists := m.ID()
  43514. if exists {
  43515. return []uint64{id}, nil
  43516. }
  43517. fallthrough
  43518. case m.op.Is(OpUpdate | OpDelete):
  43519. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  43520. default:
  43521. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43522. }
  43523. }
  43524. // SetCreatedAt sets the "created_at" field.
  43525. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  43526. m.created_at = &t
  43527. }
  43528. // CreatedAt returns the value of the "created_at" field in the mutation.
  43529. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  43530. v := m.created_at
  43531. if v == nil {
  43532. return
  43533. }
  43534. return *v, true
  43535. }
  43536. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  43537. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43539. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43540. if !m.op.Is(OpUpdateOne) {
  43541. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43542. }
  43543. if m.id == nil || m.oldValue == nil {
  43544. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43545. }
  43546. oldValue, err := m.oldValue(ctx)
  43547. if err != nil {
  43548. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43549. }
  43550. return oldValue.CreatedAt, nil
  43551. }
  43552. // ResetCreatedAt resets all changes to the "created_at" field.
  43553. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  43554. m.created_at = nil
  43555. }
  43556. // SetUpdatedAt sets the "updated_at" field.
  43557. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  43558. m.updated_at = &t
  43559. }
  43560. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43561. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  43562. v := m.updated_at
  43563. if v == nil {
  43564. return
  43565. }
  43566. return *v, true
  43567. }
  43568. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  43569. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43571. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43572. if !m.op.Is(OpUpdateOne) {
  43573. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43574. }
  43575. if m.id == nil || m.oldValue == nil {
  43576. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43577. }
  43578. oldValue, err := m.oldValue(ctx)
  43579. if err != nil {
  43580. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43581. }
  43582. return oldValue.UpdatedAt, nil
  43583. }
  43584. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43585. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  43586. m.updated_at = nil
  43587. }
  43588. // SetStatus sets the "status" field.
  43589. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  43590. m.status = &u
  43591. m.addstatus = nil
  43592. }
  43593. // Status returns the value of the "status" field in the mutation.
  43594. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  43595. v := m.status
  43596. if v == nil {
  43597. return
  43598. }
  43599. return *v, true
  43600. }
  43601. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  43602. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43604. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43605. if !m.op.Is(OpUpdateOne) {
  43606. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43607. }
  43608. if m.id == nil || m.oldValue == nil {
  43609. return v, errors.New("OldStatus requires an ID field in the mutation")
  43610. }
  43611. oldValue, err := m.oldValue(ctx)
  43612. if err != nil {
  43613. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43614. }
  43615. return oldValue.Status, nil
  43616. }
  43617. // AddStatus adds u to the "status" field.
  43618. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  43619. if m.addstatus != nil {
  43620. *m.addstatus += u
  43621. } else {
  43622. m.addstatus = &u
  43623. }
  43624. }
  43625. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43626. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  43627. v := m.addstatus
  43628. if v == nil {
  43629. return
  43630. }
  43631. return *v, true
  43632. }
  43633. // ClearStatus clears the value of the "status" field.
  43634. func (m *WhatsappChannelMutation) ClearStatus() {
  43635. m.status = nil
  43636. m.addstatus = nil
  43637. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  43638. }
  43639. // StatusCleared returns if the "status" field was cleared in this mutation.
  43640. func (m *WhatsappChannelMutation) StatusCleared() bool {
  43641. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  43642. return ok
  43643. }
  43644. // ResetStatus resets all changes to the "status" field.
  43645. func (m *WhatsappChannelMutation) ResetStatus() {
  43646. m.status = nil
  43647. m.addstatus = nil
  43648. delete(m.clearedFields, whatsappchannel.FieldStatus)
  43649. }
  43650. // SetDeletedAt sets the "deleted_at" field.
  43651. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  43652. m.deleted_at = &t
  43653. }
  43654. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43655. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  43656. v := m.deleted_at
  43657. if v == nil {
  43658. return
  43659. }
  43660. return *v, true
  43661. }
  43662. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  43663. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43665. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43666. if !m.op.Is(OpUpdateOne) {
  43667. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43668. }
  43669. if m.id == nil || m.oldValue == nil {
  43670. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43671. }
  43672. oldValue, err := m.oldValue(ctx)
  43673. if err != nil {
  43674. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43675. }
  43676. return oldValue.DeletedAt, nil
  43677. }
  43678. // ClearDeletedAt clears the value of the "deleted_at" field.
  43679. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  43680. m.deleted_at = nil
  43681. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  43682. }
  43683. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43684. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  43685. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  43686. return ok
  43687. }
  43688. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43689. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  43690. m.deleted_at = nil
  43691. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  43692. }
  43693. // SetAk sets the "ak" field.
  43694. func (m *WhatsappChannelMutation) SetAk(s string) {
  43695. m.ak = &s
  43696. }
  43697. // Ak returns the value of the "ak" field in the mutation.
  43698. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  43699. v := m.ak
  43700. if v == nil {
  43701. return
  43702. }
  43703. return *v, true
  43704. }
  43705. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  43706. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43708. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  43709. if !m.op.Is(OpUpdateOne) {
  43710. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  43711. }
  43712. if m.id == nil || m.oldValue == nil {
  43713. return v, errors.New("OldAk requires an ID field in the mutation")
  43714. }
  43715. oldValue, err := m.oldValue(ctx)
  43716. if err != nil {
  43717. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  43718. }
  43719. return oldValue.Ak, nil
  43720. }
  43721. // ClearAk clears the value of the "ak" field.
  43722. func (m *WhatsappChannelMutation) ClearAk() {
  43723. m.ak = nil
  43724. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  43725. }
  43726. // AkCleared returns if the "ak" field was cleared in this mutation.
  43727. func (m *WhatsappChannelMutation) AkCleared() bool {
  43728. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  43729. return ok
  43730. }
  43731. // ResetAk resets all changes to the "ak" field.
  43732. func (m *WhatsappChannelMutation) ResetAk() {
  43733. m.ak = nil
  43734. delete(m.clearedFields, whatsappchannel.FieldAk)
  43735. }
  43736. // SetSk sets the "sk" field.
  43737. func (m *WhatsappChannelMutation) SetSk(s string) {
  43738. m.sk = &s
  43739. }
  43740. // Sk returns the value of the "sk" field in the mutation.
  43741. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  43742. v := m.sk
  43743. if v == nil {
  43744. return
  43745. }
  43746. return *v, true
  43747. }
  43748. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  43749. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43751. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  43752. if !m.op.Is(OpUpdateOne) {
  43753. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  43754. }
  43755. if m.id == nil || m.oldValue == nil {
  43756. return v, errors.New("OldSk requires an ID field in the mutation")
  43757. }
  43758. oldValue, err := m.oldValue(ctx)
  43759. if err != nil {
  43760. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  43761. }
  43762. return oldValue.Sk, nil
  43763. }
  43764. // ResetSk resets all changes to the "sk" field.
  43765. func (m *WhatsappChannelMutation) ResetSk() {
  43766. m.sk = nil
  43767. }
  43768. // SetWaID sets the "wa_id" field.
  43769. func (m *WhatsappChannelMutation) SetWaID(s string) {
  43770. m.wa_id = &s
  43771. }
  43772. // WaID returns the value of the "wa_id" field in the mutation.
  43773. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  43774. v := m.wa_id
  43775. if v == nil {
  43776. return
  43777. }
  43778. return *v, true
  43779. }
  43780. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  43781. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43783. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  43784. if !m.op.Is(OpUpdateOne) {
  43785. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  43786. }
  43787. if m.id == nil || m.oldValue == nil {
  43788. return v, errors.New("OldWaID requires an ID field in the mutation")
  43789. }
  43790. oldValue, err := m.oldValue(ctx)
  43791. if err != nil {
  43792. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  43793. }
  43794. return oldValue.WaID, nil
  43795. }
  43796. // ClearWaID clears the value of the "wa_id" field.
  43797. func (m *WhatsappChannelMutation) ClearWaID() {
  43798. m.wa_id = nil
  43799. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  43800. }
  43801. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  43802. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  43803. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  43804. return ok
  43805. }
  43806. // ResetWaID resets all changes to the "wa_id" field.
  43807. func (m *WhatsappChannelMutation) ResetWaID() {
  43808. m.wa_id = nil
  43809. delete(m.clearedFields, whatsappchannel.FieldWaID)
  43810. }
  43811. // SetWaName sets the "wa_name" field.
  43812. func (m *WhatsappChannelMutation) SetWaName(s string) {
  43813. m.wa_name = &s
  43814. }
  43815. // WaName returns the value of the "wa_name" field in the mutation.
  43816. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  43817. v := m.wa_name
  43818. if v == nil {
  43819. return
  43820. }
  43821. return *v, true
  43822. }
  43823. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  43824. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43826. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  43827. if !m.op.Is(OpUpdateOne) {
  43828. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  43829. }
  43830. if m.id == nil || m.oldValue == nil {
  43831. return v, errors.New("OldWaName requires an ID field in the mutation")
  43832. }
  43833. oldValue, err := m.oldValue(ctx)
  43834. if err != nil {
  43835. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  43836. }
  43837. return oldValue.WaName, nil
  43838. }
  43839. // ClearWaName clears the value of the "wa_name" field.
  43840. func (m *WhatsappChannelMutation) ClearWaName() {
  43841. m.wa_name = nil
  43842. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  43843. }
  43844. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  43845. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  43846. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  43847. return ok
  43848. }
  43849. // ResetWaName resets all changes to the "wa_name" field.
  43850. func (m *WhatsappChannelMutation) ResetWaName() {
  43851. m.wa_name = nil
  43852. delete(m.clearedFields, whatsappchannel.FieldWaName)
  43853. }
  43854. // SetWabaID sets the "waba_id" field.
  43855. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  43856. m.waba_id = &u
  43857. m.addwaba_id = nil
  43858. }
  43859. // WabaID returns the value of the "waba_id" field in the mutation.
  43860. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  43861. v := m.waba_id
  43862. if v == nil {
  43863. return
  43864. }
  43865. return *v, true
  43866. }
  43867. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  43868. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43870. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  43871. if !m.op.Is(OpUpdateOne) {
  43872. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  43873. }
  43874. if m.id == nil || m.oldValue == nil {
  43875. return v, errors.New("OldWabaID requires an ID field in the mutation")
  43876. }
  43877. oldValue, err := m.oldValue(ctx)
  43878. if err != nil {
  43879. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  43880. }
  43881. return oldValue.WabaID, nil
  43882. }
  43883. // AddWabaID adds u to the "waba_id" field.
  43884. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  43885. if m.addwaba_id != nil {
  43886. *m.addwaba_id += u
  43887. } else {
  43888. m.addwaba_id = &u
  43889. }
  43890. }
  43891. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  43892. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  43893. v := m.addwaba_id
  43894. if v == nil {
  43895. return
  43896. }
  43897. return *v, true
  43898. }
  43899. // ResetWabaID resets all changes to the "waba_id" field.
  43900. func (m *WhatsappChannelMutation) ResetWabaID() {
  43901. m.waba_id = nil
  43902. m.addwaba_id = nil
  43903. }
  43904. // SetBusinessID sets the "business_id" field.
  43905. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  43906. m.business_id = &u
  43907. m.addbusiness_id = nil
  43908. }
  43909. // BusinessID returns the value of the "business_id" field in the mutation.
  43910. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  43911. v := m.business_id
  43912. if v == nil {
  43913. return
  43914. }
  43915. return *v, true
  43916. }
  43917. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  43918. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43920. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  43921. if !m.op.Is(OpUpdateOne) {
  43922. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  43923. }
  43924. if m.id == nil || m.oldValue == nil {
  43925. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  43926. }
  43927. oldValue, err := m.oldValue(ctx)
  43928. if err != nil {
  43929. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  43930. }
  43931. return oldValue.BusinessID, nil
  43932. }
  43933. // AddBusinessID adds u to the "business_id" field.
  43934. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  43935. if m.addbusiness_id != nil {
  43936. *m.addbusiness_id += u
  43937. } else {
  43938. m.addbusiness_id = &u
  43939. }
  43940. }
  43941. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  43942. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  43943. v := m.addbusiness_id
  43944. if v == nil {
  43945. return
  43946. }
  43947. return *v, true
  43948. }
  43949. // ResetBusinessID resets all changes to the "business_id" field.
  43950. func (m *WhatsappChannelMutation) ResetBusinessID() {
  43951. m.business_id = nil
  43952. m.addbusiness_id = nil
  43953. }
  43954. // SetOrganizationID sets the "organization_id" field.
  43955. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  43956. m.organization_id = &u
  43957. m.addorganization_id = nil
  43958. }
  43959. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43960. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  43961. v := m.organization_id
  43962. if v == nil {
  43963. return
  43964. }
  43965. return *v, true
  43966. }
  43967. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  43968. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43970. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43971. if !m.op.Is(OpUpdateOne) {
  43972. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43973. }
  43974. if m.id == nil || m.oldValue == nil {
  43975. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43976. }
  43977. oldValue, err := m.oldValue(ctx)
  43978. if err != nil {
  43979. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43980. }
  43981. return oldValue.OrganizationID, nil
  43982. }
  43983. // AddOrganizationID adds u to the "organization_id" field.
  43984. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  43985. if m.addorganization_id != nil {
  43986. *m.addorganization_id += u
  43987. } else {
  43988. m.addorganization_id = &u
  43989. }
  43990. }
  43991. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43992. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  43993. v := m.addorganization_id
  43994. if v == nil {
  43995. return
  43996. }
  43997. return *v, true
  43998. }
  43999. // ClearOrganizationID clears the value of the "organization_id" field.
  44000. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  44001. m.organization_id = nil
  44002. m.addorganization_id = nil
  44003. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  44004. }
  44005. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  44006. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  44007. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  44008. return ok
  44009. }
  44010. // ResetOrganizationID resets all changes to the "organization_id" field.
  44011. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  44012. m.organization_id = nil
  44013. m.addorganization_id = nil
  44014. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  44015. }
  44016. // SetVerifyAccount sets the "verify_account" field.
  44017. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  44018. m.verify_account = &s
  44019. }
  44020. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  44021. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  44022. v := m.verify_account
  44023. if v == nil {
  44024. return
  44025. }
  44026. return *v, true
  44027. }
  44028. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  44029. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44031. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  44032. if !m.op.Is(OpUpdateOne) {
  44033. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  44034. }
  44035. if m.id == nil || m.oldValue == nil {
  44036. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  44037. }
  44038. oldValue, err := m.oldValue(ctx)
  44039. if err != nil {
  44040. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  44041. }
  44042. return oldValue.VerifyAccount, nil
  44043. }
  44044. // ResetVerifyAccount resets all changes to the "verify_account" field.
  44045. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  44046. m.verify_account = nil
  44047. }
  44048. // Where appends a list predicates to the WhatsappChannelMutation builder.
  44049. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  44050. m.predicates = append(m.predicates, ps...)
  44051. }
  44052. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  44053. // users can use type-assertion to append predicates that do not depend on any generated package.
  44054. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  44055. p := make([]predicate.WhatsappChannel, len(ps))
  44056. for i := range ps {
  44057. p[i] = ps[i]
  44058. }
  44059. m.Where(p...)
  44060. }
  44061. // Op returns the operation name.
  44062. func (m *WhatsappChannelMutation) Op() Op {
  44063. return m.op
  44064. }
  44065. // SetOp allows setting the mutation operation.
  44066. func (m *WhatsappChannelMutation) SetOp(op Op) {
  44067. m.op = op
  44068. }
  44069. // Type returns the node type of this mutation (WhatsappChannel).
  44070. func (m *WhatsappChannelMutation) Type() string {
  44071. return m.typ
  44072. }
  44073. // Fields returns all fields that were changed during this mutation. Note that in
  44074. // order to get all numeric fields that were incremented/decremented, call
  44075. // AddedFields().
  44076. func (m *WhatsappChannelMutation) Fields() []string {
  44077. fields := make([]string, 0, 12)
  44078. if m.created_at != nil {
  44079. fields = append(fields, whatsappchannel.FieldCreatedAt)
  44080. }
  44081. if m.updated_at != nil {
  44082. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  44083. }
  44084. if m.status != nil {
  44085. fields = append(fields, whatsappchannel.FieldStatus)
  44086. }
  44087. if m.deleted_at != nil {
  44088. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44089. }
  44090. if m.ak != nil {
  44091. fields = append(fields, whatsappchannel.FieldAk)
  44092. }
  44093. if m.sk != nil {
  44094. fields = append(fields, whatsappchannel.FieldSk)
  44095. }
  44096. if m.wa_id != nil {
  44097. fields = append(fields, whatsappchannel.FieldWaID)
  44098. }
  44099. if m.wa_name != nil {
  44100. fields = append(fields, whatsappchannel.FieldWaName)
  44101. }
  44102. if m.waba_id != nil {
  44103. fields = append(fields, whatsappchannel.FieldWabaID)
  44104. }
  44105. if m.business_id != nil {
  44106. fields = append(fields, whatsappchannel.FieldBusinessID)
  44107. }
  44108. if m.organization_id != nil {
  44109. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44110. }
  44111. if m.verify_account != nil {
  44112. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  44113. }
  44114. return fields
  44115. }
  44116. // Field returns the value of a field with the given name. The second boolean
  44117. // return value indicates that this field was not set, or was not defined in the
  44118. // schema.
  44119. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  44120. switch name {
  44121. case whatsappchannel.FieldCreatedAt:
  44122. return m.CreatedAt()
  44123. case whatsappchannel.FieldUpdatedAt:
  44124. return m.UpdatedAt()
  44125. case whatsappchannel.FieldStatus:
  44126. return m.Status()
  44127. case whatsappchannel.FieldDeletedAt:
  44128. return m.DeletedAt()
  44129. case whatsappchannel.FieldAk:
  44130. return m.Ak()
  44131. case whatsappchannel.FieldSk:
  44132. return m.Sk()
  44133. case whatsappchannel.FieldWaID:
  44134. return m.WaID()
  44135. case whatsappchannel.FieldWaName:
  44136. return m.WaName()
  44137. case whatsappchannel.FieldWabaID:
  44138. return m.WabaID()
  44139. case whatsappchannel.FieldBusinessID:
  44140. return m.BusinessID()
  44141. case whatsappchannel.FieldOrganizationID:
  44142. return m.OrganizationID()
  44143. case whatsappchannel.FieldVerifyAccount:
  44144. return m.VerifyAccount()
  44145. }
  44146. return nil, false
  44147. }
  44148. // OldField returns the old value of the field from the database. An error is
  44149. // returned if the mutation operation is not UpdateOne, or the query to the
  44150. // database failed.
  44151. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44152. switch name {
  44153. case whatsappchannel.FieldCreatedAt:
  44154. return m.OldCreatedAt(ctx)
  44155. case whatsappchannel.FieldUpdatedAt:
  44156. return m.OldUpdatedAt(ctx)
  44157. case whatsappchannel.FieldStatus:
  44158. return m.OldStatus(ctx)
  44159. case whatsappchannel.FieldDeletedAt:
  44160. return m.OldDeletedAt(ctx)
  44161. case whatsappchannel.FieldAk:
  44162. return m.OldAk(ctx)
  44163. case whatsappchannel.FieldSk:
  44164. return m.OldSk(ctx)
  44165. case whatsappchannel.FieldWaID:
  44166. return m.OldWaID(ctx)
  44167. case whatsappchannel.FieldWaName:
  44168. return m.OldWaName(ctx)
  44169. case whatsappchannel.FieldWabaID:
  44170. return m.OldWabaID(ctx)
  44171. case whatsappchannel.FieldBusinessID:
  44172. return m.OldBusinessID(ctx)
  44173. case whatsappchannel.FieldOrganizationID:
  44174. return m.OldOrganizationID(ctx)
  44175. case whatsappchannel.FieldVerifyAccount:
  44176. return m.OldVerifyAccount(ctx)
  44177. }
  44178. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  44179. }
  44180. // SetField sets the value of a field with the given name. It returns an error if
  44181. // the field is not defined in the schema, or if the type mismatched the field
  44182. // type.
  44183. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  44184. switch name {
  44185. case whatsappchannel.FieldCreatedAt:
  44186. v, ok := value.(time.Time)
  44187. if !ok {
  44188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44189. }
  44190. m.SetCreatedAt(v)
  44191. return nil
  44192. case whatsappchannel.FieldUpdatedAt:
  44193. v, ok := value.(time.Time)
  44194. if !ok {
  44195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44196. }
  44197. m.SetUpdatedAt(v)
  44198. return nil
  44199. case whatsappchannel.FieldStatus:
  44200. v, ok := value.(uint8)
  44201. if !ok {
  44202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44203. }
  44204. m.SetStatus(v)
  44205. return nil
  44206. case whatsappchannel.FieldDeletedAt:
  44207. v, ok := value.(time.Time)
  44208. if !ok {
  44209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44210. }
  44211. m.SetDeletedAt(v)
  44212. return nil
  44213. case whatsappchannel.FieldAk:
  44214. v, ok := value.(string)
  44215. if !ok {
  44216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44217. }
  44218. m.SetAk(v)
  44219. return nil
  44220. case whatsappchannel.FieldSk:
  44221. v, ok := value.(string)
  44222. if !ok {
  44223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44224. }
  44225. m.SetSk(v)
  44226. return nil
  44227. case whatsappchannel.FieldWaID:
  44228. v, ok := value.(string)
  44229. if !ok {
  44230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44231. }
  44232. m.SetWaID(v)
  44233. return nil
  44234. case whatsappchannel.FieldWaName:
  44235. v, ok := value.(string)
  44236. if !ok {
  44237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44238. }
  44239. m.SetWaName(v)
  44240. return nil
  44241. case whatsappchannel.FieldWabaID:
  44242. v, ok := value.(uint64)
  44243. if !ok {
  44244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44245. }
  44246. m.SetWabaID(v)
  44247. return nil
  44248. case whatsappchannel.FieldBusinessID:
  44249. v, ok := value.(uint64)
  44250. if !ok {
  44251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44252. }
  44253. m.SetBusinessID(v)
  44254. return nil
  44255. case whatsappchannel.FieldOrganizationID:
  44256. v, ok := value.(uint64)
  44257. if !ok {
  44258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44259. }
  44260. m.SetOrganizationID(v)
  44261. return nil
  44262. case whatsappchannel.FieldVerifyAccount:
  44263. v, ok := value.(string)
  44264. if !ok {
  44265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44266. }
  44267. m.SetVerifyAccount(v)
  44268. return nil
  44269. }
  44270. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44271. }
  44272. // AddedFields returns all numeric fields that were incremented/decremented during
  44273. // this mutation.
  44274. func (m *WhatsappChannelMutation) AddedFields() []string {
  44275. var fields []string
  44276. if m.addstatus != nil {
  44277. fields = append(fields, whatsappchannel.FieldStatus)
  44278. }
  44279. if m.addwaba_id != nil {
  44280. fields = append(fields, whatsappchannel.FieldWabaID)
  44281. }
  44282. if m.addbusiness_id != nil {
  44283. fields = append(fields, whatsappchannel.FieldBusinessID)
  44284. }
  44285. if m.addorganization_id != nil {
  44286. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44287. }
  44288. return fields
  44289. }
  44290. // AddedField returns the numeric value that was incremented/decremented on a field
  44291. // with the given name. The second boolean return value indicates that this field
  44292. // was not set, or was not defined in the schema.
  44293. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  44294. switch name {
  44295. case whatsappchannel.FieldStatus:
  44296. return m.AddedStatus()
  44297. case whatsappchannel.FieldWabaID:
  44298. return m.AddedWabaID()
  44299. case whatsappchannel.FieldBusinessID:
  44300. return m.AddedBusinessID()
  44301. case whatsappchannel.FieldOrganizationID:
  44302. return m.AddedOrganizationID()
  44303. }
  44304. return nil, false
  44305. }
  44306. // AddField adds the value to the field with the given name. It returns an error if
  44307. // the field is not defined in the schema, or if the type mismatched the field
  44308. // type.
  44309. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  44310. switch name {
  44311. case whatsappchannel.FieldStatus:
  44312. v, ok := value.(int8)
  44313. if !ok {
  44314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44315. }
  44316. m.AddStatus(v)
  44317. return nil
  44318. case whatsappchannel.FieldWabaID:
  44319. v, ok := value.(int64)
  44320. if !ok {
  44321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44322. }
  44323. m.AddWabaID(v)
  44324. return nil
  44325. case whatsappchannel.FieldBusinessID:
  44326. v, ok := value.(int64)
  44327. if !ok {
  44328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44329. }
  44330. m.AddBusinessID(v)
  44331. return nil
  44332. case whatsappchannel.FieldOrganizationID:
  44333. v, ok := value.(int64)
  44334. if !ok {
  44335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44336. }
  44337. m.AddOrganizationID(v)
  44338. return nil
  44339. }
  44340. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  44341. }
  44342. // ClearedFields returns all nullable fields that were cleared during this
  44343. // mutation.
  44344. func (m *WhatsappChannelMutation) ClearedFields() []string {
  44345. var fields []string
  44346. if m.FieldCleared(whatsappchannel.FieldStatus) {
  44347. fields = append(fields, whatsappchannel.FieldStatus)
  44348. }
  44349. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  44350. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44351. }
  44352. if m.FieldCleared(whatsappchannel.FieldAk) {
  44353. fields = append(fields, whatsappchannel.FieldAk)
  44354. }
  44355. if m.FieldCleared(whatsappchannel.FieldWaID) {
  44356. fields = append(fields, whatsappchannel.FieldWaID)
  44357. }
  44358. if m.FieldCleared(whatsappchannel.FieldWaName) {
  44359. fields = append(fields, whatsappchannel.FieldWaName)
  44360. }
  44361. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  44362. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44363. }
  44364. return fields
  44365. }
  44366. // FieldCleared returns a boolean indicating if a field with the given name was
  44367. // cleared in this mutation.
  44368. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  44369. _, ok := m.clearedFields[name]
  44370. return ok
  44371. }
  44372. // ClearField clears the value of the field with the given name. It returns an
  44373. // error if the field is not defined in the schema.
  44374. func (m *WhatsappChannelMutation) ClearField(name string) error {
  44375. switch name {
  44376. case whatsappchannel.FieldStatus:
  44377. m.ClearStatus()
  44378. return nil
  44379. case whatsappchannel.FieldDeletedAt:
  44380. m.ClearDeletedAt()
  44381. return nil
  44382. case whatsappchannel.FieldAk:
  44383. m.ClearAk()
  44384. return nil
  44385. case whatsappchannel.FieldWaID:
  44386. m.ClearWaID()
  44387. return nil
  44388. case whatsappchannel.FieldWaName:
  44389. m.ClearWaName()
  44390. return nil
  44391. case whatsappchannel.FieldOrganizationID:
  44392. m.ClearOrganizationID()
  44393. return nil
  44394. }
  44395. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  44396. }
  44397. // ResetField resets all changes in the mutation for the field with the given name.
  44398. // It returns an error if the field is not defined in the schema.
  44399. func (m *WhatsappChannelMutation) ResetField(name string) error {
  44400. switch name {
  44401. case whatsappchannel.FieldCreatedAt:
  44402. m.ResetCreatedAt()
  44403. return nil
  44404. case whatsappchannel.FieldUpdatedAt:
  44405. m.ResetUpdatedAt()
  44406. return nil
  44407. case whatsappchannel.FieldStatus:
  44408. m.ResetStatus()
  44409. return nil
  44410. case whatsappchannel.FieldDeletedAt:
  44411. m.ResetDeletedAt()
  44412. return nil
  44413. case whatsappchannel.FieldAk:
  44414. m.ResetAk()
  44415. return nil
  44416. case whatsappchannel.FieldSk:
  44417. m.ResetSk()
  44418. return nil
  44419. case whatsappchannel.FieldWaID:
  44420. m.ResetWaID()
  44421. return nil
  44422. case whatsappchannel.FieldWaName:
  44423. m.ResetWaName()
  44424. return nil
  44425. case whatsappchannel.FieldWabaID:
  44426. m.ResetWabaID()
  44427. return nil
  44428. case whatsappchannel.FieldBusinessID:
  44429. m.ResetBusinessID()
  44430. return nil
  44431. case whatsappchannel.FieldOrganizationID:
  44432. m.ResetOrganizationID()
  44433. return nil
  44434. case whatsappchannel.FieldVerifyAccount:
  44435. m.ResetVerifyAccount()
  44436. return nil
  44437. }
  44438. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44439. }
  44440. // AddedEdges returns all edge names that were set/added in this mutation.
  44441. func (m *WhatsappChannelMutation) AddedEdges() []string {
  44442. edges := make([]string, 0, 0)
  44443. return edges
  44444. }
  44445. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44446. // name in this mutation.
  44447. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  44448. return nil
  44449. }
  44450. // RemovedEdges returns all edge names that were removed in this mutation.
  44451. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  44452. edges := make([]string, 0, 0)
  44453. return edges
  44454. }
  44455. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44456. // the given name in this mutation.
  44457. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  44458. return nil
  44459. }
  44460. // ClearedEdges returns all edge names that were cleared in this mutation.
  44461. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  44462. edges := make([]string, 0, 0)
  44463. return edges
  44464. }
  44465. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44466. // was cleared in this mutation.
  44467. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  44468. return false
  44469. }
  44470. // ClearEdge clears the value of the edge with the given name. It returns an error
  44471. // if that edge is not defined in the schema.
  44472. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  44473. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  44474. }
  44475. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44476. // It returns an error if the edge is not defined in the schema.
  44477. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  44478. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  44479. }
  44480. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  44481. type WorkExperienceMutation struct {
  44482. config
  44483. op Op
  44484. typ string
  44485. id *uint64
  44486. created_at *time.Time
  44487. updated_at *time.Time
  44488. deleted_at *time.Time
  44489. start_date *time.Time
  44490. end_date *time.Time
  44491. company *string
  44492. experience *string
  44493. organization_id *uint64
  44494. addorganization_id *int64
  44495. clearedFields map[string]struct{}
  44496. employee *uint64
  44497. clearedemployee bool
  44498. done bool
  44499. oldValue func(context.Context) (*WorkExperience, error)
  44500. predicates []predicate.WorkExperience
  44501. }
  44502. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  44503. // workexperienceOption allows management of the mutation configuration using functional options.
  44504. type workexperienceOption func(*WorkExperienceMutation)
  44505. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  44506. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  44507. m := &WorkExperienceMutation{
  44508. config: c,
  44509. op: op,
  44510. typ: TypeWorkExperience,
  44511. clearedFields: make(map[string]struct{}),
  44512. }
  44513. for _, opt := range opts {
  44514. opt(m)
  44515. }
  44516. return m
  44517. }
  44518. // withWorkExperienceID sets the ID field of the mutation.
  44519. func withWorkExperienceID(id uint64) workexperienceOption {
  44520. return func(m *WorkExperienceMutation) {
  44521. var (
  44522. err error
  44523. once sync.Once
  44524. value *WorkExperience
  44525. )
  44526. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  44527. once.Do(func() {
  44528. if m.done {
  44529. err = errors.New("querying old values post mutation is not allowed")
  44530. } else {
  44531. value, err = m.Client().WorkExperience.Get(ctx, id)
  44532. }
  44533. })
  44534. return value, err
  44535. }
  44536. m.id = &id
  44537. }
  44538. }
  44539. // withWorkExperience sets the old WorkExperience of the mutation.
  44540. func withWorkExperience(node *WorkExperience) workexperienceOption {
  44541. return func(m *WorkExperienceMutation) {
  44542. m.oldValue = func(context.Context) (*WorkExperience, error) {
  44543. return node, nil
  44544. }
  44545. m.id = &node.ID
  44546. }
  44547. }
  44548. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44549. // executed in a transaction (ent.Tx), a transactional client is returned.
  44550. func (m WorkExperienceMutation) Client() *Client {
  44551. client := &Client{config: m.config}
  44552. client.init()
  44553. return client
  44554. }
  44555. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44556. // it returns an error otherwise.
  44557. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  44558. if _, ok := m.driver.(*txDriver); !ok {
  44559. return nil, errors.New("ent: mutation is not running in a transaction")
  44560. }
  44561. tx := &Tx{config: m.config}
  44562. tx.init()
  44563. return tx, nil
  44564. }
  44565. // SetID sets the value of the id field. Note that this
  44566. // operation is only accepted on creation of WorkExperience entities.
  44567. func (m *WorkExperienceMutation) SetID(id uint64) {
  44568. m.id = &id
  44569. }
  44570. // ID returns the ID value in the mutation. Note that the ID is only available
  44571. // if it was provided to the builder or after it was returned from the database.
  44572. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  44573. if m.id == nil {
  44574. return
  44575. }
  44576. return *m.id, true
  44577. }
  44578. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44579. // That means, if the mutation is applied within a transaction with an isolation level such
  44580. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44581. // or updated by the mutation.
  44582. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  44583. switch {
  44584. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44585. id, exists := m.ID()
  44586. if exists {
  44587. return []uint64{id}, nil
  44588. }
  44589. fallthrough
  44590. case m.op.Is(OpUpdate | OpDelete):
  44591. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  44592. default:
  44593. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44594. }
  44595. }
  44596. // SetCreatedAt sets the "created_at" field.
  44597. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  44598. m.created_at = &t
  44599. }
  44600. // CreatedAt returns the value of the "created_at" field in the mutation.
  44601. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  44602. v := m.created_at
  44603. if v == nil {
  44604. return
  44605. }
  44606. return *v, true
  44607. }
  44608. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  44609. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44611. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44612. if !m.op.Is(OpUpdateOne) {
  44613. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44614. }
  44615. if m.id == nil || m.oldValue == nil {
  44616. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44617. }
  44618. oldValue, err := m.oldValue(ctx)
  44619. if err != nil {
  44620. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44621. }
  44622. return oldValue.CreatedAt, nil
  44623. }
  44624. // ResetCreatedAt resets all changes to the "created_at" field.
  44625. func (m *WorkExperienceMutation) ResetCreatedAt() {
  44626. m.created_at = nil
  44627. }
  44628. // SetUpdatedAt sets the "updated_at" field.
  44629. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  44630. m.updated_at = &t
  44631. }
  44632. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44633. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  44634. v := m.updated_at
  44635. if v == nil {
  44636. return
  44637. }
  44638. return *v, true
  44639. }
  44640. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  44641. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44643. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44644. if !m.op.Is(OpUpdateOne) {
  44645. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44646. }
  44647. if m.id == nil || m.oldValue == nil {
  44648. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44649. }
  44650. oldValue, err := m.oldValue(ctx)
  44651. if err != nil {
  44652. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44653. }
  44654. return oldValue.UpdatedAt, nil
  44655. }
  44656. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44657. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  44658. m.updated_at = nil
  44659. }
  44660. // SetDeletedAt sets the "deleted_at" field.
  44661. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  44662. m.deleted_at = &t
  44663. }
  44664. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44665. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  44666. v := m.deleted_at
  44667. if v == nil {
  44668. return
  44669. }
  44670. return *v, true
  44671. }
  44672. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  44673. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44675. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44676. if !m.op.Is(OpUpdateOne) {
  44677. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44678. }
  44679. if m.id == nil || m.oldValue == nil {
  44680. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44681. }
  44682. oldValue, err := m.oldValue(ctx)
  44683. if err != nil {
  44684. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44685. }
  44686. return oldValue.DeletedAt, nil
  44687. }
  44688. // ClearDeletedAt clears the value of the "deleted_at" field.
  44689. func (m *WorkExperienceMutation) ClearDeletedAt() {
  44690. m.deleted_at = nil
  44691. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  44692. }
  44693. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44694. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  44695. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  44696. return ok
  44697. }
  44698. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44699. func (m *WorkExperienceMutation) ResetDeletedAt() {
  44700. m.deleted_at = nil
  44701. delete(m.clearedFields, workexperience.FieldDeletedAt)
  44702. }
  44703. // SetEmployeeID sets the "employee_id" field.
  44704. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  44705. m.employee = &u
  44706. }
  44707. // EmployeeID returns the value of the "employee_id" field in the mutation.
  44708. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  44709. v := m.employee
  44710. if v == nil {
  44711. return
  44712. }
  44713. return *v, true
  44714. }
  44715. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  44716. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44718. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  44719. if !m.op.Is(OpUpdateOne) {
  44720. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  44721. }
  44722. if m.id == nil || m.oldValue == nil {
  44723. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  44724. }
  44725. oldValue, err := m.oldValue(ctx)
  44726. if err != nil {
  44727. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  44728. }
  44729. return oldValue.EmployeeID, nil
  44730. }
  44731. // ResetEmployeeID resets all changes to the "employee_id" field.
  44732. func (m *WorkExperienceMutation) ResetEmployeeID() {
  44733. m.employee = nil
  44734. }
  44735. // SetStartDate sets the "start_date" field.
  44736. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  44737. m.start_date = &t
  44738. }
  44739. // StartDate returns the value of the "start_date" field in the mutation.
  44740. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  44741. v := m.start_date
  44742. if v == nil {
  44743. return
  44744. }
  44745. return *v, true
  44746. }
  44747. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  44748. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44750. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  44751. if !m.op.Is(OpUpdateOne) {
  44752. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  44753. }
  44754. if m.id == nil || m.oldValue == nil {
  44755. return v, errors.New("OldStartDate requires an ID field in the mutation")
  44756. }
  44757. oldValue, err := m.oldValue(ctx)
  44758. if err != nil {
  44759. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  44760. }
  44761. return oldValue.StartDate, nil
  44762. }
  44763. // ResetStartDate resets all changes to the "start_date" field.
  44764. func (m *WorkExperienceMutation) ResetStartDate() {
  44765. m.start_date = nil
  44766. }
  44767. // SetEndDate sets the "end_date" field.
  44768. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  44769. m.end_date = &t
  44770. }
  44771. // EndDate returns the value of the "end_date" field in the mutation.
  44772. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  44773. v := m.end_date
  44774. if v == nil {
  44775. return
  44776. }
  44777. return *v, true
  44778. }
  44779. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  44780. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44782. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  44783. if !m.op.Is(OpUpdateOne) {
  44784. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  44785. }
  44786. if m.id == nil || m.oldValue == nil {
  44787. return v, errors.New("OldEndDate requires an ID field in the mutation")
  44788. }
  44789. oldValue, err := m.oldValue(ctx)
  44790. if err != nil {
  44791. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  44792. }
  44793. return oldValue.EndDate, nil
  44794. }
  44795. // ResetEndDate resets all changes to the "end_date" field.
  44796. func (m *WorkExperienceMutation) ResetEndDate() {
  44797. m.end_date = nil
  44798. }
  44799. // SetCompany sets the "company" field.
  44800. func (m *WorkExperienceMutation) SetCompany(s string) {
  44801. m.company = &s
  44802. }
  44803. // Company returns the value of the "company" field in the mutation.
  44804. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  44805. v := m.company
  44806. if v == nil {
  44807. return
  44808. }
  44809. return *v, true
  44810. }
  44811. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  44812. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44814. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  44815. if !m.op.Is(OpUpdateOne) {
  44816. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44817. }
  44818. if m.id == nil || m.oldValue == nil {
  44819. return v, errors.New("OldCompany requires an ID field in the mutation")
  44820. }
  44821. oldValue, err := m.oldValue(ctx)
  44822. if err != nil {
  44823. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  44824. }
  44825. return oldValue.Company, nil
  44826. }
  44827. // ResetCompany resets all changes to the "company" field.
  44828. func (m *WorkExperienceMutation) ResetCompany() {
  44829. m.company = nil
  44830. }
  44831. // SetExperience sets the "experience" field.
  44832. func (m *WorkExperienceMutation) SetExperience(s string) {
  44833. m.experience = &s
  44834. }
  44835. // Experience returns the value of the "experience" field in the mutation.
  44836. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  44837. v := m.experience
  44838. if v == nil {
  44839. return
  44840. }
  44841. return *v, true
  44842. }
  44843. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  44844. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44846. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  44847. if !m.op.Is(OpUpdateOne) {
  44848. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  44849. }
  44850. if m.id == nil || m.oldValue == nil {
  44851. return v, errors.New("OldExperience requires an ID field in the mutation")
  44852. }
  44853. oldValue, err := m.oldValue(ctx)
  44854. if err != nil {
  44855. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  44856. }
  44857. return oldValue.Experience, nil
  44858. }
  44859. // ResetExperience resets all changes to the "experience" field.
  44860. func (m *WorkExperienceMutation) ResetExperience() {
  44861. m.experience = nil
  44862. }
  44863. // SetOrganizationID sets the "organization_id" field.
  44864. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  44865. m.organization_id = &u
  44866. m.addorganization_id = nil
  44867. }
  44868. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44869. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  44870. v := m.organization_id
  44871. if v == nil {
  44872. return
  44873. }
  44874. return *v, true
  44875. }
  44876. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  44877. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44879. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44880. if !m.op.Is(OpUpdateOne) {
  44881. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44882. }
  44883. if m.id == nil || m.oldValue == nil {
  44884. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44885. }
  44886. oldValue, err := m.oldValue(ctx)
  44887. if err != nil {
  44888. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44889. }
  44890. return oldValue.OrganizationID, nil
  44891. }
  44892. // AddOrganizationID adds u to the "organization_id" field.
  44893. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  44894. if m.addorganization_id != nil {
  44895. *m.addorganization_id += u
  44896. } else {
  44897. m.addorganization_id = &u
  44898. }
  44899. }
  44900. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44901. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  44902. v := m.addorganization_id
  44903. if v == nil {
  44904. return
  44905. }
  44906. return *v, true
  44907. }
  44908. // ResetOrganizationID resets all changes to the "organization_id" field.
  44909. func (m *WorkExperienceMutation) ResetOrganizationID() {
  44910. m.organization_id = nil
  44911. m.addorganization_id = nil
  44912. }
  44913. // ClearEmployee clears the "employee" edge to the Employee entity.
  44914. func (m *WorkExperienceMutation) ClearEmployee() {
  44915. m.clearedemployee = true
  44916. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  44917. }
  44918. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  44919. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  44920. return m.clearedemployee
  44921. }
  44922. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  44923. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44924. // EmployeeID instead. It exists only for internal usage by the builders.
  44925. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  44926. if id := m.employee; id != nil {
  44927. ids = append(ids, *id)
  44928. }
  44929. return
  44930. }
  44931. // ResetEmployee resets all changes to the "employee" edge.
  44932. func (m *WorkExperienceMutation) ResetEmployee() {
  44933. m.employee = nil
  44934. m.clearedemployee = false
  44935. }
  44936. // Where appends a list predicates to the WorkExperienceMutation builder.
  44937. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  44938. m.predicates = append(m.predicates, ps...)
  44939. }
  44940. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  44941. // users can use type-assertion to append predicates that do not depend on any generated package.
  44942. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  44943. p := make([]predicate.WorkExperience, len(ps))
  44944. for i := range ps {
  44945. p[i] = ps[i]
  44946. }
  44947. m.Where(p...)
  44948. }
  44949. // Op returns the operation name.
  44950. func (m *WorkExperienceMutation) Op() Op {
  44951. return m.op
  44952. }
  44953. // SetOp allows setting the mutation operation.
  44954. func (m *WorkExperienceMutation) SetOp(op Op) {
  44955. m.op = op
  44956. }
  44957. // Type returns the node type of this mutation (WorkExperience).
  44958. func (m *WorkExperienceMutation) Type() string {
  44959. return m.typ
  44960. }
  44961. // Fields returns all fields that were changed during this mutation. Note that in
  44962. // order to get all numeric fields that were incremented/decremented, call
  44963. // AddedFields().
  44964. func (m *WorkExperienceMutation) Fields() []string {
  44965. fields := make([]string, 0, 9)
  44966. if m.created_at != nil {
  44967. fields = append(fields, workexperience.FieldCreatedAt)
  44968. }
  44969. if m.updated_at != nil {
  44970. fields = append(fields, workexperience.FieldUpdatedAt)
  44971. }
  44972. if m.deleted_at != nil {
  44973. fields = append(fields, workexperience.FieldDeletedAt)
  44974. }
  44975. if m.employee != nil {
  44976. fields = append(fields, workexperience.FieldEmployeeID)
  44977. }
  44978. if m.start_date != nil {
  44979. fields = append(fields, workexperience.FieldStartDate)
  44980. }
  44981. if m.end_date != nil {
  44982. fields = append(fields, workexperience.FieldEndDate)
  44983. }
  44984. if m.company != nil {
  44985. fields = append(fields, workexperience.FieldCompany)
  44986. }
  44987. if m.experience != nil {
  44988. fields = append(fields, workexperience.FieldExperience)
  44989. }
  44990. if m.organization_id != nil {
  44991. fields = append(fields, workexperience.FieldOrganizationID)
  44992. }
  44993. return fields
  44994. }
  44995. // Field returns the value of a field with the given name. The second boolean
  44996. // return value indicates that this field was not set, or was not defined in the
  44997. // schema.
  44998. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  44999. switch name {
  45000. case workexperience.FieldCreatedAt:
  45001. return m.CreatedAt()
  45002. case workexperience.FieldUpdatedAt:
  45003. return m.UpdatedAt()
  45004. case workexperience.FieldDeletedAt:
  45005. return m.DeletedAt()
  45006. case workexperience.FieldEmployeeID:
  45007. return m.EmployeeID()
  45008. case workexperience.FieldStartDate:
  45009. return m.StartDate()
  45010. case workexperience.FieldEndDate:
  45011. return m.EndDate()
  45012. case workexperience.FieldCompany:
  45013. return m.Company()
  45014. case workexperience.FieldExperience:
  45015. return m.Experience()
  45016. case workexperience.FieldOrganizationID:
  45017. return m.OrganizationID()
  45018. }
  45019. return nil, false
  45020. }
  45021. // OldField returns the old value of the field from the database. An error is
  45022. // returned if the mutation operation is not UpdateOne, or the query to the
  45023. // database failed.
  45024. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45025. switch name {
  45026. case workexperience.FieldCreatedAt:
  45027. return m.OldCreatedAt(ctx)
  45028. case workexperience.FieldUpdatedAt:
  45029. return m.OldUpdatedAt(ctx)
  45030. case workexperience.FieldDeletedAt:
  45031. return m.OldDeletedAt(ctx)
  45032. case workexperience.FieldEmployeeID:
  45033. return m.OldEmployeeID(ctx)
  45034. case workexperience.FieldStartDate:
  45035. return m.OldStartDate(ctx)
  45036. case workexperience.FieldEndDate:
  45037. return m.OldEndDate(ctx)
  45038. case workexperience.FieldCompany:
  45039. return m.OldCompany(ctx)
  45040. case workexperience.FieldExperience:
  45041. return m.OldExperience(ctx)
  45042. case workexperience.FieldOrganizationID:
  45043. return m.OldOrganizationID(ctx)
  45044. }
  45045. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  45046. }
  45047. // SetField sets the value of a field with the given name. It returns an error if
  45048. // the field is not defined in the schema, or if the type mismatched the field
  45049. // type.
  45050. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  45051. switch name {
  45052. case workexperience.FieldCreatedAt:
  45053. v, ok := value.(time.Time)
  45054. if !ok {
  45055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45056. }
  45057. m.SetCreatedAt(v)
  45058. return nil
  45059. case workexperience.FieldUpdatedAt:
  45060. v, ok := value.(time.Time)
  45061. if !ok {
  45062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45063. }
  45064. m.SetUpdatedAt(v)
  45065. return nil
  45066. case workexperience.FieldDeletedAt:
  45067. v, ok := value.(time.Time)
  45068. if !ok {
  45069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45070. }
  45071. m.SetDeletedAt(v)
  45072. return nil
  45073. case workexperience.FieldEmployeeID:
  45074. v, ok := value.(uint64)
  45075. if !ok {
  45076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45077. }
  45078. m.SetEmployeeID(v)
  45079. return nil
  45080. case workexperience.FieldStartDate:
  45081. v, ok := value.(time.Time)
  45082. if !ok {
  45083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45084. }
  45085. m.SetStartDate(v)
  45086. return nil
  45087. case workexperience.FieldEndDate:
  45088. v, ok := value.(time.Time)
  45089. if !ok {
  45090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45091. }
  45092. m.SetEndDate(v)
  45093. return nil
  45094. case workexperience.FieldCompany:
  45095. v, ok := value.(string)
  45096. if !ok {
  45097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45098. }
  45099. m.SetCompany(v)
  45100. return nil
  45101. case workexperience.FieldExperience:
  45102. v, ok := value.(string)
  45103. if !ok {
  45104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45105. }
  45106. m.SetExperience(v)
  45107. return nil
  45108. case workexperience.FieldOrganizationID:
  45109. v, ok := value.(uint64)
  45110. if !ok {
  45111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45112. }
  45113. m.SetOrganizationID(v)
  45114. return nil
  45115. }
  45116. return fmt.Errorf("unknown WorkExperience field %s", name)
  45117. }
  45118. // AddedFields returns all numeric fields that were incremented/decremented during
  45119. // this mutation.
  45120. func (m *WorkExperienceMutation) AddedFields() []string {
  45121. var fields []string
  45122. if m.addorganization_id != nil {
  45123. fields = append(fields, workexperience.FieldOrganizationID)
  45124. }
  45125. return fields
  45126. }
  45127. // AddedField returns the numeric value that was incremented/decremented on a field
  45128. // with the given name. The second boolean return value indicates that this field
  45129. // was not set, or was not defined in the schema.
  45130. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  45131. switch name {
  45132. case workexperience.FieldOrganizationID:
  45133. return m.AddedOrganizationID()
  45134. }
  45135. return nil, false
  45136. }
  45137. // AddField adds the value to the field with the given name. It returns an error if
  45138. // the field is not defined in the schema, or if the type mismatched the field
  45139. // type.
  45140. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  45141. switch name {
  45142. case workexperience.FieldOrganizationID:
  45143. v, ok := value.(int64)
  45144. if !ok {
  45145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45146. }
  45147. m.AddOrganizationID(v)
  45148. return nil
  45149. }
  45150. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  45151. }
  45152. // ClearedFields returns all nullable fields that were cleared during this
  45153. // mutation.
  45154. func (m *WorkExperienceMutation) ClearedFields() []string {
  45155. var fields []string
  45156. if m.FieldCleared(workexperience.FieldDeletedAt) {
  45157. fields = append(fields, workexperience.FieldDeletedAt)
  45158. }
  45159. return fields
  45160. }
  45161. // FieldCleared returns a boolean indicating if a field with the given name was
  45162. // cleared in this mutation.
  45163. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  45164. _, ok := m.clearedFields[name]
  45165. return ok
  45166. }
  45167. // ClearField clears the value of the field with the given name. It returns an
  45168. // error if the field is not defined in the schema.
  45169. func (m *WorkExperienceMutation) ClearField(name string) error {
  45170. switch name {
  45171. case workexperience.FieldDeletedAt:
  45172. m.ClearDeletedAt()
  45173. return nil
  45174. }
  45175. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  45176. }
  45177. // ResetField resets all changes in the mutation for the field with the given name.
  45178. // It returns an error if the field is not defined in the schema.
  45179. func (m *WorkExperienceMutation) ResetField(name string) error {
  45180. switch name {
  45181. case workexperience.FieldCreatedAt:
  45182. m.ResetCreatedAt()
  45183. return nil
  45184. case workexperience.FieldUpdatedAt:
  45185. m.ResetUpdatedAt()
  45186. return nil
  45187. case workexperience.FieldDeletedAt:
  45188. m.ResetDeletedAt()
  45189. return nil
  45190. case workexperience.FieldEmployeeID:
  45191. m.ResetEmployeeID()
  45192. return nil
  45193. case workexperience.FieldStartDate:
  45194. m.ResetStartDate()
  45195. return nil
  45196. case workexperience.FieldEndDate:
  45197. m.ResetEndDate()
  45198. return nil
  45199. case workexperience.FieldCompany:
  45200. m.ResetCompany()
  45201. return nil
  45202. case workexperience.FieldExperience:
  45203. m.ResetExperience()
  45204. return nil
  45205. case workexperience.FieldOrganizationID:
  45206. m.ResetOrganizationID()
  45207. return nil
  45208. }
  45209. return fmt.Errorf("unknown WorkExperience field %s", name)
  45210. }
  45211. // AddedEdges returns all edge names that were set/added in this mutation.
  45212. func (m *WorkExperienceMutation) AddedEdges() []string {
  45213. edges := make([]string, 0, 1)
  45214. if m.employee != nil {
  45215. edges = append(edges, workexperience.EdgeEmployee)
  45216. }
  45217. return edges
  45218. }
  45219. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45220. // name in this mutation.
  45221. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  45222. switch name {
  45223. case workexperience.EdgeEmployee:
  45224. if id := m.employee; id != nil {
  45225. return []ent.Value{*id}
  45226. }
  45227. }
  45228. return nil
  45229. }
  45230. // RemovedEdges returns all edge names that were removed in this mutation.
  45231. func (m *WorkExperienceMutation) RemovedEdges() []string {
  45232. edges := make([]string, 0, 1)
  45233. return edges
  45234. }
  45235. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45236. // the given name in this mutation.
  45237. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  45238. return nil
  45239. }
  45240. // ClearedEdges returns all edge names that were cleared in this mutation.
  45241. func (m *WorkExperienceMutation) ClearedEdges() []string {
  45242. edges := make([]string, 0, 1)
  45243. if m.clearedemployee {
  45244. edges = append(edges, workexperience.EdgeEmployee)
  45245. }
  45246. return edges
  45247. }
  45248. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45249. // was cleared in this mutation.
  45250. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  45251. switch name {
  45252. case workexperience.EdgeEmployee:
  45253. return m.clearedemployee
  45254. }
  45255. return false
  45256. }
  45257. // ClearEdge clears the value of the edge with the given name. It returns an error
  45258. // if that edge is not defined in the schema.
  45259. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  45260. switch name {
  45261. case workexperience.EdgeEmployee:
  45262. m.ClearEmployee()
  45263. return nil
  45264. }
  45265. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  45266. }
  45267. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45268. // It returns an error if the edge is not defined in the schema.
  45269. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  45270. switch name {
  45271. case workexperience.EdgeEmployee:
  45272. m.ResetEmployee()
  45273. return nil
  45274. }
  45275. return fmt.Errorf("unknown WorkExperience edge %s", name)
  45276. }
  45277. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  45278. type WpChatroomMutation struct {
  45279. config
  45280. op Op
  45281. typ string
  45282. id *uint64
  45283. created_at *time.Time
  45284. updated_at *time.Time
  45285. status *uint8
  45286. addstatus *int8
  45287. wx_wxid *string
  45288. chatroom_id *string
  45289. nickname *string
  45290. owner *string
  45291. avatar *string
  45292. member_list *[]string
  45293. appendmember_list []string
  45294. clearedFields map[string]struct{}
  45295. done bool
  45296. oldValue func(context.Context) (*WpChatroom, error)
  45297. predicates []predicate.WpChatroom
  45298. }
  45299. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  45300. // wpchatroomOption allows management of the mutation configuration using functional options.
  45301. type wpchatroomOption func(*WpChatroomMutation)
  45302. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  45303. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  45304. m := &WpChatroomMutation{
  45305. config: c,
  45306. op: op,
  45307. typ: TypeWpChatroom,
  45308. clearedFields: make(map[string]struct{}),
  45309. }
  45310. for _, opt := range opts {
  45311. opt(m)
  45312. }
  45313. return m
  45314. }
  45315. // withWpChatroomID sets the ID field of the mutation.
  45316. func withWpChatroomID(id uint64) wpchatroomOption {
  45317. return func(m *WpChatroomMutation) {
  45318. var (
  45319. err error
  45320. once sync.Once
  45321. value *WpChatroom
  45322. )
  45323. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  45324. once.Do(func() {
  45325. if m.done {
  45326. err = errors.New("querying old values post mutation is not allowed")
  45327. } else {
  45328. value, err = m.Client().WpChatroom.Get(ctx, id)
  45329. }
  45330. })
  45331. return value, err
  45332. }
  45333. m.id = &id
  45334. }
  45335. }
  45336. // withWpChatroom sets the old WpChatroom of the mutation.
  45337. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  45338. return func(m *WpChatroomMutation) {
  45339. m.oldValue = func(context.Context) (*WpChatroom, error) {
  45340. return node, nil
  45341. }
  45342. m.id = &node.ID
  45343. }
  45344. }
  45345. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45346. // executed in a transaction (ent.Tx), a transactional client is returned.
  45347. func (m WpChatroomMutation) Client() *Client {
  45348. client := &Client{config: m.config}
  45349. client.init()
  45350. return client
  45351. }
  45352. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45353. // it returns an error otherwise.
  45354. func (m WpChatroomMutation) Tx() (*Tx, error) {
  45355. if _, ok := m.driver.(*txDriver); !ok {
  45356. return nil, errors.New("ent: mutation is not running in a transaction")
  45357. }
  45358. tx := &Tx{config: m.config}
  45359. tx.init()
  45360. return tx, nil
  45361. }
  45362. // SetID sets the value of the id field. Note that this
  45363. // operation is only accepted on creation of WpChatroom entities.
  45364. func (m *WpChatroomMutation) SetID(id uint64) {
  45365. m.id = &id
  45366. }
  45367. // ID returns the ID value in the mutation. Note that the ID is only available
  45368. // if it was provided to the builder or after it was returned from the database.
  45369. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  45370. if m.id == nil {
  45371. return
  45372. }
  45373. return *m.id, true
  45374. }
  45375. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45376. // That means, if the mutation is applied within a transaction with an isolation level such
  45377. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45378. // or updated by the mutation.
  45379. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  45380. switch {
  45381. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45382. id, exists := m.ID()
  45383. if exists {
  45384. return []uint64{id}, nil
  45385. }
  45386. fallthrough
  45387. case m.op.Is(OpUpdate | OpDelete):
  45388. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  45389. default:
  45390. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45391. }
  45392. }
  45393. // SetCreatedAt sets the "created_at" field.
  45394. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  45395. m.created_at = &t
  45396. }
  45397. // CreatedAt returns the value of the "created_at" field in the mutation.
  45398. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  45399. v := m.created_at
  45400. if v == nil {
  45401. return
  45402. }
  45403. return *v, true
  45404. }
  45405. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  45406. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45408. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45409. if !m.op.Is(OpUpdateOne) {
  45410. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45411. }
  45412. if m.id == nil || m.oldValue == nil {
  45413. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45414. }
  45415. oldValue, err := m.oldValue(ctx)
  45416. if err != nil {
  45417. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45418. }
  45419. return oldValue.CreatedAt, nil
  45420. }
  45421. // ResetCreatedAt resets all changes to the "created_at" field.
  45422. func (m *WpChatroomMutation) ResetCreatedAt() {
  45423. m.created_at = nil
  45424. }
  45425. // SetUpdatedAt sets the "updated_at" field.
  45426. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  45427. m.updated_at = &t
  45428. }
  45429. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45430. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  45431. v := m.updated_at
  45432. if v == nil {
  45433. return
  45434. }
  45435. return *v, true
  45436. }
  45437. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  45438. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45440. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45441. if !m.op.Is(OpUpdateOne) {
  45442. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45443. }
  45444. if m.id == nil || m.oldValue == nil {
  45445. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45446. }
  45447. oldValue, err := m.oldValue(ctx)
  45448. if err != nil {
  45449. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45450. }
  45451. return oldValue.UpdatedAt, nil
  45452. }
  45453. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45454. func (m *WpChatroomMutation) ResetUpdatedAt() {
  45455. m.updated_at = nil
  45456. }
  45457. // SetStatus sets the "status" field.
  45458. func (m *WpChatroomMutation) SetStatus(u uint8) {
  45459. m.status = &u
  45460. m.addstatus = nil
  45461. }
  45462. // Status returns the value of the "status" field in the mutation.
  45463. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  45464. v := m.status
  45465. if v == nil {
  45466. return
  45467. }
  45468. return *v, true
  45469. }
  45470. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  45471. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45473. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45474. if !m.op.Is(OpUpdateOne) {
  45475. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45476. }
  45477. if m.id == nil || m.oldValue == nil {
  45478. return v, errors.New("OldStatus requires an ID field in the mutation")
  45479. }
  45480. oldValue, err := m.oldValue(ctx)
  45481. if err != nil {
  45482. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45483. }
  45484. return oldValue.Status, nil
  45485. }
  45486. // AddStatus adds u to the "status" field.
  45487. func (m *WpChatroomMutation) AddStatus(u int8) {
  45488. if m.addstatus != nil {
  45489. *m.addstatus += u
  45490. } else {
  45491. m.addstatus = &u
  45492. }
  45493. }
  45494. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45495. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  45496. v := m.addstatus
  45497. if v == nil {
  45498. return
  45499. }
  45500. return *v, true
  45501. }
  45502. // ClearStatus clears the value of the "status" field.
  45503. func (m *WpChatroomMutation) ClearStatus() {
  45504. m.status = nil
  45505. m.addstatus = nil
  45506. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  45507. }
  45508. // StatusCleared returns if the "status" field was cleared in this mutation.
  45509. func (m *WpChatroomMutation) StatusCleared() bool {
  45510. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  45511. return ok
  45512. }
  45513. // ResetStatus resets all changes to the "status" field.
  45514. func (m *WpChatroomMutation) ResetStatus() {
  45515. m.status = nil
  45516. m.addstatus = nil
  45517. delete(m.clearedFields, wpchatroom.FieldStatus)
  45518. }
  45519. // SetWxWxid sets the "wx_wxid" field.
  45520. func (m *WpChatroomMutation) SetWxWxid(s string) {
  45521. m.wx_wxid = &s
  45522. }
  45523. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45524. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  45525. v := m.wx_wxid
  45526. if v == nil {
  45527. return
  45528. }
  45529. return *v, true
  45530. }
  45531. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  45532. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45534. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45535. if !m.op.Is(OpUpdateOne) {
  45536. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45537. }
  45538. if m.id == nil || m.oldValue == nil {
  45539. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45540. }
  45541. oldValue, err := m.oldValue(ctx)
  45542. if err != nil {
  45543. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45544. }
  45545. return oldValue.WxWxid, nil
  45546. }
  45547. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45548. func (m *WpChatroomMutation) ResetWxWxid() {
  45549. m.wx_wxid = nil
  45550. }
  45551. // SetChatroomID sets the "chatroom_id" field.
  45552. func (m *WpChatroomMutation) SetChatroomID(s string) {
  45553. m.chatroom_id = &s
  45554. }
  45555. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  45556. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  45557. v := m.chatroom_id
  45558. if v == nil {
  45559. return
  45560. }
  45561. return *v, true
  45562. }
  45563. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  45564. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45566. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  45567. if !m.op.Is(OpUpdateOne) {
  45568. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  45569. }
  45570. if m.id == nil || m.oldValue == nil {
  45571. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  45572. }
  45573. oldValue, err := m.oldValue(ctx)
  45574. if err != nil {
  45575. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  45576. }
  45577. return oldValue.ChatroomID, nil
  45578. }
  45579. // ResetChatroomID resets all changes to the "chatroom_id" field.
  45580. func (m *WpChatroomMutation) ResetChatroomID() {
  45581. m.chatroom_id = nil
  45582. }
  45583. // SetNickname sets the "nickname" field.
  45584. func (m *WpChatroomMutation) SetNickname(s string) {
  45585. m.nickname = &s
  45586. }
  45587. // Nickname returns the value of the "nickname" field in the mutation.
  45588. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  45589. v := m.nickname
  45590. if v == nil {
  45591. return
  45592. }
  45593. return *v, true
  45594. }
  45595. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  45596. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45598. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  45599. if !m.op.Is(OpUpdateOne) {
  45600. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45601. }
  45602. if m.id == nil || m.oldValue == nil {
  45603. return v, errors.New("OldNickname requires an ID field in the mutation")
  45604. }
  45605. oldValue, err := m.oldValue(ctx)
  45606. if err != nil {
  45607. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45608. }
  45609. return oldValue.Nickname, nil
  45610. }
  45611. // ResetNickname resets all changes to the "nickname" field.
  45612. func (m *WpChatroomMutation) ResetNickname() {
  45613. m.nickname = nil
  45614. }
  45615. // SetOwner sets the "owner" field.
  45616. func (m *WpChatroomMutation) SetOwner(s string) {
  45617. m.owner = &s
  45618. }
  45619. // Owner returns the value of the "owner" field in the mutation.
  45620. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  45621. v := m.owner
  45622. if v == nil {
  45623. return
  45624. }
  45625. return *v, true
  45626. }
  45627. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  45628. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45630. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  45631. if !m.op.Is(OpUpdateOne) {
  45632. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  45633. }
  45634. if m.id == nil || m.oldValue == nil {
  45635. return v, errors.New("OldOwner requires an ID field in the mutation")
  45636. }
  45637. oldValue, err := m.oldValue(ctx)
  45638. if err != nil {
  45639. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  45640. }
  45641. return oldValue.Owner, nil
  45642. }
  45643. // ResetOwner resets all changes to the "owner" field.
  45644. func (m *WpChatroomMutation) ResetOwner() {
  45645. m.owner = nil
  45646. }
  45647. // SetAvatar sets the "avatar" field.
  45648. func (m *WpChatroomMutation) SetAvatar(s string) {
  45649. m.avatar = &s
  45650. }
  45651. // Avatar returns the value of the "avatar" field in the mutation.
  45652. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  45653. v := m.avatar
  45654. if v == nil {
  45655. return
  45656. }
  45657. return *v, true
  45658. }
  45659. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  45660. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45662. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45663. if !m.op.Is(OpUpdateOne) {
  45664. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45665. }
  45666. if m.id == nil || m.oldValue == nil {
  45667. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45668. }
  45669. oldValue, err := m.oldValue(ctx)
  45670. if err != nil {
  45671. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45672. }
  45673. return oldValue.Avatar, nil
  45674. }
  45675. // ResetAvatar resets all changes to the "avatar" field.
  45676. func (m *WpChatroomMutation) ResetAvatar() {
  45677. m.avatar = nil
  45678. }
  45679. // SetMemberList sets the "member_list" field.
  45680. func (m *WpChatroomMutation) SetMemberList(s []string) {
  45681. m.member_list = &s
  45682. m.appendmember_list = nil
  45683. }
  45684. // MemberList returns the value of the "member_list" field in the mutation.
  45685. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  45686. v := m.member_list
  45687. if v == nil {
  45688. return
  45689. }
  45690. return *v, true
  45691. }
  45692. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  45693. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45695. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  45696. if !m.op.Is(OpUpdateOne) {
  45697. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  45698. }
  45699. if m.id == nil || m.oldValue == nil {
  45700. return v, errors.New("OldMemberList requires an ID field in the mutation")
  45701. }
  45702. oldValue, err := m.oldValue(ctx)
  45703. if err != nil {
  45704. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  45705. }
  45706. return oldValue.MemberList, nil
  45707. }
  45708. // AppendMemberList adds s to the "member_list" field.
  45709. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  45710. m.appendmember_list = append(m.appendmember_list, s...)
  45711. }
  45712. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  45713. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  45714. if len(m.appendmember_list) == 0 {
  45715. return nil, false
  45716. }
  45717. return m.appendmember_list, true
  45718. }
  45719. // ResetMemberList resets all changes to the "member_list" field.
  45720. func (m *WpChatroomMutation) ResetMemberList() {
  45721. m.member_list = nil
  45722. m.appendmember_list = nil
  45723. }
  45724. // Where appends a list predicates to the WpChatroomMutation builder.
  45725. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  45726. m.predicates = append(m.predicates, ps...)
  45727. }
  45728. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  45729. // users can use type-assertion to append predicates that do not depend on any generated package.
  45730. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  45731. p := make([]predicate.WpChatroom, len(ps))
  45732. for i := range ps {
  45733. p[i] = ps[i]
  45734. }
  45735. m.Where(p...)
  45736. }
  45737. // Op returns the operation name.
  45738. func (m *WpChatroomMutation) Op() Op {
  45739. return m.op
  45740. }
  45741. // SetOp allows setting the mutation operation.
  45742. func (m *WpChatroomMutation) SetOp(op Op) {
  45743. m.op = op
  45744. }
  45745. // Type returns the node type of this mutation (WpChatroom).
  45746. func (m *WpChatroomMutation) Type() string {
  45747. return m.typ
  45748. }
  45749. // Fields returns all fields that were changed during this mutation. Note that in
  45750. // order to get all numeric fields that were incremented/decremented, call
  45751. // AddedFields().
  45752. func (m *WpChatroomMutation) Fields() []string {
  45753. fields := make([]string, 0, 9)
  45754. if m.created_at != nil {
  45755. fields = append(fields, wpchatroom.FieldCreatedAt)
  45756. }
  45757. if m.updated_at != nil {
  45758. fields = append(fields, wpchatroom.FieldUpdatedAt)
  45759. }
  45760. if m.status != nil {
  45761. fields = append(fields, wpchatroom.FieldStatus)
  45762. }
  45763. if m.wx_wxid != nil {
  45764. fields = append(fields, wpchatroom.FieldWxWxid)
  45765. }
  45766. if m.chatroom_id != nil {
  45767. fields = append(fields, wpchatroom.FieldChatroomID)
  45768. }
  45769. if m.nickname != nil {
  45770. fields = append(fields, wpchatroom.FieldNickname)
  45771. }
  45772. if m.owner != nil {
  45773. fields = append(fields, wpchatroom.FieldOwner)
  45774. }
  45775. if m.avatar != nil {
  45776. fields = append(fields, wpchatroom.FieldAvatar)
  45777. }
  45778. if m.member_list != nil {
  45779. fields = append(fields, wpchatroom.FieldMemberList)
  45780. }
  45781. return fields
  45782. }
  45783. // Field returns the value of a field with the given name. The second boolean
  45784. // return value indicates that this field was not set, or was not defined in the
  45785. // schema.
  45786. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  45787. switch name {
  45788. case wpchatroom.FieldCreatedAt:
  45789. return m.CreatedAt()
  45790. case wpchatroom.FieldUpdatedAt:
  45791. return m.UpdatedAt()
  45792. case wpchatroom.FieldStatus:
  45793. return m.Status()
  45794. case wpchatroom.FieldWxWxid:
  45795. return m.WxWxid()
  45796. case wpchatroom.FieldChatroomID:
  45797. return m.ChatroomID()
  45798. case wpchatroom.FieldNickname:
  45799. return m.Nickname()
  45800. case wpchatroom.FieldOwner:
  45801. return m.Owner()
  45802. case wpchatroom.FieldAvatar:
  45803. return m.Avatar()
  45804. case wpchatroom.FieldMemberList:
  45805. return m.MemberList()
  45806. }
  45807. return nil, false
  45808. }
  45809. // OldField returns the old value of the field from the database. An error is
  45810. // returned if the mutation operation is not UpdateOne, or the query to the
  45811. // database failed.
  45812. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45813. switch name {
  45814. case wpchatroom.FieldCreatedAt:
  45815. return m.OldCreatedAt(ctx)
  45816. case wpchatroom.FieldUpdatedAt:
  45817. return m.OldUpdatedAt(ctx)
  45818. case wpchatroom.FieldStatus:
  45819. return m.OldStatus(ctx)
  45820. case wpchatroom.FieldWxWxid:
  45821. return m.OldWxWxid(ctx)
  45822. case wpchatroom.FieldChatroomID:
  45823. return m.OldChatroomID(ctx)
  45824. case wpchatroom.FieldNickname:
  45825. return m.OldNickname(ctx)
  45826. case wpchatroom.FieldOwner:
  45827. return m.OldOwner(ctx)
  45828. case wpchatroom.FieldAvatar:
  45829. return m.OldAvatar(ctx)
  45830. case wpchatroom.FieldMemberList:
  45831. return m.OldMemberList(ctx)
  45832. }
  45833. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  45834. }
  45835. // SetField sets the value of a field with the given name. It returns an error if
  45836. // the field is not defined in the schema, or if the type mismatched the field
  45837. // type.
  45838. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  45839. switch name {
  45840. case wpchatroom.FieldCreatedAt:
  45841. v, ok := value.(time.Time)
  45842. if !ok {
  45843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45844. }
  45845. m.SetCreatedAt(v)
  45846. return nil
  45847. case wpchatroom.FieldUpdatedAt:
  45848. v, ok := value.(time.Time)
  45849. if !ok {
  45850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45851. }
  45852. m.SetUpdatedAt(v)
  45853. return nil
  45854. case wpchatroom.FieldStatus:
  45855. v, ok := value.(uint8)
  45856. if !ok {
  45857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45858. }
  45859. m.SetStatus(v)
  45860. return nil
  45861. case wpchatroom.FieldWxWxid:
  45862. v, ok := value.(string)
  45863. if !ok {
  45864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45865. }
  45866. m.SetWxWxid(v)
  45867. return nil
  45868. case wpchatroom.FieldChatroomID:
  45869. v, ok := value.(string)
  45870. if !ok {
  45871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45872. }
  45873. m.SetChatroomID(v)
  45874. return nil
  45875. case wpchatroom.FieldNickname:
  45876. v, ok := value.(string)
  45877. if !ok {
  45878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45879. }
  45880. m.SetNickname(v)
  45881. return nil
  45882. case wpchatroom.FieldOwner:
  45883. v, ok := value.(string)
  45884. if !ok {
  45885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45886. }
  45887. m.SetOwner(v)
  45888. return nil
  45889. case wpchatroom.FieldAvatar:
  45890. v, ok := value.(string)
  45891. if !ok {
  45892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45893. }
  45894. m.SetAvatar(v)
  45895. return nil
  45896. case wpchatroom.FieldMemberList:
  45897. v, ok := value.([]string)
  45898. if !ok {
  45899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45900. }
  45901. m.SetMemberList(v)
  45902. return nil
  45903. }
  45904. return fmt.Errorf("unknown WpChatroom field %s", name)
  45905. }
  45906. // AddedFields returns all numeric fields that were incremented/decremented during
  45907. // this mutation.
  45908. func (m *WpChatroomMutation) AddedFields() []string {
  45909. var fields []string
  45910. if m.addstatus != nil {
  45911. fields = append(fields, wpchatroom.FieldStatus)
  45912. }
  45913. return fields
  45914. }
  45915. // AddedField returns the numeric value that was incremented/decremented on a field
  45916. // with the given name. The second boolean return value indicates that this field
  45917. // was not set, or was not defined in the schema.
  45918. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  45919. switch name {
  45920. case wpchatroom.FieldStatus:
  45921. return m.AddedStatus()
  45922. }
  45923. return nil, false
  45924. }
  45925. // AddField adds the value to the field with the given name. It returns an error if
  45926. // the field is not defined in the schema, or if the type mismatched the field
  45927. // type.
  45928. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  45929. switch name {
  45930. case wpchatroom.FieldStatus:
  45931. v, ok := value.(int8)
  45932. if !ok {
  45933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45934. }
  45935. m.AddStatus(v)
  45936. return nil
  45937. }
  45938. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  45939. }
  45940. // ClearedFields returns all nullable fields that were cleared during this
  45941. // mutation.
  45942. func (m *WpChatroomMutation) ClearedFields() []string {
  45943. var fields []string
  45944. if m.FieldCleared(wpchatroom.FieldStatus) {
  45945. fields = append(fields, wpchatroom.FieldStatus)
  45946. }
  45947. return fields
  45948. }
  45949. // FieldCleared returns a boolean indicating if a field with the given name was
  45950. // cleared in this mutation.
  45951. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  45952. _, ok := m.clearedFields[name]
  45953. return ok
  45954. }
  45955. // ClearField clears the value of the field with the given name. It returns an
  45956. // error if the field is not defined in the schema.
  45957. func (m *WpChatroomMutation) ClearField(name string) error {
  45958. switch name {
  45959. case wpchatroom.FieldStatus:
  45960. m.ClearStatus()
  45961. return nil
  45962. }
  45963. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  45964. }
  45965. // ResetField resets all changes in the mutation for the field with the given name.
  45966. // It returns an error if the field is not defined in the schema.
  45967. func (m *WpChatroomMutation) ResetField(name string) error {
  45968. switch name {
  45969. case wpchatroom.FieldCreatedAt:
  45970. m.ResetCreatedAt()
  45971. return nil
  45972. case wpchatroom.FieldUpdatedAt:
  45973. m.ResetUpdatedAt()
  45974. return nil
  45975. case wpchatroom.FieldStatus:
  45976. m.ResetStatus()
  45977. return nil
  45978. case wpchatroom.FieldWxWxid:
  45979. m.ResetWxWxid()
  45980. return nil
  45981. case wpchatroom.FieldChatroomID:
  45982. m.ResetChatroomID()
  45983. return nil
  45984. case wpchatroom.FieldNickname:
  45985. m.ResetNickname()
  45986. return nil
  45987. case wpchatroom.FieldOwner:
  45988. m.ResetOwner()
  45989. return nil
  45990. case wpchatroom.FieldAvatar:
  45991. m.ResetAvatar()
  45992. return nil
  45993. case wpchatroom.FieldMemberList:
  45994. m.ResetMemberList()
  45995. return nil
  45996. }
  45997. return fmt.Errorf("unknown WpChatroom field %s", name)
  45998. }
  45999. // AddedEdges returns all edge names that were set/added in this mutation.
  46000. func (m *WpChatroomMutation) AddedEdges() []string {
  46001. edges := make([]string, 0, 0)
  46002. return edges
  46003. }
  46004. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46005. // name in this mutation.
  46006. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  46007. return nil
  46008. }
  46009. // RemovedEdges returns all edge names that were removed in this mutation.
  46010. func (m *WpChatroomMutation) RemovedEdges() []string {
  46011. edges := make([]string, 0, 0)
  46012. return edges
  46013. }
  46014. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46015. // the given name in this mutation.
  46016. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  46017. return nil
  46018. }
  46019. // ClearedEdges returns all edge names that were cleared in this mutation.
  46020. func (m *WpChatroomMutation) ClearedEdges() []string {
  46021. edges := make([]string, 0, 0)
  46022. return edges
  46023. }
  46024. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46025. // was cleared in this mutation.
  46026. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  46027. return false
  46028. }
  46029. // ClearEdge clears the value of the edge with the given name. It returns an error
  46030. // if that edge is not defined in the schema.
  46031. func (m *WpChatroomMutation) ClearEdge(name string) error {
  46032. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  46033. }
  46034. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46035. // It returns an error if the edge is not defined in the schema.
  46036. func (m *WpChatroomMutation) ResetEdge(name string) error {
  46037. return fmt.Errorf("unknown WpChatroom edge %s", name)
  46038. }
  46039. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  46040. type WpChatroomMemberMutation struct {
  46041. config
  46042. op Op
  46043. typ string
  46044. id *uint64
  46045. created_at *time.Time
  46046. updated_at *time.Time
  46047. status *uint8
  46048. addstatus *int8
  46049. wx_wxid *string
  46050. wxid *string
  46051. nickname *string
  46052. avatar *string
  46053. clearedFields map[string]struct{}
  46054. done bool
  46055. oldValue func(context.Context) (*WpChatroomMember, error)
  46056. predicates []predicate.WpChatroomMember
  46057. }
  46058. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  46059. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  46060. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  46061. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  46062. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  46063. m := &WpChatroomMemberMutation{
  46064. config: c,
  46065. op: op,
  46066. typ: TypeWpChatroomMember,
  46067. clearedFields: make(map[string]struct{}),
  46068. }
  46069. for _, opt := range opts {
  46070. opt(m)
  46071. }
  46072. return m
  46073. }
  46074. // withWpChatroomMemberID sets the ID field of the mutation.
  46075. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  46076. return func(m *WpChatroomMemberMutation) {
  46077. var (
  46078. err error
  46079. once sync.Once
  46080. value *WpChatroomMember
  46081. )
  46082. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  46083. once.Do(func() {
  46084. if m.done {
  46085. err = errors.New("querying old values post mutation is not allowed")
  46086. } else {
  46087. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  46088. }
  46089. })
  46090. return value, err
  46091. }
  46092. m.id = &id
  46093. }
  46094. }
  46095. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  46096. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  46097. return func(m *WpChatroomMemberMutation) {
  46098. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  46099. return node, nil
  46100. }
  46101. m.id = &node.ID
  46102. }
  46103. }
  46104. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46105. // executed in a transaction (ent.Tx), a transactional client is returned.
  46106. func (m WpChatroomMemberMutation) Client() *Client {
  46107. client := &Client{config: m.config}
  46108. client.init()
  46109. return client
  46110. }
  46111. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46112. // it returns an error otherwise.
  46113. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  46114. if _, ok := m.driver.(*txDriver); !ok {
  46115. return nil, errors.New("ent: mutation is not running in a transaction")
  46116. }
  46117. tx := &Tx{config: m.config}
  46118. tx.init()
  46119. return tx, nil
  46120. }
  46121. // SetID sets the value of the id field. Note that this
  46122. // operation is only accepted on creation of WpChatroomMember entities.
  46123. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  46124. m.id = &id
  46125. }
  46126. // ID returns the ID value in the mutation. Note that the ID is only available
  46127. // if it was provided to the builder or after it was returned from the database.
  46128. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  46129. if m.id == nil {
  46130. return
  46131. }
  46132. return *m.id, true
  46133. }
  46134. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46135. // That means, if the mutation is applied within a transaction with an isolation level such
  46136. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46137. // or updated by the mutation.
  46138. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  46139. switch {
  46140. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46141. id, exists := m.ID()
  46142. if exists {
  46143. return []uint64{id}, nil
  46144. }
  46145. fallthrough
  46146. case m.op.Is(OpUpdate | OpDelete):
  46147. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  46148. default:
  46149. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46150. }
  46151. }
  46152. // SetCreatedAt sets the "created_at" field.
  46153. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  46154. m.created_at = &t
  46155. }
  46156. // CreatedAt returns the value of the "created_at" field in the mutation.
  46157. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  46158. v := m.created_at
  46159. if v == nil {
  46160. return
  46161. }
  46162. return *v, true
  46163. }
  46164. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  46165. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46167. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46168. if !m.op.Is(OpUpdateOne) {
  46169. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46170. }
  46171. if m.id == nil || m.oldValue == nil {
  46172. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46173. }
  46174. oldValue, err := m.oldValue(ctx)
  46175. if err != nil {
  46176. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46177. }
  46178. return oldValue.CreatedAt, nil
  46179. }
  46180. // ResetCreatedAt resets all changes to the "created_at" field.
  46181. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  46182. m.created_at = nil
  46183. }
  46184. // SetUpdatedAt sets the "updated_at" field.
  46185. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  46186. m.updated_at = &t
  46187. }
  46188. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46189. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  46190. v := m.updated_at
  46191. if v == nil {
  46192. return
  46193. }
  46194. return *v, true
  46195. }
  46196. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  46197. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46199. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46200. if !m.op.Is(OpUpdateOne) {
  46201. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46202. }
  46203. if m.id == nil || m.oldValue == nil {
  46204. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46205. }
  46206. oldValue, err := m.oldValue(ctx)
  46207. if err != nil {
  46208. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46209. }
  46210. return oldValue.UpdatedAt, nil
  46211. }
  46212. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46213. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  46214. m.updated_at = nil
  46215. }
  46216. // SetStatus sets the "status" field.
  46217. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  46218. m.status = &u
  46219. m.addstatus = nil
  46220. }
  46221. // Status returns the value of the "status" field in the mutation.
  46222. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  46223. v := m.status
  46224. if v == nil {
  46225. return
  46226. }
  46227. return *v, true
  46228. }
  46229. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  46230. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46232. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46233. if !m.op.Is(OpUpdateOne) {
  46234. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46235. }
  46236. if m.id == nil || m.oldValue == nil {
  46237. return v, errors.New("OldStatus requires an ID field in the mutation")
  46238. }
  46239. oldValue, err := m.oldValue(ctx)
  46240. if err != nil {
  46241. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46242. }
  46243. return oldValue.Status, nil
  46244. }
  46245. // AddStatus adds u to the "status" field.
  46246. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  46247. if m.addstatus != nil {
  46248. *m.addstatus += u
  46249. } else {
  46250. m.addstatus = &u
  46251. }
  46252. }
  46253. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46254. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  46255. v := m.addstatus
  46256. if v == nil {
  46257. return
  46258. }
  46259. return *v, true
  46260. }
  46261. // ClearStatus clears the value of the "status" field.
  46262. func (m *WpChatroomMemberMutation) ClearStatus() {
  46263. m.status = nil
  46264. m.addstatus = nil
  46265. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  46266. }
  46267. // StatusCleared returns if the "status" field was cleared in this mutation.
  46268. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  46269. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  46270. return ok
  46271. }
  46272. // ResetStatus resets all changes to the "status" field.
  46273. func (m *WpChatroomMemberMutation) ResetStatus() {
  46274. m.status = nil
  46275. m.addstatus = nil
  46276. delete(m.clearedFields, wpchatroommember.FieldStatus)
  46277. }
  46278. // SetWxWxid sets the "wx_wxid" field.
  46279. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  46280. m.wx_wxid = &s
  46281. }
  46282. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  46283. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  46284. v := m.wx_wxid
  46285. if v == nil {
  46286. return
  46287. }
  46288. return *v, true
  46289. }
  46290. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  46291. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46293. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  46294. if !m.op.Is(OpUpdateOne) {
  46295. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  46296. }
  46297. if m.id == nil || m.oldValue == nil {
  46298. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  46299. }
  46300. oldValue, err := m.oldValue(ctx)
  46301. if err != nil {
  46302. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  46303. }
  46304. return oldValue.WxWxid, nil
  46305. }
  46306. // ResetWxWxid resets all changes to the "wx_wxid" field.
  46307. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  46308. m.wx_wxid = nil
  46309. }
  46310. // SetWxid sets the "wxid" field.
  46311. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  46312. m.wxid = &s
  46313. }
  46314. // Wxid returns the value of the "wxid" field in the mutation.
  46315. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  46316. v := m.wxid
  46317. if v == nil {
  46318. return
  46319. }
  46320. return *v, true
  46321. }
  46322. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  46323. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46325. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  46326. if !m.op.Is(OpUpdateOne) {
  46327. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46328. }
  46329. if m.id == nil || m.oldValue == nil {
  46330. return v, errors.New("OldWxid requires an ID field in the mutation")
  46331. }
  46332. oldValue, err := m.oldValue(ctx)
  46333. if err != nil {
  46334. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46335. }
  46336. return oldValue.Wxid, nil
  46337. }
  46338. // ResetWxid resets all changes to the "wxid" field.
  46339. func (m *WpChatroomMemberMutation) ResetWxid() {
  46340. m.wxid = nil
  46341. }
  46342. // SetNickname sets the "nickname" field.
  46343. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  46344. m.nickname = &s
  46345. }
  46346. // Nickname returns the value of the "nickname" field in the mutation.
  46347. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  46348. v := m.nickname
  46349. if v == nil {
  46350. return
  46351. }
  46352. return *v, true
  46353. }
  46354. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  46355. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46357. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  46358. if !m.op.Is(OpUpdateOne) {
  46359. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46360. }
  46361. if m.id == nil || m.oldValue == nil {
  46362. return v, errors.New("OldNickname requires an ID field in the mutation")
  46363. }
  46364. oldValue, err := m.oldValue(ctx)
  46365. if err != nil {
  46366. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46367. }
  46368. return oldValue.Nickname, nil
  46369. }
  46370. // ResetNickname resets all changes to the "nickname" field.
  46371. func (m *WpChatroomMemberMutation) ResetNickname() {
  46372. m.nickname = nil
  46373. }
  46374. // SetAvatar sets the "avatar" field.
  46375. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  46376. m.avatar = &s
  46377. }
  46378. // Avatar returns the value of the "avatar" field in the mutation.
  46379. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  46380. v := m.avatar
  46381. if v == nil {
  46382. return
  46383. }
  46384. return *v, true
  46385. }
  46386. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  46387. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46389. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46390. if !m.op.Is(OpUpdateOne) {
  46391. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46392. }
  46393. if m.id == nil || m.oldValue == nil {
  46394. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46395. }
  46396. oldValue, err := m.oldValue(ctx)
  46397. if err != nil {
  46398. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46399. }
  46400. return oldValue.Avatar, nil
  46401. }
  46402. // ResetAvatar resets all changes to the "avatar" field.
  46403. func (m *WpChatroomMemberMutation) ResetAvatar() {
  46404. m.avatar = nil
  46405. }
  46406. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  46407. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  46408. m.predicates = append(m.predicates, ps...)
  46409. }
  46410. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  46411. // users can use type-assertion to append predicates that do not depend on any generated package.
  46412. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  46413. p := make([]predicate.WpChatroomMember, len(ps))
  46414. for i := range ps {
  46415. p[i] = ps[i]
  46416. }
  46417. m.Where(p...)
  46418. }
  46419. // Op returns the operation name.
  46420. func (m *WpChatroomMemberMutation) Op() Op {
  46421. return m.op
  46422. }
  46423. // SetOp allows setting the mutation operation.
  46424. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  46425. m.op = op
  46426. }
  46427. // Type returns the node type of this mutation (WpChatroomMember).
  46428. func (m *WpChatroomMemberMutation) Type() string {
  46429. return m.typ
  46430. }
  46431. // Fields returns all fields that were changed during this mutation. Note that in
  46432. // order to get all numeric fields that were incremented/decremented, call
  46433. // AddedFields().
  46434. func (m *WpChatroomMemberMutation) Fields() []string {
  46435. fields := make([]string, 0, 7)
  46436. if m.created_at != nil {
  46437. fields = append(fields, wpchatroommember.FieldCreatedAt)
  46438. }
  46439. if m.updated_at != nil {
  46440. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  46441. }
  46442. if m.status != nil {
  46443. fields = append(fields, wpchatroommember.FieldStatus)
  46444. }
  46445. if m.wx_wxid != nil {
  46446. fields = append(fields, wpchatroommember.FieldWxWxid)
  46447. }
  46448. if m.wxid != nil {
  46449. fields = append(fields, wpchatroommember.FieldWxid)
  46450. }
  46451. if m.nickname != nil {
  46452. fields = append(fields, wpchatroommember.FieldNickname)
  46453. }
  46454. if m.avatar != nil {
  46455. fields = append(fields, wpchatroommember.FieldAvatar)
  46456. }
  46457. return fields
  46458. }
  46459. // Field returns the value of a field with the given name. The second boolean
  46460. // return value indicates that this field was not set, or was not defined in the
  46461. // schema.
  46462. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  46463. switch name {
  46464. case wpchatroommember.FieldCreatedAt:
  46465. return m.CreatedAt()
  46466. case wpchatroommember.FieldUpdatedAt:
  46467. return m.UpdatedAt()
  46468. case wpchatroommember.FieldStatus:
  46469. return m.Status()
  46470. case wpchatroommember.FieldWxWxid:
  46471. return m.WxWxid()
  46472. case wpchatroommember.FieldWxid:
  46473. return m.Wxid()
  46474. case wpchatroommember.FieldNickname:
  46475. return m.Nickname()
  46476. case wpchatroommember.FieldAvatar:
  46477. return m.Avatar()
  46478. }
  46479. return nil, false
  46480. }
  46481. // OldField returns the old value of the field from the database. An error is
  46482. // returned if the mutation operation is not UpdateOne, or the query to the
  46483. // database failed.
  46484. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46485. switch name {
  46486. case wpchatroommember.FieldCreatedAt:
  46487. return m.OldCreatedAt(ctx)
  46488. case wpchatroommember.FieldUpdatedAt:
  46489. return m.OldUpdatedAt(ctx)
  46490. case wpchatroommember.FieldStatus:
  46491. return m.OldStatus(ctx)
  46492. case wpchatroommember.FieldWxWxid:
  46493. return m.OldWxWxid(ctx)
  46494. case wpchatroommember.FieldWxid:
  46495. return m.OldWxid(ctx)
  46496. case wpchatroommember.FieldNickname:
  46497. return m.OldNickname(ctx)
  46498. case wpchatroommember.FieldAvatar:
  46499. return m.OldAvatar(ctx)
  46500. }
  46501. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  46502. }
  46503. // SetField sets the value of a field with the given name. It returns an error if
  46504. // the field is not defined in the schema, or if the type mismatched the field
  46505. // type.
  46506. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  46507. switch name {
  46508. case wpchatroommember.FieldCreatedAt:
  46509. v, ok := value.(time.Time)
  46510. if !ok {
  46511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46512. }
  46513. m.SetCreatedAt(v)
  46514. return nil
  46515. case wpchatroommember.FieldUpdatedAt:
  46516. v, ok := value.(time.Time)
  46517. if !ok {
  46518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46519. }
  46520. m.SetUpdatedAt(v)
  46521. return nil
  46522. case wpchatroommember.FieldStatus:
  46523. v, ok := value.(uint8)
  46524. if !ok {
  46525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46526. }
  46527. m.SetStatus(v)
  46528. return nil
  46529. case wpchatroommember.FieldWxWxid:
  46530. v, ok := value.(string)
  46531. if !ok {
  46532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46533. }
  46534. m.SetWxWxid(v)
  46535. return nil
  46536. case wpchatroommember.FieldWxid:
  46537. v, ok := value.(string)
  46538. if !ok {
  46539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46540. }
  46541. m.SetWxid(v)
  46542. return nil
  46543. case wpchatroommember.FieldNickname:
  46544. v, ok := value.(string)
  46545. if !ok {
  46546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46547. }
  46548. m.SetNickname(v)
  46549. return nil
  46550. case wpchatroommember.FieldAvatar:
  46551. v, ok := value.(string)
  46552. if !ok {
  46553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46554. }
  46555. m.SetAvatar(v)
  46556. return nil
  46557. }
  46558. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46559. }
  46560. // AddedFields returns all numeric fields that were incremented/decremented during
  46561. // this mutation.
  46562. func (m *WpChatroomMemberMutation) AddedFields() []string {
  46563. var fields []string
  46564. if m.addstatus != nil {
  46565. fields = append(fields, wpchatroommember.FieldStatus)
  46566. }
  46567. return fields
  46568. }
  46569. // AddedField returns the numeric value that was incremented/decremented on a field
  46570. // with the given name. The second boolean return value indicates that this field
  46571. // was not set, or was not defined in the schema.
  46572. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  46573. switch name {
  46574. case wpchatroommember.FieldStatus:
  46575. return m.AddedStatus()
  46576. }
  46577. return nil, false
  46578. }
  46579. // AddField adds the value to the field with the given name. It returns an error if
  46580. // the field is not defined in the schema, or if the type mismatched the field
  46581. // type.
  46582. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  46583. switch name {
  46584. case wpchatroommember.FieldStatus:
  46585. v, ok := value.(int8)
  46586. if !ok {
  46587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46588. }
  46589. m.AddStatus(v)
  46590. return nil
  46591. }
  46592. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  46593. }
  46594. // ClearedFields returns all nullable fields that were cleared during this
  46595. // mutation.
  46596. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  46597. var fields []string
  46598. if m.FieldCleared(wpchatroommember.FieldStatus) {
  46599. fields = append(fields, wpchatroommember.FieldStatus)
  46600. }
  46601. return fields
  46602. }
  46603. // FieldCleared returns a boolean indicating if a field with the given name was
  46604. // cleared in this mutation.
  46605. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  46606. _, ok := m.clearedFields[name]
  46607. return ok
  46608. }
  46609. // ClearField clears the value of the field with the given name. It returns an
  46610. // error if the field is not defined in the schema.
  46611. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  46612. switch name {
  46613. case wpchatroommember.FieldStatus:
  46614. m.ClearStatus()
  46615. return nil
  46616. }
  46617. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  46618. }
  46619. // ResetField resets all changes in the mutation for the field with the given name.
  46620. // It returns an error if the field is not defined in the schema.
  46621. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  46622. switch name {
  46623. case wpchatroommember.FieldCreatedAt:
  46624. m.ResetCreatedAt()
  46625. return nil
  46626. case wpchatroommember.FieldUpdatedAt:
  46627. m.ResetUpdatedAt()
  46628. return nil
  46629. case wpchatroommember.FieldStatus:
  46630. m.ResetStatus()
  46631. return nil
  46632. case wpchatroommember.FieldWxWxid:
  46633. m.ResetWxWxid()
  46634. return nil
  46635. case wpchatroommember.FieldWxid:
  46636. m.ResetWxid()
  46637. return nil
  46638. case wpchatroommember.FieldNickname:
  46639. m.ResetNickname()
  46640. return nil
  46641. case wpchatroommember.FieldAvatar:
  46642. m.ResetAvatar()
  46643. return nil
  46644. }
  46645. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46646. }
  46647. // AddedEdges returns all edge names that were set/added in this mutation.
  46648. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  46649. edges := make([]string, 0, 0)
  46650. return edges
  46651. }
  46652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46653. // name in this mutation.
  46654. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  46655. return nil
  46656. }
  46657. // RemovedEdges returns all edge names that were removed in this mutation.
  46658. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  46659. edges := make([]string, 0, 0)
  46660. return edges
  46661. }
  46662. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46663. // the given name in this mutation.
  46664. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  46665. return nil
  46666. }
  46667. // ClearedEdges returns all edge names that were cleared in this mutation.
  46668. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  46669. edges := make([]string, 0, 0)
  46670. return edges
  46671. }
  46672. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46673. // was cleared in this mutation.
  46674. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  46675. return false
  46676. }
  46677. // ClearEdge clears the value of the edge with the given name. It returns an error
  46678. // if that edge is not defined in the schema.
  46679. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  46680. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  46681. }
  46682. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46683. // It returns an error if the edge is not defined in the schema.
  46684. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  46685. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  46686. }
  46687. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  46688. type WxMutation struct {
  46689. config
  46690. op Op
  46691. typ string
  46692. id *uint64
  46693. created_at *time.Time
  46694. updated_at *time.Time
  46695. status *uint8
  46696. addstatus *int8
  46697. deleted_at *time.Time
  46698. port *string
  46699. process_id *string
  46700. callback *string
  46701. wxid *string
  46702. account *string
  46703. nickname *string
  46704. tel *string
  46705. head_big *string
  46706. organization_id *uint64
  46707. addorganization_id *int64
  46708. api_base *string
  46709. api_key *string
  46710. allow_list *[]string
  46711. appendallow_list []string
  46712. group_allow_list *[]string
  46713. appendgroup_allow_list []string
  46714. block_list *[]string
  46715. appendblock_list []string
  46716. group_block_list *[]string
  46717. appendgroup_block_list []string
  46718. ctype *uint64
  46719. addctype *int64
  46720. clearedFields map[string]struct{}
  46721. server *uint64
  46722. clearedserver bool
  46723. agent *uint64
  46724. clearedagent bool
  46725. done bool
  46726. oldValue func(context.Context) (*Wx, error)
  46727. predicates []predicate.Wx
  46728. }
  46729. var _ ent.Mutation = (*WxMutation)(nil)
  46730. // wxOption allows management of the mutation configuration using functional options.
  46731. type wxOption func(*WxMutation)
  46732. // newWxMutation creates new mutation for the Wx entity.
  46733. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  46734. m := &WxMutation{
  46735. config: c,
  46736. op: op,
  46737. typ: TypeWx,
  46738. clearedFields: make(map[string]struct{}),
  46739. }
  46740. for _, opt := range opts {
  46741. opt(m)
  46742. }
  46743. return m
  46744. }
  46745. // withWxID sets the ID field of the mutation.
  46746. func withWxID(id uint64) wxOption {
  46747. return func(m *WxMutation) {
  46748. var (
  46749. err error
  46750. once sync.Once
  46751. value *Wx
  46752. )
  46753. m.oldValue = func(ctx context.Context) (*Wx, error) {
  46754. once.Do(func() {
  46755. if m.done {
  46756. err = errors.New("querying old values post mutation is not allowed")
  46757. } else {
  46758. value, err = m.Client().Wx.Get(ctx, id)
  46759. }
  46760. })
  46761. return value, err
  46762. }
  46763. m.id = &id
  46764. }
  46765. }
  46766. // withWx sets the old Wx of the mutation.
  46767. func withWx(node *Wx) wxOption {
  46768. return func(m *WxMutation) {
  46769. m.oldValue = func(context.Context) (*Wx, error) {
  46770. return node, nil
  46771. }
  46772. m.id = &node.ID
  46773. }
  46774. }
  46775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46776. // executed in a transaction (ent.Tx), a transactional client is returned.
  46777. func (m WxMutation) Client() *Client {
  46778. client := &Client{config: m.config}
  46779. client.init()
  46780. return client
  46781. }
  46782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46783. // it returns an error otherwise.
  46784. func (m WxMutation) Tx() (*Tx, error) {
  46785. if _, ok := m.driver.(*txDriver); !ok {
  46786. return nil, errors.New("ent: mutation is not running in a transaction")
  46787. }
  46788. tx := &Tx{config: m.config}
  46789. tx.init()
  46790. return tx, nil
  46791. }
  46792. // SetID sets the value of the id field. Note that this
  46793. // operation is only accepted on creation of Wx entities.
  46794. func (m *WxMutation) SetID(id uint64) {
  46795. m.id = &id
  46796. }
  46797. // ID returns the ID value in the mutation. Note that the ID is only available
  46798. // if it was provided to the builder or after it was returned from the database.
  46799. func (m *WxMutation) ID() (id uint64, exists bool) {
  46800. if m.id == nil {
  46801. return
  46802. }
  46803. return *m.id, true
  46804. }
  46805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46806. // That means, if the mutation is applied within a transaction with an isolation level such
  46807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46808. // or updated by the mutation.
  46809. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  46810. switch {
  46811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46812. id, exists := m.ID()
  46813. if exists {
  46814. return []uint64{id}, nil
  46815. }
  46816. fallthrough
  46817. case m.op.Is(OpUpdate | OpDelete):
  46818. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  46819. default:
  46820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46821. }
  46822. }
  46823. // SetCreatedAt sets the "created_at" field.
  46824. func (m *WxMutation) SetCreatedAt(t time.Time) {
  46825. m.created_at = &t
  46826. }
  46827. // CreatedAt returns the value of the "created_at" field in the mutation.
  46828. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  46829. v := m.created_at
  46830. if v == nil {
  46831. return
  46832. }
  46833. return *v, true
  46834. }
  46835. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  46836. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46838. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46839. if !m.op.Is(OpUpdateOne) {
  46840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46841. }
  46842. if m.id == nil || m.oldValue == nil {
  46843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46844. }
  46845. oldValue, err := m.oldValue(ctx)
  46846. if err != nil {
  46847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46848. }
  46849. return oldValue.CreatedAt, nil
  46850. }
  46851. // ResetCreatedAt resets all changes to the "created_at" field.
  46852. func (m *WxMutation) ResetCreatedAt() {
  46853. m.created_at = nil
  46854. }
  46855. // SetUpdatedAt sets the "updated_at" field.
  46856. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  46857. m.updated_at = &t
  46858. }
  46859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46860. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  46861. v := m.updated_at
  46862. if v == nil {
  46863. return
  46864. }
  46865. return *v, true
  46866. }
  46867. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  46868. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46870. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46871. if !m.op.Is(OpUpdateOne) {
  46872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46873. }
  46874. if m.id == nil || m.oldValue == nil {
  46875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46876. }
  46877. oldValue, err := m.oldValue(ctx)
  46878. if err != nil {
  46879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46880. }
  46881. return oldValue.UpdatedAt, nil
  46882. }
  46883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46884. func (m *WxMutation) ResetUpdatedAt() {
  46885. m.updated_at = nil
  46886. }
  46887. // SetStatus sets the "status" field.
  46888. func (m *WxMutation) SetStatus(u uint8) {
  46889. m.status = &u
  46890. m.addstatus = nil
  46891. }
  46892. // Status returns the value of the "status" field in the mutation.
  46893. func (m *WxMutation) Status() (r uint8, exists bool) {
  46894. v := m.status
  46895. if v == nil {
  46896. return
  46897. }
  46898. return *v, true
  46899. }
  46900. // OldStatus returns the old "status" field's value of the Wx entity.
  46901. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46903. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46904. if !m.op.Is(OpUpdateOne) {
  46905. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46906. }
  46907. if m.id == nil || m.oldValue == nil {
  46908. return v, errors.New("OldStatus requires an ID field in the mutation")
  46909. }
  46910. oldValue, err := m.oldValue(ctx)
  46911. if err != nil {
  46912. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46913. }
  46914. return oldValue.Status, nil
  46915. }
  46916. // AddStatus adds u to the "status" field.
  46917. func (m *WxMutation) AddStatus(u int8) {
  46918. if m.addstatus != nil {
  46919. *m.addstatus += u
  46920. } else {
  46921. m.addstatus = &u
  46922. }
  46923. }
  46924. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46925. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  46926. v := m.addstatus
  46927. if v == nil {
  46928. return
  46929. }
  46930. return *v, true
  46931. }
  46932. // ClearStatus clears the value of the "status" field.
  46933. func (m *WxMutation) ClearStatus() {
  46934. m.status = nil
  46935. m.addstatus = nil
  46936. m.clearedFields[wx.FieldStatus] = struct{}{}
  46937. }
  46938. // StatusCleared returns if the "status" field was cleared in this mutation.
  46939. func (m *WxMutation) StatusCleared() bool {
  46940. _, ok := m.clearedFields[wx.FieldStatus]
  46941. return ok
  46942. }
  46943. // ResetStatus resets all changes to the "status" field.
  46944. func (m *WxMutation) ResetStatus() {
  46945. m.status = nil
  46946. m.addstatus = nil
  46947. delete(m.clearedFields, wx.FieldStatus)
  46948. }
  46949. // SetDeletedAt sets the "deleted_at" field.
  46950. func (m *WxMutation) SetDeletedAt(t time.Time) {
  46951. m.deleted_at = &t
  46952. }
  46953. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46954. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  46955. v := m.deleted_at
  46956. if v == nil {
  46957. return
  46958. }
  46959. return *v, true
  46960. }
  46961. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  46962. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46964. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46965. if !m.op.Is(OpUpdateOne) {
  46966. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46967. }
  46968. if m.id == nil || m.oldValue == nil {
  46969. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46970. }
  46971. oldValue, err := m.oldValue(ctx)
  46972. if err != nil {
  46973. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46974. }
  46975. return oldValue.DeletedAt, nil
  46976. }
  46977. // ClearDeletedAt clears the value of the "deleted_at" field.
  46978. func (m *WxMutation) ClearDeletedAt() {
  46979. m.deleted_at = nil
  46980. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  46981. }
  46982. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46983. func (m *WxMutation) DeletedAtCleared() bool {
  46984. _, ok := m.clearedFields[wx.FieldDeletedAt]
  46985. return ok
  46986. }
  46987. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46988. func (m *WxMutation) ResetDeletedAt() {
  46989. m.deleted_at = nil
  46990. delete(m.clearedFields, wx.FieldDeletedAt)
  46991. }
  46992. // SetServerID sets the "server_id" field.
  46993. func (m *WxMutation) SetServerID(u uint64) {
  46994. m.server = &u
  46995. }
  46996. // ServerID returns the value of the "server_id" field in the mutation.
  46997. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  46998. v := m.server
  46999. if v == nil {
  47000. return
  47001. }
  47002. return *v, true
  47003. }
  47004. // OldServerID returns the old "server_id" field's value of the Wx entity.
  47005. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47007. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  47008. if !m.op.Is(OpUpdateOne) {
  47009. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  47010. }
  47011. if m.id == nil || m.oldValue == nil {
  47012. return v, errors.New("OldServerID requires an ID field in the mutation")
  47013. }
  47014. oldValue, err := m.oldValue(ctx)
  47015. if err != nil {
  47016. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  47017. }
  47018. return oldValue.ServerID, nil
  47019. }
  47020. // ClearServerID clears the value of the "server_id" field.
  47021. func (m *WxMutation) ClearServerID() {
  47022. m.server = nil
  47023. m.clearedFields[wx.FieldServerID] = struct{}{}
  47024. }
  47025. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  47026. func (m *WxMutation) ServerIDCleared() bool {
  47027. _, ok := m.clearedFields[wx.FieldServerID]
  47028. return ok
  47029. }
  47030. // ResetServerID resets all changes to the "server_id" field.
  47031. func (m *WxMutation) ResetServerID() {
  47032. m.server = nil
  47033. delete(m.clearedFields, wx.FieldServerID)
  47034. }
  47035. // SetPort sets the "port" field.
  47036. func (m *WxMutation) SetPort(s string) {
  47037. m.port = &s
  47038. }
  47039. // Port returns the value of the "port" field in the mutation.
  47040. func (m *WxMutation) Port() (r string, exists bool) {
  47041. v := m.port
  47042. if v == nil {
  47043. return
  47044. }
  47045. return *v, true
  47046. }
  47047. // OldPort returns the old "port" field's value of the Wx entity.
  47048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47050. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  47051. if !m.op.Is(OpUpdateOne) {
  47052. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  47053. }
  47054. if m.id == nil || m.oldValue == nil {
  47055. return v, errors.New("OldPort requires an ID field in the mutation")
  47056. }
  47057. oldValue, err := m.oldValue(ctx)
  47058. if err != nil {
  47059. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  47060. }
  47061. return oldValue.Port, nil
  47062. }
  47063. // ResetPort resets all changes to the "port" field.
  47064. func (m *WxMutation) ResetPort() {
  47065. m.port = nil
  47066. }
  47067. // SetProcessID sets the "process_id" field.
  47068. func (m *WxMutation) SetProcessID(s string) {
  47069. m.process_id = &s
  47070. }
  47071. // ProcessID returns the value of the "process_id" field in the mutation.
  47072. func (m *WxMutation) ProcessID() (r string, exists bool) {
  47073. v := m.process_id
  47074. if v == nil {
  47075. return
  47076. }
  47077. return *v, true
  47078. }
  47079. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  47080. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47082. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  47083. if !m.op.Is(OpUpdateOne) {
  47084. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  47085. }
  47086. if m.id == nil || m.oldValue == nil {
  47087. return v, errors.New("OldProcessID requires an ID field in the mutation")
  47088. }
  47089. oldValue, err := m.oldValue(ctx)
  47090. if err != nil {
  47091. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  47092. }
  47093. return oldValue.ProcessID, nil
  47094. }
  47095. // ResetProcessID resets all changes to the "process_id" field.
  47096. func (m *WxMutation) ResetProcessID() {
  47097. m.process_id = nil
  47098. }
  47099. // SetCallback sets the "callback" field.
  47100. func (m *WxMutation) SetCallback(s string) {
  47101. m.callback = &s
  47102. }
  47103. // Callback returns the value of the "callback" field in the mutation.
  47104. func (m *WxMutation) Callback() (r string, exists bool) {
  47105. v := m.callback
  47106. if v == nil {
  47107. return
  47108. }
  47109. return *v, true
  47110. }
  47111. // OldCallback returns the old "callback" field's value of the Wx entity.
  47112. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47114. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  47115. if !m.op.Is(OpUpdateOne) {
  47116. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  47117. }
  47118. if m.id == nil || m.oldValue == nil {
  47119. return v, errors.New("OldCallback requires an ID field in the mutation")
  47120. }
  47121. oldValue, err := m.oldValue(ctx)
  47122. if err != nil {
  47123. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  47124. }
  47125. return oldValue.Callback, nil
  47126. }
  47127. // ResetCallback resets all changes to the "callback" field.
  47128. func (m *WxMutation) ResetCallback() {
  47129. m.callback = nil
  47130. }
  47131. // SetWxid sets the "wxid" field.
  47132. func (m *WxMutation) SetWxid(s string) {
  47133. m.wxid = &s
  47134. }
  47135. // Wxid returns the value of the "wxid" field in the mutation.
  47136. func (m *WxMutation) Wxid() (r string, exists bool) {
  47137. v := m.wxid
  47138. if v == nil {
  47139. return
  47140. }
  47141. return *v, true
  47142. }
  47143. // OldWxid returns the old "wxid" field's value of the Wx entity.
  47144. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47146. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  47147. if !m.op.Is(OpUpdateOne) {
  47148. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47149. }
  47150. if m.id == nil || m.oldValue == nil {
  47151. return v, errors.New("OldWxid requires an ID field in the mutation")
  47152. }
  47153. oldValue, err := m.oldValue(ctx)
  47154. if err != nil {
  47155. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47156. }
  47157. return oldValue.Wxid, nil
  47158. }
  47159. // ResetWxid resets all changes to the "wxid" field.
  47160. func (m *WxMutation) ResetWxid() {
  47161. m.wxid = nil
  47162. }
  47163. // SetAccount sets the "account" field.
  47164. func (m *WxMutation) SetAccount(s string) {
  47165. m.account = &s
  47166. }
  47167. // Account returns the value of the "account" field in the mutation.
  47168. func (m *WxMutation) Account() (r string, exists bool) {
  47169. v := m.account
  47170. if v == nil {
  47171. return
  47172. }
  47173. return *v, true
  47174. }
  47175. // OldAccount returns the old "account" field's value of the Wx entity.
  47176. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47178. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  47179. if !m.op.Is(OpUpdateOne) {
  47180. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47181. }
  47182. if m.id == nil || m.oldValue == nil {
  47183. return v, errors.New("OldAccount requires an ID field in the mutation")
  47184. }
  47185. oldValue, err := m.oldValue(ctx)
  47186. if err != nil {
  47187. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47188. }
  47189. return oldValue.Account, nil
  47190. }
  47191. // ResetAccount resets all changes to the "account" field.
  47192. func (m *WxMutation) ResetAccount() {
  47193. m.account = nil
  47194. }
  47195. // SetNickname sets the "nickname" field.
  47196. func (m *WxMutation) SetNickname(s string) {
  47197. m.nickname = &s
  47198. }
  47199. // Nickname returns the value of the "nickname" field in the mutation.
  47200. func (m *WxMutation) Nickname() (r string, exists bool) {
  47201. v := m.nickname
  47202. if v == nil {
  47203. return
  47204. }
  47205. return *v, true
  47206. }
  47207. // OldNickname returns the old "nickname" field's value of the Wx entity.
  47208. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47210. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  47211. if !m.op.Is(OpUpdateOne) {
  47212. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47213. }
  47214. if m.id == nil || m.oldValue == nil {
  47215. return v, errors.New("OldNickname requires an ID field in the mutation")
  47216. }
  47217. oldValue, err := m.oldValue(ctx)
  47218. if err != nil {
  47219. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47220. }
  47221. return oldValue.Nickname, nil
  47222. }
  47223. // ResetNickname resets all changes to the "nickname" field.
  47224. func (m *WxMutation) ResetNickname() {
  47225. m.nickname = nil
  47226. }
  47227. // SetTel sets the "tel" field.
  47228. func (m *WxMutation) SetTel(s string) {
  47229. m.tel = &s
  47230. }
  47231. // Tel returns the value of the "tel" field in the mutation.
  47232. func (m *WxMutation) Tel() (r string, exists bool) {
  47233. v := m.tel
  47234. if v == nil {
  47235. return
  47236. }
  47237. return *v, true
  47238. }
  47239. // OldTel returns the old "tel" field's value of the Wx entity.
  47240. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47242. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  47243. if !m.op.Is(OpUpdateOne) {
  47244. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  47245. }
  47246. if m.id == nil || m.oldValue == nil {
  47247. return v, errors.New("OldTel requires an ID field in the mutation")
  47248. }
  47249. oldValue, err := m.oldValue(ctx)
  47250. if err != nil {
  47251. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  47252. }
  47253. return oldValue.Tel, nil
  47254. }
  47255. // ResetTel resets all changes to the "tel" field.
  47256. func (m *WxMutation) ResetTel() {
  47257. m.tel = nil
  47258. }
  47259. // SetHeadBig sets the "head_big" field.
  47260. func (m *WxMutation) SetHeadBig(s string) {
  47261. m.head_big = &s
  47262. }
  47263. // HeadBig returns the value of the "head_big" field in the mutation.
  47264. func (m *WxMutation) HeadBig() (r string, exists bool) {
  47265. v := m.head_big
  47266. if v == nil {
  47267. return
  47268. }
  47269. return *v, true
  47270. }
  47271. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  47272. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47274. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  47275. if !m.op.Is(OpUpdateOne) {
  47276. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  47277. }
  47278. if m.id == nil || m.oldValue == nil {
  47279. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  47280. }
  47281. oldValue, err := m.oldValue(ctx)
  47282. if err != nil {
  47283. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  47284. }
  47285. return oldValue.HeadBig, nil
  47286. }
  47287. // ResetHeadBig resets all changes to the "head_big" field.
  47288. func (m *WxMutation) ResetHeadBig() {
  47289. m.head_big = nil
  47290. }
  47291. // SetOrganizationID sets the "organization_id" field.
  47292. func (m *WxMutation) SetOrganizationID(u uint64) {
  47293. m.organization_id = &u
  47294. m.addorganization_id = nil
  47295. }
  47296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47297. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  47298. v := m.organization_id
  47299. if v == nil {
  47300. return
  47301. }
  47302. return *v, true
  47303. }
  47304. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  47305. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47307. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47308. if !m.op.Is(OpUpdateOne) {
  47309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47310. }
  47311. if m.id == nil || m.oldValue == nil {
  47312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47313. }
  47314. oldValue, err := m.oldValue(ctx)
  47315. if err != nil {
  47316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47317. }
  47318. return oldValue.OrganizationID, nil
  47319. }
  47320. // AddOrganizationID adds u to the "organization_id" field.
  47321. func (m *WxMutation) AddOrganizationID(u int64) {
  47322. if m.addorganization_id != nil {
  47323. *m.addorganization_id += u
  47324. } else {
  47325. m.addorganization_id = &u
  47326. }
  47327. }
  47328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47329. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  47330. v := m.addorganization_id
  47331. if v == nil {
  47332. return
  47333. }
  47334. return *v, true
  47335. }
  47336. // ClearOrganizationID clears the value of the "organization_id" field.
  47337. func (m *WxMutation) ClearOrganizationID() {
  47338. m.organization_id = nil
  47339. m.addorganization_id = nil
  47340. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  47341. }
  47342. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  47343. func (m *WxMutation) OrganizationIDCleared() bool {
  47344. _, ok := m.clearedFields[wx.FieldOrganizationID]
  47345. return ok
  47346. }
  47347. // ResetOrganizationID resets all changes to the "organization_id" field.
  47348. func (m *WxMutation) ResetOrganizationID() {
  47349. m.organization_id = nil
  47350. m.addorganization_id = nil
  47351. delete(m.clearedFields, wx.FieldOrganizationID)
  47352. }
  47353. // SetAgentID sets the "agent_id" field.
  47354. func (m *WxMutation) SetAgentID(u uint64) {
  47355. m.agent = &u
  47356. }
  47357. // AgentID returns the value of the "agent_id" field in the mutation.
  47358. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  47359. v := m.agent
  47360. if v == nil {
  47361. return
  47362. }
  47363. return *v, true
  47364. }
  47365. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  47366. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47368. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47369. if !m.op.Is(OpUpdateOne) {
  47370. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47371. }
  47372. if m.id == nil || m.oldValue == nil {
  47373. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47374. }
  47375. oldValue, err := m.oldValue(ctx)
  47376. if err != nil {
  47377. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47378. }
  47379. return oldValue.AgentID, nil
  47380. }
  47381. // ResetAgentID resets all changes to the "agent_id" field.
  47382. func (m *WxMutation) ResetAgentID() {
  47383. m.agent = nil
  47384. }
  47385. // SetAPIBase sets the "api_base" field.
  47386. func (m *WxMutation) SetAPIBase(s string) {
  47387. m.api_base = &s
  47388. }
  47389. // APIBase returns the value of the "api_base" field in the mutation.
  47390. func (m *WxMutation) APIBase() (r string, exists bool) {
  47391. v := m.api_base
  47392. if v == nil {
  47393. return
  47394. }
  47395. return *v, true
  47396. }
  47397. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  47398. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47400. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47401. if !m.op.Is(OpUpdateOne) {
  47402. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47403. }
  47404. if m.id == nil || m.oldValue == nil {
  47405. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47406. }
  47407. oldValue, err := m.oldValue(ctx)
  47408. if err != nil {
  47409. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47410. }
  47411. return oldValue.APIBase, nil
  47412. }
  47413. // ClearAPIBase clears the value of the "api_base" field.
  47414. func (m *WxMutation) ClearAPIBase() {
  47415. m.api_base = nil
  47416. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  47417. }
  47418. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47419. func (m *WxMutation) APIBaseCleared() bool {
  47420. _, ok := m.clearedFields[wx.FieldAPIBase]
  47421. return ok
  47422. }
  47423. // ResetAPIBase resets all changes to the "api_base" field.
  47424. func (m *WxMutation) ResetAPIBase() {
  47425. m.api_base = nil
  47426. delete(m.clearedFields, wx.FieldAPIBase)
  47427. }
  47428. // SetAPIKey sets the "api_key" field.
  47429. func (m *WxMutation) SetAPIKey(s string) {
  47430. m.api_key = &s
  47431. }
  47432. // APIKey returns the value of the "api_key" field in the mutation.
  47433. func (m *WxMutation) APIKey() (r string, exists bool) {
  47434. v := m.api_key
  47435. if v == nil {
  47436. return
  47437. }
  47438. return *v, true
  47439. }
  47440. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  47441. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47443. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47444. if !m.op.Is(OpUpdateOne) {
  47445. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47446. }
  47447. if m.id == nil || m.oldValue == nil {
  47448. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47449. }
  47450. oldValue, err := m.oldValue(ctx)
  47451. if err != nil {
  47452. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47453. }
  47454. return oldValue.APIKey, nil
  47455. }
  47456. // ClearAPIKey clears the value of the "api_key" field.
  47457. func (m *WxMutation) ClearAPIKey() {
  47458. m.api_key = nil
  47459. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  47460. }
  47461. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47462. func (m *WxMutation) APIKeyCleared() bool {
  47463. _, ok := m.clearedFields[wx.FieldAPIKey]
  47464. return ok
  47465. }
  47466. // ResetAPIKey resets all changes to the "api_key" field.
  47467. func (m *WxMutation) ResetAPIKey() {
  47468. m.api_key = nil
  47469. delete(m.clearedFields, wx.FieldAPIKey)
  47470. }
  47471. // SetAllowList sets the "allow_list" field.
  47472. func (m *WxMutation) SetAllowList(s []string) {
  47473. m.allow_list = &s
  47474. m.appendallow_list = nil
  47475. }
  47476. // AllowList returns the value of the "allow_list" field in the mutation.
  47477. func (m *WxMutation) AllowList() (r []string, exists bool) {
  47478. v := m.allow_list
  47479. if v == nil {
  47480. return
  47481. }
  47482. return *v, true
  47483. }
  47484. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  47485. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47487. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  47488. if !m.op.Is(OpUpdateOne) {
  47489. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  47490. }
  47491. if m.id == nil || m.oldValue == nil {
  47492. return v, errors.New("OldAllowList requires an ID field in the mutation")
  47493. }
  47494. oldValue, err := m.oldValue(ctx)
  47495. if err != nil {
  47496. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  47497. }
  47498. return oldValue.AllowList, nil
  47499. }
  47500. // AppendAllowList adds s to the "allow_list" field.
  47501. func (m *WxMutation) AppendAllowList(s []string) {
  47502. m.appendallow_list = append(m.appendallow_list, s...)
  47503. }
  47504. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  47505. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  47506. if len(m.appendallow_list) == 0 {
  47507. return nil, false
  47508. }
  47509. return m.appendallow_list, true
  47510. }
  47511. // ResetAllowList resets all changes to the "allow_list" field.
  47512. func (m *WxMutation) ResetAllowList() {
  47513. m.allow_list = nil
  47514. m.appendallow_list = nil
  47515. }
  47516. // SetGroupAllowList sets the "group_allow_list" field.
  47517. func (m *WxMutation) SetGroupAllowList(s []string) {
  47518. m.group_allow_list = &s
  47519. m.appendgroup_allow_list = nil
  47520. }
  47521. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  47522. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  47523. v := m.group_allow_list
  47524. if v == nil {
  47525. return
  47526. }
  47527. return *v, true
  47528. }
  47529. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  47530. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47532. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  47533. if !m.op.Is(OpUpdateOne) {
  47534. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  47535. }
  47536. if m.id == nil || m.oldValue == nil {
  47537. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  47538. }
  47539. oldValue, err := m.oldValue(ctx)
  47540. if err != nil {
  47541. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  47542. }
  47543. return oldValue.GroupAllowList, nil
  47544. }
  47545. // AppendGroupAllowList adds s to the "group_allow_list" field.
  47546. func (m *WxMutation) AppendGroupAllowList(s []string) {
  47547. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  47548. }
  47549. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  47550. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  47551. if len(m.appendgroup_allow_list) == 0 {
  47552. return nil, false
  47553. }
  47554. return m.appendgroup_allow_list, true
  47555. }
  47556. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  47557. func (m *WxMutation) ResetGroupAllowList() {
  47558. m.group_allow_list = nil
  47559. m.appendgroup_allow_list = nil
  47560. }
  47561. // SetBlockList sets the "block_list" field.
  47562. func (m *WxMutation) SetBlockList(s []string) {
  47563. m.block_list = &s
  47564. m.appendblock_list = nil
  47565. }
  47566. // BlockList returns the value of the "block_list" field in the mutation.
  47567. func (m *WxMutation) BlockList() (r []string, exists bool) {
  47568. v := m.block_list
  47569. if v == nil {
  47570. return
  47571. }
  47572. return *v, true
  47573. }
  47574. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  47575. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47577. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  47578. if !m.op.Is(OpUpdateOne) {
  47579. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  47580. }
  47581. if m.id == nil || m.oldValue == nil {
  47582. return v, errors.New("OldBlockList requires an ID field in the mutation")
  47583. }
  47584. oldValue, err := m.oldValue(ctx)
  47585. if err != nil {
  47586. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  47587. }
  47588. return oldValue.BlockList, nil
  47589. }
  47590. // AppendBlockList adds s to the "block_list" field.
  47591. func (m *WxMutation) AppendBlockList(s []string) {
  47592. m.appendblock_list = append(m.appendblock_list, s...)
  47593. }
  47594. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  47595. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  47596. if len(m.appendblock_list) == 0 {
  47597. return nil, false
  47598. }
  47599. return m.appendblock_list, true
  47600. }
  47601. // ResetBlockList resets all changes to the "block_list" field.
  47602. func (m *WxMutation) ResetBlockList() {
  47603. m.block_list = nil
  47604. m.appendblock_list = nil
  47605. }
  47606. // SetGroupBlockList sets the "group_block_list" field.
  47607. func (m *WxMutation) SetGroupBlockList(s []string) {
  47608. m.group_block_list = &s
  47609. m.appendgroup_block_list = nil
  47610. }
  47611. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  47612. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  47613. v := m.group_block_list
  47614. if v == nil {
  47615. return
  47616. }
  47617. return *v, true
  47618. }
  47619. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  47620. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47622. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  47623. if !m.op.Is(OpUpdateOne) {
  47624. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  47625. }
  47626. if m.id == nil || m.oldValue == nil {
  47627. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  47628. }
  47629. oldValue, err := m.oldValue(ctx)
  47630. if err != nil {
  47631. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  47632. }
  47633. return oldValue.GroupBlockList, nil
  47634. }
  47635. // AppendGroupBlockList adds s to the "group_block_list" field.
  47636. func (m *WxMutation) AppendGroupBlockList(s []string) {
  47637. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  47638. }
  47639. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  47640. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  47641. if len(m.appendgroup_block_list) == 0 {
  47642. return nil, false
  47643. }
  47644. return m.appendgroup_block_list, true
  47645. }
  47646. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  47647. func (m *WxMutation) ResetGroupBlockList() {
  47648. m.group_block_list = nil
  47649. m.appendgroup_block_list = nil
  47650. }
  47651. // SetCtype sets the "ctype" field.
  47652. func (m *WxMutation) SetCtype(u uint64) {
  47653. m.ctype = &u
  47654. m.addctype = nil
  47655. }
  47656. // Ctype returns the value of the "ctype" field in the mutation.
  47657. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  47658. v := m.ctype
  47659. if v == nil {
  47660. return
  47661. }
  47662. return *v, true
  47663. }
  47664. // OldCtype returns the old "ctype" field's value of the Wx entity.
  47665. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47667. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  47668. if !m.op.Is(OpUpdateOne) {
  47669. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  47670. }
  47671. if m.id == nil || m.oldValue == nil {
  47672. return v, errors.New("OldCtype requires an ID field in the mutation")
  47673. }
  47674. oldValue, err := m.oldValue(ctx)
  47675. if err != nil {
  47676. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  47677. }
  47678. return oldValue.Ctype, nil
  47679. }
  47680. // AddCtype adds u to the "ctype" field.
  47681. func (m *WxMutation) AddCtype(u int64) {
  47682. if m.addctype != nil {
  47683. *m.addctype += u
  47684. } else {
  47685. m.addctype = &u
  47686. }
  47687. }
  47688. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  47689. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  47690. v := m.addctype
  47691. if v == nil {
  47692. return
  47693. }
  47694. return *v, true
  47695. }
  47696. // ClearCtype clears the value of the "ctype" field.
  47697. func (m *WxMutation) ClearCtype() {
  47698. m.ctype = nil
  47699. m.addctype = nil
  47700. m.clearedFields[wx.FieldCtype] = struct{}{}
  47701. }
  47702. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  47703. func (m *WxMutation) CtypeCleared() bool {
  47704. _, ok := m.clearedFields[wx.FieldCtype]
  47705. return ok
  47706. }
  47707. // ResetCtype resets all changes to the "ctype" field.
  47708. func (m *WxMutation) ResetCtype() {
  47709. m.ctype = nil
  47710. m.addctype = nil
  47711. delete(m.clearedFields, wx.FieldCtype)
  47712. }
  47713. // ClearServer clears the "server" edge to the Server entity.
  47714. func (m *WxMutation) ClearServer() {
  47715. m.clearedserver = true
  47716. m.clearedFields[wx.FieldServerID] = struct{}{}
  47717. }
  47718. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  47719. func (m *WxMutation) ServerCleared() bool {
  47720. return m.ServerIDCleared() || m.clearedserver
  47721. }
  47722. // ServerIDs returns the "server" edge IDs in the mutation.
  47723. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47724. // ServerID instead. It exists only for internal usage by the builders.
  47725. func (m *WxMutation) ServerIDs() (ids []uint64) {
  47726. if id := m.server; id != nil {
  47727. ids = append(ids, *id)
  47728. }
  47729. return
  47730. }
  47731. // ResetServer resets all changes to the "server" edge.
  47732. func (m *WxMutation) ResetServer() {
  47733. m.server = nil
  47734. m.clearedserver = false
  47735. }
  47736. // ClearAgent clears the "agent" edge to the Agent entity.
  47737. func (m *WxMutation) ClearAgent() {
  47738. m.clearedagent = true
  47739. m.clearedFields[wx.FieldAgentID] = struct{}{}
  47740. }
  47741. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47742. func (m *WxMutation) AgentCleared() bool {
  47743. return m.clearedagent
  47744. }
  47745. // AgentIDs returns the "agent" edge IDs in the mutation.
  47746. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47747. // AgentID instead. It exists only for internal usage by the builders.
  47748. func (m *WxMutation) AgentIDs() (ids []uint64) {
  47749. if id := m.agent; id != nil {
  47750. ids = append(ids, *id)
  47751. }
  47752. return
  47753. }
  47754. // ResetAgent resets all changes to the "agent" edge.
  47755. func (m *WxMutation) ResetAgent() {
  47756. m.agent = nil
  47757. m.clearedagent = false
  47758. }
  47759. // Where appends a list predicates to the WxMutation builder.
  47760. func (m *WxMutation) Where(ps ...predicate.Wx) {
  47761. m.predicates = append(m.predicates, ps...)
  47762. }
  47763. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  47764. // users can use type-assertion to append predicates that do not depend on any generated package.
  47765. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  47766. p := make([]predicate.Wx, len(ps))
  47767. for i := range ps {
  47768. p[i] = ps[i]
  47769. }
  47770. m.Where(p...)
  47771. }
  47772. // Op returns the operation name.
  47773. func (m *WxMutation) Op() Op {
  47774. return m.op
  47775. }
  47776. // SetOp allows setting the mutation operation.
  47777. func (m *WxMutation) SetOp(op Op) {
  47778. m.op = op
  47779. }
  47780. // Type returns the node type of this mutation (Wx).
  47781. func (m *WxMutation) Type() string {
  47782. return m.typ
  47783. }
  47784. // Fields returns all fields that were changed during this mutation. Note that in
  47785. // order to get all numeric fields that were incremented/decremented, call
  47786. // AddedFields().
  47787. func (m *WxMutation) Fields() []string {
  47788. fields := make([]string, 0, 22)
  47789. if m.created_at != nil {
  47790. fields = append(fields, wx.FieldCreatedAt)
  47791. }
  47792. if m.updated_at != nil {
  47793. fields = append(fields, wx.FieldUpdatedAt)
  47794. }
  47795. if m.status != nil {
  47796. fields = append(fields, wx.FieldStatus)
  47797. }
  47798. if m.deleted_at != nil {
  47799. fields = append(fields, wx.FieldDeletedAt)
  47800. }
  47801. if m.server != nil {
  47802. fields = append(fields, wx.FieldServerID)
  47803. }
  47804. if m.port != nil {
  47805. fields = append(fields, wx.FieldPort)
  47806. }
  47807. if m.process_id != nil {
  47808. fields = append(fields, wx.FieldProcessID)
  47809. }
  47810. if m.callback != nil {
  47811. fields = append(fields, wx.FieldCallback)
  47812. }
  47813. if m.wxid != nil {
  47814. fields = append(fields, wx.FieldWxid)
  47815. }
  47816. if m.account != nil {
  47817. fields = append(fields, wx.FieldAccount)
  47818. }
  47819. if m.nickname != nil {
  47820. fields = append(fields, wx.FieldNickname)
  47821. }
  47822. if m.tel != nil {
  47823. fields = append(fields, wx.FieldTel)
  47824. }
  47825. if m.head_big != nil {
  47826. fields = append(fields, wx.FieldHeadBig)
  47827. }
  47828. if m.organization_id != nil {
  47829. fields = append(fields, wx.FieldOrganizationID)
  47830. }
  47831. if m.agent != nil {
  47832. fields = append(fields, wx.FieldAgentID)
  47833. }
  47834. if m.api_base != nil {
  47835. fields = append(fields, wx.FieldAPIBase)
  47836. }
  47837. if m.api_key != nil {
  47838. fields = append(fields, wx.FieldAPIKey)
  47839. }
  47840. if m.allow_list != nil {
  47841. fields = append(fields, wx.FieldAllowList)
  47842. }
  47843. if m.group_allow_list != nil {
  47844. fields = append(fields, wx.FieldGroupAllowList)
  47845. }
  47846. if m.block_list != nil {
  47847. fields = append(fields, wx.FieldBlockList)
  47848. }
  47849. if m.group_block_list != nil {
  47850. fields = append(fields, wx.FieldGroupBlockList)
  47851. }
  47852. if m.ctype != nil {
  47853. fields = append(fields, wx.FieldCtype)
  47854. }
  47855. return fields
  47856. }
  47857. // Field returns the value of a field with the given name. The second boolean
  47858. // return value indicates that this field was not set, or was not defined in the
  47859. // schema.
  47860. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  47861. switch name {
  47862. case wx.FieldCreatedAt:
  47863. return m.CreatedAt()
  47864. case wx.FieldUpdatedAt:
  47865. return m.UpdatedAt()
  47866. case wx.FieldStatus:
  47867. return m.Status()
  47868. case wx.FieldDeletedAt:
  47869. return m.DeletedAt()
  47870. case wx.FieldServerID:
  47871. return m.ServerID()
  47872. case wx.FieldPort:
  47873. return m.Port()
  47874. case wx.FieldProcessID:
  47875. return m.ProcessID()
  47876. case wx.FieldCallback:
  47877. return m.Callback()
  47878. case wx.FieldWxid:
  47879. return m.Wxid()
  47880. case wx.FieldAccount:
  47881. return m.Account()
  47882. case wx.FieldNickname:
  47883. return m.Nickname()
  47884. case wx.FieldTel:
  47885. return m.Tel()
  47886. case wx.FieldHeadBig:
  47887. return m.HeadBig()
  47888. case wx.FieldOrganizationID:
  47889. return m.OrganizationID()
  47890. case wx.FieldAgentID:
  47891. return m.AgentID()
  47892. case wx.FieldAPIBase:
  47893. return m.APIBase()
  47894. case wx.FieldAPIKey:
  47895. return m.APIKey()
  47896. case wx.FieldAllowList:
  47897. return m.AllowList()
  47898. case wx.FieldGroupAllowList:
  47899. return m.GroupAllowList()
  47900. case wx.FieldBlockList:
  47901. return m.BlockList()
  47902. case wx.FieldGroupBlockList:
  47903. return m.GroupBlockList()
  47904. case wx.FieldCtype:
  47905. return m.Ctype()
  47906. }
  47907. return nil, false
  47908. }
  47909. // OldField returns the old value of the field from the database. An error is
  47910. // returned if the mutation operation is not UpdateOne, or the query to the
  47911. // database failed.
  47912. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47913. switch name {
  47914. case wx.FieldCreatedAt:
  47915. return m.OldCreatedAt(ctx)
  47916. case wx.FieldUpdatedAt:
  47917. return m.OldUpdatedAt(ctx)
  47918. case wx.FieldStatus:
  47919. return m.OldStatus(ctx)
  47920. case wx.FieldDeletedAt:
  47921. return m.OldDeletedAt(ctx)
  47922. case wx.FieldServerID:
  47923. return m.OldServerID(ctx)
  47924. case wx.FieldPort:
  47925. return m.OldPort(ctx)
  47926. case wx.FieldProcessID:
  47927. return m.OldProcessID(ctx)
  47928. case wx.FieldCallback:
  47929. return m.OldCallback(ctx)
  47930. case wx.FieldWxid:
  47931. return m.OldWxid(ctx)
  47932. case wx.FieldAccount:
  47933. return m.OldAccount(ctx)
  47934. case wx.FieldNickname:
  47935. return m.OldNickname(ctx)
  47936. case wx.FieldTel:
  47937. return m.OldTel(ctx)
  47938. case wx.FieldHeadBig:
  47939. return m.OldHeadBig(ctx)
  47940. case wx.FieldOrganizationID:
  47941. return m.OldOrganizationID(ctx)
  47942. case wx.FieldAgentID:
  47943. return m.OldAgentID(ctx)
  47944. case wx.FieldAPIBase:
  47945. return m.OldAPIBase(ctx)
  47946. case wx.FieldAPIKey:
  47947. return m.OldAPIKey(ctx)
  47948. case wx.FieldAllowList:
  47949. return m.OldAllowList(ctx)
  47950. case wx.FieldGroupAllowList:
  47951. return m.OldGroupAllowList(ctx)
  47952. case wx.FieldBlockList:
  47953. return m.OldBlockList(ctx)
  47954. case wx.FieldGroupBlockList:
  47955. return m.OldGroupBlockList(ctx)
  47956. case wx.FieldCtype:
  47957. return m.OldCtype(ctx)
  47958. }
  47959. return nil, fmt.Errorf("unknown Wx field %s", name)
  47960. }
  47961. // SetField sets the value of a field with the given name. It returns an error if
  47962. // the field is not defined in the schema, or if the type mismatched the field
  47963. // type.
  47964. func (m *WxMutation) SetField(name string, value ent.Value) error {
  47965. switch name {
  47966. case wx.FieldCreatedAt:
  47967. v, ok := value.(time.Time)
  47968. if !ok {
  47969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47970. }
  47971. m.SetCreatedAt(v)
  47972. return nil
  47973. case wx.FieldUpdatedAt:
  47974. v, ok := value.(time.Time)
  47975. if !ok {
  47976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47977. }
  47978. m.SetUpdatedAt(v)
  47979. return nil
  47980. case wx.FieldStatus:
  47981. v, ok := value.(uint8)
  47982. if !ok {
  47983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47984. }
  47985. m.SetStatus(v)
  47986. return nil
  47987. case wx.FieldDeletedAt:
  47988. v, ok := value.(time.Time)
  47989. if !ok {
  47990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47991. }
  47992. m.SetDeletedAt(v)
  47993. return nil
  47994. case wx.FieldServerID:
  47995. v, ok := value.(uint64)
  47996. if !ok {
  47997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47998. }
  47999. m.SetServerID(v)
  48000. return nil
  48001. case wx.FieldPort:
  48002. v, ok := value.(string)
  48003. if !ok {
  48004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48005. }
  48006. m.SetPort(v)
  48007. return nil
  48008. case wx.FieldProcessID:
  48009. v, ok := value.(string)
  48010. if !ok {
  48011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48012. }
  48013. m.SetProcessID(v)
  48014. return nil
  48015. case wx.FieldCallback:
  48016. v, ok := value.(string)
  48017. if !ok {
  48018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48019. }
  48020. m.SetCallback(v)
  48021. return nil
  48022. case wx.FieldWxid:
  48023. v, ok := value.(string)
  48024. if !ok {
  48025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48026. }
  48027. m.SetWxid(v)
  48028. return nil
  48029. case wx.FieldAccount:
  48030. v, ok := value.(string)
  48031. if !ok {
  48032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48033. }
  48034. m.SetAccount(v)
  48035. return nil
  48036. case wx.FieldNickname:
  48037. v, ok := value.(string)
  48038. if !ok {
  48039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48040. }
  48041. m.SetNickname(v)
  48042. return nil
  48043. case wx.FieldTel:
  48044. v, ok := value.(string)
  48045. if !ok {
  48046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48047. }
  48048. m.SetTel(v)
  48049. return nil
  48050. case wx.FieldHeadBig:
  48051. v, ok := value.(string)
  48052. if !ok {
  48053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48054. }
  48055. m.SetHeadBig(v)
  48056. return nil
  48057. case wx.FieldOrganizationID:
  48058. v, ok := value.(uint64)
  48059. if !ok {
  48060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48061. }
  48062. m.SetOrganizationID(v)
  48063. return nil
  48064. case wx.FieldAgentID:
  48065. v, ok := value.(uint64)
  48066. if !ok {
  48067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48068. }
  48069. m.SetAgentID(v)
  48070. return nil
  48071. case wx.FieldAPIBase:
  48072. v, ok := value.(string)
  48073. if !ok {
  48074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48075. }
  48076. m.SetAPIBase(v)
  48077. return nil
  48078. case wx.FieldAPIKey:
  48079. v, ok := value.(string)
  48080. if !ok {
  48081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48082. }
  48083. m.SetAPIKey(v)
  48084. return nil
  48085. case wx.FieldAllowList:
  48086. v, ok := value.([]string)
  48087. if !ok {
  48088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48089. }
  48090. m.SetAllowList(v)
  48091. return nil
  48092. case wx.FieldGroupAllowList:
  48093. v, ok := value.([]string)
  48094. if !ok {
  48095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48096. }
  48097. m.SetGroupAllowList(v)
  48098. return nil
  48099. case wx.FieldBlockList:
  48100. v, ok := value.([]string)
  48101. if !ok {
  48102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48103. }
  48104. m.SetBlockList(v)
  48105. return nil
  48106. case wx.FieldGroupBlockList:
  48107. v, ok := value.([]string)
  48108. if !ok {
  48109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48110. }
  48111. m.SetGroupBlockList(v)
  48112. return nil
  48113. case wx.FieldCtype:
  48114. v, ok := value.(uint64)
  48115. if !ok {
  48116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48117. }
  48118. m.SetCtype(v)
  48119. return nil
  48120. }
  48121. return fmt.Errorf("unknown Wx field %s", name)
  48122. }
  48123. // AddedFields returns all numeric fields that were incremented/decremented during
  48124. // this mutation.
  48125. func (m *WxMutation) AddedFields() []string {
  48126. var fields []string
  48127. if m.addstatus != nil {
  48128. fields = append(fields, wx.FieldStatus)
  48129. }
  48130. if m.addorganization_id != nil {
  48131. fields = append(fields, wx.FieldOrganizationID)
  48132. }
  48133. if m.addctype != nil {
  48134. fields = append(fields, wx.FieldCtype)
  48135. }
  48136. return fields
  48137. }
  48138. // AddedField returns the numeric value that was incremented/decremented on a field
  48139. // with the given name. The second boolean return value indicates that this field
  48140. // was not set, or was not defined in the schema.
  48141. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  48142. switch name {
  48143. case wx.FieldStatus:
  48144. return m.AddedStatus()
  48145. case wx.FieldOrganizationID:
  48146. return m.AddedOrganizationID()
  48147. case wx.FieldCtype:
  48148. return m.AddedCtype()
  48149. }
  48150. return nil, false
  48151. }
  48152. // AddField adds the value to the field with the given name. It returns an error if
  48153. // the field is not defined in the schema, or if the type mismatched the field
  48154. // type.
  48155. func (m *WxMutation) AddField(name string, value ent.Value) error {
  48156. switch name {
  48157. case wx.FieldStatus:
  48158. v, ok := value.(int8)
  48159. if !ok {
  48160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48161. }
  48162. m.AddStatus(v)
  48163. return nil
  48164. case wx.FieldOrganizationID:
  48165. v, ok := value.(int64)
  48166. if !ok {
  48167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48168. }
  48169. m.AddOrganizationID(v)
  48170. return nil
  48171. case wx.FieldCtype:
  48172. v, ok := value.(int64)
  48173. if !ok {
  48174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48175. }
  48176. m.AddCtype(v)
  48177. return nil
  48178. }
  48179. return fmt.Errorf("unknown Wx numeric field %s", name)
  48180. }
  48181. // ClearedFields returns all nullable fields that were cleared during this
  48182. // mutation.
  48183. func (m *WxMutation) ClearedFields() []string {
  48184. var fields []string
  48185. if m.FieldCleared(wx.FieldStatus) {
  48186. fields = append(fields, wx.FieldStatus)
  48187. }
  48188. if m.FieldCleared(wx.FieldDeletedAt) {
  48189. fields = append(fields, wx.FieldDeletedAt)
  48190. }
  48191. if m.FieldCleared(wx.FieldServerID) {
  48192. fields = append(fields, wx.FieldServerID)
  48193. }
  48194. if m.FieldCleared(wx.FieldOrganizationID) {
  48195. fields = append(fields, wx.FieldOrganizationID)
  48196. }
  48197. if m.FieldCleared(wx.FieldAPIBase) {
  48198. fields = append(fields, wx.FieldAPIBase)
  48199. }
  48200. if m.FieldCleared(wx.FieldAPIKey) {
  48201. fields = append(fields, wx.FieldAPIKey)
  48202. }
  48203. if m.FieldCleared(wx.FieldCtype) {
  48204. fields = append(fields, wx.FieldCtype)
  48205. }
  48206. return fields
  48207. }
  48208. // FieldCleared returns a boolean indicating if a field with the given name was
  48209. // cleared in this mutation.
  48210. func (m *WxMutation) FieldCleared(name string) bool {
  48211. _, ok := m.clearedFields[name]
  48212. return ok
  48213. }
  48214. // ClearField clears the value of the field with the given name. It returns an
  48215. // error if the field is not defined in the schema.
  48216. func (m *WxMutation) ClearField(name string) error {
  48217. switch name {
  48218. case wx.FieldStatus:
  48219. m.ClearStatus()
  48220. return nil
  48221. case wx.FieldDeletedAt:
  48222. m.ClearDeletedAt()
  48223. return nil
  48224. case wx.FieldServerID:
  48225. m.ClearServerID()
  48226. return nil
  48227. case wx.FieldOrganizationID:
  48228. m.ClearOrganizationID()
  48229. return nil
  48230. case wx.FieldAPIBase:
  48231. m.ClearAPIBase()
  48232. return nil
  48233. case wx.FieldAPIKey:
  48234. m.ClearAPIKey()
  48235. return nil
  48236. case wx.FieldCtype:
  48237. m.ClearCtype()
  48238. return nil
  48239. }
  48240. return fmt.Errorf("unknown Wx nullable field %s", name)
  48241. }
  48242. // ResetField resets all changes in the mutation for the field with the given name.
  48243. // It returns an error if the field is not defined in the schema.
  48244. func (m *WxMutation) ResetField(name string) error {
  48245. switch name {
  48246. case wx.FieldCreatedAt:
  48247. m.ResetCreatedAt()
  48248. return nil
  48249. case wx.FieldUpdatedAt:
  48250. m.ResetUpdatedAt()
  48251. return nil
  48252. case wx.FieldStatus:
  48253. m.ResetStatus()
  48254. return nil
  48255. case wx.FieldDeletedAt:
  48256. m.ResetDeletedAt()
  48257. return nil
  48258. case wx.FieldServerID:
  48259. m.ResetServerID()
  48260. return nil
  48261. case wx.FieldPort:
  48262. m.ResetPort()
  48263. return nil
  48264. case wx.FieldProcessID:
  48265. m.ResetProcessID()
  48266. return nil
  48267. case wx.FieldCallback:
  48268. m.ResetCallback()
  48269. return nil
  48270. case wx.FieldWxid:
  48271. m.ResetWxid()
  48272. return nil
  48273. case wx.FieldAccount:
  48274. m.ResetAccount()
  48275. return nil
  48276. case wx.FieldNickname:
  48277. m.ResetNickname()
  48278. return nil
  48279. case wx.FieldTel:
  48280. m.ResetTel()
  48281. return nil
  48282. case wx.FieldHeadBig:
  48283. m.ResetHeadBig()
  48284. return nil
  48285. case wx.FieldOrganizationID:
  48286. m.ResetOrganizationID()
  48287. return nil
  48288. case wx.FieldAgentID:
  48289. m.ResetAgentID()
  48290. return nil
  48291. case wx.FieldAPIBase:
  48292. m.ResetAPIBase()
  48293. return nil
  48294. case wx.FieldAPIKey:
  48295. m.ResetAPIKey()
  48296. return nil
  48297. case wx.FieldAllowList:
  48298. m.ResetAllowList()
  48299. return nil
  48300. case wx.FieldGroupAllowList:
  48301. m.ResetGroupAllowList()
  48302. return nil
  48303. case wx.FieldBlockList:
  48304. m.ResetBlockList()
  48305. return nil
  48306. case wx.FieldGroupBlockList:
  48307. m.ResetGroupBlockList()
  48308. return nil
  48309. case wx.FieldCtype:
  48310. m.ResetCtype()
  48311. return nil
  48312. }
  48313. return fmt.Errorf("unknown Wx field %s", name)
  48314. }
  48315. // AddedEdges returns all edge names that were set/added in this mutation.
  48316. func (m *WxMutation) AddedEdges() []string {
  48317. edges := make([]string, 0, 2)
  48318. if m.server != nil {
  48319. edges = append(edges, wx.EdgeServer)
  48320. }
  48321. if m.agent != nil {
  48322. edges = append(edges, wx.EdgeAgent)
  48323. }
  48324. return edges
  48325. }
  48326. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48327. // name in this mutation.
  48328. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  48329. switch name {
  48330. case wx.EdgeServer:
  48331. if id := m.server; id != nil {
  48332. return []ent.Value{*id}
  48333. }
  48334. case wx.EdgeAgent:
  48335. if id := m.agent; id != nil {
  48336. return []ent.Value{*id}
  48337. }
  48338. }
  48339. return nil
  48340. }
  48341. // RemovedEdges returns all edge names that were removed in this mutation.
  48342. func (m *WxMutation) RemovedEdges() []string {
  48343. edges := make([]string, 0, 2)
  48344. return edges
  48345. }
  48346. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48347. // the given name in this mutation.
  48348. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  48349. return nil
  48350. }
  48351. // ClearedEdges returns all edge names that were cleared in this mutation.
  48352. func (m *WxMutation) ClearedEdges() []string {
  48353. edges := make([]string, 0, 2)
  48354. if m.clearedserver {
  48355. edges = append(edges, wx.EdgeServer)
  48356. }
  48357. if m.clearedagent {
  48358. edges = append(edges, wx.EdgeAgent)
  48359. }
  48360. return edges
  48361. }
  48362. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48363. // was cleared in this mutation.
  48364. func (m *WxMutation) EdgeCleared(name string) bool {
  48365. switch name {
  48366. case wx.EdgeServer:
  48367. return m.clearedserver
  48368. case wx.EdgeAgent:
  48369. return m.clearedagent
  48370. }
  48371. return false
  48372. }
  48373. // ClearEdge clears the value of the edge with the given name. It returns an error
  48374. // if that edge is not defined in the schema.
  48375. func (m *WxMutation) ClearEdge(name string) error {
  48376. switch name {
  48377. case wx.EdgeServer:
  48378. m.ClearServer()
  48379. return nil
  48380. case wx.EdgeAgent:
  48381. m.ClearAgent()
  48382. return nil
  48383. }
  48384. return fmt.Errorf("unknown Wx unique edge %s", name)
  48385. }
  48386. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48387. // It returns an error if the edge is not defined in the schema.
  48388. func (m *WxMutation) ResetEdge(name string) error {
  48389. switch name {
  48390. case wx.EdgeServer:
  48391. m.ResetServer()
  48392. return nil
  48393. case wx.EdgeAgent:
  48394. m.ResetAgent()
  48395. return nil
  48396. }
  48397. return fmt.Errorf("unknown Wx edge %s", name)
  48398. }
  48399. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  48400. type WxCardMutation struct {
  48401. config
  48402. op Op
  48403. typ string
  48404. id *uint64
  48405. created_at *time.Time
  48406. updated_at *time.Time
  48407. deleted_at *time.Time
  48408. user_id *uint64
  48409. adduser_id *int64
  48410. wx_user_id *uint64
  48411. addwx_user_id *int64
  48412. avatar *string
  48413. logo *string
  48414. name *string
  48415. company *string
  48416. address *string
  48417. phone *string
  48418. official_account *string
  48419. wechat_account *string
  48420. email *string
  48421. api_base *string
  48422. api_key *string
  48423. ai_info *string
  48424. intro *string
  48425. clearedFields map[string]struct{}
  48426. done bool
  48427. oldValue func(context.Context) (*WxCard, error)
  48428. predicates []predicate.WxCard
  48429. }
  48430. var _ ent.Mutation = (*WxCardMutation)(nil)
  48431. // wxcardOption allows management of the mutation configuration using functional options.
  48432. type wxcardOption func(*WxCardMutation)
  48433. // newWxCardMutation creates new mutation for the WxCard entity.
  48434. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  48435. m := &WxCardMutation{
  48436. config: c,
  48437. op: op,
  48438. typ: TypeWxCard,
  48439. clearedFields: make(map[string]struct{}),
  48440. }
  48441. for _, opt := range opts {
  48442. opt(m)
  48443. }
  48444. return m
  48445. }
  48446. // withWxCardID sets the ID field of the mutation.
  48447. func withWxCardID(id uint64) wxcardOption {
  48448. return func(m *WxCardMutation) {
  48449. var (
  48450. err error
  48451. once sync.Once
  48452. value *WxCard
  48453. )
  48454. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  48455. once.Do(func() {
  48456. if m.done {
  48457. err = errors.New("querying old values post mutation is not allowed")
  48458. } else {
  48459. value, err = m.Client().WxCard.Get(ctx, id)
  48460. }
  48461. })
  48462. return value, err
  48463. }
  48464. m.id = &id
  48465. }
  48466. }
  48467. // withWxCard sets the old WxCard of the mutation.
  48468. func withWxCard(node *WxCard) wxcardOption {
  48469. return func(m *WxCardMutation) {
  48470. m.oldValue = func(context.Context) (*WxCard, error) {
  48471. return node, nil
  48472. }
  48473. m.id = &node.ID
  48474. }
  48475. }
  48476. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48477. // executed in a transaction (ent.Tx), a transactional client is returned.
  48478. func (m WxCardMutation) Client() *Client {
  48479. client := &Client{config: m.config}
  48480. client.init()
  48481. return client
  48482. }
  48483. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48484. // it returns an error otherwise.
  48485. func (m WxCardMutation) Tx() (*Tx, error) {
  48486. if _, ok := m.driver.(*txDriver); !ok {
  48487. return nil, errors.New("ent: mutation is not running in a transaction")
  48488. }
  48489. tx := &Tx{config: m.config}
  48490. tx.init()
  48491. return tx, nil
  48492. }
  48493. // SetID sets the value of the id field. Note that this
  48494. // operation is only accepted on creation of WxCard entities.
  48495. func (m *WxCardMutation) SetID(id uint64) {
  48496. m.id = &id
  48497. }
  48498. // ID returns the ID value in the mutation. Note that the ID is only available
  48499. // if it was provided to the builder or after it was returned from the database.
  48500. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  48501. if m.id == nil {
  48502. return
  48503. }
  48504. return *m.id, true
  48505. }
  48506. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48507. // That means, if the mutation is applied within a transaction with an isolation level such
  48508. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48509. // or updated by the mutation.
  48510. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  48511. switch {
  48512. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48513. id, exists := m.ID()
  48514. if exists {
  48515. return []uint64{id}, nil
  48516. }
  48517. fallthrough
  48518. case m.op.Is(OpUpdate | OpDelete):
  48519. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  48520. default:
  48521. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48522. }
  48523. }
  48524. // SetCreatedAt sets the "created_at" field.
  48525. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  48526. m.created_at = &t
  48527. }
  48528. // CreatedAt returns the value of the "created_at" field in the mutation.
  48529. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  48530. v := m.created_at
  48531. if v == nil {
  48532. return
  48533. }
  48534. return *v, true
  48535. }
  48536. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  48537. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48539. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48540. if !m.op.Is(OpUpdateOne) {
  48541. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48542. }
  48543. if m.id == nil || m.oldValue == nil {
  48544. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48545. }
  48546. oldValue, err := m.oldValue(ctx)
  48547. if err != nil {
  48548. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48549. }
  48550. return oldValue.CreatedAt, nil
  48551. }
  48552. // ResetCreatedAt resets all changes to the "created_at" field.
  48553. func (m *WxCardMutation) ResetCreatedAt() {
  48554. m.created_at = nil
  48555. }
  48556. // SetUpdatedAt sets the "updated_at" field.
  48557. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  48558. m.updated_at = &t
  48559. }
  48560. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48561. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  48562. v := m.updated_at
  48563. if v == nil {
  48564. return
  48565. }
  48566. return *v, true
  48567. }
  48568. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  48569. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48571. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48572. if !m.op.Is(OpUpdateOne) {
  48573. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48574. }
  48575. if m.id == nil || m.oldValue == nil {
  48576. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48577. }
  48578. oldValue, err := m.oldValue(ctx)
  48579. if err != nil {
  48580. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48581. }
  48582. return oldValue.UpdatedAt, nil
  48583. }
  48584. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48585. func (m *WxCardMutation) ResetUpdatedAt() {
  48586. m.updated_at = nil
  48587. }
  48588. // SetDeletedAt sets the "deleted_at" field.
  48589. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  48590. m.deleted_at = &t
  48591. }
  48592. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48593. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  48594. v := m.deleted_at
  48595. if v == nil {
  48596. return
  48597. }
  48598. return *v, true
  48599. }
  48600. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  48601. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48603. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48604. if !m.op.Is(OpUpdateOne) {
  48605. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48606. }
  48607. if m.id == nil || m.oldValue == nil {
  48608. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48609. }
  48610. oldValue, err := m.oldValue(ctx)
  48611. if err != nil {
  48612. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48613. }
  48614. return oldValue.DeletedAt, nil
  48615. }
  48616. // ClearDeletedAt clears the value of the "deleted_at" field.
  48617. func (m *WxCardMutation) ClearDeletedAt() {
  48618. m.deleted_at = nil
  48619. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  48620. }
  48621. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48622. func (m *WxCardMutation) DeletedAtCleared() bool {
  48623. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  48624. return ok
  48625. }
  48626. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48627. func (m *WxCardMutation) ResetDeletedAt() {
  48628. m.deleted_at = nil
  48629. delete(m.clearedFields, wxcard.FieldDeletedAt)
  48630. }
  48631. // SetUserID sets the "user_id" field.
  48632. func (m *WxCardMutation) SetUserID(u uint64) {
  48633. m.user_id = &u
  48634. m.adduser_id = nil
  48635. }
  48636. // UserID returns the value of the "user_id" field in the mutation.
  48637. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  48638. v := m.user_id
  48639. if v == nil {
  48640. return
  48641. }
  48642. return *v, true
  48643. }
  48644. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  48645. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48647. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48648. if !m.op.Is(OpUpdateOne) {
  48649. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48650. }
  48651. if m.id == nil || m.oldValue == nil {
  48652. return v, errors.New("OldUserID requires an ID field in the mutation")
  48653. }
  48654. oldValue, err := m.oldValue(ctx)
  48655. if err != nil {
  48656. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48657. }
  48658. return oldValue.UserID, nil
  48659. }
  48660. // AddUserID adds u to the "user_id" field.
  48661. func (m *WxCardMutation) AddUserID(u int64) {
  48662. if m.adduser_id != nil {
  48663. *m.adduser_id += u
  48664. } else {
  48665. m.adduser_id = &u
  48666. }
  48667. }
  48668. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48669. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  48670. v := m.adduser_id
  48671. if v == nil {
  48672. return
  48673. }
  48674. return *v, true
  48675. }
  48676. // ClearUserID clears the value of the "user_id" field.
  48677. func (m *WxCardMutation) ClearUserID() {
  48678. m.user_id = nil
  48679. m.adduser_id = nil
  48680. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  48681. }
  48682. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48683. func (m *WxCardMutation) UserIDCleared() bool {
  48684. _, ok := m.clearedFields[wxcard.FieldUserID]
  48685. return ok
  48686. }
  48687. // ResetUserID resets all changes to the "user_id" field.
  48688. func (m *WxCardMutation) ResetUserID() {
  48689. m.user_id = nil
  48690. m.adduser_id = nil
  48691. delete(m.clearedFields, wxcard.FieldUserID)
  48692. }
  48693. // SetWxUserID sets the "wx_user_id" field.
  48694. func (m *WxCardMutation) SetWxUserID(u uint64) {
  48695. m.wx_user_id = &u
  48696. m.addwx_user_id = nil
  48697. }
  48698. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  48699. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  48700. v := m.wx_user_id
  48701. if v == nil {
  48702. return
  48703. }
  48704. return *v, true
  48705. }
  48706. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  48707. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48709. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  48710. if !m.op.Is(OpUpdateOne) {
  48711. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  48712. }
  48713. if m.id == nil || m.oldValue == nil {
  48714. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  48715. }
  48716. oldValue, err := m.oldValue(ctx)
  48717. if err != nil {
  48718. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  48719. }
  48720. return oldValue.WxUserID, nil
  48721. }
  48722. // AddWxUserID adds u to the "wx_user_id" field.
  48723. func (m *WxCardMutation) AddWxUserID(u int64) {
  48724. if m.addwx_user_id != nil {
  48725. *m.addwx_user_id += u
  48726. } else {
  48727. m.addwx_user_id = &u
  48728. }
  48729. }
  48730. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  48731. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  48732. v := m.addwx_user_id
  48733. if v == nil {
  48734. return
  48735. }
  48736. return *v, true
  48737. }
  48738. // ClearWxUserID clears the value of the "wx_user_id" field.
  48739. func (m *WxCardMutation) ClearWxUserID() {
  48740. m.wx_user_id = nil
  48741. m.addwx_user_id = nil
  48742. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  48743. }
  48744. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  48745. func (m *WxCardMutation) WxUserIDCleared() bool {
  48746. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  48747. return ok
  48748. }
  48749. // ResetWxUserID resets all changes to the "wx_user_id" field.
  48750. func (m *WxCardMutation) ResetWxUserID() {
  48751. m.wx_user_id = nil
  48752. m.addwx_user_id = nil
  48753. delete(m.clearedFields, wxcard.FieldWxUserID)
  48754. }
  48755. // SetAvatar sets the "avatar" field.
  48756. func (m *WxCardMutation) SetAvatar(s string) {
  48757. m.avatar = &s
  48758. }
  48759. // Avatar returns the value of the "avatar" field in the mutation.
  48760. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  48761. v := m.avatar
  48762. if v == nil {
  48763. return
  48764. }
  48765. return *v, true
  48766. }
  48767. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  48768. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48770. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  48771. if !m.op.Is(OpUpdateOne) {
  48772. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  48773. }
  48774. if m.id == nil || m.oldValue == nil {
  48775. return v, errors.New("OldAvatar requires an ID field in the mutation")
  48776. }
  48777. oldValue, err := m.oldValue(ctx)
  48778. if err != nil {
  48779. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  48780. }
  48781. return oldValue.Avatar, nil
  48782. }
  48783. // ResetAvatar resets all changes to the "avatar" field.
  48784. func (m *WxCardMutation) ResetAvatar() {
  48785. m.avatar = nil
  48786. }
  48787. // SetLogo sets the "logo" field.
  48788. func (m *WxCardMutation) SetLogo(s string) {
  48789. m.logo = &s
  48790. }
  48791. // Logo returns the value of the "logo" field in the mutation.
  48792. func (m *WxCardMutation) Logo() (r string, exists bool) {
  48793. v := m.logo
  48794. if v == nil {
  48795. return
  48796. }
  48797. return *v, true
  48798. }
  48799. // OldLogo returns the old "logo" field's value of the WxCard entity.
  48800. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48802. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  48803. if !m.op.Is(OpUpdateOne) {
  48804. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  48805. }
  48806. if m.id == nil || m.oldValue == nil {
  48807. return v, errors.New("OldLogo requires an ID field in the mutation")
  48808. }
  48809. oldValue, err := m.oldValue(ctx)
  48810. if err != nil {
  48811. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  48812. }
  48813. return oldValue.Logo, nil
  48814. }
  48815. // ResetLogo resets all changes to the "logo" field.
  48816. func (m *WxCardMutation) ResetLogo() {
  48817. m.logo = nil
  48818. }
  48819. // SetName sets the "name" field.
  48820. func (m *WxCardMutation) SetName(s string) {
  48821. m.name = &s
  48822. }
  48823. // Name returns the value of the "name" field in the mutation.
  48824. func (m *WxCardMutation) Name() (r string, exists bool) {
  48825. v := m.name
  48826. if v == nil {
  48827. return
  48828. }
  48829. return *v, true
  48830. }
  48831. // OldName returns the old "name" field's value of the WxCard entity.
  48832. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48834. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  48835. if !m.op.Is(OpUpdateOne) {
  48836. return v, errors.New("OldName is only allowed on UpdateOne operations")
  48837. }
  48838. if m.id == nil || m.oldValue == nil {
  48839. return v, errors.New("OldName requires an ID field in the mutation")
  48840. }
  48841. oldValue, err := m.oldValue(ctx)
  48842. if err != nil {
  48843. return v, fmt.Errorf("querying old value for OldName: %w", err)
  48844. }
  48845. return oldValue.Name, nil
  48846. }
  48847. // ResetName resets all changes to the "name" field.
  48848. func (m *WxCardMutation) ResetName() {
  48849. m.name = nil
  48850. }
  48851. // SetCompany sets the "company" field.
  48852. func (m *WxCardMutation) SetCompany(s string) {
  48853. m.company = &s
  48854. }
  48855. // Company returns the value of the "company" field in the mutation.
  48856. func (m *WxCardMutation) Company() (r string, exists bool) {
  48857. v := m.company
  48858. if v == nil {
  48859. return
  48860. }
  48861. return *v, true
  48862. }
  48863. // OldCompany returns the old "company" field's value of the WxCard entity.
  48864. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48866. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  48867. if !m.op.Is(OpUpdateOne) {
  48868. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  48869. }
  48870. if m.id == nil || m.oldValue == nil {
  48871. return v, errors.New("OldCompany requires an ID field in the mutation")
  48872. }
  48873. oldValue, err := m.oldValue(ctx)
  48874. if err != nil {
  48875. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  48876. }
  48877. return oldValue.Company, nil
  48878. }
  48879. // ResetCompany resets all changes to the "company" field.
  48880. func (m *WxCardMutation) ResetCompany() {
  48881. m.company = nil
  48882. }
  48883. // SetAddress sets the "address" field.
  48884. func (m *WxCardMutation) SetAddress(s string) {
  48885. m.address = &s
  48886. }
  48887. // Address returns the value of the "address" field in the mutation.
  48888. func (m *WxCardMutation) Address() (r string, exists bool) {
  48889. v := m.address
  48890. if v == nil {
  48891. return
  48892. }
  48893. return *v, true
  48894. }
  48895. // OldAddress returns the old "address" field's value of the WxCard entity.
  48896. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48898. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  48899. if !m.op.Is(OpUpdateOne) {
  48900. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  48901. }
  48902. if m.id == nil || m.oldValue == nil {
  48903. return v, errors.New("OldAddress requires an ID field in the mutation")
  48904. }
  48905. oldValue, err := m.oldValue(ctx)
  48906. if err != nil {
  48907. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  48908. }
  48909. return oldValue.Address, nil
  48910. }
  48911. // ResetAddress resets all changes to the "address" field.
  48912. func (m *WxCardMutation) ResetAddress() {
  48913. m.address = nil
  48914. }
  48915. // SetPhone sets the "phone" field.
  48916. func (m *WxCardMutation) SetPhone(s string) {
  48917. m.phone = &s
  48918. }
  48919. // Phone returns the value of the "phone" field in the mutation.
  48920. func (m *WxCardMutation) Phone() (r string, exists bool) {
  48921. v := m.phone
  48922. if v == nil {
  48923. return
  48924. }
  48925. return *v, true
  48926. }
  48927. // OldPhone returns the old "phone" field's value of the WxCard entity.
  48928. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48930. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  48931. if !m.op.Is(OpUpdateOne) {
  48932. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  48933. }
  48934. if m.id == nil || m.oldValue == nil {
  48935. return v, errors.New("OldPhone requires an ID field in the mutation")
  48936. }
  48937. oldValue, err := m.oldValue(ctx)
  48938. if err != nil {
  48939. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  48940. }
  48941. return oldValue.Phone, nil
  48942. }
  48943. // ResetPhone resets all changes to the "phone" field.
  48944. func (m *WxCardMutation) ResetPhone() {
  48945. m.phone = nil
  48946. }
  48947. // SetOfficialAccount sets the "official_account" field.
  48948. func (m *WxCardMutation) SetOfficialAccount(s string) {
  48949. m.official_account = &s
  48950. }
  48951. // OfficialAccount returns the value of the "official_account" field in the mutation.
  48952. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  48953. v := m.official_account
  48954. if v == nil {
  48955. return
  48956. }
  48957. return *v, true
  48958. }
  48959. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  48960. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48962. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  48963. if !m.op.Is(OpUpdateOne) {
  48964. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  48965. }
  48966. if m.id == nil || m.oldValue == nil {
  48967. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  48968. }
  48969. oldValue, err := m.oldValue(ctx)
  48970. if err != nil {
  48971. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  48972. }
  48973. return oldValue.OfficialAccount, nil
  48974. }
  48975. // ResetOfficialAccount resets all changes to the "official_account" field.
  48976. func (m *WxCardMutation) ResetOfficialAccount() {
  48977. m.official_account = nil
  48978. }
  48979. // SetWechatAccount sets the "wechat_account" field.
  48980. func (m *WxCardMutation) SetWechatAccount(s string) {
  48981. m.wechat_account = &s
  48982. }
  48983. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  48984. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  48985. v := m.wechat_account
  48986. if v == nil {
  48987. return
  48988. }
  48989. return *v, true
  48990. }
  48991. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  48992. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48994. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  48995. if !m.op.Is(OpUpdateOne) {
  48996. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  48997. }
  48998. if m.id == nil || m.oldValue == nil {
  48999. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  49000. }
  49001. oldValue, err := m.oldValue(ctx)
  49002. if err != nil {
  49003. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  49004. }
  49005. return oldValue.WechatAccount, nil
  49006. }
  49007. // ResetWechatAccount resets all changes to the "wechat_account" field.
  49008. func (m *WxCardMutation) ResetWechatAccount() {
  49009. m.wechat_account = nil
  49010. }
  49011. // SetEmail sets the "email" field.
  49012. func (m *WxCardMutation) SetEmail(s string) {
  49013. m.email = &s
  49014. }
  49015. // Email returns the value of the "email" field in the mutation.
  49016. func (m *WxCardMutation) Email() (r string, exists bool) {
  49017. v := m.email
  49018. if v == nil {
  49019. return
  49020. }
  49021. return *v, true
  49022. }
  49023. // OldEmail returns the old "email" field's value of the WxCard entity.
  49024. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49026. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  49027. if !m.op.Is(OpUpdateOne) {
  49028. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  49029. }
  49030. if m.id == nil || m.oldValue == nil {
  49031. return v, errors.New("OldEmail requires an ID field in the mutation")
  49032. }
  49033. oldValue, err := m.oldValue(ctx)
  49034. if err != nil {
  49035. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  49036. }
  49037. return oldValue.Email, nil
  49038. }
  49039. // ClearEmail clears the value of the "email" field.
  49040. func (m *WxCardMutation) ClearEmail() {
  49041. m.email = nil
  49042. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  49043. }
  49044. // EmailCleared returns if the "email" field was cleared in this mutation.
  49045. func (m *WxCardMutation) EmailCleared() bool {
  49046. _, ok := m.clearedFields[wxcard.FieldEmail]
  49047. return ok
  49048. }
  49049. // ResetEmail resets all changes to the "email" field.
  49050. func (m *WxCardMutation) ResetEmail() {
  49051. m.email = nil
  49052. delete(m.clearedFields, wxcard.FieldEmail)
  49053. }
  49054. // SetAPIBase sets the "api_base" field.
  49055. func (m *WxCardMutation) SetAPIBase(s string) {
  49056. m.api_base = &s
  49057. }
  49058. // APIBase returns the value of the "api_base" field in the mutation.
  49059. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  49060. v := m.api_base
  49061. if v == nil {
  49062. return
  49063. }
  49064. return *v, true
  49065. }
  49066. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  49067. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49069. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49070. if !m.op.Is(OpUpdateOne) {
  49071. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49072. }
  49073. if m.id == nil || m.oldValue == nil {
  49074. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49075. }
  49076. oldValue, err := m.oldValue(ctx)
  49077. if err != nil {
  49078. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49079. }
  49080. return oldValue.APIBase, nil
  49081. }
  49082. // ClearAPIBase clears the value of the "api_base" field.
  49083. func (m *WxCardMutation) ClearAPIBase() {
  49084. m.api_base = nil
  49085. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  49086. }
  49087. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49088. func (m *WxCardMutation) APIBaseCleared() bool {
  49089. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  49090. return ok
  49091. }
  49092. // ResetAPIBase resets all changes to the "api_base" field.
  49093. func (m *WxCardMutation) ResetAPIBase() {
  49094. m.api_base = nil
  49095. delete(m.clearedFields, wxcard.FieldAPIBase)
  49096. }
  49097. // SetAPIKey sets the "api_key" field.
  49098. func (m *WxCardMutation) SetAPIKey(s string) {
  49099. m.api_key = &s
  49100. }
  49101. // APIKey returns the value of the "api_key" field in the mutation.
  49102. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  49103. v := m.api_key
  49104. if v == nil {
  49105. return
  49106. }
  49107. return *v, true
  49108. }
  49109. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  49110. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49112. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49113. if !m.op.Is(OpUpdateOne) {
  49114. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49115. }
  49116. if m.id == nil || m.oldValue == nil {
  49117. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49118. }
  49119. oldValue, err := m.oldValue(ctx)
  49120. if err != nil {
  49121. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49122. }
  49123. return oldValue.APIKey, nil
  49124. }
  49125. // ClearAPIKey clears the value of the "api_key" field.
  49126. func (m *WxCardMutation) ClearAPIKey() {
  49127. m.api_key = nil
  49128. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  49129. }
  49130. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49131. func (m *WxCardMutation) APIKeyCleared() bool {
  49132. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  49133. return ok
  49134. }
  49135. // ResetAPIKey resets all changes to the "api_key" field.
  49136. func (m *WxCardMutation) ResetAPIKey() {
  49137. m.api_key = nil
  49138. delete(m.clearedFields, wxcard.FieldAPIKey)
  49139. }
  49140. // SetAiInfo sets the "ai_info" field.
  49141. func (m *WxCardMutation) SetAiInfo(s string) {
  49142. m.ai_info = &s
  49143. }
  49144. // AiInfo returns the value of the "ai_info" field in the mutation.
  49145. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  49146. v := m.ai_info
  49147. if v == nil {
  49148. return
  49149. }
  49150. return *v, true
  49151. }
  49152. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  49153. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49155. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  49156. if !m.op.Is(OpUpdateOne) {
  49157. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  49158. }
  49159. if m.id == nil || m.oldValue == nil {
  49160. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  49161. }
  49162. oldValue, err := m.oldValue(ctx)
  49163. if err != nil {
  49164. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  49165. }
  49166. return oldValue.AiInfo, nil
  49167. }
  49168. // ClearAiInfo clears the value of the "ai_info" field.
  49169. func (m *WxCardMutation) ClearAiInfo() {
  49170. m.ai_info = nil
  49171. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  49172. }
  49173. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  49174. func (m *WxCardMutation) AiInfoCleared() bool {
  49175. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  49176. return ok
  49177. }
  49178. // ResetAiInfo resets all changes to the "ai_info" field.
  49179. func (m *WxCardMutation) ResetAiInfo() {
  49180. m.ai_info = nil
  49181. delete(m.clearedFields, wxcard.FieldAiInfo)
  49182. }
  49183. // SetIntro sets the "intro" field.
  49184. func (m *WxCardMutation) SetIntro(s string) {
  49185. m.intro = &s
  49186. }
  49187. // Intro returns the value of the "intro" field in the mutation.
  49188. func (m *WxCardMutation) Intro() (r string, exists bool) {
  49189. v := m.intro
  49190. if v == nil {
  49191. return
  49192. }
  49193. return *v, true
  49194. }
  49195. // OldIntro returns the old "intro" field's value of the WxCard entity.
  49196. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49198. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  49199. if !m.op.Is(OpUpdateOne) {
  49200. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  49201. }
  49202. if m.id == nil || m.oldValue == nil {
  49203. return v, errors.New("OldIntro requires an ID field in the mutation")
  49204. }
  49205. oldValue, err := m.oldValue(ctx)
  49206. if err != nil {
  49207. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  49208. }
  49209. return oldValue.Intro, nil
  49210. }
  49211. // ClearIntro clears the value of the "intro" field.
  49212. func (m *WxCardMutation) ClearIntro() {
  49213. m.intro = nil
  49214. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  49215. }
  49216. // IntroCleared returns if the "intro" field was cleared in this mutation.
  49217. func (m *WxCardMutation) IntroCleared() bool {
  49218. _, ok := m.clearedFields[wxcard.FieldIntro]
  49219. return ok
  49220. }
  49221. // ResetIntro resets all changes to the "intro" field.
  49222. func (m *WxCardMutation) ResetIntro() {
  49223. m.intro = nil
  49224. delete(m.clearedFields, wxcard.FieldIntro)
  49225. }
  49226. // Where appends a list predicates to the WxCardMutation builder.
  49227. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  49228. m.predicates = append(m.predicates, ps...)
  49229. }
  49230. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  49231. // users can use type-assertion to append predicates that do not depend on any generated package.
  49232. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  49233. p := make([]predicate.WxCard, len(ps))
  49234. for i := range ps {
  49235. p[i] = ps[i]
  49236. }
  49237. m.Where(p...)
  49238. }
  49239. // Op returns the operation name.
  49240. func (m *WxCardMutation) Op() Op {
  49241. return m.op
  49242. }
  49243. // SetOp allows setting the mutation operation.
  49244. func (m *WxCardMutation) SetOp(op Op) {
  49245. m.op = op
  49246. }
  49247. // Type returns the node type of this mutation (WxCard).
  49248. func (m *WxCardMutation) Type() string {
  49249. return m.typ
  49250. }
  49251. // Fields returns all fields that were changed during this mutation. Note that in
  49252. // order to get all numeric fields that were incremented/decremented, call
  49253. // AddedFields().
  49254. func (m *WxCardMutation) Fields() []string {
  49255. fields := make([]string, 0, 18)
  49256. if m.created_at != nil {
  49257. fields = append(fields, wxcard.FieldCreatedAt)
  49258. }
  49259. if m.updated_at != nil {
  49260. fields = append(fields, wxcard.FieldUpdatedAt)
  49261. }
  49262. if m.deleted_at != nil {
  49263. fields = append(fields, wxcard.FieldDeletedAt)
  49264. }
  49265. if m.user_id != nil {
  49266. fields = append(fields, wxcard.FieldUserID)
  49267. }
  49268. if m.wx_user_id != nil {
  49269. fields = append(fields, wxcard.FieldWxUserID)
  49270. }
  49271. if m.avatar != nil {
  49272. fields = append(fields, wxcard.FieldAvatar)
  49273. }
  49274. if m.logo != nil {
  49275. fields = append(fields, wxcard.FieldLogo)
  49276. }
  49277. if m.name != nil {
  49278. fields = append(fields, wxcard.FieldName)
  49279. }
  49280. if m.company != nil {
  49281. fields = append(fields, wxcard.FieldCompany)
  49282. }
  49283. if m.address != nil {
  49284. fields = append(fields, wxcard.FieldAddress)
  49285. }
  49286. if m.phone != nil {
  49287. fields = append(fields, wxcard.FieldPhone)
  49288. }
  49289. if m.official_account != nil {
  49290. fields = append(fields, wxcard.FieldOfficialAccount)
  49291. }
  49292. if m.wechat_account != nil {
  49293. fields = append(fields, wxcard.FieldWechatAccount)
  49294. }
  49295. if m.email != nil {
  49296. fields = append(fields, wxcard.FieldEmail)
  49297. }
  49298. if m.api_base != nil {
  49299. fields = append(fields, wxcard.FieldAPIBase)
  49300. }
  49301. if m.api_key != nil {
  49302. fields = append(fields, wxcard.FieldAPIKey)
  49303. }
  49304. if m.ai_info != nil {
  49305. fields = append(fields, wxcard.FieldAiInfo)
  49306. }
  49307. if m.intro != nil {
  49308. fields = append(fields, wxcard.FieldIntro)
  49309. }
  49310. return fields
  49311. }
  49312. // Field returns the value of a field with the given name. The second boolean
  49313. // return value indicates that this field was not set, or was not defined in the
  49314. // schema.
  49315. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  49316. switch name {
  49317. case wxcard.FieldCreatedAt:
  49318. return m.CreatedAt()
  49319. case wxcard.FieldUpdatedAt:
  49320. return m.UpdatedAt()
  49321. case wxcard.FieldDeletedAt:
  49322. return m.DeletedAt()
  49323. case wxcard.FieldUserID:
  49324. return m.UserID()
  49325. case wxcard.FieldWxUserID:
  49326. return m.WxUserID()
  49327. case wxcard.FieldAvatar:
  49328. return m.Avatar()
  49329. case wxcard.FieldLogo:
  49330. return m.Logo()
  49331. case wxcard.FieldName:
  49332. return m.Name()
  49333. case wxcard.FieldCompany:
  49334. return m.Company()
  49335. case wxcard.FieldAddress:
  49336. return m.Address()
  49337. case wxcard.FieldPhone:
  49338. return m.Phone()
  49339. case wxcard.FieldOfficialAccount:
  49340. return m.OfficialAccount()
  49341. case wxcard.FieldWechatAccount:
  49342. return m.WechatAccount()
  49343. case wxcard.FieldEmail:
  49344. return m.Email()
  49345. case wxcard.FieldAPIBase:
  49346. return m.APIBase()
  49347. case wxcard.FieldAPIKey:
  49348. return m.APIKey()
  49349. case wxcard.FieldAiInfo:
  49350. return m.AiInfo()
  49351. case wxcard.FieldIntro:
  49352. return m.Intro()
  49353. }
  49354. return nil, false
  49355. }
  49356. // OldField returns the old value of the field from the database. An error is
  49357. // returned if the mutation operation is not UpdateOne, or the query to the
  49358. // database failed.
  49359. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49360. switch name {
  49361. case wxcard.FieldCreatedAt:
  49362. return m.OldCreatedAt(ctx)
  49363. case wxcard.FieldUpdatedAt:
  49364. return m.OldUpdatedAt(ctx)
  49365. case wxcard.FieldDeletedAt:
  49366. return m.OldDeletedAt(ctx)
  49367. case wxcard.FieldUserID:
  49368. return m.OldUserID(ctx)
  49369. case wxcard.FieldWxUserID:
  49370. return m.OldWxUserID(ctx)
  49371. case wxcard.FieldAvatar:
  49372. return m.OldAvatar(ctx)
  49373. case wxcard.FieldLogo:
  49374. return m.OldLogo(ctx)
  49375. case wxcard.FieldName:
  49376. return m.OldName(ctx)
  49377. case wxcard.FieldCompany:
  49378. return m.OldCompany(ctx)
  49379. case wxcard.FieldAddress:
  49380. return m.OldAddress(ctx)
  49381. case wxcard.FieldPhone:
  49382. return m.OldPhone(ctx)
  49383. case wxcard.FieldOfficialAccount:
  49384. return m.OldOfficialAccount(ctx)
  49385. case wxcard.FieldWechatAccount:
  49386. return m.OldWechatAccount(ctx)
  49387. case wxcard.FieldEmail:
  49388. return m.OldEmail(ctx)
  49389. case wxcard.FieldAPIBase:
  49390. return m.OldAPIBase(ctx)
  49391. case wxcard.FieldAPIKey:
  49392. return m.OldAPIKey(ctx)
  49393. case wxcard.FieldAiInfo:
  49394. return m.OldAiInfo(ctx)
  49395. case wxcard.FieldIntro:
  49396. return m.OldIntro(ctx)
  49397. }
  49398. return nil, fmt.Errorf("unknown WxCard field %s", name)
  49399. }
  49400. // SetField sets the value of a field with the given name. It returns an error if
  49401. // the field is not defined in the schema, or if the type mismatched the field
  49402. // type.
  49403. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  49404. switch name {
  49405. case wxcard.FieldCreatedAt:
  49406. v, ok := value.(time.Time)
  49407. if !ok {
  49408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49409. }
  49410. m.SetCreatedAt(v)
  49411. return nil
  49412. case wxcard.FieldUpdatedAt:
  49413. v, ok := value.(time.Time)
  49414. if !ok {
  49415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49416. }
  49417. m.SetUpdatedAt(v)
  49418. return nil
  49419. case wxcard.FieldDeletedAt:
  49420. v, ok := value.(time.Time)
  49421. if !ok {
  49422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49423. }
  49424. m.SetDeletedAt(v)
  49425. return nil
  49426. case wxcard.FieldUserID:
  49427. v, ok := value.(uint64)
  49428. if !ok {
  49429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49430. }
  49431. m.SetUserID(v)
  49432. return nil
  49433. case wxcard.FieldWxUserID:
  49434. v, ok := value.(uint64)
  49435. if !ok {
  49436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49437. }
  49438. m.SetWxUserID(v)
  49439. return nil
  49440. case wxcard.FieldAvatar:
  49441. v, ok := value.(string)
  49442. if !ok {
  49443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49444. }
  49445. m.SetAvatar(v)
  49446. return nil
  49447. case wxcard.FieldLogo:
  49448. v, ok := value.(string)
  49449. if !ok {
  49450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49451. }
  49452. m.SetLogo(v)
  49453. return nil
  49454. case wxcard.FieldName:
  49455. v, ok := value.(string)
  49456. if !ok {
  49457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49458. }
  49459. m.SetName(v)
  49460. return nil
  49461. case wxcard.FieldCompany:
  49462. v, ok := value.(string)
  49463. if !ok {
  49464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49465. }
  49466. m.SetCompany(v)
  49467. return nil
  49468. case wxcard.FieldAddress:
  49469. v, ok := value.(string)
  49470. if !ok {
  49471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49472. }
  49473. m.SetAddress(v)
  49474. return nil
  49475. case wxcard.FieldPhone:
  49476. v, ok := value.(string)
  49477. if !ok {
  49478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49479. }
  49480. m.SetPhone(v)
  49481. return nil
  49482. case wxcard.FieldOfficialAccount:
  49483. v, ok := value.(string)
  49484. if !ok {
  49485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49486. }
  49487. m.SetOfficialAccount(v)
  49488. return nil
  49489. case wxcard.FieldWechatAccount:
  49490. v, ok := value.(string)
  49491. if !ok {
  49492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49493. }
  49494. m.SetWechatAccount(v)
  49495. return nil
  49496. case wxcard.FieldEmail:
  49497. v, ok := value.(string)
  49498. if !ok {
  49499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49500. }
  49501. m.SetEmail(v)
  49502. return nil
  49503. case wxcard.FieldAPIBase:
  49504. v, ok := value.(string)
  49505. if !ok {
  49506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49507. }
  49508. m.SetAPIBase(v)
  49509. return nil
  49510. case wxcard.FieldAPIKey:
  49511. v, ok := value.(string)
  49512. if !ok {
  49513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49514. }
  49515. m.SetAPIKey(v)
  49516. return nil
  49517. case wxcard.FieldAiInfo:
  49518. v, ok := value.(string)
  49519. if !ok {
  49520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49521. }
  49522. m.SetAiInfo(v)
  49523. return nil
  49524. case wxcard.FieldIntro:
  49525. v, ok := value.(string)
  49526. if !ok {
  49527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49528. }
  49529. m.SetIntro(v)
  49530. return nil
  49531. }
  49532. return fmt.Errorf("unknown WxCard field %s", name)
  49533. }
  49534. // AddedFields returns all numeric fields that were incremented/decremented during
  49535. // this mutation.
  49536. func (m *WxCardMutation) AddedFields() []string {
  49537. var fields []string
  49538. if m.adduser_id != nil {
  49539. fields = append(fields, wxcard.FieldUserID)
  49540. }
  49541. if m.addwx_user_id != nil {
  49542. fields = append(fields, wxcard.FieldWxUserID)
  49543. }
  49544. return fields
  49545. }
  49546. // AddedField returns the numeric value that was incremented/decremented on a field
  49547. // with the given name. The second boolean return value indicates that this field
  49548. // was not set, or was not defined in the schema.
  49549. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  49550. switch name {
  49551. case wxcard.FieldUserID:
  49552. return m.AddedUserID()
  49553. case wxcard.FieldWxUserID:
  49554. return m.AddedWxUserID()
  49555. }
  49556. return nil, false
  49557. }
  49558. // AddField adds the value to the field with the given name. It returns an error if
  49559. // the field is not defined in the schema, or if the type mismatched the field
  49560. // type.
  49561. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  49562. switch name {
  49563. case wxcard.FieldUserID:
  49564. v, ok := value.(int64)
  49565. if !ok {
  49566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49567. }
  49568. m.AddUserID(v)
  49569. return nil
  49570. case wxcard.FieldWxUserID:
  49571. v, ok := value.(int64)
  49572. if !ok {
  49573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49574. }
  49575. m.AddWxUserID(v)
  49576. return nil
  49577. }
  49578. return fmt.Errorf("unknown WxCard numeric field %s", name)
  49579. }
  49580. // ClearedFields returns all nullable fields that were cleared during this
  49581. // mutation.
  49582. func (m *WxCardMutation) ClearedFields() []string {
  49583. var fields []string
  49584. if m.FieldCleared(wxcard.FieldDeletedAt) {
  49585. fields = append(fields, wxcard.FieldDeletedAt)
  49586. }
  49587. if m.FieldCleared(wxcard.FieldUserID) {
  49588. fields = append(fields, wxcard.FieldUserID)
  49589. }
  49590. if m.FieldCleared(wxcard.FieldWxUserID) {
  49591. fields = append(fields, wxcard.FieldWxUserID)
  49592. }
  49593. if m.FieldCleared(wxcard.FieldEmail) {
  49594. fields = append(fields, wxcard.FieldEmail)
  49595. }
  49596. if m.FieldCleared(wxcard.FieldAPIBase) {
  49597. fields = append(fields, wxcard.FieldAPIBase)
  49598. }
  49599. if m.FieldCleared(wxcard.FieldAPIKey) {
  49600. fields = append(fields, wxcard.FieldAPIKey)
  49601. }
  49602. if m.FieldCleared(wxcard.FieldAiInfo) {
  49603. fields = append(fields, wxcard.FieldAiInfo)
  49604. }
  49605. if m.FieldCleared(wxcard.FieldIntro) {
  49606. fields = append(fields, wxcard.FieldIntro)
  49607. }
  49608. return fields
  49609. }
  49610. // FieldCleared returns a boolean indicating if a field with the given name was
  49611. // cleared in this mutation.
  49612. func (m *WxCardMutation) FieldCleared(name string) bool {
  49613. _, ok := m.clearedFields[name]
  49614. return ok
  49615. }
  49616. // ClearField clears the value of the field with the given name. It returns an
  49617. // error if the field is not defined in the schema.
  49618. func (m *WxCardMutation) ClearField(name string) error {
  49619. switch name {
  49620. case wxcard.FieldDeletedAt:
  49621. m.ClearDeletedAt()
  49622. return nil
  49623. case wxcard.FieldUserID:
  49624. m.ClearUserID()
  49625. return nil
  49626. case wxcard.FieldWxUserID:
  49627. m.ClearWxUserID()
  49628. return nil
  49629. case wxcard.FieldEmail:
  49630. m.ClearEmail()
  49631. return nil
  49632. case wxcard.FieldAPIBase:
  49633. m.ClearAPIBase()
  49634. return nil
  49635. case wxcard.FieldAPIKey:
  49636. m.ClearAPIKey()
  49637. return nil
  49638. case wxcard.FieldAiInfo:
  49639. m.ClearAiInfo()
  49640. return nil
  49641. case wxcard.FieldIntro:
  49642. m.ClearIntro()
  49643. return nil
  49644. }
  49645. return fmt.Errorf("unknown WxCard nullable field %s", name)
  49646. }
  49647. // ResetField resets all changes in the mutation for the field with the given name.
  49648. // It returns an error if the field is not defined in the schema.
  49649. func (m *WxCardMutation) ResetField(name string) error {
  49650. switch name {
  49651. case wxcard.FieldCreatedAt:
  49652. m.ResetCreatedAt()
  49653. return nil
  49654. case wxcard.FieldUpdatedAt:
  49655. m.ResetUpdatedAt()
  49656. return nil
  49657. case wxcard.FieldDeletedAt:
  49658. m.ResetDeletedAt()
  49659. return nil
  49660. case wxcard.FieldUserID:
  49661. m.ResetUserID()
  49662. return nil
  49663. case wxcard.FieldWxUserID:
  49664. m.ResetWxUserID()
  49665. return nil
  49666. case wxcard.FieldAvatar:
  49667. m.ResetAvatar()
  49668. return nil
  49669. case wxcard.FieldLogo:
  49670. m.ResetLogo()
  49671. return nil
  49672. case wxcard.FieldName:
  49673. m.ResetName()
  49674. return nil
  49675. case wxcard.FieldCompany:
  49676. m.ResetCompany()
  49677. return nil
  49678. case wxcard.FieldAddress:
  49679. m.ResetAddress()
  49680. return nil
  49681. case wxcard.FieldPhone:
  49682. m.ResetPhone()
  49683. return nil
  49684. case wxcard.FieldOfficialAccount:
  49685. m.ResetOfficialAccount()
  49686. return nil
  49687. case wxcard.FieldWechatAccount:
  49688. m.ResetWechatAccount()
  49689. return nil
  49690. case wxcard.FieldEmail:
  49691. m.ResetEmail()
  49692. return nil
  49693. case wxcard.FieldAPIBase:
  49694. m.ResetAPIBase()
  49695. return nil
  49696. case wxcard.FieldAPIKey:
  49697. m.ResetAPIKey()
  49698. return nil
  49699. case wxcard.FieldAiInfo:
  49700. m.ResetAiInfo()
  49701. return nil
  49702. case wxcard.FieldIntro:
  49703. m.ResetIntro()
  49704. return nil
  49705. }
  49706. return fmt.Errorf("unknown WxCard field %s", name)
  49707. }
  49708. // AddedEdges returns all edge names that were set/added in this mutation.
  49709. func (m *WxCardMutation) AddedEdges() []string {
  49710. edges := make([]string, 0, 0)
  49711. return edges
  49712. }
  49713. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49714. // name in this mutation.
  49715. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  49716. return nil
  49717. }
  49718. // RemovedEdges returns all edge names that were removed in this mutation.
  49719. func (m *WxCardMutation) RemovedEdges() []string {
  49720. edges := make([]string, 0, 0)
  49721. return edges
  49722. }
  49723. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49724. // the given name in this mutation.
  49725. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  49726. return nil
  49727. }
  49728. // ClearedEdges returns all edge names that were cleared in this mutation.
  49729. func (m *WxCardMutation) ClearedEdges() []string {
  49730. edges := make([]string, 0, 0)
  49731. return edges
  49732. }
  49733. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49734. // was cleared in this mutation.
  49735. func (m *WxCardMutation) EdgeCleared(name string) bool {
  49736. return false
  49737. }
  49738. // ClearEdge clears the value of the edge with the given name. It returns an error
  49739. // if that edge is not defined in the schema.
  49740. func (m *WxCardMutation) ClearEdge(name string) error {
  49741. return fmt.Errorf("unknown WxCard unique edge %s", name)
  49742. }
  49743. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49744. // It returns an error if the edge is not defined in the schema.
  49745. func (m *WxCardMutation) ResetEdge(name string) error {
  49746. return fmt.Errorf("unknown WxCard edge %s", name)
  49747. }
  49748. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  49749. type WxCardUserMutation struct {
  49750. config
  49751. op Op
  49752. typ string
  49753. id *uint64
  49754. created_at *time.Time
  49755. updated_at *time.Time
  49756. deleted_at *time.Time
  49757. wxid *string
  49758. account *string
  49759. avatar *string
  49760. nickname *string
  49761. remark *string
  49762. phone *string
  49763. open_id *string
  49764. union_id *string
  49765. session_key *string
  49766. is_vip *int
  49767. addis_vip *int
  49768. clearedFields map[string]struct{}
  49769. done bool
  49770. oldValue func(context.Context) (*WxCardUser, error)
  49771. predicates []predicate.WxCardUser
  49772. }
  49773. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  49774. // wxcarduserOption allows management of the mutation configuration using functional options.
  49775. type wxcarduserOption func(*WxCardUserMutation)
  49776. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  49777. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  49778. m := &WxCardUserMutation{
  49779. config: c,
  49780. op: op,
  49781. typ: TypeWxCardUser,
  49782. clearedFields: make(map[string]struct{}),
  49783. }
  49784. for _, opt := range opts {
  49785. opt(m)
  49786. }
  49787. return m
  49788. }
  49789. // withWxCardUserID sets the ID field of the mutation.
  49790. func withWxCardUserID(id uint64) wxcarduserOption {
  49791. return func(m *WxCardUserMutation) {
  49792. var (
  49793. err error
  49794. once sync.Once
  49795. value *WxCardUser
  49796. )
  49797. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  49798. once.Do(func() {
  49799. if m.done {
  49800. err = errors.New("querying old values post mutation is not allowed")
  49801. } else {
  49802. value, err = m.Client().WxCardUser.Get(ctx, id)
  49803. }
  49804. })
  49805. return value, err
  49806. }
  49807. m.id = &id
  49808. }
  49809. }
  49810. // withWxCardUser sets the old WxCardUser of the mutation.
  49811. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  49812. return func(m *WxCardUserMutation) {
  49813. m.oldValue = func(context.Context) (*WxCardUser, error) {
  49814. return node, nil
  49815. }
  49816. m.id = &node.ID
  49817. }
  49818. }
  49819. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49820. // executed in a transaction (ent.Tx), a transactional client is returned.
  49821. func (m WxCardUserMutation) Client() *Client {
  49822. client := &Client{config: m.config}
  49823. client.init()
  49824. return client
  49825. }
  49826. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49827. // it returns an error otherwise.
  49828. func (m WxCardUserMutation) Tx() (*Tx, error) {
  49829. if _, ok := m.driver.(*txDriver); !ok {
  49830. return nil, errors.New("ent: mutation is not running in a transaction")
  49831. }
  49832. tx := &Tx{config: m.config}
  49833. tx.init()
  49834. return tx, nil
  49835. }
  49836. // SetID sets the value of the id field. Note that this
  49837. // operation is only accepted on creation of WxCardUser entities.
  49838. func (m *WxCardUserMutation) SetID(id uint64) {
  49839. m.id = &id
  49840. }
  49841. // ID returns the ID value in the mutation. Note that the ID is only available
  49842. // if it was provided to the builder or after it was returned from the database.
  49843. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  49844. if m.id == nil {
  49845. return
  49846. }
  49847. return *m.id, true
  49848. }
  49849. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49850. // That means, if the mutation is applied within a transaction with an isolation level such
  49851. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49852. // or updated by the mutation.
  49853. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  49854. switch {
  49855. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49856. id, exists := m.ID()
  49857. if exists {
  49858. return []uint64{id}, nil
  49859. }
  49860. fallthrough
  49861. case m.op.Is(OpUpdate | OpDelete):
  49862. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  49863. default:
  49864. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49865. }
  49866. }
  49867. // SetCreatedAt sets the "created_at" field.
  49868. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  49869. m.created_at = &t
  49870. }
  49871. // CreatedAt returns the value of the "created_at" field in the mutation.
  49872. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  49873. v := m.created_at
  49874. if v == nil {
  49875. return
  49876. }
  49877. return *v, true
  49878. }
  49879. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  49880. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49882. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49883. if !m.op.Is(OpUpdateOne) {
  49884. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49885. }
  49886. if m.id == nil || m.oldValue == nil {
  49887. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49888. }
  49889. oldValue, err := m.oldValue(ctx)
  49890. if err != nil {
  49891. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49892. }
  49893. return oldValue.CreatedAt, nil
  49894. }
  49895. // ResetCreatedAt resets all changes to the "created_at" field.
  49896. func (m *WxCardUserMutation) ResetCreatedAt() {
  49897. m.created_at = nil
  49898. }
  49899. // SetUpdatedAt sets the "updated_at" field.
  49900. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  49901. m.updated_at = &t
  49902. }
  49903. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49904. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  49905. v := m.updated_at
  49906. if v == nil {
  49907. return
  49908. }
  49909. return *v, true
  49910. }
  49911. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  49912. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49914. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49915. if !m.op.Is(OpUpdateOne) {
  49916. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49917. }
  49918. if m.id == nil || m.oldValue == nil {
  49919. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49920. }
  49921. oldValue, err := m.oldValue(ctx)
  49922. if err != nil {
  49923. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49924. }
  49925. return oldValue.UpdatedAt, nil
  49926. }
  49927. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49928. func (m *WxCardUserMutation) ResetUpdatedAt() {
  49929. m.updated_at = nil
  49930. }
  49931. // SetDeletedAt sets the "deleted_at" field.
  49932. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  49933. m.deleted_at = &t
  49934. }
  49935. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49936. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  49937. v := m.deleted_at
  49938. if v == nil {
  49939. return
  49940. }
  49941. return *v, true
  49942. }
  49943. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  49944. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49946. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49947. if !m.op.Is(OpUpdateOne) {
  49948. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49949. }
  49950. if m.id == nil || m.oldValue == nil {
  49951. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49952. }
  49953. oldValue, err := m.oldValue(ctx)
  49954. if err != nil {
  49955. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49956. }
  49957. return oldValue.DeletedAt, nil
  49958. }
  49959. // ClearDeletedAt clears the value of the "deleted_at" field.
  49960. func (m *WxCardUserMutation) ClearDeletedAt() {
  49961. m.deleted_at = nil
  49962. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  49963. }
  49964. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49965. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  49966. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  49967. return ok
  49968. }
  49969. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49970. func (m *WxCardUserMutation) ResetDeletedAt() {
  49971. m.deleted_at = nil
  49972. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  49973. }
  49974. // SetWxid sets the "wxid" field.
  49975. func (m *WxCardUserMutation) SetWxid(s string) {
  49976. m.wxid = &s
  49977. }
  49978. // Wxid returns the value of the "wxid" field in the mutation.
  49979. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  49980. v := m.wxid
  49981. if v == nil {
  49982. return
  49983. }
  49984. return *v, true
  49985. }
  49986. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  49987. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49989. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  49990. if !m.op.Is(OpUpdateOne) {
  49991. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  49992. }
  49993. if m.id == nil || m.oldValue == nil {
  49994. return v, errors.New("OldWxid requires an ID field in the mutation")
  49995. }
  49996. oldValue, err := m.oldValue(ctx)
  49997. if err != nil {
  49998. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  49999. }
  50000. return oldValue.Wxid, nil
  50001. }
  50002. // ResetWxid resets all changes to the "wxid" field.
  50003. func (m *WxCardUserMutation) ResetWxid() {
  50004. m.wxid = nil
  50005. }
  50006. // SetAccount sets the "account" field.
  50007. func (m *WxCardUserMutation) SetAccount(s string) {
  50008. m.account = &s
  50009. }
  50010. // Account returns the value of the "account" field in the mutation.
  50011. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  50012. v := m.account
  50013. if v == nil {
  50014. return
  50015. }
  50016. return *v, true
  50017. }
  50018. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  50019. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50021. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  50022. if !m.op.Is(OpUpdateOne) {
  50023. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  50024. }
  50025. if m.id == nil || m.oldValue == nil {
  50026. return v, errors.New("OldAccount requires an ID field in the mutation")
  50027. }
  50028. oldValue, err := m.oldValue(ctx)
  50029. if err != nil {
  50030. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  50031. }
  50032. return oldValue.Account, nil
  50033. }
  50034. // ResetAccount resets all changes to the "account" field.
  50035. func (m *WxCardUserMutation) ResetAccount() {
  50036. m.account = nil
  50037. }
  50038. // SetAvatar sets the "avatar" field.
  50039. func (m *WxCardUserMutation) SetAvatar(s string) {
  50040. m.avatar = &s
  50041. }
  50042. // Avatar returns the value of the "avatar" field in the mutation.
  50043. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  50044. v := m.avatar
  50045. if v == nil {
  50046. return
  50047. }
  50048. return *v, true
  50049. }
  50050. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  50051. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50053. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  50054. if !m.op.Is(OpUpdateOne) {
  50055. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  50056. }
  50057. if m.id == nil || m.oldValue == nil {
  50058. return v, errors.New("OldAvatar requires an ID field in the mutation")
  50059. }
  50060. oldValue, err := m.oldValue(ctx)
  50061. if err != nil {
  50062. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  50063. }
  50064. return oldValue.Avatar, nil
  50065. }
  50066. // ResetAvatar resets all changes to the "avatar" field.
  50067. func (m *WxCardUserMutation) ResetAvatar() {
  50068. m.avatar = nil
  50069. }
  50070. // SetNickname sets the "nickname" field.
  50071. func (m *WxCardUserMutation) SetNickname(s string) {
  50072. m.nickname = &s
  50073. }
  50074. // Nickname returns the value of the "nickname" field in the mutation.
  50075. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  50076. v := m.nickname
  50077. if v == nil {
  50078. return
  50079. }
  50080. return *v, true
  50081. }
  50082. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  50083. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50085. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  50086. if !m.op.Is(OpUpdateOne) {
  50087. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  50088. }
  50089. if m.id == nil || m.oldValue == nil {
  50090. return v, errors.New("OldNickname requires an ID field in the mutation")
  50091. }
  50092. oldValue, err := m.oldValue(ctx)
  50093. if err != nil {
  50094. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  50095. }
  50096. return oldValue.Nickname, nil
  50097. }
  50098. // ResetNickname resets all changes to the "nickname" field.
  50099. func (m *WxCardUserMutation) ResetNickname() {
  50100. m.nickname = nil
  50101. }
  50102. // SetRemark sets the "remark" field.
  50103. func (m *WxCardUserMutation) SetRemark(s string) {
  50104. m.remark = &s
  50105. }
  50106. // Remark returns the value of the "remark" field in the mutation.
  50107. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  50108. v := m.remark
  50109. if v == nil {
  50110. return
  50111. }
  50112. return *v, true
  50113. }
  50114. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  50115. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50117. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  50118. if !m.op.Is(OpUpdateOne) {
  50119. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  50120. }
  50121. if m.id == nil || m.oldValue == nil {
  50122. return v, errors.New("OldRemark requires an ID field in the mutation")
  50123. }
  50124. oldValue, err := m.oldValue(ctx)
  50125. if err != nil {
  50126. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  50127. }
  50128. return oldValue.Remark, nil
  50129. }
  50130. // ResetRemark resets all changes to the "remark" field.
  50131. func (m *WxCardUserMutation) ResetRemark() {
  50132. m.remark = nil
  50133. }
  50134. // SetPhone sets the "phone" field.
  50135. func (m *WxCardUserMutation) SetPhone(s string) {
  50136. m.phone = &s
  50137. }
  50138. // Phone returns the value of the "phone" field in the mutation.
  50139. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  50140. v := m.phone
  50141. if v == nil {
  50142. return
  50143. }
  50144. return *v, true
  50145. }
  50146. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  50147. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50149. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  50150. if !m.op.Is(OpUpdateOne) {
  50151. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  50152. }
  50153. if m.id == nil || m.oldValue == nil {
  50154. return v, errors.New("OldPhone requires an ID field in the mutation")
  50155. }
  50156. oldValue, err := m.oldValue(ctx)
  50157. if err != nil {
  50158. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  50159. }
  50160. return oldValue.Phone, nil
  50161. }
  50162. // ResetPhone resets all changes to the "phone" field.
  50163. func (m *WxCardUserMutation) ResetPhone() {
  50164. m.phone = nil
  50165. }
  50166. // SetOpenID sets the "open_id" field.
  50167. func (m *WxCardUserMutation) SetOpenID(s string) {
  50168. m.open_id = &s
  50169. }
  50170. // OpenID returns the value of the "open_id" field in the mutation.
  50171. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  50172. v := m.open_id
  50173. if v == nil {
  50174. return
  50175. }
  50176. return *v, true
  50177. }
  50178. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  50179. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50181. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  50182. if !m.op.Is(OpUpdateOne) {
  50183. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  50184. }
  50185. if m.id == nil || m.oldValue == nil {
  50186. return v, errors.New("OldOpenID requires an ID field in the mutation")
  50187. }
  50188. oldValue, err := m.oldValue(ctx)
  50189. if err != nil {
  50190. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  50191. }
  50192. return oldValue.OpenID, nil
  50193. }
  50194. // ResetOpenID resets all changes to the "open_id" field.
  50195. func (m *WxCardUserMutation) ResetOpenID() {
  50196. m.open_id = nil
  50197. }
  50198. // SetUnionID sets the "union_id" field.
  50199. func (m *WxCardUserMutation) SetUnionID(s string) {
  50200. m.union_id = &s
  50201. }
  50202. // UnionID returns the value of the "union_id" field in the mutation.
  50203. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  50204. v := m.union_id
  50205. if v == nil {
  50206. return
  50207. }
  50208. return *v, true
  50209. }
  50210. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  50211. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50213. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  50214. if !m.op.Is(OpUpdateOne) {
  50215. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  50216. }
  50217. if m.id == nil || m.oldValue == nil {
  50218. return v, errors.New("OldUnionID requires an ID field in the mutation")
  50219. }
  50220. oldValue, err := m.oldValue(ctx)
  50221. if err != nil {
  50222. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  50223. }
  50224. return oldValue.UnionID, nil
  50225. }
  50226. // ResetUnionID resets all changes to the "union_id" field.
  50227. func (m *WxCardUserMutation) ResetUnionID() {
  50228. m.union_id = nil
  50229. }
  50230. // SetSessionKey sets the "session_key" field.
  50231. func (m *WxCardUserMutation) SetSessionKey(s string) {
  50232. m.session_key = &s
  50233. }
  50234. // SessionKey returns the value of the "session_key" field in the mutation.
  50235. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  50236. v := m.session_key
  50237. if v == nil {
  50238. return
  50239. }
  50240. return *v, true
  50241. }
  50242. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  50243. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50245. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  50246. if !m.op.Is(OpUpdateOne) {
  50247. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  50248. }
  50249. if m.id == nil || m.oldValue == nil {
  50250. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  50251. }
  50252. oldValue, err := m.oldValue(ctx)
  50253. if err != nil {
  50254. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  50255. }
  50256. return oldValue.SessionKey, nil
  50257. }
  50258. // ResetSessionKey resets all changes to the "session_key" field.
  50259. func (m *WxCardUserMutation) ResetSessionKey() {
  50260. m.session_key = nil
  50261. }
  50262. // SetIsVip sets the "is_vip" field.
  50263. func (m *WxCardUserMutation) SetIsVip(i int) {
  50264. m.is_vip = &i
  50265. m.addis_vip = nil
  50266. }
  50267. // IsVip returns the value of the "is_vip" field in the mutation.
  50268. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  50269. v := m.is_vip
  50270. if v == nil {
  50271. return
  50272. }
  50273. return *v, true
  50274. }
  50275. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  50276. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50278. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  50279. if !m.op.Is(OpUpdateOne) {
  50280. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  50281. }
  50282. if m.id == nil || m.oldValue == nil {
  50283. return v, errors.New("OldIsVip requires an ID field in the mutation")
  50284. }
  50285. oldValue, err := m.oldValue(ctx)
  50286. if err != nil {
  50287. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  50288. }
  50289. return oldValue.IsVip, nil
  50290. }
  50291. // AddIsVip adds i to the "is_vip" field.
  50292. func (m *WxCardUserMutation) AddIsVip(i int) {
  50293. if m.addis_vip != nil {
  50294. *m.addis_vip += i
  50295. } else {
  50296. m.addis_vip = &i
  50297. }
  50298. }
  50299. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  50300. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  50301. v := m.addis_vip
  50302. if v == nil {
  50303. return
  50304. }
  50305. return *v, true
  50306. }
  50307. // ResetIsVip resets all changes to the "is_vip" field.
  50308. func (m *WxCardUserMutation) ResetIsVip() {
  50309. m.is_vip = nil
  50310. m.addis_vip = nil
  50311. }
  50312. // Where appends a list predicates to the WxCardUserMutation builder.
  50313. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  50314. m.predicates = append(m.predicates, ps...)
  50315. }
  50316. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  50317. // users can use type-assertion to append predicates that do not depend on any generated package.
  50318. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  50319. p := make([]predicate.WxCardUser, len(ps))
  50320. for i := range ps {
  50321. p[i] = ps[i]
  50322. }
  50323. m.Where(p...)
  50324. }
  50325. // Op returns the operation name.
  50326. func (m *WxCardUserMutation) Op() Op {
  50327. return m.op
  50328. }
  50329. // SetOp allows setting the mutation operation.
  50330. func (m *WxCardUserMutation) SetOp(op Op) {
  50331. m.op = op
  50332. }
  50333. // Type returns the node type of this mutation (WxCardUser).
  50334. func (m *WxCardUserMutation) Type() string {
  50335. return m.typ
  50336. }
  50337. // Fields returns all fields that were changed during this mutation. Note that in
  50338. // order to get all numeric fields that were incremented/decremented, call
  50339. // AddedFields().
  50340. func (m *WxCardUserMutation) Fields() []string {
  50341. fields := make([]string, 0, 13)
  50342. if m.created_at != nil {
  50343. fields = append(fields, wxcarduser.FieldCreatedAt)
  50344. }
  50345. if m.updated_at != nil {
  50346. fields = append(fields, wxcarduser.FieldUpdatedAt)
  50347. }
  50348. if m.deleted_at != nil {
  50349. fields = append(fields, wxcarduser.FieldDeletedAt)
  50350. }
  50351. if m.wxid != nil {
  50352. fields = append(fields, wxcarduser.FieldWxid)
  50353. }
  50354. if m.account != nil {
  50355. fields = append(fields, wxcarduser.FieldAccount)
  50356. }
  50357. if m.avatar != nil {
  50358. fields = append(fields, wxcarduser.FieldAvatar)
  50359. }
  50360. if m.nickname != nil {
  50361. fields = append(fields, wxcarduser.FieldNickname)
  50362. }
  50363. if m.remark != nil {
  50364. fields = append(fields, wxcarduser.FieldRemark)
  50365. }
  50366. if m.phone != nil {
  50367. fields = append(fields, wxcarduser.FieldPhone)
  50368. }
  50369. if m.open_id != nil {
  50370. fields = append(fields, wxcarduser.FieldOpenID)
  50371. }
  50372. if m.union_id != nil {
  50373. fields = append(fields, wxcarduser.FieldUnionID)
  50374. }
  50375. if m.session_key != nil {
  50376. fields = append(fields, wxcarduser.FieldSessionKey)
  50377. }
  50378. if m.is_vip != nil {
  50379. fields = append(fields, wxcarduser.FieldIsVip)
  50380. }
  50381. return fields
  50382. }
  50383. // Field returns the value of a field with the given name. The second boolean
  50384. // return value indicates that this field was not set, or was not defined in the
  50385. // schema.
  50386. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  50387. switch name {
  50388. case wxcarduser.FieldCreatedAt:
  50389. return m.CreatedAt()
  50390. case wxcarduser.FieldUpdatedAt:
  50391. return m.UpdatedAt()
  50392. case wxcarduser.FieldDeletedAt:
  50393. return m.DeletedAt()
  50394. case wxcarduser.FieldWxid:
  50395. return m.Wxid()
  50396. case wxcarduser.FieldAccount:
  50397. return m.Account()
  50398. case wxcarduser.FieldAvatar:
  50399. return m.Avatar()
  50400. case wxcarduser.FieldNickname:
  50401. return m.Nickname()
  50402. case wxcarduser.FieldRemark:
  50403. return m.Remark()
  50404. case wxcarduser.FieldPhone:
  50405. return m.Phone()
  50406. case wxcarduser.FieldOpenID:
  50407. return m.OpenID()
  50408. case wxcarduser.FieldUnionID:
  50409. return m.UnionID()
  50410. case wxcarduser.FieldSessionKey:
  50411. return m.SessionKey()
  50412. case wxcarduser.FieldIsVip:
  50413. return m.IsVip()
  50414. }
  50415. return nil, false
  50416. }
  50417. // OldField returns the old value of the field from the database. An error is
  50418. // returned if the mutation operation is not UpdateOne, or the query to the
  50419. // database failed.
  50420. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50421. switch name {
  50422. case wxcarduser.FieldCreatedAt:
  50423. return m.OldCreatedAt(ctx)
  50424. case wxcarduser.FieldUpdatedAt:
  50425. return m.OldUpdatedAt(ctx)
  50426. case wxcarduser.FieldDeletedAt:
  50427. return m.OldDeletedAt(ctx)
  50428. case wxcarduser.FieldWxid:
  50429. return m.OldWxid(ctx)
  50430. case wxcarduser.FieldAccount:
  50431. return m.OldAccount(ctx)
  50432. case wxcarduser.FieldAvatar:
  50433. return m.OldAvatar(ctx)
  50434. case wxcarduser.FieldNickname:
  50435. return m.OldNickname(ctx)
  50436. case wxcarduser.FieldRemark:
  50437. return m.OldRemark(ctx)
  50438. case wxcarduser.FieldPhone:
  50439. return m.OldPhone(ctx)
  50440. case wxcarduser.FieldOpenID:
  50441. return m.OldOpenID(ctx)
  50442. case wxcarduser.FieldUnionID:
  50443. return m.OldUnionID(ctx)
  50444. case wxcarduser.FieldSessionKey:
  50445. return m.OldSessionKey(ctx)
  50446. case wxcarduser.FieldIsVip:
  50447. return m.OldIsVip(ctx)
  50448. }
  50449. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  50450. }
  50451. // SetField sets the value of a field with the given name. It returns an error if
  50452. // the field is not defined in the schema, or if the type mismatched the field
  50453. // type.
  50454. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  50455. switch name {
  50456. case wxcarduser.FieldCreatedAt:
  50457. v, ok := value.(time.Time)
  50458. if !ok {
  50459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50460. }
  50461. m.SetCreatedAt(v)
  50462. return nil
  50463. case wxcarduser.FieldUpdatedAt:
  50464. v, ok := value.(time.Time)
  50465. if !ok {
  50466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50467. }
  50468. m.SetUpdatedAt(v)
  50469. return nil
  50470. case wxcarduser.FieldDeletedAt:
  50471. v, ok := value.(time.Time)
  50472. if !ok {
  50473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50474. }
  50475. m.SetDeletedAt(v)
  50476. return nil
  50477. case wxcarduser.FieldWxid:
  50478. v, ok := value.(string)
  50479. if !ok {
  50480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50481. }
  50482. m.SetWxid(v)
  50483. return nil
  50484. case wxcarduser.FieldAccount:
  50485. v, ok := value.(string)
  50486. if !ok {
  50487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50488. }
  50489. m.SetAccount(v)
  50490. return nil
  50491. case wxcarduser.FieldAvatar:
  50492. v, ok := value.(string)
  50493. if !ok {
  50494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50495. }
  50496. m.SetAvatar(v)
  50497. return nil
  50498. case wxcarduser.FieldNickname:
  50499. v, ok := value.(string)
  50500. if !ok {
  50501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50502. }
  50503. m.SetNickname(v)
  50504. return nil
  50505. case wxcarduser.FieldRemark:
  50506. v, ok := value.(string)
  50507. if !ok {
  50508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50509. }
  50510. m.SetRemark(v)
  50511. return nil
  50512. case wxcarduser.FieldPhone:
  50513. v, ok := value.(string)
  50514. if !ok {
  50515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50516. }
  50517. m.SetPhone(v)
  50518. return nil
  50519. case wxcarduser.FieldOpenID:
  50520. v, ok := value.(string)
  50521. if !ok {
  50522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50523. }
  50524. m.SetOpenID(v)
  50525. return nil
  50526. case wxcarduser.FieldUnionID:
  50527. v, ok := value.(string)
  50528. if !ok {
  50529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50530. }
  50531. m.SetUnionID(v)
  50532. return nil
  50533. case wxcarduser.FieldSessionKey:
  50534. v, ok := value.(string)
  50535. if !ok {
  50536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50537. }
  50538. m.SetSessionKey(v)
  50539. return nil
  50540. case wxcarduser.FieldIsVip:
  50541. v, ok := value.(int)
  50542. if !ok {
  50543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50544. }
  50545. m.SetIsVip(v)
  50546. return nil
  50547. }
  50548. return fmt.Errorf("unknown WxCardUser field %s", name)
  50549. }
  50550. // AddedFields returns all numeric fields that were incremented/decremented during
  50551. // this mutation.
  50552. func (m *WxCardUserMutation) AddedFields() []string {
  50553. var fields []string
  50554. if m.addis_vip != nil {
  50555. fields = append(fields, wxcarduser.FieldIsVip)
  50556. }
  50557. return fields
  50558. }
  50559. // AddedField returns the numeric value that was incremented/decremented on a field
  50560. // with the given name. The second boolean return value indicates that this field
  50561. // was not set, or was not defined in the schema.
  50562. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  50563. switch name {
  50564. case wxcarduser.FieldIsVip:
  50565. return m.AddedIsVip()
  50566. }
  50567. return nil, false
  50568. }
  50569. // AddField adds the value to the field with the given name. It returns an error if
  50570. // the field is not defined in the schema, or if the type mismatched the field
  50571. // type.
  50572. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  50573. switch name {
  50574. case wxcarduser.FieldIsVip:
  50575. v, ok := value.(int)
  50576. if !ok {
  50577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50578. }
  50579. m.AddIsVip(v)
  50580. return nil
  50581. }
  50582. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  50583. }
  50584. // ClearedFields returns all nullable fields that were cleared during this
  50585. // mutation.
  50586. func (m *WxCardUserMutation) ClearedFields() []string {
  50587. var fields []string
  50588. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  50589. fields = append(fields, wxcarduser.FieldDeletedAt)
  50590. }
  50591. return fields
  50592. }
  50593. // FieldCleared returns a boolean indicating if a field with the given name was
  50594. // cleared in this mutation.
  50595. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  50596. _, ok := m.clearedFields[name]
  50597. return ok
  50598. }
  50599. // ClearField clears the value of the field with the given name. It returns an
  50600. // error if the field is not defined in the schema.
  50601. func (m *WxCardUserMutation) ClearField(name string) error {
  50602. switch name {
  50603. case wxcarduser.FieldDeletedAt:
  50604. m.ClearDeletedAt()
  50605. return nil
  50606. }
  50607. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  50608. }
  50609. // ResetField resets all changes in the mutation for the field with the given name.
  50610. // It returns an error if the field is not defined in the schema.
  50611. func (m *WxCardUserMutation) ResetField(name string) error {
  50612. switch name {
  50613. case wxcarduser.FieldCreatedAt:
  50614. m.ResetCreatedAt()
  50615. return nil
  50616. case wxcarduser.FieldUpdatedAt:
  50617. m.ResetUpdatedAt()
  50618. return nil
  50619. case wxcarduser.FieldDeletedAt:
  50620. m.ResetDeletedAt()
  50621. return nil
  50622. case wxcarduser.FieldWxid:
  50623. m.ResetWxid()
  50624. return nil
  50625. case wxcarduser.FieldAccount:
  50626. m.ResetAccount()
  50627. return nil
  50628. case wxcarduser.FieldAvatar:
  50629. m.ResetAvatar()
  50630. return nil
  50631. case wxcarduser.FieldNickname:
  50632. m.ResetNickname()
  50633. return nil
  50634. case wxcarduser.FieldRemark:
  50635. m.ResetRemark()
  50636. return nil
  50637. case wxcarduser.FieldPhone:
  50638. m.ResetPhone()
  50639. return nil
  50640. case wxcarduser.FieldOpenID:
  50641. m.ResetOpenID()
  50642. return nil
  50643. case wxcarduser.FieldUnionID:
  50644. m.ResetUnionID()
  50645. return nil
  50646. case wxcarduser.FieldSessionKey:
  50647. m.ResetSessionKey()
  50648. return nil
  50649. case wxcarduser.FieldIsVip:
  50650. m.ResetIsVip()
  50651. return nil
  50652. }
  50653. return fmt.Errorf("unknown WxCardUser field %s", name)
  50654. }
  50655. // AddedEdges returns all edge names that were set/added in this mutation.
  50656. func (m *WxCardUserMutation) AddedEdges() []string {
  50657. edges := make([]string, 0, 0)
  50658. return edges
  50659. }
  50660. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50661. // name in this mutation.
  50662. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  50663. return nil
  50664. }
  50665. // RemovedEdges returns all edge names that were removed in this mutation.
  50666. func (m *WxCardUserMutation) RemovedEdges() []string {
  50667. edges := make([]string, 0, 0)
  50668. return edges
  50669. }
  50670. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50671. // the given name in this mutation.
  50672. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  50673. return nil
  50674. }
  50675. // ClearedEdges returns all edge names that were cleared in this mutation.
  50676. func (m *WxCardUserMutation) ClearedEdges() []string {
  50677. edges := make([]string, 0, 0)
  50678. return edges
  50679. }
  50680. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50681. // was cleared in this mutation.
  50682. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  50683. return false
  50684. }
  50685. // ClearEdge clears the value of the edge with the given name. It returns an error
  50686. // if that edge is not defined in the schema.
  50687. func (m *WxCardUserMutation) ClearEdge(name string) error {
  50688. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  50689. }
  50690. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50691. // It returns an error if the edge is not defined in the schema.
  50692. func (m *WxCardUserMutation) ResetEdge(name string) error {
  50693. return fmt.Errorf("unknown WxCardUser edge %s", name)
  50694. }
  50695. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  50696. type WxCardVisitMutation struct {
  50697. config
  50698. op Op
  50699. typ string
  50700. id *uint64
  50701. created_at *time.Time
  50702. updated_at *time.Time
  50703. deleted_at *time.Time
  50704. user_id *uint64
  50705. adduser_id *int64
  50706. bot_id *uint64
  50707. addbot_id *int64
  50708. bot_type *uint8
  50709. addbot_type *int8
  50710. clearedFields map[string]struct{}
  50711. done bool
  50712. oldValue func(context.Context) (*WxCardVisit, error)
  50713. predicates []predicate.WxCardVisit
  50714. }
  50715. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  50716. // wxcardvisitOption allows management of the mutation configuration using functional options.
  50717. type wxcardvisitOption func(*WxCardVisitMutation)
  50718. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  50719. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  50720. m := &WxCardVisitMutation{
  50721. config: c,
  50722. op: op,
  50723. typ: TypeWxCardVisit,
  50724. clearedFields: make(map[string]struct{}),
  50725. }
  50726. for _, opt := range opts {
  50727. opt(m)
  50728. }
  50729. return m
  50730. }
  50731. // withWxCardVisitID sets the ID field of the mutation.
  50732. func withWxCardVisitID(id uint64) wxcardvisitOption {
  50733. return func(m *WxCardVisitMutation) {
  50734. var (
  50735. err error
  50736. once sync.Once
  50737. value *WxCardVisit
  50738. )
  50739. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  50740. once.Do(func() {
  50741. if m.done {
  50742. err = errors.New("querying old values post mutation is not allowed")
  50743. } else {
  50744. value, err = m.Client().WxCardVisit.Get(ctx, id)
  50745. }
  50746. })
  50747. return value, err
  50748. }
  50749. m.id = &id
  50750. }
  50751. }
  50752. // withWxCardVisit sets the old WxCardVisit of the mutation.
  50753. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  50754. return func(m *WxCardVisitMutation) {
  50755. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  50756. return node, nil
  50757. }
  50758. m.id = &node.ID
  50759. }
  50760. }
  50761. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50762. // executed in a transaction (ent.Tx), a transactional client is returned.
  50763. func (m WxCardVisitMutation) Client() *Client {
  50764. client := &Client{config: m.config}
  50765. client.init()
  50766. return client
  50767. }
  50768. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50769. // it returns an error otherwise.
  50770. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  50771. if _, ok := m.driver.(*txDriver); !ok {
  50772. return nil, errors.New("ent: mutation is not running in a transaction")
  50773. }
  50774. tx := &Tx{config: m.config}
  50775. tx.init()
  50776. return tx, nil
  50777. }
  50778. // SetID sets the value of the id field. Note that this
  50779. // operation is only accepted on creation of WxCardVisit entities.
  50780. func (m *WxCardVisitMutation) SetID(id uint64) {
  50781. m.id = &id
  50782. }
  50783. // ID returns the ID value in the mutation. Note that the ID is only available
  50784. // if it was provided to the builder or after it was returned from the database.
  50785. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  50786. if m.id == nil {
  50787. return
  50788. }
  50789. return *m.id, true
  50790. }
  50791. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50792. // That means, if the mutation is applied within a transaction with an isolation level such
  50793. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50794. // or updated by the mutation.
  50795. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  50796. switch {
  50797. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50798. id, exists := m.ID()
  50799. if exists {
  50800. return []uint64{id}, nil
  50801. }
  50802. fallthrough
  50803. case m.op.Is(OpUpdate | OpDelete):
  50804. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  50805. default:
  50806. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50807. }
  50808. }
  50809. // SetCreatedAt sets the "created_at" field.
  50810. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  50811. m.created_at = &t
  50812. }
  50813. // CreatedAt returns the value of the "created_at" field in the mutation.
  50814. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  50815. v := m.created_at
  50816. if v == nil {
  50817. return
  50818. }
  50819. return *v, true
  50820. }
  50821. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  50822. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50824. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50825. if !m.op.Is(OpUpdateOne) {
  50826. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50827. }
  50828. if m.id == nil || m.oldValue == nil {
  50829. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50830. }
  50831. oldValue, err := m.oldValue(ctx)
  50832. if err != nil {
  50833. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50834. }
  50835. return oldValue.CreatedAt, nil
  50836. }
  50837. // ResetCreatedAt resets all changes to the "created_at" field.
  50838. func (m *WxCardVisitMutation) ResetCreatedAt() {
  50839. m.created_at = nil
  50840. }
  50841. // SetUpdatedAt sets the "updated_at" field.
  50842. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  50843. m.updated_at = &t
  50844. }
  50845. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50846. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  50847. v := m.updated_at
  50848. if v == nil {
  50849. return
  50850. }
  50851. return *v, true
  50852. }
  50853. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  50854. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50856. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50857. if !m.op.Is(OpUpdateOne) {
  50858. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50859. }
  50860. if m.id == nil || m.oldValue == nil {
  50861. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50862. }
  50863. oldValue, err := m.oldValue(ctx)
  50864. if err != nil {
  50865. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50866. }
  50867. return oldValue.UpdatedAt, nil
  50868. }
  50869. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50870. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  50871. m.updated_at = nil
  50872. }
  50873. // SetDeletedAt sets the "deleted_at" field.
  50874. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  50875. m.deleted_at = &t
  50876. }
  50877. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50878. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  50879. v := m.deleted_at
  50880. if v == nil {
  50881. return
  50882. }
  50883. return *v, true
  50884. }
  50885. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  50886. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50888. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50889. if !m.op.Is(OpUpdateOne) {
  50890. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50891. }
  50892. if m.id == nil || m.oldValue == nil {
  50893. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50894. }
  50895. oldValue, err := m.oldValue(ctx)
  50896. if err != nil {
  50897. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50898. }
  50899. return oldValue.DeletedAt, nil
  50900. }
  50901. // ClearDeletedAt clears the value of the "deleted_at" field.
  50902. func (m *WxCardVisitMutation) ClearDeletedAt() {
  50903. m.deleted_at = nil
  50904. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  50905. }
  50906. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50907. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  50908. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  50909. return ok
  50910. }
  50911. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50912. func (m *WxCardVisitMutation) ResetDeletedAt() {
  50913. m.deleted_at = nil
  50914. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  50915. }
  50916. // SetUserID sets the "user_id" field.
  50917. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  50918. m.user_id = &u
  50919. m.adduser_id = nil
  50920. }
  50921. // UserID returns the value of the "user_id" field in the mutation.
  50922. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  50923. v := m.user_id
  50924. if v == nil {
  50925. return
  50926. }
  50927. return *v, true
  50928. }
  50929. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  50930. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50932. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  50933. if !m.op.Is(OpUpdateOne) {
  50934. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  50935. }
  50936. if m.id == nil || m.oldValue == nil {
  50937. return v, errors.New("OldUserID requires an ID field in the mutation")
  50938. }
  50939. oldValue, err := m.oldValue(ctx)
  50940. if err != nil {
  50941. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  50942. }
  50943. return oldValue.UserID, nil
  50944. }
  50945. // AddUserID adds u to the "user_id" field.
  50946. func (m *WxCardVisitMutation) AddUserID(u int64) {
  50947. if m.adduser_id != nil {
  50948. *m.adduser_id += u
  50949. } else {
  50950. m.adduser_id = &u
  50951. }
  50952. }
  50953. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  50954. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  50955. v := m.adduser_id
  50956. if v == nil {
  50957. return
  50958. }
  50959. return *v, true
  50960. }
  50961. // ClearUserID clears the value of the "user_id" field.
  50962. func (m *WxCardVisitMutation) ClearUserID() {
  50963. m.user_id = nil
  50964. m.adduser_id = nil
  50965. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  50966. }
  50967. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  50968. func (m *WxCardVisitMutation) UserIDCleared() bool {
  50969. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  50970. return ok
  50971. }
  50972. // ResetUserID resets all changes to the "user_id" field.
  50973. func (m *WxCardVisitMutation) ResetUserID() {
  50974. m.user_id = nil
  50975. m.adduser_id = nil
  50976. delete(m.clearedFields, wxcardvisit.FieldUserID)
  50977. }
  50978. // SetBotID sets the "bot_id" field.
  50979. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  50980. m.bot_id = &u
  50981. m.addbot_id = nil
  50982. }
  50983. // BotID returns the value of the "bot_id" field in the mutation.
  50984. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  50985. v := m.bot_id
  50986. if v == nil {
  50987. return
  50988. }
  50989. return *v, true
  50990. }
  50991. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  50992. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50994. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  50995. if !m.op.Is(OpUpdateOne) {
  50996. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  50997. }
  50998. if m.id == nil || m.oldValue == nil {
  50999. return v, errors.New("OldBotID requires an ID field in the mutation")
  51000. }
  51001. oldValue, err := m.oldValue(ctx)
  51002. if err != nil {
  51003. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  51004. }
  51005. return oldValue.BotID, nil
  51006. }
  51007. // AddBotID adds u to the "bot_id" field.
  51008. func (m *WxCardVisitMutation) AddBotID(u int64) {
  51009. if m.addbot_id != nil {
  51010. *m.addbot_id += u
  51011. } else {
  51012. m.addbot_id = &u
  51013. }
  51014. }
  51015. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  51016. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  51017. v := m.addbot_id
  51018. if v == nil {
  51019. return
  51020. }
  51021. return *v, true
  51022. }
  51023. // ResetBotID resets all changes to the "bot_id" field.
  51024. func (m *WxCardVisitMutation) ResetBotID() {
  51025. m.bot_id = nil
  51026. m.addbot_id = nil
  51027. }
  51028. // SetBotType sets the "bot_type" field.
  51029. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  51030. m.bot_type = &u
  51031. m.addbot_type = nil
  51032. }
  51033. // BotType returns the value of the "bot_type" field in the mutation.
  51034. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  51035. v := m.bot_type
  51036. if v == nil {
  51037. return
  51038. }
  51039. return *v, true
  51040. }
  51041. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  51042. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51044. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  51045. if !m.op.Is(OpUpdateOne) {
  51046. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  51047. }
  51048. if m.id == nil || m.oldValue == nil {
  51049. return v, errors.New("OldBotType requires an ID field in the mutation")
  51050. }
  51051. oldValue, err := m.oldValue(ctx)
  51052. if err != nil {
  51053. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  51054. }
  51055. return oldValue.BotType, nil
  51056. }
  51057. // AddBotType adds u to the "bot_type" field.
  51058. func (m *WxCardVisitMutation) AddBotType(u int8) {
  51059. if m.addbot_type != nil {
  51060. *m.addbot_type += u
  51061. } else {
  51062. m.addbot_type = &u
  51063. }
  51064. }
  51065. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  51066. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  51067. v := m.addbot_type
  51068. if v == nil {
  51069. return
  51070. }
  51071. return *v, true
  51072. }
  51073. // ResetBotType resets all changes to the "bot_type" field.
  51074. func (m *WxCardVisitMutation) ResetBotType() {
  51075. m.bot_type = nil
  51076. m.addbot_type = nil
  51077. }
  51078. // Where appends a list predicates to the WxCardVisitMutation builder.
  51079. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  51080. m.predicates = append(m.predicates, ps...)
  51081. }
  51082. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  51083. // users can use type-assertion to append predicates that do not depend on any generated package.
  51084. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  51085. p := make([]predicate.WxCardVisit, len(ps))
  51086. for i := range ps {
  51087. p[i] = ps[i]
  51088. }
  51089. m.Where(p...)
  51090. }
  51091. // Op returns the operation name.
  51092. func (m *WxCardVisitMutation) Op() Op {
  51093. return m.op
  51094. }
  51095. // SetOp allows setting the mutation operation.
  51096. func (m *WxCardVisitMutation) SetOp(op Op) {
  51097. m.op = op
  51098. }
  51099. // Type returns the node type of this mutation (WxCardVisit).
  51100. func (m *WxCardVisitMutation) Type() string {
  51101. return m.typ
  51102. }
  51103. // Fields returns all fields that were changed during this mutation. Note that in
  51104. // order to get all numeric fields that were incremented/decremented, call
  51105. // AddedFields().
  51106. func (m *WxCardVisitMutation) Fields() []string {
  51107. fields := make([]string, 0, 6)
  51108. if m.created_at != nil {
  51109. fields = append(fields, wxcardvisit.FieldCreatedAt)
  51110. }
  51111. if m.updated_at != nil {
  51112. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  51113. }
  51114. if m.deleted_at != nil {
  51115. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51116. }
  51117. if m.user_id != nil {
  51118. fields = append(fields, wxcardvisit.FieldUserID)
  51119. }
  51120. if m.bot_id != nil {
  51121. fields = append(fields, wxcardvisit.FieldBotID)
  51122. }
  51123. if m.bot_type != nil {
  51124. fields = append(fields, wxcardvisit.FieldBotType)
  51125. }
  51126. return fields
  51127. }
  51128. // Field returns the value of a field with the given name. The second boolean
  51129. // return value indicates that this field was not set, or was not defined in the
  51130. // schema.
  51131. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  51132. switch name {
  51133. case wxcardvisit.FieldCreatedAt:
  51134. return m.CreatedAt()
  51135. case wxcardvisit.FieldUpdatedAt:
  51136. return m.UpdatedAt()
  51137. case wxcardvisit.FieldDeletedAt:
  51138. return m.DeletedAt()
  51139. case wxcardvisit.FieldUserID:
  51140. return m.UserID()
  51141. case wxcardvisit.FieldBotID:
  51142. return m.BotID()
  51143. case wxcardvisit.FieldBotType:
  51144. return m.BotType()
  51145. }
  51146. return nil, false
  51147. }
  51148. // OldField returns the old value of the field from the database. An error is
  51149. // returned if the mutation operation is not UpdateOne, or the query to the
  51150. // database failed.
  51151. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51152. switch name {
  51153. case wxcardvisit.FieldCreatedAt:
  51154. return m.OldCreatedAt(ctx)
  51155. case wxcardvisit.FieldUpdatedAt:
  51156. return m.OldUpdatedAt(ctx)
  51157. case wxcardvisit.FieldDeletedAt:
  51158. return m.OldDeletedAt(ctx)
  51159. case wxcardvisit.FieldUserID:
  51160. return m.OldUserID(ctx)
  51161. case wxcardvisit.FieldBotID:
  51162. return m.OldBotID(ctx)
  51163. case wxcardvisit.FieldBotType:
  51164. return m.OldBotType(ctx)
  51165. }
  51166. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  51167. }
  51168. // SetField sets the value of a field with the given name. It returns an error if
  51169. // the field is not defined in the schema, or if the type mismatched the field
  51170. // type.
  51171. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  51172. switch name {
  51173. case wxcardvisit.FieldCreatedAt:
  51174. v, ok := value.(time.Time)
  51175. if !ok {
  51176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51177. }
  51178. m.SetCreatedAt(v)
  51179. return nil
  51180. case wxcardvisit.FieldUpdatedAt:
  51181. v, ok := value.(time.Time)
  51182. if !ok {
  51183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51184. }
  51185. m.SetUpdatedAt(v)
  51186. return nil
  51187. case wxcardvisit.FieldDeletedAt:
  51188. v, ok := value.(time.Time)
  51189. if !ok {
  51190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51191. }
  51192. m.SetDeletedAt(v)
  51193. return nil
  51194. case wxcardvisit.FieldUserID:
  51195. v, ok := value.(uint64)
  51196. if !ok {
  51197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51198. }
  51199. m.SetUserID(v)
  51200. return nil
  51201. case wxcardvisit.FieldBotID:
  51202. v, ok := value.(uint64)
  51203. if !ok {
  51204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51205. }
  51206. m.SetBotID(v)
  51207. return nil
  51208. case wxcardvisit.FieldBotType:
  51209. v, ok := value.(uint8)
  51210. if !ok {
  51211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51212. }
  51213. m.SetBotType(v)
  51214. return nil
  51215. }
  51216. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51217. }
  51218. // AddedFields returns all numeric fields that were incremented/decremented during
  51219. // this mutation.
  51220. func (m *WxCardVisitMutation) AddedFields() []string {
  51221. var fields []string
  51222. if m.adduser_id != nil {
  51223. fields = append(fields, wxcardvisit.FieldUserID)
  51224. }
  51225. if m.addbot_id != nil {
  51226. fields = append(fields, wxcardvisit.FieldBotID)
  51227. }
  51228. if m.addbot_type != nil {
  51229. fields = append(fields, wxcardvisit.FieldBotType)
  51230. }
  51231. return fields
  51232. }
  51233. // AddedField returns the numeric value that was incremented/decremented on a field
  51234. // with the given name. The second boolean return value indicates that this field
  51235. // was not set, or was not defined in the schema.
  51236. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  51237. switch name {
  51238. case wxcardvisit.FieldUserID:
  51239. return m.AddedUserID()
  51240. case wxcardvisit.FieldBotID:
  51241. return m.AddedBotID()
  51242. case wxcardvisit.FieldBotType:
  51243. return m.AddedBotType()
  51244. }
  51245. return nil, false
  51246. }
  51247. // AddField adds the value to the field with the given name. It returns an error if
  51248. // the field is not defined in the schema, or if the type mismatched the field
  51249. // type.
  51250. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  51251. switch name {
  51252. case wxcardvisit.FieldUserID:
  51253. v, ok := value.(int64)
  51254. if !ok {
  51255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51256. }
  51257. m.AddUserID(v)
  51258. return nil
  51259. case wxcardvisit.FieldBotID:
  51260. v, ok := value.(int64)
  51261. if !ok {
  51262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51263. }
  51264. m.AddBotID(v)
  51265. return nil
  51266. case wxcardvisit.FieldBotType:
  51267. v, ok := value.(int8)
  51268. if !ok {
  51269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51270. }
  51271. m.AddBotType(v)
  51272. return nil
  51273. }
  51274. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  51275. }
  51276. // ClearedFields returns all nullable fields that were cleared during this
  51277. // mutation.
  51278. func (m *WxCardVisitMutation) ClearedFields() []string {
  51279. var fields []string
  51280. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  51281. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51282. }
  51283. if m.FieldCleared(wxcardvisit.FieldUserID) {
  51284. fields = append(fields, wxcardvisit.FieldUserID)
  51285. }
  51286. return fields
  51287. }
  51288. // FieldCleared returns a boolean indicating if a field with the given name was
  51289. // cleared in this mutation.
  51290. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  51291. _, ok := m.clearedFields[name]
  51292. return ok
  51293. }
  51294. // ClearField clears the value of the field with the given name. It returns an
  51295. // error if the field is not defined in the schema.
  51296. func (m *WxCardVisitMutation) ClearField(name string) error {
  51297. switch name {
  51298. case wxcardvisit.FieldDeletedAt:
  51299. m.ClearDeletedAt()
  51300. return nil
  51301. case wxcardvisit.FieldUserID:
  51302. m.ClearUserID()
  51303. return nil
  51304. }
  51305. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  51306. }
  51307. // ResetField resets all changes in the mutation for the field with the given name.
  51308. // It returns an error if the field is not defined in the schema.
  51309. func (m *WxCardVisitMutation) ResetField(name string) error {
  51310. switch name {
  51311. case wxcardvisit.FieldCreatedAt:
  51312. m.ResetCreatedAt()
  51313. return nil
  51314. case wxcardvisit.FieldUpdatedAt:
  51315. m.ResetUpdatedAt()
  51316. return nil
  51317. case wxcardvisit.FieldDeletedAt:
  51318. m.ResetDeletedAt()
  51319. return nil
  51320. case wxcardvisit.FieldUserID:
  51321. m.ResetUserID()
  51322. return nil
  51323. case wxcardvisit.FieldBotID:
  51324. m.ResetBotID()
  51325. return nil
  51326. case wxcardvisit.FieldBotType:
  51327. m.ResetBotType()
  51328. return nil
  51329. }
  51330. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51331. }
  51332. // AddedEdges returns all edge names that were set/added in this mutation.
  51333. func (m *WxCardVisitMutation) AddedEdges() []string {
  51334. edges := make([]string, 0, 0)
  51335. return edges
  51336. }
  51337. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51338. // name in this mutation.
  51339. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  51340. return nil
  51341. }
  51342. // RemovedEdges returns all edge names that were removed in this mutation.
  51343. func (m *WxCardVisitMutation) RemovedEdges() []string {
  51344. edges := make([]string, 0, 0)
  51345. return edges
  51346. }
  51347. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51348. // the given name in this mutation.
  51349. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  51350. return nil
  51351. }
  51352. // ClearedEdges returns all edge names that were cleared in this mutation.
  51353. func (m *WxCardVisitMutation) ClearedEdges() []string {
  51354. edges := make([]string, 0, 0)
  51355. return edges
  51356. }
  51357. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51358. // was cleared in this mutation.
  51359. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  51360. return false
  51361. }
  51362. // ClearEdge clears the value of the edge with the given name. It returns an error
  51363. // if that edge is not defined in the schema.
  51364. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  51365. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  51366. }
  51367. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51368. // It returns an error if the edge is not defined in the schema.
  51369. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  51370. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  51371. }
  51372. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  51373. type XunjiMutation struct {
  51374. config
  51375. op Op
  51376. typ string
  51377. id *uint64
  51378. created_at *time.Time
  51379. updated_at *time.Time
  51380. status *uint8
  51381. addstatus *int8
  51382. deleted_at *time.Time
  51383. app_key *string
  51384. app_secret *string
  51385. token *string
  51386. encoding_key *string
  51387. organization_id *uint64
  51388. addorganization_id *int64
  51389. clearedFields map[string]struct{}
  51390. done bool
  51391. oldValue func(context.Context) (*Xunji, error)
  51392. predicates []predicate.Xunji
  51393. }
  51394. var _ ent.Mutation = (*XunjiMutation)(nil)
  51395. // xunjiOption allows management of the mutation configuration using functional options.
  51396. type xunjiOption func(*XunjiMutation)
  51397. // newXunjiMutation creates new mutation for the Xunji entity.
  51398. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  51399. m := &XunjiMutation{
  51400. config: c,
  51401. op: op,
  51402. typ: TypeXunji,
  51403. clearedFields: make(map[string]struct{}),
  51404. }
  51405. for _, opt := range opts {
  51406. opt(m)
  51407. }
  51408. return m
  51409. }
  51410. // withXunjiID sets the ID field of the mutation.
  51411. func withXunjiID(id uint64) xunjiOption {
  51412. return func(m *XunjiMutation) {
  51413. var (
  51414. err error
  51415. once sync.Once
  51416. value *Xunji
  51417. )
  51418. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  51419. once.Do(func() {
  51420. if m.done {
  51421. err = errors.New("querying old values post mutation is not allowed")
  51422. } else {
  51423. value, err = m.Client().Xunji.Get(ctx, id)
  51424. }
  51425. })
  51426. return value, err
  51427. }
  51428. m.id = &id
  51429. }
  51430. }
  51431. // withXunji sets the old Xunji of the mutation.
  51432. func withXunji(node *Xunji) xunjiOption {
  51433. return func(m *XunjiMutation) {
  51434. m.oldValue = func(context.Context) (*Xunji, error) {
  51435. return node, nil
  51436. }
  51437. m.id = &node.ID
  51438. }
  51439. }
  51440. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51441. // executed in a transaction (ent.Tx), a transactional client is returned.
  51442. func (m XunjiMutation) Client() *Client {
  51443. client := &Client{config: m.config}
  51444. client.init()
  51445. return client
  51446. }
  51447. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51448. // it returns an error otherwise.
  51449. func (m XunjiMutation) Tx() (*Tx, error) {
  51450. if _, ok := m.driver.(*txDriver); !ok {
  51451. return nil, errors.New("ent: mutation is not running in a transaction")
  51452. }
  51453. tx := &Tx{config: m.config}
  51454. tx.init()
  51455. return tx, nil
  51456. }
  51457. // SetID sets the value of the id field. Note that this
  51458. // operation is only accepted on creation of Xunji entities.
  51459. func (m *XunjiMutation) SetID(id uint64) {
  51460. m.id = &id
  51461. }
  51462. // ID returns the ID value in the mutation. Note that the ID is only available
  51463. // if it was provided to the builder or after it was returned from the database.
  51464. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  51465. if m.id == nil {
  51466. return
  51467. }
  51468. return *m.id, true
  51469. }
  51470. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51471. // That means, if the mutation is applied within a transaction with an isolation level such
  51472. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51473. // or updated by the mutation.
  51474. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  51475. switch {
  51476. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51477. id, exists := m.ID()
  51478. if exists {
  51479. return []uint64{id}, nil
  51480. }
  51481. fallthrough
  51482. case m.op.Is(OpUpdate | OpDelete):
  51483. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  51484. default:
  51485. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51486. }
  51487. }
  51488. // SetCreatedAt sets the "created_at" field.
  51489. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  51490. m.created_at = &t
  51491. }
  51492. // CreatedAt returns the value of the "created_at" field in the mutation.
  51493. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  51494. v := m.created_at
  51495. if v == nil {
  51496. return
  51497. }
  51498. return *v, true
  51499. }
  51500. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  51501. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51503. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51504. if !m.op.Is(OpUpdateOne) {
  51505. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51506. }
  51507. if m.id == nil || m.oldValue == nil {
  51508. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51509. }
  51510. oldValue, err := m.oldValue(ctx)
  51511. if err != nil {
  51512. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51513. }
  51514. return oldValue.CreatedAt, nil
  51515. }
  51516. // ResetCreatedAt resets all changes to the "created_at" field.
  51517. func (m *XunjiMutation) ResetCreatedAt() {
  51518. m.created_at = nil
  51519. }
  51520. // SetUpdatedAt sets the "updated_at" field.
  51521. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  51522. m.updated_at = &t
  51523. }
  51524. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51525. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  51526. v := m.updated_at
  51527. if v == nil {
  51528. return
  51529. }
  51530. return *v, true
  51531. }
  51532. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  51533. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51535. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51536. if !m.op.Is(OpUpdateOne) {
  51537. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51538. }
  51539. if m.id == nil || m.oldValue == nil {
  51540. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51541. }
  51542. oldValue, err := m.oldValue(ctx)
  51543. if err != nil {
  51544. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51545. }
  51546. return oldValue.UpdatedAt, nil
  51547. }
  51548. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51549. func (m *XunjiMutation) ResetUpdatedAt() {
  51550. m.updated_at = nil
  51551. }
  51552. // SetStatus sets the "status" field.
  51553. func (m *XunjiMutation) SetStatus(u uint8) {
  51554. m.status = &u
  51555. m.addstatus = nil
  51556. }
  51557. // Status returns the value of the "status" field in the mutation.
  51558. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  51559. v := m.status
  51560. if v == nil {
  51561. return
  51562. }
  51563. return *v, true
  51564. }
  51565. // OldStatus returns the old "status" field's value of the Xunji entity.
  51566. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51568. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51569. if !m.op.Is(OpUpdateOne) {
  51570. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51571. }
  51572. if m.id == nil || m.oldValue == nil {
  51573. return v, errors.New("OldStatus requires an ID field in the mutation")
  51574. }
  51575. oldValue, err := m.oldValue(ctx)
  51576. if err != nil {
  51577. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51578. }
  51579. return oldValue.Status, nil
  51580. }
  51581. // AddStatus adds u to the "status" field.
  51582. func (m *XunjiMutation) AddStatus(u int8) {
  51583. if m.addstatus != nil {
  51584. *m.addstatus += u
  51585. } else {
  51586. m.addstatus = &u
  51587. }
  51588. }
  51589. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51590. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  51591. v := m.addstatus
  51592. if v == nil {
  51593. return
  51594. }
  51595. return *v, true
  51596. }
  51597. // ClearStatus clears the value of the "status" field.
  51598. func (m *XunjiMutation) ClearStatus() {
  51599. m.status = nil
  51600. m.addstatus = nil
  51601. m.clearedFields[xunji.FieldStatus] = struct{}{}
  51602. }
  51603. // StatusCleared returns if the "status" field was cleared in this mutation.
  51604. func (m *XunjiMutation) StatusCleared() bool {
  51605. _, ok := m.clearedFields[xunji.FieldStatus]
  51606. return ok
  51607. }
  51608. // ResetStatus resets all changes to the "status" field.
  51609. func (m *XunjiMutation) ResetStatus() {
  51610. m.status = nil
  51611. m.addstatus = nil
  51612. delete(m.clearedFields, xunji.FieldStatus)
  51613. }
  51614. // SetDeletedAt sets the "deleted_at" field.
  51615. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  51616. m.deleted_at = &t
  51617. }
  51618. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51619. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  51620. v := m.deleted_at
  51621. if v == nil {
  51622. return
  51623. }
  51624. return *v, true
  51625. }
  51626. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  51627. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51629. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51630. if !m.op.Is(OpUpdateOne) {
  51631. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51632. }
  51633. if m.id == nil || m.oldValue == nil {
  51634. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51635. }
  51636. oldValue, err := m.oldValue(ctx)
  51637. if err != nil {
  51638. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51639. }
  51640. return oldValue.DeletedAt, nil
  51641. }
  51642. // ClearDeletedAt clears the value of the "deleted_at" field.
  51643. func (m *XunjiMutation) ClearDeletedAt() {
  51644. m.deleted_at = nil
  51645. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  51646. }
  51647. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51648. func (m *XunjiMutation) DeletedAtCleared() bool {
  51649. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  51650. return ok
  51651. }
  51652. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51653. func (m *XunjiMutation) ResetDeletedAt() {
  51654. m.deleted_at = nil
  51655. delete(m.clearedFields, xunji.FieldDeletedAt)
  51656. }
  51657. // SetAppKey sets the "app_key" field.
  51658. func (m *XunjiMutation) SetAppKey(s string) {
  51659. m.app_key = &s
  51660. }
  51661. // AppKey returns the value of the "app_key" field in the mutation.
  51662. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  51663. v := m.app_key
  51664. if v == nil {
  51665. return
  51666. }
  51667. return *v, true
  51668. }
  51669. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  51670. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51672. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  51673. if !m.op.Is(OpUpdateOne) {
  51674. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  51675. }
  51676. if m.id == nil || m.oldValue == nil {
  51677. return v, errors.New("OldAppKey requires an ID field in the mutation")
  51678. }
  51679. oldValue, err := m.oldValue(ctx)
  51680. if err != nil {
  51681. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  51682. }
  51683. return oldValue.AppKey, nil
  51684. }
  51685. // ClearAppKey clears the value of the "app_key" field.
  51686. func (m *XunjiMutation) ClearAppKey() {
  51687. m.app_key = nil
  51688. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  51689. }
  51690. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  51691. func (m *XunjiMutation) AppKeyCleared() bool {
  51692. _, ok := m.clearedFields[xunji.FieldAppKey]
  51693. return ok
  51694. }
  51695. // ResetAppKey resets all changes to the "app_key" field.
  51696. func (m *XunjiMutation) ResetAppKey() {
  51697. m.app_key = nil
  51698. delete(m.clearedFields, xunji.FieldAppKey)
  51699. }
  51700. // SetAppSecret sets the "app_secret" field.
  51701. func (m *XunjiMutation) SetAppSecret(s string) {
  51702. m.app_secret = &s
  51703. }
  51704. // AppSecret returns the value of the "app_secret" field in the mutation.
  51705. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  51706. v := m.app_secret
  51707. if v == nil {
  51708. return
  51709. }
  51710. return *v, true
  51711. }
  51712. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  51713. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51715. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  51716. if !m.op.Is(OpUpdateOne) {
  51717. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  51718. }
  51719. if m.id == nil || m.oldValue == nil {
  51720. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  51721. }
  51722. oldValue, err := m.oldValue(ctx)
  51723. if err != nil {
  51724. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  51725. }
  51726. return oldValue.AppSecret, nil
  51727. }
  51728. // ClearAppSecret clears the value of the "app_secret" field.
  51729. func (m *XunjiMutation) ClearAppSecret() {
  51730. m.app_secret = nil
  51731. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  51732. }
  51733. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  51734. func (m *XunjiMutation) AppSecretCleared() bool {
  51735. _, ok := m.clearedFields[xunji.FieldAppSecret]
  51736. return ok
  51737. }
  51738. // ResetAppSecret resets all changes to the "app_secret" field.
  51739. func (m *XunjiMutation) ResetAppSecret() {
  51740. m.app_secret = nil
  51741. delete(m.clearedFields, xunji.FieldAppSecret)
  51742. }
  51743. // SetToken sets the "token" field.
  51744. func (m *XunjiMutation) SetToken(s string) {
  51745. m.token = &s
  51746. }
  51747. // Token returns the value of the "token" field in the mutation.
  51748. func (m *XunjiMutation) Token() (r string, exists bool) {
  51749. v := m.token
  51750. if v == nil {
  51751. return
  51752. }
  51753. return *v, true
  51754. }
  51755. // OldToken returns the old "token" field's value of the Xunji entity.
  51756. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51758. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  51759. if !m.op.Is(OpUpdateOne) {
  51760. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  51761. }
  51762. if m.id == nil || m.oldValue == nil {
  51763. return v, errors.New("OldToken requires an ID field in the mutation")
  51764. }
  51765. oldValue, err := m.oldValue(ctx)
  51766. if err != nil {
  51767. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  51768. }
  51769. return oldValue.Token, nil
  51770. }
  51771. // ClearToken clears the value of the "token" field.
  51772. func (m *XunjiMutation) ClearToken() {
  51773. m.token = nil
  51774. m.clearedFields[xunji.FieldToken] = struct{}{}
  51775. }
  51776. // TokenCleared returns if the "token" field was cleared in this mutation.
  51777. func (m *XunjiMutation) TokenCleared() bool {
  51778. _, ok := m.clearedFields[xunji.FieldToken]
  51779. return ok
  51780. }
  51781. // ResetToken resets all changes to the "token" field.
  51782. func (m *XunjiMutation) ResetToken() {
  51783. m.token = nil
  51784. delete(m.clearedFields, xunji.FieldToken)
  51785. }
  51786. // SetEncodingKey sets the "encoding_key" field.
  51787. func (m *XunjiMutation) SetEncodingKey(s string) {
  51788. m.encoding_key = &s
  51789. }
  51790. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  51791. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  51792. v := m.encoding_key
  51793. if v == nil {
  51794. return
  51795. }
  51796. return *v, true
  51797. }
  51798. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  51799. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51801. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  51802. if !m.op.Is(OpUpdateOne) {
  51803. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  51804. }
  51805. if m.id == nil || m.oldValue == nil {
  51806. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  51807. }
  51808. oldValue, err := m.oldValue(ctx)
  51809. if err != nil {
  51810. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  51811. }
  51812. return oldValue.EncodingKey, nil
  51813. }
  51814. // ClearEncodingKey clears the value of the "encoding_key" field.
  51815. func (m *XunjiMutation) ClearEncodingKey() {
  51816. m.encoding_key = nil
  51817. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  51818. }
  51819. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  51820. func (m *XunjiMutation) EncodingKeyCleared() bool {
  51821. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  51822. return ok
  51823. }
  51824. // ResetEncodingKey resets all changes to the "encoding_key" field.
  51825. func (m *XunjiMutation) ResetEncodingKey() {
  51826. m.encoding_key = nil
  51827. delete(m.clearedFields, xunji.FieldEncodingKey)
  51828. }
  51829. // SetOrganizationID sets the "organization_id" field.
  51830. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  51831. m.organization_id = &u
  51832. m.addorganization_id = nil
  51833. }
  51834. // OrganizationID returns the value of the "organization_id" field in the mutation.
  51835. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  51836. v := m.organization_id
  51837. if v == nil {
  51838. return
  51839. }
  51840. return *v, true
  51841. }
  51842. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  51843. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51845. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  51846. if !m.op.Is(OpUpdateOne) {
  51847. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  51848. }
  51849. if m.id == nil || m.oldValue == nil {
  51850. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  51851. }
  51852. oldValue, err := m.oldValue(ctx)
  51853. if err != nil {
  51854. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  51855. }
  51856. return oldValue.OrganizationID, nil
  51857. }
  51858. // AddOrganizationID adds u to the "organization_id" field.
  51859. func (m *XunjiMutation) AddOrganizationID(u int64) {
  51860. if m.addorganization_id != nil {
  51861. *m.addorganization_id += u
  51862. } else {
  51863. m.addorganization_id = &u
  51864. }
  51865. }
  51866. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  51867. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  51868. v := m.addorganization_id
  51869. if v == nil {
  51870. return
  51871. }
  51872. return *v, true
  51873. }
  51874. // ResetOrganizationID resets all changes to the "organization_id" field.
  51875. func (m *XunjiMutation) ResetOrganizationID() {
  51876. m.organization_id = nil
  51877. m.addorganization_id = nil
  51878. }
  51879. // Where appends a list predicates to the XunjiMutation builder.
  51880. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  51881. m.predicates = append(m.predicates, ps...)
  51882. }
  51883. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  51884. // users can use type-assertion to append predicates that do not depend on any generated package.
  51885. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  51886. p := make([]predicate.Xunji, len(ps))
  51887. for i := range ps {
  51888. p[i] = ps[i]
  51889. }
  51890. m.Where(p...)
  51891. }
  51892. // Op returns the operation name.
  51893. func (m *XunjiMutation) Op() Op {
  51894. return m.op
  51895. }
  51896. // SetOp allows setting the mutation operation.
  51897. func (m *XunjiMutation) SetOp(op Op) {
  51898. m.op = op
  51899. }
  51900. // Type returns the node type of this mutation (Xunji).
  51901. func (m *XunjiMutation) Type() string {
  51902. return m.typ
  51903. }
  51904. // Fields returns all fields that were changed during this mutation. Note that in
  51905. // order to get all numeric fields that were incremented/decremented, call
  51906. // AddedFields().
  51907. func (m *XunjiMutation) Fields() []string {
  51908. fields := make([]string, 0, 9)
  51909. if m.created_at != nil {
  51910. fields = append(fields, xunji.FieldCreatedAt)
  51911. }
  51912. if m.updated_at != nil {
  51913. fields = append(fields, xunji.FieldUpdatedAt)
  51914. }
  51915. if m.status != nil {
  51916. fields = append(fields, xunji.FieldStatus)
  51917. }
  51918. if m.deleted_at != nil {
  51919. fields = append(fields, xunji.FieldDeletedAt)
  51920. }
  51921. if m.app_key != nil {
  51922. fields = append(fields, xunji.FieldAppKey)
  51923. }
  51924. if m.app_secret != nil {
  51925. fields = append(fields, xunji.FieldAppSecret)
  51926. }
  51927. if m.token != nil {
  51928. fields = append(fields, xunji.FieldToken)
  51929. }
  51930. if m.encoding_key != nil {
  51931. fields = append(fields, xunji.FieldEncodingKey)
  51932. }
  51933. if m.organization_id != nil {
  51934. fields = append(fields, xunji.FieldOrganizationID)
  51935. }
  51936. return fields
  51937. }
  51938. // Field returns the value of a field with the given name. The second boolean
  51939. // return value indicates that this field was not set, or was not defined in the
  51940. // schema.
  51941. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  51942. switch name {
  51943. case xunji.FieldCreatedAt:
  51944. return m.CreatedAt()
  51945. case xunji.FieldUpdatedAt:
  51946. return m.UpdatedAt()
  51947. case xunji.FieldStatus:
  51948. return m.Status()
  51949. case xunji.FieldDeletedAt:
  51950. return m.DeletedAt()
  51951. case xunji.FieldAppKey:
  51952. return m.AppKey()
  51953. case xunji.FieldAppSecret:
  51954. return m.AppSecret()
  51955. case xunji.FieldToken:
  51956. return m.Token()
  51957. case xunji.FieldEncodingKey:
  51958. return m.EncodingKey()
  51959. case xunji.FieldOrganizationID:
  51960. return m.OrganizationID()
  51961. }
  51962. return nil, false
  51963. }
  51964. // OldField returns the old value of the field from the database. An error is
  51965. // returned if the mutation operation is not UpdateOne, or the query to the
  51966. // database failed.
  51967. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51968. switch name {
  51969. case xunji.FieldCreatedAt:
  51970. return m.OldCreatedAt(ctx)
  51971. case xunji.FieldUpdatedAt:
  51972. return m.OldUpdatedAt(ctx)
  51973. case xunji.FieldStatus:
  51974. return m.OldStatus(ctx)
  51975. case xunji.FieldDeletedAt:
  51976. return m.OldDeletedAt(ctx)
  51977. case xunji.FieldAppKey:
  51978. return m.OldAppKey(ctx)
  51979. case xunji.FieldAppSecret:
  51980. return m.OldAppSecret(ctx)
  51981. case xunji.FieldToken:
  51982. return m.OldToken(ctx)
  51983. case xunji.FieldEncodingKey:
  51984. return m.OldEncodingKey(ctx)
  51985. case xunji.FieldOrganizationID:
  51986. return m.OldOrganizationID(ctx)
  51987. }
  51988. return nil, fmt.Errorf("unknown Xunji field %s", name)
  51989. }
  51990. // SetField sets the value of a field with the given name. It returns an error if
  51991. // the field is not defined in the schema, or if the type mismatched the field
  51992. // type.
  51993. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  51994. switch name {
  51995. case xunji.FieldCreatedAt:
  51996. v, ok := value.(time.Time)
  51997. if !ok {
  51998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51999. }
  52000. m.SetCreatedAt(v)
  52001. return nil
  52002. case xunji.FieldUpdatedAt:
  52003. v, ok := value.(time.Time)
  52004. if !ok {
  52005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52006. }
  52007. m.SetUpdatedAt(v)
  52008. return nil
  52009. case xunji.FieldStatus:
  52010. v, ok := value.(uint8)
  52011. if !ok {
  52012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52013. }
  52014. m.SetStatus(v)
  52015. return nil
  52016. case xunji.FieldDeletedAt:
  52017. v, ok := value.(time.Time)
  52018. if !ok {
  52019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52020. }
  52021. m.SetDeletedAt(v)
  52022. return nil
  52023. case xunji.FieldAppKey:
  52024. v, ok := value.(string)
  52025. if !ok {
  52026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52027. }
  52028. m.SetAppKey(v)
  52029. return nil
  52030. case xunji.FieldAppSecret:
  52031. v, ok := value.(string)
  52032. if !ok {
  52033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52034. }
  52035. m.SetAppSecret(v)
  52036. return nil
  52037. case xunji.FieldToken:
  52038. v, ok := value.(string)
  52039. if !ok {
  52040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52041. }
  52042. m.SetToken(v)
  52043. return nil
  52044. case xunji.FieldEncodingKey:
  52045. v, ok := value.(string)
  52046. if !ok {
  52047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52048. }
  52049. m.SetEncodingKey(v)
  52050. return nil
  52051. case xunji.FieldOrganizationID:
  52052. v, ok := value.(uint64)
  52053. if !ok {
  52054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52055. }
  52056. m.SetOrganizationID(v)
  52057. return nil
  52058. }
  52059. return fmt.Errorf("unknown Xunji field %s", name)
  52060. }
  52061. // AddedFields returns all numeric fields that were incremented/decremented during
  52062. // this mutation.
  52063. func (m *XunjiMutation) AddedFields() []string {
  52064. var fields []string
  52065. if m.addstatus != nil {
  52066. fields = append(fields, xunji.FieldStatus)
  52067. }
  52068. if m.addorganization_id != nil {
  52069. fields = append(fields, xunji.FieldOrganizationID)
  52070. }
  52071. return fields
  52072. }
  52073. // AddedField returns the numeric value that was incremented/decremented on a field
  52074. // with the given name. The second boolean return value indicates that this field
  52075. // was not set, or was not defined in the schema.
  52076. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  52077. switch name {
  52078. case xunji.FieldStatus:
  52079. return m.AddedStatus()
  52080. case xunji.FieldOrganizationID:
  52081. return m.AddedOrganizationID()
  52082. }
  52083. return nil, false
  52084. }
  52085. // AddField adds the value to the field with the given name. It returns an error if
  52086. // the field is not defined in the schema, or if the type mismatched the field
  52087. // type.
  52088. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  52089. switch name {
  52090. case xunji.FieldStatus:
  52091. v, ok := value.(int8)
  52092. if !ok {
  52093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52094. }
  52095. m.AddStatus(v)
  52096. return nil
  52097. case xunji.FieldOrganizationID:
  52098. v, ok := value.(int64)
  52099. if !ok {
  52100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52101. }
  52102. m.AddOrganizationID(v)
  52103. return nil
  52104. }
  52105. return fmt.Errorf("unknown Xunji numeric field %s", name)
  52106. }
  52107. // ClearedFields returns all nullable fields that were cleared during this
  52108. // mutation.
  52109. func (m *XunjiMutation) ClearedFields() []string {
  52110. var fields []string
  52111. if m.FieldCleared(xunji.FieldStatus) {
  52112. fields = append(fields, xunji.FieldStatus)
  52113. }
  52114. if m.FieldCleared(xunji.FieldDeletedAt) {
  52115. fields = append(fields, xunji.FieldDeletedAt)
  52116. }
  52117. if m.FieldCleared(xunji.FieldAppKey) {
  52118. fields = append(fields, xunji.FieldAppKey)
  52119. }
  52120. if m.FieldCleared(xunji.FieldAppSecret) {
  52121. fields = append(fields, xunji.FieldAppSecret)
  52122. }
  52123. if m.FieldCleared(xunji.FieldToken) {
  52124. fields = append(fields, xunji.FieldToken)
  52125. }
  52126. if m.FieldCleared(xunji.FieldEncodingKey) {
  52127. fields = append(fields, xunji.FieldEncodingKey)
  52128. }
  52129. return fields
  52130. }
  52131. // FieldCleared returns a boolean indicating if a field with the given name was
  52132. // cleared in this mutation.
  52133. func (m *XunjiMutation) FieldCleared(name string) bool {
  52134. _, ok := m.clearedFields[name]
  52135. return ok
  52136. }
  52137. // ClearField clears the value of the field with the given name. It returns an
  52138. // error if the field is not defined in the schema.
  52139. func (m *XunjiMutation) ClearField(name string) error {
  52140. switch name {
  52141. case xunji.FieldStatus:
  52142. m.ClearStatus()
  52143. return nil
  52144. case xunji.FieldDeletedAt:
  52145. m.ClearDeletedAt()
  52146. return nil
  52147. case xunji.FieldAppKey:
  52148. m.ClearAppKey()
  52149. return nil
  52150. case xunji.FieldAppSecret:
  52151. m.ClearAppSecret()
  52152. return nil
  52153. case xunji.FieldToken:
  52154. m.ClearToken()
  52155. return nil
  52156. case xunji.FieldEncodingKey:
  52157. m.ClearEncodingKey()
  52158. return nil
  52159. }
  52160. return fmt.Errorf("unknown Xunji nullable field %s", name)
  52161. }
  52162. // ResetField resets all changes in the mutation for the field with the given name.
  52163. // It returns an error if the field is not defined in the schema.
  52164. func (m *XunjiMutation) ResetField(name string) error {
  52165. switch name {
  52166. case xunji.FieldCreatedAt:
  52167. m.ResetCreatedAt()
  52168. return nil
  52169. case xunji.FieldUpdatedAt:
  52170. m.ResetUpdatedAt()
  52171. return nil
  52172. case xunji.FieldStatus:
  52173. m.ResetStatus()
  52174. return nil
  52175. case xunji.FieldDeletedAt:
  52176. m.ResetDeletedAt()
  52177. return nil
  52178. case xunji.FieldAppKey:
  52179. m.ResetAppKey()
  52180. return nil
  52181. case xunji.FieldAppSecret:
  52182. m.ResetAppSecret()
  52183. return nil
  52184. case xunji.FieldToken:
  52185. m.ResetToken()
  52186. return nil
  52187. case xunji.FieldEncodingKey:
  52188. m.ResetEncodingKey()
  52189. return nil
  52190. case xunji.FieldOrganizationID:
  52191. m.ResetOrganizationID()
  52192. return nil
  52193. }
  52194. return fmt.Errorf("unknown Xunji field %s", name)
  52195. }
  52196. // AddedEdges returns all edge names that were set/added in this mutation.
  52197. func (m *XunjiMutation) AddedEdges() []string {
  52198. edges := make([]string, 0, 0)
  52199. return edges
  52200. }
  52201. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52202. // name in this mutation.
  52203. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  52204. return nil
  52205. }
  52206. // RemovedEdges returns all edge names that were removed in this mutation.
  52207. func (m *XunjiMutation) RemovedEdges() []string {
  52208. edges := make([]string, 0, 0)
  52209. return edges
  52210. }
  52211. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52212. // the given name in this mutation.
  52213. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  52214. return nil
  52215. }
  52216. // ClearedEdges returns all edge names that were cleared in this mutation.
  52217. func (m *XunjiMutation) ClearedEdges() []string {
  52218. edges := make([]string, 0, 0)
  52219. return edges
  52220. }
  52221. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52222. // was cleared in this mutation.
  52223. func (m *XunjiMutation) EdgeCleared(name string) bool {
  52224. return false
  52225. }
  52226. // ClearEdge clears the value of the edge with the given name. It returns an error
  52227. // if that edge is not defined in the schema.
  52228. func (m *XunjiMutation) ClearEdge(name string) error {
  52229. return fmt.Errorf("unknown Xunji unique edge %s", name)
  52230. }
  52231. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52232. // It returns an error if the edge is not defined in the schema.
  52233. func (m *XunjiMutation) ResetEdge(name string) error {
  52234. return fmt.Errorf("unknown Xunji edge %s", name)
  52235. }
  52236. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  52237. type XunjiServiceMutation struct {
  52238. config
  52239. op Op
  52240. typ string
  52241. id *uint64
  52242. created_at *time.Time
  52243. updated_at *time.Time
  52244. status *uint8
  52245. addstatus *int8
  52246. deleted_at *time.Time
  52247. xunji_id *uint64
  52248. addxunji_id *int64
  52249. organization_id *uint64
  52250. addorganization_id *int64
  52251. wxid *string
  52252. api_base *string
  52253. api_key *string
  52254. clearedFields map[string]struct{}
  52255. agent *uint64
  52256. clearedagent bool
  52257. done bool
  52258. oldValue func(context.Context) (*XunjiService, error)
  52259. predicates []predicate.XunjiService
  52260. }
  52261. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  52262. // xunjiserviceOption allows management of the mutation configuration using functional options.
  52263. type xunjiserviceOption func(*XunjiServiceMutation)
  52264. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  52265. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  52266. m := &XunjiServiceMutation{
  52267. config: c,
  52268. op: op,
  52269. typ: TypeXunjiService,
  52270. clearedFields: make(map[string]struct{}),
  52271. }
  52272. for _, opt := range opts {
  52273. opt(m)
  52274. }
  52275. return m
  52276. }
  52277. // withXunjiServiceID sets the ID field of the mutation.
  52278. func withXunjiServiceID(id uint64) xunjiserviceOption {
  52279. return func(m *XunjiServiceMutation) {
  52280. var (
  52281. err error
  52282. once sync.Once
  52283. value *XunjiService
  52284. )
  52285. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  52286. once.Do(func() {
  52287. if m.done {
  52288. err = errors.New("querying old values post mutation is not allowed")
  52289. } else {
  52290. value, err = m.Client().XunjiService.Get(ctx, id)
  52291. }
  52292. })
  52293. return value, err
  52294. }
  52295. m.id = &id
  52296. }
  52297. }
  52298. // withXunjiService sets the old XunjiService of the mutation.
  52299. func withXunjiService(node *XunjiService) xunjiserviceOption {
  52300. return func(m *XunjiServiceMutation) {
  52301. m.oldValue = func(context.Context) (*XunjiService, error) {
  52302. return node, nil
  52303. }
  52304. m.id = &node.ID
  52305. }
  52306. }
  52307. // Client returns a new `ent.Client` from the mutation. If the mutation was
  52308. // executed in a transaction (ent.Tx), a transactional client is returned.
  52309. func (m XunjiServiceMutation) Client() *Client {
  52310. client := &Client{config: m.config}
  52311. client.init()
  52312. return client
  52313. }
  52314. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  52315. // it returns an error otherwise.
  52316. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  52317. if _, ok := m.driver.(*txDriver); !ok {
  52318. return nil, errors.New("ent: mutation is not running in a transaction")
  52319. }
  52320. tx := &Tx{config: m.config}
  52321. tx.init()
  52322. return tx, nil
  52323. }
  52324. // SetID sets the value of the id field. Note that this
  52325. // operation is only accepted on creation of XunjiService entities.
  52326. func (m *XunjiServiceMutation) SetID(id uint64) {
  52327. m.id = &id
  52328. }
  52329. // ID returns the ID value in the mutation. Note that the ID is only available
  52330. // if it was provided to the builder or after it was returned from the database.
  52331. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  52332. if m.id == nil {
  52333. return
  52334. }
  52335. return *m.id, true
  52336. }
  52337. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  52338. // That means, if the mutation is applied within a transaction with an isolation level such
  52339. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  52340. // or updated by the mutation.
  52341. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  52342. switch {
  52343. case m.op.Is(OpUpdateOne | OpDeleteOne):
  52344. id, exists := m.ID()
  52345. if exists {
  52346. return []uint64{id}, nil
  52347. }
  52348. fallthrough
  52349. case m.op.Is(OpUpdate | OpDelete):
  52350. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  52351. default:
  52352. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  52353. }
  52354. }
  52355. // SetCreatedAt sets the "created_at" field.
  52356. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  52357. m.created_at = &t
  52358. }
  52359. // CreatedAt returns the value of the "created_at" field in the mutation.
  52360. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  52361. v := m.created_at
  52362. if v == nil {
  52363. return
  52364. }
  52365. return *v, true
  52366. }
  52367. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  52368. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52370. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  52371. if !m.op.Is(OpUpdateOne) {
  52372. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  52373. }
  52374. if m.id == nil || m.oldValue == nil {
  52375. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  52376. }
  52377. oldValue, err := m.oldValue(ctx)
  52378. if err != nil {
  52379. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  52380. }
  52381. return oldValue.CreatedAt, nil
  52382. }
  52383. // ResetCreatedAt resets all changes to the "created_at" field.
  52384. func (m *XunjiServiceMutation) ResetCreatedAt() {
  52385. m.created_at = nil
  52386. }
  52387. // SetUpdatedAt sets the "updated_at" field.
  52388. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  52389. m.updated_at = &t
  52390. }
  52391. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  52392. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  52393. v := m.updated_at
  52394. if v == nil {
  52395. return
  52396. }
  52397. return *v, true
  52398. }
  52399. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  52400. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52402. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  52403. if !m.op.Is(OpUpdateOne) {
  52404. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  52405. }
  52406. if m.id == nil || m.oldValue == nil {
  52407. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  52408. }
  52409. oldValue, err := m.oldValue(ctx)
  52410. if err != nil {
  52411. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  52412. }
  52413. return oldValue.UpdatedAt, nil
  52414. }
  52415. // ResetUpdatedAt resets all changes to the "updated_at" field.
  52416. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  52417. m.updated_at = nil
  52418. }
  52419. // SetStatus sets the "status" field.
  52420. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  52421. m.status = &u
  52422. m.addstatus = nil
  52423. }
  52424. // Status returns the value of the "status" field in the mutation.
  52425. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  52426. v := m.status
  52427. if v == nil {
  52428. return
  52429. }
  52430. return *v, true
  52431. }
  52432. // OldStatus returns the old "status" field's value of the XunjiService entity.
  52433. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52435. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  52436. if !m.op.Is(OpUpdateOne) {
  52437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  52438. }
  52439. if m.id == nil || m.oldValue == nil {
  52440. return v, errors.New("OldStatus requires an ID field in the mutation")
  52441. }
  52442. oldValue, err := m.oldValue(ctx)
  52443. if err != nil {
  52444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  52445. }
  52446. return oldValue.Status, nil
  52447. }
  52448. // AddStatus adds u to the "status" field.
  52449. func (m *XunjiServiceMutation) AddStatus(u int8) {
  52450. if m.addstatus != nil {
  52451. *m.addstatus += u
  52452. } else {
  52453. m.addstatus = &u
  52454. }
  52455. }
  52456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  52457. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  52458. v := m.addstatus
  52459. if v == nil {
  52460. return
  52461. }
  52462. return *v, true
  52463. }
  52464. // ClearStatus clears the value of the "status" field.
  52465. func (m *XunjiServiceMutation) ClearStatus() {
  52466. m.status = nil
  52467. m.addstatus = nil
  52468. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  52469. }
  52470. // StatusCleared returns if the "status" field was cleared in this mutation.
  52471. func (m *XunjiServiceMutation) StatusCleared() bool {
  52472. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  52473. return ok
  52474. }
  52475. // ResetStatus resets all changes to the "status" field.
  52476. func (m *XunjiServiceMutation) ResetStatus() {
  52477. m.status = nil
  52478. m.addstatus = nil
  52479. delete(m.clearedFields, xunjiservice.FieldStatus)
  52480. }
  52481. // SetDeletedAt sets the "deleted_at" field.
  52482. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  52483. m.deleted_at = &t
  52484. }
  52485. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  52486. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  52487. v := m.deleted_at
  52488. if v == nil {
  52489. return
  52490. }
  52491. return *v, true
  52492. }
  52493. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  52494. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52496. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  52497. if !m.op.Is(OpUpdateOne) {
  52498. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  52499. }
  52500. if m.id == nil || m.oldValue == nil {
  52501. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  52502. }
  52503. oldValue, err := m.oldValue(ctx)
  52504. if err != nil {
  52505. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  52506. }
  52507. return oldValue.DeletedAt, nil
  52508. }
  52509. // ClearDeletedAt clears the value of the "deleted_at" field.
  52510. func (m *XunjiServiceMutation) ClearDeletedAt() {
  52511. m.deleted_at = nil
  52512. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  52513. }
  52514. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  52515. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  52516. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  52517. return ok
  52518. }
  52519. // ResetDeletedAt resets all changes to the "deleted_at" field.
  52520. func (m *XunjiServiceMutation) ResetDeletedAt() {
  52521. m.deleted_at = nil
  52522. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  52523. }
  52524. // SetXunjiID sets the "xunji_id" field.
  52525. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  52526. m.xunji_id = &u
  52527. m.addxunji_id = nil
  52528. }
  52529. // XunjiID returns the value of the "xunji_id" field in the mutation.
  52530. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  52531. v := m.xunji_id
  52532. if v == nil {
  52533. return
  52534. }
  52535. return *v, true
  52536. }
  52537. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  52538. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52540. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  52541. if !m.op.Is(OpUpdateOne) {
  52542. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  52543. }
  52544. if m.id == nil || m.oldValue == nil {
  52545. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  52546. }
  52547. oldValue, err := m.oldValue(ctx)
  52548. if err != nil {
  52549. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  52550. }
  52551. return oldValue.XunjiID, nil
  52552. }
  52553. // AddXunjiID adds u to the "xunji_id" field.
  52554. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  52555. if m.addxunji_id != nil {
  52556. *m.addxunji_id += u
  52557. } else {
  52558. m.addxunji_id = &u
  52559. }
  52560. }
  52561. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  52562. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  52563. v := m.addxunji_id
  52564. if v == nil {
  52565. return
  52566. }
  52567. return *v, true
  52568. }
  52569. // ResetXunjiID resets all changes to the "xunji_id" field.
  52570. func (m *XunjiServiceMutation) ResetXunjiID() {
  52571. m.xunji_id = nil
  52572. m.addxunji_id = nil
  52573. }
  52574. // SetAgentID sets the "agent_id" field.
  52575. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  52576. m.agent = &u
  52577. }
  52578. // AgentID returns the value of the "agent_id" field in the mutation.
  52579. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  52580. v := m.agent
  52581. if v == nil {
  52582. return
  52583. }
  52584. return *v, true
  52585. }
  52586. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  52587. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52589. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  52590. if !m.op.Is(OpUpdateOne) {
  52591. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  52592. }
  52593. if m.id == nil || m.oldValue == nil {
  52594. return v, errors.New("OldAgentID requires an ID field in the mutation")
  52595. }
  52596. oldValue, err := m.oldValue(ctx)
  52597. if err != nil {
  52598. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  52599. }
  52600. return oldValue.AgentID, nil
  52601. }
  52602. // ResetAgentID resets all changes to the "agent_id" field.
  52603. func (m *XunjiServiceMutation) ResetAgentID() {
  52604. m.agent = nil
  52605. }
  52606. // SetOrganizationID sets the "organization_id" field.
  52607. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  52608. m.organization_id = &u
  52609. m.addorganization_id = nil
  52610. }
  52611. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52612. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  52613. v := m.organization_id
  52614. if v == nil {
  52615. return
  52616. }
  52617. return *v, true
  52618. }
  52619. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  52620. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52622. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52623. if !m.op.Is(OpUpdateOne) {
  52624. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52625. }
  52626. if m.id == nil || m.oldValue == nil {
  52627. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52628. }
  52629. oldValue, err := m.oldValue(ctx)
  52630. if err != nil {
  52631. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52632. }
  52633. return oldValue.OrganizationID, nil
  52634. }
  52635. // AddOrganizationID adds u to the "organization_id" field.
  52636. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  52637. if m.addorganization_id != nil {
  52638. *m.addorganization_id += u
  52639. } else {
  52640. m.addorganization_id = &u
  52641. }
  52642. }
  52643. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52644. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  52645. v := m.addorganization_id
  52646. if v == nil {
  52647. return
  52648. }
  52649. return *v, true
  52650. }
  52651. // ResetOrganizationID resets all changes to the "organization_id" field.
  52652. func (m *XunjiServiceMutation) ResetOrganizationID() {
  52653. m.organization_id = nil
  52654. m.addorganization_id = nil
  52655. }
  52656. // SetWxid sets the "wxid" field.
  52657. func (m *XunjiServiceMutation) SetWxid(s string) {
  52658. m.wxid = &s
  52659. }
  52660. // Wxid returns the value of the "wxid" field in the mutation.
  52661. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  52662. v := m.wxid
  52663. if v == nil {
  52664. return
  52665. }
  52666. return *v, true
  52667. }
  52668. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  52669. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52671. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  52672. if !m.op.Is(OpUpdateOne) {
  52673. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  52674. }
  52675. if m.id == nil || m.oldValue == nil {
  52676. return v, errors.New("OldWxid requires an ID field in the mutation")
  52677. }
  52678. oldValue, err := m.oldValue(ctx)
  52679. if err != nil {
  52680. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  52681. }
  52682. return oldValue.Wxid, nil
  52683. }
  52684. // ResetWxid resets all changes to the "wxid" field.
  52685. func (m *XunjiServiceMutation) ResetWxid() {
  52686. m.wxid = nil
  52687. }
  52688. // SetAPIBase sets the "api_base" field.
  52689. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  52690. m.api_base = &s
  52691. }
  52692. // APIBase returns the value of the "api_base" field in the mutation.
  52693. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  52694. v := m.api_base
  52695. if v == nil {
  52696. return
  52697. }
  52698. return *v, true
  52699. }
  52700. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  52701. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52703. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  52704. if !m.op.Is(OpUpdateOne) {
  52705. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  52706. }
  52707. if m.id == nil || m.oldValue == nil {
  52708. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  52709. }
  52710. oldValue, err := m.oldValue(ctx)
  52711. if err != nil {
  52712. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  52713. }
  52714. return oldValue.APIBase, nil
  52715. }
  52716. // ClearAPIBase clears the value of the "api_base" field.
  52717. func (m *XunjiServiceMutation) ClearAPIBase() {
  52718. m.api_base = nil
  52719. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  52720. }
  52721. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  52722. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  52723. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  52724. return ok
  52725. }
  52726. // ResetAPIBase resets all changes to the "api_base" field.
  52727. func (m *XunjiServiceMutation) ResetAPIBase() {
  52728. m.api_base = nil
  52729. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  52730. }
  52731. // SetAPIKey sets the "api_key" field.
  52732. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  52733. m.api_key = &s
  52734. }
  52735. // APIKey returns the value of the "api_key" field in the mutation.
  52736. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  52737. v := m.api_key
  52738. if v == nil {
  52739. return
  52740. }
  52741. return *v, true
  52742. }
  52743. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  52744. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52746. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  52747. if !m.op.Is(OpUpdateOne) {
  52748. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  52749. }
  52750. if m.id == nil || m.oldValue == nil {
  52751. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  52752. }
  52753. oldValue, err := m.oldValue(ctx)
  52754. if err != nil {
  52755. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  52756. }
  52757. return oldValue.APIKey, nil
  52758. }
  52759. // ClearAPIKey clears the value of the "api_key" field.
  52760. func (m *XunjiServiceMutation) ClearAPIKey() {
  52761. m.api_key = nil
  52762. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  52763. }
  52764. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  52765. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  52766. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  52767. return ok
  52768. }
  52769. // ResetAPIKey resets all changes to the "api_key" field.
  52770. func (m *XunjiServiceMutation) ResetAPIKey() {
  52771. m.api_key = nil
  52772. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  52773. }
  52774. // ClearAgent clears the "agent" edge to the Agent entity.
  52775. func (m *XunjiServiceMutation) ClearAgent() {
  52776. m.clearedagent = true
  52777. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  52778. }
  52779. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  52780. func (m *XunjiServiceMutation) AgentCleared() bool {
  52781. return m.clearedagent
  52782. }
  52783. // AgentIDs returns the "agent" edge IDs in the mutation.
  52784. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  52785. // AgentID instead. It exists only for internal usage by the builders.
  52786. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  52787. if id := m.agent; id != nil {
  52788. ids = append(ids, *id)
  52789. }
  52790. return
  52791. }
  52792. // ResetAgent resets all changes to the "agent" edge.
  52793. func (m *XunjiServiceMutation) ResetAgent() {
  52794. m.agent = nil
  52795. m.clearedagent = false
  52796. }
  52797. // Where appends a list predicates to the XunjiServiceMutation builder.
  52798. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  52799. m.predicates = append(m.predicates, ps...)
  52800. }
  52801. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  52802. // users can use type-assertion to append predicates that do not depend on any generated package.
  52803. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  52804. p := make([]predicate.XunjiService, len(ps))
  52805. for i := range ps {
  52806. p[i] = ps[i]
  52807. }
  52808. m.Where(p...)
  52809. }
  52810. // Op returns the operation name.
  52811. func (m *XunjiServiceMutation) Op() Op {
  52812. return m.op
  52813. }
  52814. // SetOp allows setting the mutation operation.
  52815. func (m *XunjiServiceMutation) SetOp(op Op) {
  52816. m.op = op
  52817. }
  52818. // Type returns the node type of this mutation (XunjiService).
  52819. func (m *XunjiServiceMutation) Type() string {
  52820. return m.typ
  52821. }
  52822. // Fields returns all fields that were changed during this mutation. Note that in
  52823. // order to get all numeric fields that were incremented/decremented, call
  52824. // AddedFields().
  52825. func (m *XunjiServiceMutation) Fields() []string {
  52826. fields := make([]string, 0, 10)
  52827. if m.created_at != nil {
  52828. fields = append(fields, xunjiservice.FieldCreatedAt)
  52829. }
  52830. if m.updated_at != nil {
  52831. fields = append(fields, xunjiservice.FieldUpdatedAt)
  52832. }
  52833. if m.status != nil {
  52834. fields = append(fields, xunjiservice.FieldStatus)
  52835. }
  52836. if m.deleted_at != nil {
  52837. fields = append(fields, xunjiservice.FieldDeletedAt)
  52838. }
  52839. if m.xunji_id != nil {
  52840. fields = append(fields, xunjiservice.FieldXunjiID)
  52841. }
  52842. if m.agent != nil {
  52843. fields = append(fields, xunjiservice.FieldAgentID)
  52844. }
  52845. if m.organization_id != nil {
  52846. fields = append(fields, xunjiservice.FieldOrganizationID)
  52847. }
  52848. if m.wxid != nil {
  52849. fields = append(fields, xunjiservice.FieldWxid)
  52850. }
  52851. if m.api_base != nil {
  52852. fields = append(fields, xunjiservice.FieldAPIBase)
  52853. }
  52854. if m.api_key != nil {
  52855. fields = append(fields, xunjiservice.FieldAPIKey)
  52856. }
  52857. return fields
  52858. }
  52859. // Field returns the value of a field with the given name. The second boolean
  52860. // return value indicates that this field was not set, or was not defined in the
  52861. // schema.
  52862. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  52863. switch name {
  52864. case xunjiservice.FieldCreatedAt:
  52865. return m.CreatedAt()
  52866. case xunjiservice.FieldUpdatedAt:
  52867. return m.UpdatedAt()
  52868. case xunjiservice.FieldStatus:
  52869. return m.Status()
  52870. case xunjiservice.FieldDeletedAt:
  52871. return m.DeletedAt()
  52872. case xunjiservice.FieldXunjiID:
  52873. return m.XunjiID()
  52874. case xunjiservice.FieldAgentID:
  52875. return m.AgentID()
  52876. case xunjiservice.FieldOrganizationID:
  52877. return m.OrganizationID()
  52878. case xunjiservice.FieldWxid:
  52879. return m.Wxid()
  52880. case xunjiservice.FieldAPIBase:
  52881. return m.APIBase()
  52882. case xunjiservice.FieldAPIKey:
  52883. return m.APIKey()
  52884. }
  52885. return nil, false
  52886. }
  52887. // OldField returns the old value of the field from the database. An error is
  52888. // returned if the mutation operation is not UpdateOne, or the query to the
  52889. // database failed.
  52890. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52891. switch name {
  52892. case xunjiservice.FieldCreatedAt:
  52893. return m.OldCreatedAt(ctx)
  52894. case xunjiservice.FieldUpdatedAt:
  52895. return m.OldUpdatedAt(ctx)
  52896. case xunjiservice.FieldStatus:
  52897. return m.OldStatus(ctx)
  52898. case xunjiservice.FieldDeletedAt:
  52899. return m.OldDeletedAt(ctx)
  52900. case xunjiservice.FieldXunjiID:
  52901. return m.OldXunjiID(ctx)
  52902. case xunjiservice.FieldAgentID:
  52903. return m.OldAgentID(ctx)
  52904. case xunjiservice.FieldOrganizationID:
  52905. return m.OldOrganizationID(ctx)
  52906. case xunjiservice.FieldWxid:
  52907. return m.OldWxid(ctx)
  52908. case xunjiservice.FieldAPIBase:
  52909. return m.OldAPIBase(ctx)
  52910. case xunjiservice.FieldAPIKey:
  52911. return m.OldAPIKey(ctx)
  52912. }
  52913. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  52914. }
  52915. // SetField sets the value of a field with the given name. It returns an error if
  52916. // the field is not defined in the schema, or if the type mismatched the field
  52917. // type.
  52918. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  52919. switch name {
  52920. case xunjiservice.FieldCreatedAt:
  52921. v, ok := value.(time.Time)
  52922. if !ok {
  52923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52924. }
  52925. m.SetCreatedAt(v)
  52926. return nil
  52927. case xunjiservice.FieldUpdatedAt:
  52928. v, ok := value.(time.Time)
  52929. if !ok {
  52930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52931. }
  52932. m.SetUpdatedAt(v)
  52933. return nil
  52934. case xunjiservice.FieldStatus:
  52935. v, ok := value.(uint8)
  52936. if !ok {
  52937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52938. }
  52939. m.SetStatus(v)
  52940. return nil
  52941. case xunjiservice.FieldDeletedAt:
  52942. v, ok := value.(time.Time)
  52943. if !ok {
  52944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52945. }
  52946. m.SetDeletedAt(v)
  52947. return nil
  52948. case xunjiservice.FieldXunjiID:
  52949. v, ok := value.(uint64)
  52950. if !ok {
  52951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52952. }
  52953. m.SetXunjiID(v)
  52954. return nil
  52955. case xunjiservice.FieldAgentID:
  52956. v, ok := value.(uint64)
  52957. if !ok {
  52958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52959. }
  52960. m.SetAgentID(v)
  52961. return nil
  52962. case xunjiservice.FieldOrganizationID:
  52963. v, ok := value.(uint64)
  52964. if !ok {
  52965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52966. }
  52967. m.SetOrganizationID(v)
  52968. return nil
  52969. case xunjiservice.FieldWxid:
  52970. v, ok := value.(string)
  52971. if !ok {
  52972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52973. }
  52974. m.SetWxid(v)
  52975. return nil
  52976. case xunjiservice.FieldAPIBase:
  52977. v, ok := value.(string)
  52978. if !ok {
  52979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52980. }
  52981. m.SetAPIBase(v)
  52982. return nil
  52983. case xunjiservice.FieldAPIKey:
  52984. v, ok := value.(string)
  52985. if !ok {
  52986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52987. }
  52988. m.SetAPIKey(v)
  52989. return nil
  52990. }
  52991. return fmt.Errorf("unknown XunjiService field %s", name)
  52992. }
  52993. // AddedFields returns all numeric fields that were incremented/decremented during
  52994. // this mutation.
  52995. func (m *XunjiServiceMutation) AddedFields() []string {
  52996. var fields []string
  52997. if m.addstatus != nil {
  52998. fields = append(fields, xunjiservice.FieldStatus)
  52999. }
  53000. if m.addxunji_id != nil {
  53001. fields = append(fields, xunjiservice.FieldXunjiID)
  53002. }
  53003. if m.addorganization_id != nil {
  53004. fields = append(fields, xunjiservice.FieldOrganizationID)
  53005. }
  53006. return fields
  53007. }
  53008. // AddedField returns the numeric value that was incremented/decremented on a field
  53009. // with the given name. The second boolean return value indicates that this field
  53010. // was not set, or was not defined in the schema.
  53011. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  53012. switch name {
  53013. case xunjiservice.FieldStatus:
  53014. return m.AddedStatus()
  53015. case xunjiservice.FieldXunjiID:
  53016. return m.AddedXunjiID()
  53017. case xunjiservice.FieldOrganizationID:
  53018. return m.AddedOrganizationID()
  53019. }
  53020. return nil, false
  53021. }
  53022. // AddField adds the value to the field with the given name. It returns an error if
  53023. // the field is not defined in the schema, or if the type mismatched the field
  53024. // type.
  53025. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  53026. switch name {
  53027. case xunjiservice.FieldStatus:
  53028. v, ok := value.(int8)
  53029. if !ok {
  53030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53031. }
  53032. m.AddStatus(v)
  53033. return nil
  53034. case xunjiservice.FieldXunjiID:
  53035. v, ok := value.(int64)
  53036. if !ok {
  53037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53038. }
  53039. m.AddXunjiID(v)
  53040. return nil
  53041. case xunjiservice.FieldOrganizationID:
  53042. v, ok := value.(int64)
  53043. if !ok {
  53044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53045. }
  53046. m.AddOrganizationID(v)
  53047. return nil
  53048. }
  53049. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  53050. }
  53051. // ClearedFields returns all nullable fields that were cleared during this
  53052. // mutation.
  53053. func (m *XunjiServiceMutation) ClearedFields() []string {
  53054. var fields []string
  53055. if m.FieldCleared(xunjiservice.FieldStatus) {
  53056. fields = append(fields, xunjiservice.FieldStatus)
  53057. }
  53058. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  53059. fields = append(fields, xunjiservice.FieldDeletedAt)
  53060. }
  53061. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  53062. fields = append(fields, xunjiservice.FieldAPIBase)
  53063. }
  53064. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  53065. fields = append(fields, xunjiservice.FieldAPIKey)
  53066. }
  53067. return fields
  53068. }
  53069. // FieldCleared returns a boolean indicating if a field with the given name was
  53070. // cleared in this mutation.
  53071. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  53072. _, ok := m.clearedFields[name]
  53073. return ok
  53074. }
  53075. // ClearField clears the value of the field with the given name. It returns an
  53076. // error if the field is not defined in the schema.
  53077. func (m *XunjiServiceMutation) ClearField(name string) error {
  53078. switch name {
  53079. case xunjiservice.FieldStatus:
  53080. m.ClearStatus()
  53081. return nil
  53082. case xunjiservice.FieldDeletedAt:
  53083. m.ClearDeletedAt()
  53084. return nil
  53085. case xunjiservice.FieldAPIBase:
  53086. m.ClearAPIBase()
  53087. return nil
  53088. case xunjiservice.FieldAPIKey:
  53089. m.ClearAPIKey()
  53090. return nil
  53091. }
  53092. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  53093. }
  53094. // ResetField resets all changes in the mutation for the field with the given name.
  53095. // It returns an error if the field is not defined in the schema.
  53096. func (m *XunjiServiceMutation) ResetField(name string) error {
  53097. switch name {
  53098. case xunjiservice.FieldCreatedAt:
  53099. m.ResetCreatedAt()
  53100. return nil
  53101. case xunjiservice.FieldUpdatedAt:
  53102. m.ResetUpdatedAt()
  53103. return nil
  53104. case xunjiservice.FieldStatus:
  53105. m.ResetStatus()
  53106. return nil
  53107. case xunjiservice.FieldDeletedAt:
  53108. m.ResetDeletedAt()
  53109. return nil
  53110. case xunjiservice.FieldXunjiID:
  53111. m.ResetXunjiID()
  53112. return nil
  53113. case xunjiservice.FieldAgentID:
  53114. m.ResetAgentID()
  53115. return nil
  53116. case xunjiservice.FieldOrganizationID:
  53117. m.ResetOrganizationID()
  53118. return nil
  53119. case xunjiservice.FieldWxid:
  53120. m.ResetWxid()
  53121. return nil
  53122. case xunjiservice.FieldAPIBase:
  53123. m.ResetAPIBase()
  53124. return nil
  53125. case xunjiservice.FieldAPIKey:
  53126. m.ResetAPIKey()
  53127. return nil
  53128. }
  53129. return fmt.Errorf("unknown XunjiService field %s", name)
  53130. }
  53131. // AddedEdges returns all edge names that were set/added in this mutation.
  53132. func (m *XunjiServiceMutation) AddedEdges() []string {
  53133. edges := make([]string, 0, 1)
  53134. if m.agent != nil {
  53135. edges = append(edges, xunjiservice.EdgeAgent)
  53136. }
  53137. return edges
  53138. }
  53139. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  53140. // name in this mutation.
  53141. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  53142. switch name {
  53143. case xunjiservice.EdgeAgent:
  53144. if id := m.agent; id != nil {
  53145. return []ent.Value{*id}
  53146. }
  53147. }
  53148. return nil
  53149. }
  53150. // RemovedEdges returns all edge names that were removed in this mutation.
  53151. func (m *XunjiServiceMutation) RemovedEdges() []string {
  53152. edges := make([]string, 0, 1)
  53153. return edges
  53154. }
  53155. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  53156. // the given name in this mutation.
  53157. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  53158. return nil
  53159. }
  53160. // ClearedEdges returns all edge names that were cleared in this mutation.
  53161. func (m *XunjiServiceMutation) ClearedEdges() []string {
  53162. edges := make([]string, 0, 1)
  53163. if m.clearedagent {
  53164. edges = append(edges, xunjiservice.EdgeAgent)
  53165. }
  53166. return edges
  53167. }
  53168. // EdgeCleared returns a boolean which indicates if the edge with the given name
  53169. // was cleared in this mutation.
  53170. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  53171. switch name {
  53172. case xunjiservice.EdgeAgent:
  53173. return m.clearedagent
  53174. }
  53175. return false
  53176. }
  53177. // ClearEdge clears the value of the edge with the given name. It returns an error
  53178. // if that edge is not defined in the schema.
  53179. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  53180. switch name {
  53181. case xunjiservice.EdgeAgent:
  53182. m.ClearAgent()
  53183. return nil
  53184. }
  53185. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  53186. }
  53187. // ResetEdge resets all changes to the edge with the given name in this mutation.
  53188. // It returns an error if the edge is not defined in the schema.
  53189. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  53190. switch name {
  53191. case xunjiservice.EdgeAgent:
  53192. m.ResetAgent()
  53193. return nil
  53194. }
  53195. return fmt.Errorf("unknown XunjiService edge %s", name)
  53196. }