mutation.go 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "wechat-api/ent/xunji"
  52. "wechat-api/ent/xunjiservice"
  53. "entgo.io/ent"
  54. "entgo.io/ent/dialect/sql"
  55. )
  56. const (
  57. // Operation types.
  58. OpCreate = ent.OpCreate
  59. OpDelete = ent.OpDelete
  60. OpDeleteOne = ent.OpDeleteOne
  61. OpUpdate = ent.OpUpdate
  62. OpUpdateOne = ent.OpUpdateOne
  63. // Node types.
  64. TypeAgent = "Agent"
  65. TypeAgentBase = "AgentBase"
  66. TypeAliyunAvatar = "AliyunAvatar"
  67. TypeAllocAgent = "AllocAgent"
  68. TypeBatchMsg = "BatchMsg"
  69. TypeCategory = "Category"
  70. TypeChatRecords = "ChatRecords"
  71. TypeChatSession = "ChatSession"
  72. TypeContact = "Contact"
  73. TypeCreditBalance = "CreditBalance"
  74. TypeCreditUsage = "CreditUsage"
  75. TypeEmployee = "Employee"
  76. TypeEmployeeConfig = "EmployeeConfig"
  77. TypeLabel = "Label"
  78. TypeLabelRelationship = "LabelRelationship"
  79. TypeLabelTagging = "LabelTagging"
  80. TypeMessage = "Message"
  81. TypeMessageRecords = "MessageRecords"
  82. TypeMsg = "Msg"
  83. TypePayRecharge = "PayRecharge"
  84. TypeServer = "Server"
  85. TypeSopNode = "SopNode"
  86. TypeSopStage = "SopStage"
  87. TypeSopTask = "SopTask"
  88. TypeToken = "Token"
  89. TypeTutorial = "Tutorial"
  90. TypeUsageDetail = "UsageDetail"
  91. TypeUsageStatisticDay = "UsageStatisticDay"
  92. TypeUsageStatisticHour = "UsageStatisticHour"
  93. TypeUsageStatisticMonth = "UsageStatisticMonth"
  94. TypeUsageTotal = "UsageTotal"
  95. TypeWhatsapp = "Whatsapp"
  96. TypeWhatsappChannel = "WhatsappChannel"
  97. TypeWorkExperience = "WorkExperience"
  98. TypeWpChatroom = "WpChatroom"
  99. TypeWpChatroomMember = "WpChatroomMember"
  100. TypeWx = "Wx"
  101. TypeWxCard = "WxCard"
  102. TypeWxCardUser = "WxCardUser"
  103. TypeWxCardVisit = "WxCardVisit"
  104. TypeXunji = "Xunji"
  105. TypeXunjiService = "XunjiService"
  106. )
  107. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  108. type AgentMutation struct {
  109. config
  110. op Op
  111. typ string
  112. id *uint64
  113. created_at *time.Time
  114. updated_at *time.Time
  115. deleted_at *time.Time
  116. name *string
  117. role *string
  118. status *int
  119. addstatus *int
  120. background *string
  121. examples *string
  122. organization_id *uint64
  123. addorganization_id *int64
  124. dataset_id *string
  125. collection_id *string
  126. clearedFields map[string]struct{}
  127. wx_agent map[uint64]struct{}
  128. removedwx_agent map[uint64]struct{}
  129. clearedwx_agent bool
  130. token_agent map[uint64]struct{}
  131. removedtoken_agent map[uint64]struct{}
  132. clearedtoken_agent bool
  133. wa_agent map[uint64]struct{}
  134. removedwa_agent map[uint64]struct{}
  135. clearedwa_agent bool
  136. xjs_agent map[uint64]struct{}
  137. removedxjs_agent map[uint64]struct{}
  138. clearedxjs_agent bool
  139. done bool
  140. oldValue func(context.Context) (*Agent, error)
  141. predicates []predicate.Agent
  142. }
  143. var _ ent.Mutation = (*AgentMutation)(nil)
  144. // agentOption allows management of the mutation configuration using functional options.
  145. type agentOption func(*AgentMutation)
  146. // newAgentMutation creates new mutation for the Agent entity.
  147. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  148. m := &AgentMutation{
  149. config: c,
  150. op: op,
  151. typ: TypeAgent,
  152. clearedFields: make(map[string]struct{}),
  153. }
  154. for _, opt := range opts {
  155. opt(m)
  156. }
  157. return m
  158. }
  159. // withAgentID sets the ID field of the mutation.
  160. func withAgentID(id uint64) agentOption {
  161. return func(m *AgentMutation) {
  162. var (
  163. err error
  164. once sync.Once
  165. value *Agent
  166. )
  167. m.oldValue = func(ctx context.Context) (*Agent, error) {
  168. once.Do(func() {
  169. if m.done {
  170. err = errors.New("querying old values post mutation is not allowed")
  171. } else {
  172. value, err = m.Client().Agent.Get(ctx, id)
  173. }
  174. })
  175. return value, err
  176. }
  177. m.id = &id
  178. }
  179. }
  180. // withAgent sets the old Agent of the mutation.
  181. func withAgent(node *Agent) agentOption {
  182. return func(m *AgentMutation) {
  183. m.oldValue = func(context.Context) (*Agent, error) {
  184. return node, nil
  185. }
  186. m.id = &node.ID
  187. }
  188. }
  189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  190. // executed in a transaction (ent.Tx), a transactional client is returned.
  191. func (m AgentMutation) Client() *Client {
  192. client := &Client{config: m.config}
  193. client.init()
  194. return client
  195. }
  196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  197. // it returns an error otherwise.
  198. func (m AgentMutation) Tx() (*Tx, error) {
  199. if _, ok := m.driver.(*txDriver); !ok {
  200. return nil, errors.New("ent: mutation is not running in a transaction")
  201. }
  202. tx := &Tx{config: m.config}
  203. tx.init()
  204. return tx, nil
  205. }
  206. // SetID sets the value of the id field. Note that this
  207. // operation is only accepted on creation of Agent entities.
  208. func (m *AgentMutation) SetID(id uint64) {
  209. m.id = &id
  210. }
  211. // ID returns the ID value in the mutation. Note that the ID is only available
  212. // if it was provided to the builder or after it was returned from the database.
  213. func (m *AgentMutation) ID() (id uint64, exists bool) {
  214. if m.id == nil {
  215. return
  216. }
  217. return *m.id, true
  218. }
  219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  220. // That means, if the mutation is applied within a transaction with an isolation level such
  221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  222. // or updated by the mutation.
  223. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  224. switch {
  225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  226. id, exists := m.ID()
  227. if exists {
  228. return []uint64{id}, nil
  229. }
  230. fallthrough
  231. case m.op.Is(OpUpdate | OpDelete):
  232. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  233. default:
  234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  235. }
  236. }
  237. // SetCreatedAt sets the "created_at" field.
  238. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  239. m.created_at = &t
  240. }
  241. // CreatedAt returns the value of the "created_at" field in the mutation.
  242. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  243. v := m.created_at
  244. if v == nil {
  245. return
  246. }
  247. return *v, true
  248. }
  249. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  250. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  252. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  253. if !m.op.Is(OpUpdateOne) {
  254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  255. }
  256. if m.id == nil || m.oldValue == nil {
  257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  258. }
  259. oldValue, err := m.oldValue(ctx)
  260. if err != nil {
  261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  262. }
  263. return oldValue.CreatedAt, nil
  264. }
  265. // ResetCreatedAt resets all changes to the "created_at" field.
  266. func (m *AgentMutation) ResetCreatedAt() {
  267. m.created_at = nil
  268. }
  269. // SetUpdatedAt sets the "updated_at" field.
  270. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  271. m.updated_at = &t
  272. }
  273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  274. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  275. v := m.updated_at
  276. if v == nil {
  277. return
  278. }
  279. return *v, true
  280. }
  281. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  282. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  284. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  285. if !m.op.Is(OpUpdateOne) {
  286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  287. }
  288. if m.id == nil || m.oldValue == nil {
  289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  290. }
  291. oldValue, err := m.oldValue(ctx)
  292. if err != nil {
  293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  294. }
  295. return oldValue.UpdatedAt, nil
  296. }
  297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  298. func (m *AgentMutation) ResetUpdatedAt() {
  299. m.updated_at = nil
  300. }
  301. // SetDeletedAt sets the "deleted_at" field.
  302. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  303. m.deleted_at = &t
  304. }
  305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  306. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  307. v := m.deleted_at
  308. if v == nil {
  309. return
  310. }
  311. return *v, true
  312. }
  313. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  314. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  316. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  317. if !m.op.Is(OpUpdateOne) {
  318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  319. }
  320. if m.id == nil || m.oldValue == nil {
  321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  322. }
  323. oldValue, err := m.oldValue(ctx)
  324. if err != nil {
  325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  326. }
  327. return oldValue.DeletedAt, nil
  328. }
  329. // ClearDeletedAt clears the value of the "deleted_at" field.
  330. func (m *AgentMutation) ClearDeletedAt() {
  331. m.deleted_at = nil
  332. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  333. }
  334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  335. func (m *AgentMutation) DeletedAtCleared() bool {
  336. _, ok := m.clearedFields[agent.FieldDeletedAt]
  337. return ok
  338. }
  339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  340. func (m *AgentMutation) ResetDeletedAt() {
  341. m.deleted_at = nil
  342. delete(m.clearedFields, agent.FieldDeletedAt)
  343. }
  344. // SetName sets the "name" field.
  345. func (m *AgentMutation) SetName(s string) {
  346. m.name = &s
  347. }
  348. // Name returns the value of the "name" field in the mutation.
  349. func (m *AgentMutation) Name() (r string, exists bool) {
  350. v := m.name
  351. if v == nil {
  352. return
  353. }
  354. return *v, true
  355. }
  356. // OldName returns the old "name" field's value of the Agent entity.
  357. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  359. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  360. if !m.op.Is(OpUpdateOne) {
  361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  362. }
  363. if m.id == nil || m.oldValue == nil {
  364. return v, errors.New("OldName requires an ID field in the mutation")
  365. }
  366. oldValue, err := m.oldValue(ctx)
  367. if err != nil {
  368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  369. }
  370. return oldValue.Name, nil
  371. }
  372. // ResetName resets all changes to the "name" field.
  373. func (m *AgentMutation) ResetName() {
  374. m.name = nil
  375. }
  376. // SetRole sets the "role" field.
  377. func (m *AgentMutation) SetRole(s string) {
  378. m.role = &s
  379. }
  380. // Role returns the value of the "role" field in the mutation.
  381. func (m *AgentMutation) Role() (r string, exists bool) {
  382. v := m.role
  383. if v == nil {
  384. return
  385. }
  386. return *v, true
  387. }
  388. // OldRole returns the old "role" field's value of the Agent entity.
  389. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  391. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  392. if !m.op.Is(OpUpdateOne) {
  393. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  394. }
  395. if m.id == nil || m.oldValue == nil {
  396. return v, errors.New("OldRole requires an ID field in the mutation")
  397. }
  398. oldValue, err := m.oldValue(ctx)
  399. if err != nil {
  400. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  401. }
  402. return oldValue.Role, nil
  403. }
  404. // ResetRole resets all changes to the "role" field.
  405. func (m *AgentMutation) ResetRole() {
  406. m.role = nil
  407. }
  408. // SetStatus sets the "status" field.
  409. func (m *AgentMutation) SetStatus(i int) {
  410. m.status = &i
  411. m.addstatus = nil
  412. }
  413. // Status returns the value of the "status" field in the mutation.
  414. func (m *AgentMutation) Status() (r int, exists bool) {
  415. v := m.status
  416. if v == nil {
  417. return
  418. }
  419. return *v, true
  420. }
  421. // OldStatus returns the old "status" field's value of the Agent entity.
  422. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  424. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  425. if !m.op.Is(OpUpdateOne) {
  426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  427. }
  428. if m.id == nil || m.oldValue == nil {
  429. return v, errors.New("OldStatus requires an ID field in the mutation")
  430. }
  431. oldValue, err := m.oldValue(ctx)
  432. if err != nil {
  433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  434. }
  435. return oldValue.Status, nil
  436. }
  437. // AddStatus adds i to the "status" field.
  438. func (m *AgentMutation) AddStatus(i int) {
  439. if m.addstatus != nil {
  440. *m.addstatus += i
  441. } else {
  442. m.addstatus = &i
  443. }
  444. }
  445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  446. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  447. v := m.addstatus
  448. if v == nil {
  449. return
  450. }
  451. return *v, true
  452. }
  453. // ClearStatus clears the value of the "status" field.
  454. func (m *AgentMutation) ClearStatus() {
  455. m.status = nil
  456. m.addstatus = nil
  457. m.clearedFields[agent.FieldStatus] = struct{}{}
  458. }
  459. // StatusCleared returns if the "status" field was cleared in this mutation.
  460. func (m *AgentMutation) StatusCleared() bool {
  461. _, ok := m.clearedFields[agent.FieldStatus]
  462. return ok
  463. }
  464. // ResetStatus resets all changes to the "status" field.
  465. func (m *AgentMutation) ResetStatus() {
  466. m.status = nil
  467. m.addstatus = nil
  468. delete(m.clearedFields, agent.FieldStatus)
  469. }
  470. // SetBackground sets the "background" field.
  471. func (m *AgentMutation) SetBackground(s string) {
  472. m.background = &s
  473. }
  474. // Background returns the value of the "background" field in the mutation.
  475. func (m *AgentMutation) Background() (r string, exists bool) {
  476. v := m.background
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // OldBackground returns the old "background" field's value of the Agent entity.
  483. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  485. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  486. if !m.op.Is(OpUpdateOne) {
  487. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  488. }
  489. if m.id == nil || m.oldValue == nil {
  490. return v, errors.New("OldBackground requires an ID field in the mutation")
  491. }
  492. oldValue, err := m.oldValue(ctx)
  493. if err != nil {
  494. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  495. }
  496. return oldValue.Background, nil
  497. }
  498. // ClearBackground clears the value of the "background" field.
  499. func (m *AgentMutation) ClearBackground() {
  500. m.background = nil
  501. m.clearedFields[agent.FieldBackground] = struct{}{}
  502. }
  503. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  504. func (m *AgentMutation) BackgroundCleared() bool {
  505. _, ok := m.clearedFields[agent.FieldBackground]
  506. return ok
  507. }
  508. // ResetBackground resets all changes to the "background" field.
  509. func (m *AgentMutation) ResetBackground() {
  510. m.background = nil
  511. delete(m.clearedFields, agent.FieldBackground)
  512. }
  513. // SetExamples sets the "examples" field.
  514. func (m *AgentMutation) SetExamples(s string) {
  515. m.examples = &s
  516. }
  517. // Examples returns the value of the "examples" field in the mutation.
  518. func (m *AgentMutation) Examples() (r string, exists bool) {
  519. v := m.examples
  520. if v == nil {
  521. return
  522. }
  523. return *v, true
  524. }
  525. // OldExamples returns the old "examples" field's value of the Agent entity.
  526. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  528. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  529. if !m.op.Is(OpUpdateOne) {
  530. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  531. }
  532. if m.id == nil || m.oldValue == nil {
  533. return v, errors.New("OldExamples requires an ID field in the mutation")
  534. }
  535. oldValue, err := m.oldValue(ctx)
  536. if err != nil {
  537. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  538. }
  539. return oldValue.Examples, nil
  540. }
  541. // ClearExamples clears the value of the "examples" field.
  542. func (m *AgentMutation) ClearExamples() {
  543. m.examples = nil
  544. m.clearedFields[agent.FieldExamples] = struct{}{}
  545. }
  546. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  547. func (m *AgentMutation) ExamplesCleared() bool {
  548. _, ok := m.clearedFields[agent.FieldExamples]
  549. return ok
  550. }
  551. // ResetExamples resets all changes to the "examples" field.
  552. func (m *AgentMutation) ResetExamples() {
  553. m.examples = nil
  554. delete(m.clearedFields, agent.FieldExamples)
  555. }
  556. // SetOrganizationID sets the "organization_id" field.
  557. func (m *AgentMutation) SetOrganizationID(u uint64) {
  558. m.organization_id = &u
  559. m.addorganization_id = nil
  560. }
  561. // OrganizationID returns the value of the "organization_id" field in the mutation.
  562. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  563. v := m.organization_id
  564. if v == nil {
  565. return
  566. }
  567. return *v, true
  568. }
  569. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  570. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  572. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  573. if !m.op.Is(OpUpdateOne) {
  574. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  575. }
  576. if m.id == nil || m.oldValue == nil {
  577. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  578. }
  579. oldValue, err := m.oldValue(ctx)
  580. if err != nil {
  581. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  582. }
  583. return oldValue.OrganizationID, nil
  584. }
  585. // AddOrganizationID adds u to the "organization_id" field.
  586. func (m *AgentMutation) AddOrganizationID(u int64) {
  587. if m.addorganization_id != nil {
  588. *m.addorganization_id += u
  589. } else {
  590. m.addorganization_id = &u
  591. }
  592. }
  593. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  594. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  595. v := m.addorganization_id
  596. if v == nil {
  597. return
  598. }
  599. return *v, true
  600. }
  601. // ResetOrganizationID resets all changes to the "organization_id" field.
  602. func (m *AgentMutation) ResetOrganizationID() {
  603. m.organization_id = nil
  604. m.addorganization_id = nil
  605. }
  606. // SetDatasetID sets the "dataset_id" field.
  607. func (m *AgentMutation) SetDatasetID(s string) {
  608. m.dataset_id = &s
  609. }
  610. // DatasetID returns the value of the "dataset_id" field in the mutation.
  611. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  612. v := m.dataset_id
  613. if v == nil {
  614. return
  615. }
  616. return *v, true
  617. }
  618. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  619. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  621. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  622. if !m.op.Is(OpUpdateOne) {
  623. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  624. }
  625. if m.id == nil || m.oldValue == nil {
  626. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  627. }
  628. oldValue, err := m.oldValue(ctx)
  629. if err != nil {
  630. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  631. }
  632. return oldValue.DatasetID, nil
  633. }
  634. // ResetDatasetID resets all changes to the "dataset_id" field.
  635. func (m *AgentMutation) ResetDatasetID() {
  636. m.dataset_id = nil
  637. }
  638. // SetCollectionID sets the "collection_id" field.
  639. func (m *AgentMutation) SetCollectionID(s string) {
  640. m.collection_id = &s
  641. }
  642. // CollectionID returns the value of the "collection_id" field in the mutation.
  643. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  644. v := m.collection_id
  645. if v == nil {
  646. return
  647. }
  648. return *v, true
  649. }
  650. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  651. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  653. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  654. if !m.op.Is(OpUpdateOne) {
  655. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  656. }
  657. if m.id == nil || m.oldValue == nil {
  658. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  659. }
  660. oldValue, err := m.oldValue(ctx)
  661. if err != nil {
  662. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  663. }
  664. return oldValue.CollectionID, nil
  665. }
  666. // ResetCollectionID resets all changes to the "collection_id" field.
  667. func (m *AgentMutation) ResetCollectionID() {
  668. m.collection_id = nil
  669. }
  670. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  671. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  672. if m.wx_agent == nil {
  673. m.wx_agent = make(map[uint64]struct{})
  674. }
  675. for i := range ids {
  676. m.wx_agent[ids[i]] = struct{}{}
  677. }
  678. }
  679. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  680. func (m *AgentMutation) ClearWxAgent() {
  681. m.clearedwx_agent = true
  682. }
  683. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  684. func (m *AgentMutation) WxAgentCleared() bool {
  685. return m.clearedwx_agent
  686. }
  687. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  688. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  689. if m.removedwx_agent == nil {
  690. m.removedwx_agent = make(map[uint64]struct{})
  691. }
  692. for i := range ids {
  693. delete(m.wx_agent, ids[i])
  694. m.removedwx_agent[ids[i]] = struct{}{}
  695. }
  696. }
  697. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  698. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  699. for id := range m.removedwx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  705. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  706. for id := range m.wx_agent {
  707. ids = append(ids, id)
  708. }
  709. return
  710. }
  711. // ResetWxAgent resets all changes to the "wx_agent" edge.
  712. func (m *AgentMutation) ResetWxAgent() {
  713. m.wx_agent = nil
  714. m.clearedwx_agent = false
  715. m.removedwx_agent = nil
  716. }
  717. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  718. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  719. if m.token_agent == nil {
  720. m.token_agent = make(map[uint64]struct{})
  721. }
  722. for i := range ids {
  723. m.token_agent[ids[i]] = struct{}{}
  724. }
  725. }
  726. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  727. func (m *AgentMutation) ClearTokenAgent() {
  728. m.clearedtoken_agent = true
  729. }
  730. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  731. func (m *AgentMutation) TokenAgentCleared() bool {
  732. return m.clearedtoken_agent
  733. }
  734. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  735. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  736. if m.removedtoken_agent == nil {
  737. m.removedtoken_agent = make(map[uint64]struct{})
  738. }
  739. for i := range ids {
  740. delete(m.token_agent, ids[i])
  741. m.removedtoken_agent[ids[i]] = struct{}{}
  742. }
  743. }
  744. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  745. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  746. for id := range m.removedtoken_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  752. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  753. for id := range m.token_agent {
  754. ids = append(ids, id)
  755. }
  756. return
  757. }
  758. // ResetTokenAgent resets all changes to the "token_agent" edge.
  759. func (m *AgentMutation) ResetTokenAgent() {
  760. m.token_agent = nil
  761. m.clearedtoken_agent = false
  762. m.removedtoken_agent = nil
  763. }
  764. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  765. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  766. if m.wa_agent == nil {
  767. m.wa_agent = make(map[uint64]struct{})
  768. }
  769. for i := range ids {
  770. m.wa_agent[ids[i]] = struct{}{}
  771. }
  772. }
  773. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  774. func (m *AgentMutation) ClearWaAgent() {
  775. m.clearedwa_agent = true
  776. }
  777. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  778. func (m *AgentMutation) WaAgentCleared() bool {
  779. return m.clearedwa_agent
  780. }
  781. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  782. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  783. if m.removedwa_agent == nil {
  784. m.removedwa_agent = make(map[uint64]struct{})
  785. }
  786. for i := range ids {
  787. delete(m.wa_agent, ids[i])
  788. m.removedwa_agent[ids[i]] = struct{}{}
  789. }
  790. }
  791. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  792. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  793. for id := range m.removedwa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  799. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  800. for id := range m.wa_agent {
  801. ids = append(ids, id)
  802. }
  803. return
  804. }
  805. // ResetWaAgent resets all changes to the "wa_agent" edge.
  806. func (m *AgentMutation) ResetWaAgent() {
  807. m.wa_agent = nil
  808. m.clearedwa_agent = false
  809. m.removedwa_agent = nil
  810. }
  811. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  812. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  813. if m.xjs_agent == nil {
  814. m.xjs_agent = make(map[uint64]struct{})
  815. }
  816. for i := range ids {
  817. m.xjs_agent[ids[i]] = struct{}{}
  818. }
  819. }
  820. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  821. func (m *AgentMutation) ClearXjsAgent() {
  822. m.clearedxjs_agent = true
  823. }
  824. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  825. func (m *AgentMutation) XjsAgentCleared() bool {
  826. return m.clearedxjs_agent
  827. }
  828. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  829. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  830. if m.removedxjs_agent == nil {
  831. m.removedxjs_agent = make(map[uint64]struct{})
  832. }
  833. for i := range ids {
  834. delete(m.xjs_agent, ids[i])
  835. m.removedxjs_agent[ids[i]] = struct{}{}
  836. }
  837. }
  838. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  839. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  840. for id := range m.removedxjs_agent {
  841. ids = append(ids, id)
  842. }
  843. return
  844. }
  845. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  846. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  847. for id := range m.xjs_agent {
  848. ids = append(ids, id)
  849. }
  850. return
  851. }
  852. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  853. func (m *AgentMutation) ResetXjsAgent() {
  854. m.xjs_agent = nil
  855. m.clearedxjs_agent = false
  856. m.removedxjs_agent = nil
  857. }
  858. // Where appends a list predicates to the AgentMutation builder.
  859. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  860. m.predicates = append(m.predicates, ps...)
  861. }
  862. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  863. // users can use type-assertion to append predicates that do not depend on any generated package.
  864. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  865. p := make([]predicate.Agent, len(ps))
  866. for i := range ps {
  867. p[i] = ps[i]
  868. }
  869. m.Where(p...)
  870. }
  871. // Op returns the operation name.
  872. func (m *AgentMutation) Op() Op {
  873. return m.op
  874. }
  875. // SetOp allows setting the mutation operation.
  876. func (m *AgentMutation) SetOp(op Op) {
  877. m.op = op
  878. }
  879. // Type returns the node type of this mutation (Agent).
  880. func (m *AgentMutation) Type() string {
  881. return m.typ
  882. }
  883. // Fields returns all fields that were changed during this mutation. Note that in
  884. // order to get all numeric fields that were incremented/decremented, call
  885. // AddedFields().
  886. func (m *AgentMutation) Fields() []string {
  887. fields := make([]string, 0, 11)
  888. if m.created_at != nil {
  889. fields = append(fields, agent.FieldCreatedAt)
  890. }
  891. if m.updated_at != nil {
  892. fields = append(fields, agent.FieldUpdatedAt)
  893. }
  894. if m.deleted_at != nil {
  895. fields = append(fields, agent.FieldDeletedAt)
  896. }
  897. if m.name != nil {
  898. fields = append(fields, agent.FieldName)
  899. }
  900. if m.role != nil {
  901. fields = append(fields, agent.FieldRole)
  902. }
  903. if m.status != nil {
  904. fields = append(fields, agent.FieldStatus)
  905. }
  906. if m.background != nil {
  907. fields = append(fields, agent.FieldBackground)
  908. }
  909. if m.examples != nil {
  910. fields = append(fields, agent.FieldExamples)
  911. }
  912. if m.organization_id != nil {
  913. fields = append(fields, agent.FieldOrganizationID)
  914. }
  915. if m.dataset_id != nil {
  916. fields = append(fields, agent.FieldDatasetID)
  917. }
  918. if m.collection_id != nil {
  919. fields = append(fields, agent.FieldCollectionID)
  920. }
  921. return fields
  922. }
  923. // Field returns the value of a field with the given name. The second boolean
  924. // return value indicates that this field was not set, or was not defined in the
  925. // schema.
  926. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  927. switch name {
  928. case agent.FieldCreatedAt:
  929. return m.CreatedAt()
  930. case agent.FieldUpdatedAt:
  931. return m.UpdatedAt()
  932. case agent.FieldDeletedAt:
  933. return m.DeletedAt()
  934. case agent.FieldName:
  935. return m.Name()
  936. case agent.FieldRole:
  937. return m.Role()
  938. case agent.FieldStatus:
  939. return m.Status()
  940. case agent.FieldBackground:
  941. return m.Background()
  942. case agent.FieldExamples:
  943. return m.Examples()
  944. case agent.FieldOrganizationID:
  945. return m.OrganizationID()
  946. case agent.FieldDatasetID:
  947. return m.DatasetID()
  948. case agent.FieldCollectionID:
  949. return m.CollectionID()
  950. }
  951. return nil, false
  952. }
  953. // OldField returns the old value of the field from the database. An error is
  954. // returned if the mutation operation is not UpdateOne, or the query to the
  955. // database failed.
  956. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  957. switch name {
  958. case agent.FieldCreatedAt:
  959. return m.OldCreatedAt(ctx)
  960. case agent.FieldUpdatedAt:
  961. return m.OldUpdatedAt(ctx)
  962. case agent.FieldDeletedAt:
  963. return m.OldDeletedAt(ctx)
  964. case agent.FieldName:
  965. return m.OldName(ctx)
  966. case agent.FieldRole:
  967. return m.OldRole(ctx)
  968. case agent.FieldStatus:
  969. return m.OldStatus(ctx)
  970. case agent.FieldBackground:
  971. return m.OldBackground(ctx)
  972. case agent.FieldExamples:
  973. return m.OldExamples(ctx)
  974. case agent.FieldOrganizationID:
  975. return m.OldOrganizationID(ctx)
  976. case agent.FieldDatasetID:
  977. return m.OldDatasetID(ctx)
  978. case agent.FieldCollectionID:
  979. return m.OldCollectionID(ctx)
  980. }
  981. return nil, fmt.Errorf("unknown Agent field %s", name)
  982. }
  983. // SetField sets the value of a field with the given name. It returns an error if
  984. // the field is not defined in the schema, or if the type mismatched the field
  985. // type.
  986. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  987. switch name {
  988. case agent.FieldCreatedAt:
  989. v, ok := value.(time.Time)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.SetCreatedAt(v)
  994. return nil
  995. case agent.FieldUpdatedAt:
  996. v, ok := value.(time.Time)
  997. if !ok {
  998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  999. }
  1000. m.SetUpdatedAt(v)
  1001. return nil
  1002. case agent.FieldDeletedAt:
  1003. v, ok := value.(time.Time)
  1004. if !ok {
  1005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1006. }
  1007. m.SetDeletedAt(v)
  1008. return nil
  1009. case agent.FieldName:
  1010. v, ok := value.(string)
  1011. if !ok {
  1012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1013. }
  1014. m.SetName(v)
  1015. return nil
  1016. case agent.FieldRole:
  1017. v, ok := value.(string)
  1018. if !ok {
  1019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1020. }
  1021. m.SetRole(v)
  1022. return nil
  1023. case agent.FieldStatus:
  1024. v, ok := value.(int)
  1025. if !ok {
  1026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1027. }
  1028. m.SetStatus(v)
  1029. return nil
  1030. case agent.FieldBackground:
  1031. v, ok := value.(string)
  1032. if !ok {
  1033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1034. }
  1035. m.SetBackground(v)
  1036. return nil
  1037. case agent.FieldExamples:
  1038. v, ok := value.(string)
  1039. if !ok {
  1040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1041. }
  1042. m.SetExamples(v)
  1043. return nil
  1044. case agent.FieldOrganizationID:
  1045. v, ok := value.(uint64)
  1046. if !ok {
  1047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1048. }
  1049. m.SetOrganizationID(v)
  1050. return nil
  1051. case agent.FieldDatasetID:
  1052. v, ok := value.(string)
  1053. if !ok {
  1054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1055. }
  1056. m.SetDatasetID(v)
  1057. return nil
  1058. case agent.FieldCollectionID:
  1059. v, ok := value.(string)
  1060. if !ok {
  1061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1062. }
  1063. m.SetCollectionID(v)
  1064. return nil
  1065. }
  1066. return fmt.Errorf("unknown Agent field %s", name)
  1067. }
  1068. // AddedFields returns all numeric fields that were incremented/decremented during
  1069. // this mutation.
  1070. func (m *AgentMutation) AddedFields() []string {
  1071. var fields []string
  1072. if m.addstatus != nil {
  1073. fields = append(fields, agent.FieldStatus)
  1074. }
  1075. if m.addorganization_id != nil {
  1076. fields = append(fields, agent.FieldOrganizationID)
  1077. }
  1078. return fields
  1079. }
  1080. // AddedField returns the numeric value that was incremented/decremented on a field
  1081. // with the given name. The second boolean return value indicates that this field
  1082. // was not set, or was not defined in the schema.
  1083. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1084. switch name {
  1085. case agent.FieldStatus:
  1086. return m.AddedStatus()
  1087. case agent.FieldOrganizationID:
  1088. return m.AddedOrganizationID()
  1089. }
  1090. return nil, false
  1091. }
  1092. // AddField adds the value to the field with the given name. It returns an error if
  1093. // the field is not defined in the schema, or if the type mismatched the field
  1094. // type.
  1095. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1096. switch name {
  1097. case agent.FieldStatus:
  1098. v, ok := value.(int)
  1099. if !ok {
  1100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1101. }
  1102. m.AddStatus(v)
  1103. return nil
  1104. case agent.FieldOrganizationID:
  1105. v, ok := value.(int64)
  1106. if !ok {
  1107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1108. }
  1109. m.AddOrganizationID(v)
  1110. return nil
  1111. }
  1112. return fmt.Errorf("unknown Agent numeric field %s", name)
  1113. }
  1114. // ClearedFields returns all nullable fields that were cleared during this
  1115. // mutation.
  1116. func (m *AgentMutation) ClearedFields() []string {
  1117. var fields []string
  1118. if m.FieldCleared(agent.FieldDeletedAt) {
  1119. fields = append(fields, agent.FieldDeletedAt)
  1120. }
  1121. if m.FieldCleared(agent.FieldStatus) {
  1122. fields = append(fields, agent.FieldStatus)
  1123. }
  1124. if m.FieldCleared(agent.FieldBackground) {
  1125. fields = append(fields, agent.FieldBackground)
  1126. }
  1127. if m.FieldCleared(agent.FieldExamples) {
  1128. fields = append(fields, agent.FieldExamples)
  1129. }
  1130. return fields
  1131. }
  1132. // FieldCleared returns a boolean indicating if a field with the given name was
  1133. // cleared in this mutation.
  1134. func (m *AgentMutation) FieldCleared(name string) bool {
  1135. _, ok := m.clearedFields[name]
  1136. return ok
  1137. }
  1138. // ClearField clears the value of the field with the given name. It returns an
  1139. // error if the field is not defined in the schema.
  1140. func (m *AgentMutation) ClearField(name string) error {
  1141. switch name {
  1142. case agent.FieldDeletedAt:
  1143. m.ClearDeletedAt()
  1144. return nil
  1145. case agent.FieldStatus:
  1146. m.ClearStatus()
  1147. return nil
  1148. case agent.FieldBackground:
  1149. m.ClearBackground()
  1150. return nil
  1151. case agent.FieldExamples:
  1152. m.ClearExamples()
  1153. return nil
  1154. }
  1155. return fmt.Errorf("unknown Agent nullable field %s", name)
  1156. }
  1157. // ResetField resets all changes in the mutation for the field with the given name.
  1158. // It returns an error if the field is not defined in the schema.
  1159. func (m *AgentMutation) ResetField(name string) error {
  1160. switch name {
  1161. case agent.FieldCreatedAt:
  1162. m.ResetCreatedAt()
  1163. return nil
  1164. case agent.FieldUpdatedAt:
  1165. m.ResetUpdatedAt()
  1166. return nil
  1167. case agent.FieldDeletedAt:
  1168. m.ResetDeletedAt()
  1169. return nil
  1170. case agent.FieldName:
  1171. m.ResetName()
  1172. return nil
  1173. case agent.FieldRole:
  1174. m.ResetRole()
  1175. return nil
  1176. case agent.FieldStatus:
  1177. m.ResetStatus()
  1178. return nil
  1179. case agent.FieldBackground:
  1180. m.ResetBackground()
  1181. return nil
  1182. case agent.FieldExamples:
  1183. m.ResetExamples()
  1184. return nil
  1185. case agent.FieldOrganizationID:
  1186. m.ResetOrganizationID()
  1187. return nil
  1188. case agent.FieldDatasetID:
  1189. m.ResetDatasetID()
  1190. return nil
  1191. case agent.FieldCollectionID:
  1192. m.ResetCollectionID()
  1193. return nil
  1194. }
  1195. return fmt.Errorf("unknown Agent field %s", name)
  1196. }
  1197. // AddedEdges returns all edge names that were set/added in this mutation.
  1198. func (m *AgentMutation) AddedEdges() []string {
  1199. edges := make([]string, 0, 4)
  1200. if m.wx_agent != nil {
  1201. edges = append(edges, agent.EdgeWxAgent)
  1202. }
  1203. if m.token_agent != nil {
  1204. edges = append(edges, agent.EdgeTokenAgent)
  1205. }
  1206. if m.wa_agent != nil {
  1207. edges = append(edges, agent.EdgeWaAgent)
  1208. }
  1209. if m.xjs_agent != nil {
  1210. edges = append(edges, agent.EdgeXjsAgent)
  1211. }
  1212. return edges
  1213. }
  1214. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1215. // name in this mutation.
  1216. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1217. switch name {
  1218. case agent.EdgeWxAgent:
  1219. ids := make([]ent.Value, 0, len(m.wx_agent))
  1220. for id := range m.wx_agent {
  1221. ids = append(ids, id)
  1222. }
  1223. return ids
  1224. case agent.EdgeTokenAgent:
  1225. ids := make([]ent.Value, 0, len(m.token_agent))
  1226. for id := range m.token_agent {
  1227. ids = append(ids, id)
  1228. }
  1229. return ids
  1230. case agent.EdgeWaAgent:
  1231. ids := make([]ent.Value, 0, len(m.wa_agent))
  1232. for id := range m.wa_agent {
  1233. ids = append(ids, id)
  1234. }
  1235. return ids
  1236. case agent.EdgeXjsAgent:
  1237. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1238. for id := range m.xjs_agent {
  1239. ids = append(ids, id)
  1240. }
  1241. return ids
  1242. }
  1243. return nil
  1244. }
  1245. // RemovedEdges returns all edge names that were removed in this mutation.
  1246. func (m *AgentMutation) RemovedEdges() []string {
  1247. edges := make([]string, 0, 4)
  1248. if m.removedwx_agent != nil {
  1249. edges = append(edges, agent.EdgeWxAgent)
  1250. }
  1251. if m.removedtoken_agent != nil {
  1252. edges = append(edges, agent.EdgeTokenAgent)
  1253. }
  1254. if m.removedwa_agent != nil {
  1255. edges = append(edges, agent.EdgeWaAgent)
  1256. }
  1257. if m.removedxjs_agent != nil {
  1258. edges = append(edges, agent.EdgeXjsAgent)
  1259. }
  1260. return edges
  1261. }
  1262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1263. // the given name in this mutation.
  1264. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1265. switch name {
  1266. case agent.EdgeWxAgent:
  1267. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1268. for id := range m.removedwx_agent {
  1269. ids = append(ids, id)
  1270. }
  1271. return ids
  1272. case agent.EdgeTokenAgent:
  1273. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1274. for id := range m.removedtoken_agent {
  1275. ids = append(ids, id)
  1276. }
  1277. return ids
  1278. case agent.EdgeWaAgent:
  1279. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1280. for id := range m.removedwa_agent {
  1281. ids = append(ids, id)
  1282. }
  1283. return ids
  1284. case agent.EdgeXjsAgent:
  1285. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1286. for id := range m.removedxjs_agent {
  1287. ids = append(ids, id)
  1288. }
  1289. return ids
  1290. }
  1291. return nil
  1292. }
  1293. // ClearedEdges returns all edge names that were cleared in this mutation.
  1294. func (m *AgentMutation) ClearedEdges() []string {
  1295. edges := make([]string, 0, 4)
  1296. if m.clearedwx_agent {
  1297. edges = append(edges, agent.EdgeWxAgent)
  1298. }
  1299. if m.clearedtoken_agent {
  1300. edges = append(edges, agent.EdgeTokenAgent)
  1301. }
  1302. if m.clearedwa_agent {
  1303. edges = append(edges, agent.EdgeWaAgent)
  1304. }
  1305. if m.clearedxjs_agent {
  1306. edges = append(edges, agent.EdgeXjsAgent)
  1307. }
  1308. return edges
  1309. }
  1310. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1311. // was cleared in this mutation.
  1312. func (m *AgentMutation) EdgeCleared(name string) bool {
  1313. switch name {
  1314. case agent.EdgeWxAgent:
  1315. return m.clearedwx_agent
  1316. case agent.EdgeTokenAgent:
  1317. return m.clearedtoken_agent
  1318. case agent.EdgeWaAgent:
  1319. return m.clearedwa_agent
  1320. case agent.EdgeXjsAgent:
  1321. return m.clearedxjs_agent
  1322. }
  1323. return false
  1324. }
  1325. // ClearEdge clears the value of the edge with the given name. It returns an error
  1326. // if that edge is not defined in the schema.
  1327. func (m *AgentMutation) ClearEdge(name string) error {
  1328. switch name {
  1329. }
  1330. return fmt.Errorf("unknown Agent unique edge %s", name)
  1331. }
  1332. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1333. // It returns an error if the edge is not defined in the schema.
  1334. func (m *AgentMutation) ResetEdge(name string) error {
  1335. switch name {
  1336. case agent.EdgeWxAgent:
  1337. m.ResetWxAgent()
  1338. return nil
  1339. case agent.EdgeTokenAgent:
  1340. m.ResetTokenAgent()
  1341. return nil
  1342. case agent.EdgeWaAgent:
  1343. m.ResetWaAgent()
  1344. return nil
  1345. case agent.EdgeXjsAgent:
  1346. m.ResetXjsAgent()
  1347. return nil
  1348. }
  1349. return fmt.Errorf("unknown Agent edge %s", name)
  1350. }
  1351. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1352. type AgentBaseMutation struct {
  1353. config
  1354. op Op
  1355. typ string
  1356. id *string
  1357. q *string
  1358. a *string
  1359. chunk_index *uint64
  1360. addchunk_index *int64
  1361. indexes *[]string
  1362. appendindexes []string
  1363. dataset_id *string
  1364. collection_id *string
  1365. source_name *string
  1366. can_write *[]bool
  1367. appendcan_write []bool
  1368. is_owner *[]bool
  1369. appendis_owner []bool
  1370. clearedFields map[string]struct{}
  1371. wx_agent map[uint64]struct{}
  1372. removedwx_agent map[uint64]struct{}
  1373. clearedwx_agent bool
  1374. done bool
  1375. oldValue func(context.Context) (*AgentBase, error)
  1376. predicates []predicate.AgentBase
  1377. }
  1378. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1379. // agentbaseOption allows management of the mutation configuration using functional options.
  1380. type agentbaseOption func(*AgentBaseMutation)
  1381. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1382. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1383. m := &AgentBaseMutation{
  1384. config: c,
  1385. op: op,
  1386. typ: TypeAgentBase,
  1387. clearedFields: make(map[string]struct{}),
  1388. }
  1389. for _, opt := range opts {
  1390. opt(m)
  1391. }
  1392. return m
  1393. }
  1394. // withAgentBaseID sets the ID field of the mutation.
  1395. func withAgentBaseID(id string) agentbaseOption {
  1396. return func(m *AgentBaseMutation) {
  1397. var (
  1398. err error
  1399. once sync.Once
  1400. value *AgentBase
  1401. )
  1402. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1403. once.Do(func() {
  1404. if m.done {
  1405. err = errors.New("querying old values post mutation is not allowed")
  1406. } else {
  1407. value, err = m.Client().AgentBase.Get(ctx, id)
  1408. }
  1409. })
  1410. return value, err
  1411. }
  1412. m.id = &id
  1413. }
  1414. }
  1415. // withAgentBase sets the old AgentBase of the mutation.
  1416. func withAgentBase(node *AgentBase) agentbaseOption {
  1417. return func(m *AgentBaseMutation) {
  1418. m.oldValue = func(context.Context) (*AgentBase, error) {
  1419. return node, nil
  1420. }
  1421. m.id = &node.ID
  1422. }
  1423. }
  1424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1425. // executed in a transaction (ent.Tx), a transactional client is returned.
  1426. func (m AgentBaseMutation) Client() *Client {
  1427. client := &Client{config: m.config}
  1428. client.init()
  1429. return client
  1430. }
  1431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1432. // it returns an error otherwise.
  1433. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1434. if _, ok := m.driver.(*txDriver); !ok {
  1435. return nil, errors.New("ent: mutation is not running in a transaction")
  1436. }
  1437. tx := &Tx{config: m.config}
  1438. tx.init()
  1439. return tx, nil
  1440. }
  1441. // SetID sets the value of the id field. Note that this
  1442. // operation is only accepted on creation of AgentBase entities.
  1443. func (m *AgentBaseMutation) SetID(id string) {
  1444. m.id = &id
  1445. }
  1446. // ID returns the ID value in the mutation. Note that the ID is only available
  1447. // if it was provided to the builder or after it was returned from the database.
  1448. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1449. if m.id == nil {
  1450. return
  1451. }
  1452. return *m.id, true
  1453. }
  1454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1455. // That means, if the mutation is applied within a transaction with an isolation level such
  1456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1457. // or updated by the mutation.
  1458. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1459. switch {
  1460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1461. id, exists := m.ID()
  1462. if exists {
  1463. return []string{id}, nil
  1464. }
  1465. fallthrough
  1466. case m.op.Is(OpUpdate | OpDelete):
  1467. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1468. default:
  1469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1470. }
  1471. }
  1472. // SetQ sets the "q" field.
  1473. func (m *AgentBaseMutation) SetQ(s string) {
  1474. m.q = &s
  1475. }
  1476. // Q returns the value of the "q" field in the mutation.
  1477. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1478. v := m.q
  1479. if v == nil {
  1480. return
  1481. }
  1482. return *v, true
  1483. }
  1484. // OldQ returns the old "q" field's value of the AgentBase entity.
  1485. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1487. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1488. if !m.op.Is(OpUpdateOne) {
  1489. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1490. }
  1491. if m.id == nil || m.oldValue == nil {
  1492. return v, errors.New("OldQ requires an ID field in the mutation")
  1493. }
  1494. oldValue, err := m.oldValue(ctx)
  1495. if err != nil {
  1496. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1497. }
  1498. return oldValue.Q, nil
  1499. }
  1500. // ClearQ clears the value of the "q" field.
  1501. func (m *AgentBaseMutation) ClearQ() {
  1502. m.q = nil
  1503. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1504. }
  1505. // QCleared returns if the "q" field was cleared in this mutation.
  1506. func (m *AgentBaseMutation) QCleared() bool {
  1507. _, ok := m.clearedFields[agentbase.FieldQ]
  1508. return ok
  1509. }
  1510. // ResetQ resets all changes to the "q" field.
  1511. func (m *AgentBaseMutation) ResetQ() {
  1512. m.q = nil
  1513. delete(m.clearedFields, agentbase.FieldQ)
  1514. }
  1515. // SetA sets the "a" field.
  1516. func (m *AgentBaseMutation) SetA(s string) {
  1517. m.a = &s
  1518. }
  1519. // A returns the value of the "a" field in the mutation.
  1520. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1521. v := m.a
  1522. if v == nil {
  1523. return
  1524. }
  1525. return *v, true
  1526. }
  1527. // OldA returns the old "a" field's value of the AgentBase entity.
  1528. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1530. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1531. if !m.op.Is(OpUpdateOne) {
  1532. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1533. }
  1534. if m.id == nil || m.oldValue == nil {
  1535. return v, errors.New("OldA requires an ID field in the mutation")
  1536. }
  1537. oldValue, err := m.oldValue(ctx)
  1538. if err != nil {
  1539. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1540. }
  1541. return oldValue.A, nil
  1542. }
  1543. // ClearA clears the value of the "a" field.
  1544. func (m *AgentBaseMutation) ClearA() {
  1545. m.a = nil
  1546. m.clearedFields[agentbase.FieldA] = struct{}{}
  1547. }
  1548. // ACleared returns if the "a" field was cleared in this mutation.
  1549. func (m *AgentBaseMutation) ACleared() bool {
  1550. _, ok := m.clearedFields[agentbase.FieldA]
  1551. return ok
  1552. }
  1553. // ResetA resets all changes to the "a" field.
  1554. func (m *AgentBaseMutation) ResetA() {
  1555. m.a = nil
  1556. delete(m.clearedFields, agentbase.FieldA)
  1557. }
  1558. // SetChunkIndex sets the "chunk_index" field.
  1559. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1560. m.chunk_index = &u
  1561. m.addchunk_index = nil
  1562. }
  1563. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1564. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1565. v := m.chunk_index
  1566. if v == nil {
  1567. return
  1568. }
  1569. return *v, true
  1570. }
  1571. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1572. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1574. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1575. if !m.op.Is(OpUpdateOne) {
  1576. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1577. }
  1578. if m.id == nil || m.oldValue == nil {
  1579. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1580. }
  1581. oldValue, err := m.oldValue(ctx)
  1582. if err != nil {
  1583. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1584. }
  1585. return oldValue.ChunkIndex, nil
  1586. }
  1587. // AddChunkIndex adds u to the "chunk_index" field.
  1588. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1589. if m.addchunk_index != nil {
  1590. *m.addchunk_index += u
  1591. } else {
  1592. m.addchunk_index = &u
  1593. }
  1594. }
  1595. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1596. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1597. v := m.addchunk_index
  1598. if v == nil {
  1599. return
  1600. }
  1601. return *v, true
  1602. }
  1603. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1604. func (m *AgentBaseMutation) ResetChunkIndex() {
  1605. m.chunk_index = nil
  1606. m.addchunk_index = nil
  1607. }
  1608. // SetIndexes sets the "indexes" field.
  1609. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1610. m.indexes = &s
  1611. m.appendindexes = nil
  1612. }
  1613. // Indexes returns the value of the "indexes" field in the mutation.
  1614. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1615. v := m.indexes
  1616. if v == nil {
  1617. return
  1618. }
  1619. return *v, true
  1620. }
  1621. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1622. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1624. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1625. if !m.op.Is(OpUpdateOne) {
  1626. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1627. }
  1628. if m.id == nil || m.oldValue == nil {
  1629. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1630. }
  1631. oldValue, err := m.oldValue(ctx)
  1632. if err != nil {
  1633. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1634. }
  1635. return oldValue.Indexes, nil
  1636. }
  1637. // AppendIndexes adds s to the "indexes" field.
  1638. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1639. m.appendindexes = append(m.appendindexes, s...)
  1640. }
  1641. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1642. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1643. if len(m.appendindexes) == 0 {
  1644. return nil, false
  1645. }
  1646. return m.appendindexes, true
  1647. }
  1648. // ClearIndexes clears the value of the "indexes" field.
  1649. func (m *AgentBaseMutation) ClearIndexes() {
  1650. m.indexes = nil
  1651. m.appendindexes = nil
  1652. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1653. }
  1654. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1655. func (m *AgentBaseMutation) IndexesCleared() bool {
  1656. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1657. return ok
  1658. }
  1659. // ResetIndexes resets all changes to the "indexes" field.
  1660. func (m *AgentBaseMutation) ResetIndexes() {
  1661. m.indexes = nil
  1662. m.appendindexes = nil
  1663. delete(m.clearedFields, agentbase.FieldIndexes)
  1664. }
  1665. // SetDatasetID sets the "dataset_id" field.
  1666. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1667. m.dataset_id = &s
  1668. }
  1669. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1670. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1671. v := m.dataset_id
  1672. if v == nil {
  1673. return
  1674. }
  1675. return *v, true
  1676. }
  1677. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1678. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1680. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1681. if !m.op.Is(OpUpdateOne) {
  1682. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1683. }
  1684. if m.id == nil || m.oldValue == nil {
  1685. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1686. }
  1687. oldValue, err := m.oldValue(ctx)
  1688. if err != nil {
  1689. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1690. }
  1691. return oldValue.DatasetID, nil
  1692. }
  1693. // ClearDatasetID clears the value of the "dataset_id" field.
  1694. func (m *AgentBaseMutation) ClearDatasetID() {
  1695. m.dataset_id = nil
  1696. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1697. }
  1698. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1699. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1700. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1701. return ok
  1702. }
  1703. // ResetDatasetID resets all changes to the "dataset_id" field.
  1704. func (m *AgentBaseMutation) ResetDatasetID() {
  1705. m.dataset_id = nil
  1706. delete(m.clearedFields, agentbase.FieldDatasetID)
  1707. }
  1708. // SetCollectionID sets the "collection_id" field.
  1709. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1710. m.collection_id = &s
  1711. }
  1712. // CollectionID returns the value of the "collection_id" field in the mutation.
  1713. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1714. v := m.collection_id
  1715. if v == nil {
  1716. return
  1717. }
  1718. return *v, true
  1719. }
  1720. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1721. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1723. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1724. if !m.op.Is(OpUpdateOne) {
  1725. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1726. }
  1727. if m.id == nil || m.oldValue == nil {
  1728. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1729. }
  1730. oldValue, err := m.oldValue(ctx)
  1731. if err != nil {
  1732. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1733. }
  1734. return oldValue.CollectionID, nil
  1735. }
  1736. // ClearCollectionID clears the value of the "collection_id" field.
  1737. func (m *AgentBaseMutation) ClearCollectionID() {
  1738. m.collection_id = nil
  1739. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1740. }
  1741. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1742. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1743. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1744. return ok
  1745. }
  1746. // ResetCollectionID resets all changes to the "collection_id" field.
  1747. func (m *AgentBaseMutation) ResetCollectionID() {
  1748. m.collection_id = nil
  1749. delete(m.clearedFields, agentbase.FieldCollectionID)
  1750. }
  1751. // SetSourceName sets the "source_name" field.
  1752. func (m *AgentBaseMutation) SetSourceName(s string) {
  1753. m.source_name = &s
  1754. }
  1755. // SourceName returns the value of the "source_name" field in the mutation.
  1756. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1757. v := m.source_name
  1758. if v == nil {
  1759. return
  1760. }
  1761. return *v, true
  1762. }
  1763. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1764. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1766. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1767. if !m.op.Is(OpUpdateOne) {
  1768. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1769. }
  1770. if m.id == nil || m.oldValue == nil {
  1771. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1772. }
  1773. oldValue, err := m.oldValue(ctx)
  1774. if err != nil {
  1775. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1776. }
  1777. return oldValue.SourceName, nil
  1778. }
  1779. // ClearSourceName clears the value of the "source_name" field.
  1780. func (m *AgentBaseMutation) ClearSourceName() {
  1781. m.source_name = nil
  1782. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1783. }
  1784. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1785. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1786. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1787. return ok
  1788. }
  1789. // ResetSourceName resets all changes to the "source_name" field.
  1790. func (m *AgentBaseMutation) ResetSourceName() {
  1791. m.source_name = nil
  1792. delete(m.clearedFields, agentbase.FieldSourceName)
  1793. }
  1794. // SetCanWrite sets the "can_write" field.
  1795. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1796. m.can_write = &b
  1797. m.appendcan_write = nil
  1798. }
  1799. // CanWrite returns the value of the "can_write" field in the mutation.
  1800. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1801. v := m.can_write
  1802. if v == nil {
  1803. return
  1804. }
  1805. return *v, true
  1806. }
  1807. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1808. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1810. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1811. if !m.op.Is(OpUpdateOne) {
  1812. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1813. }
  1814. if m.id == nil || m.oldValue == nil {
  1815. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1816. }
  1817. oldValue, err := m.oldValue(ctx)
  1818. if err != nil {
  1819. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1820. }
  1821. return oldValue.CanWrite, nil
  1822. }
  1823. // AppendCanWrite adds b to the "can_write" field.
  1824. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1825. m.appendcan_write = append(m.appendcan_write, b...)
  1826. }
  1827. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1828. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1829. if len(m.appendcan_write) == 0 {
  1830. return nil, false
  1831. }
  1832. return m.appendcan_write, true
  1833. }
  1834. // ClearCanWrite clears the value of the "can_write" field.
  1835. func (m *AgentBaseMutation) ClearCanWrite() {
  1836. m.can_write = nil
  1837. m.appendcan_write = nil
  1838. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1839. }
  1840. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1841. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1842. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1843. return ok
  1844. }
  1845. // ResetCanWrite resets all changes to the "can_write" field.
  1846. func (m *AgentBaseMutation) ResetCanWrite() {
  1847. m.can_write = nil
  1848. m.appendcan_write = nil
  1849. delete(m.clearedFields, agentbase.FieldCanWrite)
  1850. }
  1851. // SetIsOwner sets the "is_owner" field.
  1852. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1853. m.is_owner = &b
  1854. m.appendis_owner = nil
  1855. }
  1856. // IsOwner returns the value of the "is_owner" field in the mutation.
  1857. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1858. v := m.is_owner
  1859. if v == nil {
  1860. return
  1861. }
  1862. return *v, true
  1863. }
  1864. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1865. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1867. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1868. if !m.op.Is(OpUpdateOne) {
  1869. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1870. }
  1871. if m.id == nil || m.oldValue == nil {
  1872. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1873. }
  1874. oldValue, err := m.oldValue(ctx)
  1875. if err != nil {
  1876. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1877. }
  1878. return oldValue.IsOwner, nil
  1879. }
  1880. // AppendIsOwner adds b to the "is_owner" field.
  1881. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1882. m.appendis_owner = append(m.appendis_owner, b...)
  1883. }
  1884. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1885. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1886. if len(m.appendis_owner) == 0 {
  1887. return nil, false
  1888. }
  1889. return m.appendis_owner, true
  1890. }
  1891. // ClearIsOwner clears the value of the "is_owner" field.
  1892. func (m *AgentBaseMutation) ClearIsOwner() {
  1893. m.is_owner = nil
  1894. m.appendis_owner = nil
  1895. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1896. }
  1897. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1898. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1899. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1900. return ok
  1901. }
  1902. // ResetIsOwner resets all changes to the "is_owner" field.
  1903. func (m *AgentBaseMutation) ResetIsOwner() {
  1904. m.is_owner = nil
  1905. m.appendis_owner = nil
  1906. delete(m.clearedFields, agentbase.FieldIsOwner)
  1907. }
  1908. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1909. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1910. if m.wx_agent == nil {
  1911. m.wx_agent = make(map[uint64]struct{})
  1912. }
  1913. for i := range ids {
  1914. m.wx_agent[ids[i]] = struct{}{}
  1915. }
  1916. }
  1917. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1918. func (m *AgentBaseMutation) ClearWxAgent() {
  1919. m.clearedwx_agent = true
  1920. }
  1921. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1922. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1923. return m.clearedwx_agent
  1924. }
  1925. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1926. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1927. if m.removedwx_agent == nil {
  1928. m.removedwx_agent = make(map[uint64]struct{})
  1929. }
  1930. for i := range ids {
  1931. delete(m.wx_agent, ids[i])
  1932. m.removedwx_agent[ids[i]] = struct{}{}
  1933. }
  1934. }
  1935. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1936. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1937. for id := range m.removedwx_agent {
  1938. ids = append(ids, id)
  1939. }
  1940. return
  1941. }
  1942. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1943. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1944. for id := range m.wx_agent {
  1945. ids = append(ids, id)
  1946. }
  1947. return
  1948. }
  1949. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1950. func (m *AgentBaseMutation) ResetWxAgent() {
  1951. m.wx_agent = nil
  1952. m.clearedwx_agent = false
  1953. m.removedwx_agent = nil
  1954. }
  1955. // Where appends a list predicates to the AgentBaseMutation builder.
  1956. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1957. m.predicates = append(m.predicates, ps...)
  1958. }
  1959. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1960. // users can use type-assertion to append predicates that do not depend on any generated package.
  1961. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1962. p := make([]predicate.AgentBase, len(ps))
  1963. for i := range ps {
  1964. p[i] = ps[i]
  1965. }
  1966. m.Where(p...)
  1967. }
  1968. // Op returns the operation name.
  1969. func (m *AgentBaseMutation) Op() Op {
  1970. return m.op
  1971. }
  1972. // SetOp allows setting the mutation operation.
  1973. func (m *AgentBaseMutation) SetOp(op Op) {
  1974. m.op = op
  1975. }
  1976. // Type returns the node type of this mutation (AgentBase).
  1977. func (m *AgentBaseMutation) Type() string {
  1978. return m.typ
  1979. }
  1980. // Fields returns all fields that were changed during this mutation. Note that in
  1981. // order to get all numeric fields that were incremented/decremented, call
  1982. // AddedFields().
  1983. func (m *AgentBaseMutation) Fields() []string {
  1984. fields := make([]string, 0, 9)
  1985. if m.q != nil {
  1986. fields = append(fields, agentbase.FieldQ)
  1987. }
  1988. if m.a != nil {
  1989. fields = append(fields, agentbase.FieldA)
  1990. }
  1991. if m.chunk_index != nil {
  1992. fields = append(fields, agentbase.FieldChunkIndex)
  1993. }
  1994. if m.indexes != nil {
  1995. fields = append(fields, agentbase.FieldIndexes)
  1996. }
  1997. if m.dataset_id != nil {
  1998. fields = append(fields, agentbase.FieldDatasetID)
  1999. }
  2000. if m.collection_id != nil {
  2001. fields = append(fields, agentbase.FieldCollectionID)
  2002. }
  2003. if m.source_name != nil {
  2004. fields = append(fields, agentbase.FieldSourceName)
  2005. }
  2006. if m.can_write != nil {
  2007. fields = append(fields, agentbase.FieldCanWrite)
  2008. }
  2009. if m.is_owner != nil {
  2010. fields = append(fields, agentbase.FieldIsOwner)
  2011. }
  2012. return fields
  2013. }
  2014. // Field returns the value of a field with the given name. The second boolean
  2015. // return value indicates that this field was not set, or was not defined in the
  2016. // schema.
  2017. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2018. switch name {
  2019. case agentbase.FieldQ:
  2020. return m.Q()
  2021. case agentbase.FieldA:
  2022. return m.A()
  2023. case agentbase.FieldChunkIndex:
  2024. return m.ChunkIndex()
  2025. case agentbase.FieldIndexes:
  2026. return m.Indexes()
  2027. case agentbase.FieldDatasetID:
  2028. return m.DatasetID()
  2029. case agentbase.FieldCollectionID:
  2030. return m.CollectionID()
  2031. case agentbase.FieldSourceName:
  2032. return m.SourceName()
  2033. case agentbase.FieldCanWrite:
  2034. return m.CanWrite()
  2035. case agentbase.FieldIsOwner:
  2036. return m.IsOwner()
  2037. }
  2038. return nil, false
  2039. }
  2040. // OldField returns the old value of the field from the database. An error is
  2041. // returned if the mutation operation is not UpdateOne, or the query to the
  2042. // database failed.
  2043. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2044. switch name {
  2045. case agentbase.FieldQ:
  2046. return m.OldQ(ctx)
  2047. case agentbase.FieldA:
  2048. return m.OldA(ctx)
  2049. case agentbase.FieldChunkIndex:
  2050. return m.OldChunkIndex(ctx)
  2051. case agentbase.FieldIndexes:
  2052. return m.OldIndexes(ctx)
  2053. case agentbase.FieldDatasetID:
  2054. return m.OldDatasetID(ctx)
  2055. case agentbase.FieldCollectionID:
  2056. return m.OldCollectionID(ctx)
  2057. case agentbase.FieldSourceName:
  2058. return m.OldSourceName(ctx)
  2059. case agentbase.FieldCanWrite:
  2060. return m.OldCanWrite(ctx)
  2061. case agentbase.FieldIsOwner:
  2062. return m.OldIsOwner(ctx)
  2063. }
  2064. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2065. }
  2066. // SetField sets the value of a field with the given name. It returns an error if
  2067. // the field is not defined in the schema, or if the type mismatched the field
  2068. // type.
  2069. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2070. switch name {
  2071. case agentbase.FieldQ:
  2072. v, ok := value.(string)
  2073. if !ok {
  2074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2075. }
  2076. m.SetQ(v)
  2077. return nil
  2078. case agentbase.FieldA:
  2079. v, ok := value.(string)
  2080. if !ok {
  2081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2082. }
  2083. m.SetA(v)
  2084. return nil
  2085. case agentbase.FieldChunkIndex:
  2086. v, ok := value.(uint64)
  2087. if !ok {
  2088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2089. }
  2090. m.SetChunkIndex(v)
  2091. return nil
  2092. case agentbase.FieldIndexes:
  2093. v, ok := value.([]string)
  2094. if !ok {
  2095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2096. }
  2097. m.SetIndexes(v)
  2098. return nil
  2099. case agentbase.FieldDatasetID:
  2100. v, ok := value.(string)
  2101. if !ok {
  2102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2103. }
  2104. m.SetDatasetID(v)
  2105. return nil
  2106. case agentbase.FieldCollectionID:
  2107. v, ok := value.(string)
  2108. if !ok {
  2109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2110. }
  2111. m.SetCollectionID(v)
  2112. return nil
  2113. case agentbase.FieldSourceName:
  2114. v, ok := value.(string)
  2115. if !ok {
  2116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2117. }
  2118. m.SetSourceName(v)
  2119. return nil
  2120. case agentbase.FieldCanWrite:
  2121. v, ok := value.([]bool)
  2122. if !ok {
  2123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2124. }
  2125. m.SetCanWrite(v)
  2126. return nil
  2127. case agentbase.FieldIsOwner:
  2128. v, ok := value.([]bool)
  2129. if !ok {
  2130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2131. }
  2132. m.SetIsOwner(v)
  2133. return nil
  2134. }
  2135. return fmt.Errorf("unknown AgentBase field %s", name)
  2136. }
  2137. // AddedFields returns all numeric fields that were incremented/decremented during
  2138. // this mutation.
  2139. func (m *AgentBaseMutation) AddedFields() []string {
  2140. var fields []string
  2141. if m.addchunk_index != nil {
  2142. fields = append(fields, agentbase.FieldChunkIndex)
  2143. }
  2144. return fields
  2145. }
  2146. // AddedField returns the numeric value that was incremented/decremented on a field
  2147. // with the given name. The second boolean return value indicates that this field
  2148. // was not set, or was not defined in the schema.
  2149. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2150. switch name {
  2151. case agentbase.FieldChunkIndex:
  2152. return m.AddedChunkIndex()
  2153. }
  2154. return nil, false
  2155. }
  2156. // AddField adds the value to the field with the given name. It returns an error if
  2157. // the field is not defined in the schema, or if the type mismatched the field
  2158. // type.
  2159. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2160. switch name {
  2161. case agentbase.FieldChunkIndex:
  2162. v, ok := value.(int64)
  2163. if !ok {
  2164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2165. }
  2166. m.AddChunkIndex(v)
  2167. return nil
  2168. }
  2169. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2170. }
  2171. // ClearedFields returns all nullable fields that were cleared during this
  2172. // mutation.
  2173. func (m *AgentBaseMutation) ClearedFields() []string {
  2174. var fields []string
  2175. if m.FieldCleared(agentbase.FieldQ) {
  2176. fields = append(fields, agentbase.FieldQ)
  2177. }
  2178. if m.FieldCleared(agentbase.FieldA) {
  2179. fields = append(fields, agentbase.FieldA)
  2180. }
  2181. if m.FieldCleared(agentbase.FieldIndexes) {
  2182. fields = append(fields, agentbase.FieldIndexes)
  2183. }
  2184. if m.FieldCleared(agentbase.FieldDatasetID) {
  2185. fields = append(fields, agentbase.FieldDatasetID)
  2186. }
  2187. if m.FieldCleared(agentbase.FieldCollectionID) {
  2188. fields = append(fields, agentbase.FieldCollectionID)
  2189. }
  2190. if m.FieldCleared(agentbase.FieldSourceName) {
  2191. fields = append(fields, agentbase.FieldSourceName)
  2192. }
  2193. if m.FieldCleared(agentbase.FieldCanWrite) {
  2194. fields = append(fields, agentbase.FieldCanWrite)
  2195. }
  2196. if m.FieldCleared(agentbase.FieldIsOwner) {
  2197. fields = append(fields, agentbase.FieldIsOwner)
  2198. }
  2199. return fields
  2200. }
  2201. // FieldCleared returns a boolean indicating if a field with the given name was
  2202. // cleared in this mutation.
  2203. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2204. _, ok := m.clearedFields[name]
  2205. return ok
  2206. }
  2207. // ClearField clears the value of the field with the given name. It returns an
  2208. // error if the field is not defined in the schema.
  2209. func (m *AgentBaseMutation) ClearField(name string) error {
  2210. switch name {
  2211. case agentbase.FieldQ:
  2212. m.ClearQ()
  2213. return nil
  2214. case agentbase.FieldA:
  2215. m.ClearA()
  2216. return nil
  2217. case agentbase.FieldIndexes:
  2218. m.ClearIndexes()
  2219. return nil
  2220. case agentbase.FieldDatasetID:
  2221. m.ClearDatasetID()
  2222. return nil
  2223. case agentbase.FieldCollectionID:
  2224. m.ClearCollectionID()
  2225. return nil
  2226. case agentbase.FieldSourceName:
  2227. m.ClearSourceName()
  2228. return nil
  2229. case agentbase.FieldCanWrite:
  2230. m.ClearCanWrite()
  2231. return nil
  2232. case agentbase.FieldIsOwner:
  2233. m.ClearIsOwner()
  2234. return nil
  2235. }
  2236. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2237. }
  2238. // ResetField resets all changes in the mutation for the field with the given name.
  2239. // It returns an error if the field is not defined in the schema.
  2240. func (m *AgentBaseMutation) ResetField(name string) error {
  2241. switch name {
  2242. case agentbase.FieldQ:
  2243. m.ResetQ()
  2244. return nil
  2245. case agentbase.FieldA:
  2246. m.ResetA()
  2247. return nil
  2248. case agentbase.FieldChunkIndex:
  2249. m.ResetChunkIndex()
  2250. return nil
  2251. case agentbase.FieldIndexes:
  2252. m.ResetIndexes()
  2253. return nil
  2254. case agentbase.FieldDatasetID:
  2255. m.ResetDatasetID()
  2256. return nil
  2257. case agentbase.FieldCollectionID:
  2258. m.ResetCollectionID()
  2259. return nil
  2260. case agentbase.FieldSourceName:
  2261. m.ResetSourceName()
  2262. return nil
  2263. case agentbase.FieldCanWrite:
  2264. m.ResetCanWrite()
  2265. return nil
  2266. case agentbase.FieldIsOwner:
  2267. m.ResetIsOwner()
  2268. return nil
  2269. }
  2270. return fmt.Errorf("unknown AgentBase field %s", name)
  2271. }
  2272. // AddedEdges returns all edge names that were set/added in this mutation.
  2273. func (m *AgentBaseMutation) AddedEdges() []string {
  2274. edges := make([]string, 0, 1)
  2275. if m.wx_agent != nil {
  2276. edges = append(edges, agentbase.EdgeWxAgent)
  2277. }
  2278. return edges
  2279. }
  2280. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2281. // name in this mutation.
  2282. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2283. switch name {
  2284. case agentbase.EdgeWxAgent:
  2285. ids := make([]ent.Value, 0, len(m.wx_agent))
  2286. for id := range m.wx_agent {
  2287. ids = append(ids, id)
  2288. }
  2289. return ids
  2290. }
  2291. return nil
  2292. }
  2293. // RemovedEdges returns all edge names that were removed in this mutation.
  2294. func (m *AgentBaseMutation) RemovedEdges() []string {
  2295. edges := make([]string, 0, 1)
  2296. if m.removedwx_agent != nil {
  2297. edges = append(edges, agentbase.EdgeWxAgent)
  2298. }
  2299. return edges
  2300. }
  2301. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2302. // the given name in this mutation.
  2303. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2304. switch name {
  2305. case agentbase.EdgeWxAgent:
  2306. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2307. for id := range m.removedwx_agent {
  2308. ids = append(ids, id)
  2309. }
  2310. return ids
  2311. }
  2312. return nil
  2313. }
  2314. // ClearedEdges returns all edge names that were cleared in this mutation.
  2315. func (m *AgentBaseMutation) ClearedEdges() []string {
  2316. edges := make([]string, 0, 1)
  2317. if m.clearedwx_agent {
  2318. edges = append(edges, agentbase.EdgeWxAgent)
  2319. }
  2320. return edges
  2321. }
  2322. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2323. // was cleared in this mutation.
  2324. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2325. switch name {
  2326. case agentbase.EdgeWxAgent:
  2327. return m.clearedwx_agent
  2328. }
  2329. return false
  2330. }
  2331. // ClearEdge clears the value of the edge with the given name. It returns an error
  2332. // if that edge is not defined in the schema.
  2333. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2334. switch name {
  2335. }
  2336. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2337. }
  2338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2339. // It returns an error if the edge is not defined in the schema.
  2340. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2341. switch name {
  2342. case agentbase.EdgeWxAgent:
  2343. m.ResetWxAgent()
  2344. return nil
  2345. }
  2346. return fmt.Errorf("unknown AgentBase edge %s", name)
  2347. }
  2348. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2349. type AliyunAvatarMutation struct {
  2350. config
  2351. op Op
  2352. typ string
  2353. id *uint64
  2354. created_at *time.Time
  2355. updated_at *time.Time
  2356. deleted_at *time.Time
  2357. user_id *uint64
  2358. adduser_id *int64
  2359. biz_id *string
  2360. access_key_id *string
  2361. access_key_secret *string
  2362. app_id *string
  2363. tenant_id *uint64
  2364. addtenant_id *int64
  2365. response *string
  2366. token *string
  2367. session_id *string
  2368. clearedFields map[string]struct{}
  2369. done bool
  2370. oldValue func(context.Context) (*AliyunAvatar, error)
  2371. predicates []predicate.AliyunAvatar
  2372. }
  2373. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2374. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2375. type aliyunavatarOption func(*AliyunAvatarMutation)
  2376. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2377. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2378. m := &AliyunAvatarMutation{
  2379. config: c,
  2380. op: op,
  2381. typ: TypeAliyunAvatar,
  2382. clearedFields: make(map[string]struct{}),
  2383. }
  2384. for _, opt := range opts {
  2385. opt(m)
  2386. }
  2387. return m
  2388. }
  2389. // withAliyunAvatarID sets the ID field of the mutation.
  2390. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2391. return func(m *AliyunAvatarMutation) {
  2392. var (
  2393. err error
  2394. once sync.Once
  2395. value *AliyunAvatar
  2396. )
  2397. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2398. once.Do(func() {
  2399. if m.done {
  2400. err = errors.New("querying old values post mutation is not allowed")
  2401. } else {
  2402. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2403. }
  2404. })
  2405. return value, err
  2406. }
  2407. m.id = &id
  2408. }
  2409. }
  2410. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2411. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2412. return func(m *AliyunAvatarMutation) {
  2413. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2414. return node, nil
  2415. }
  2416. m.id = &node.ID
  2417. }
  2418. }
  2419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2420. // executed in a transaction (ent.Tx), a transactional client is returned.
  2421. func (m AliyunAvatarMutation) Client() *Client {
  2422. client := &Client{config: m.config}
  2423. client.init()
  2424. return client
  2425. }
  2426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2427. // it returns an error otherwise.
  2428. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2429. if _, ok := m.driver.(*txDriver); !ok {
  2430. return nil, errors.New("ent: mutation is not running in a transaction")
  2431. }
  2432. tx := &Tx{config: m.config}
  2433. tx.init()
  2434. return tx, nil
  2435. }
  2436. // SetID sets the value of the id field. Note that this
  2437. // operation is only accepted on creation of AliyunAvatar entities.
  2438. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2439. m.id = &id
  2440. }
  2441. // ID returns the ID value in the mutation. Note that the ID is only available
  2442. // if it was provided to the builder or after it was returned from the database.
  2443. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2444. if m.id == nil {
  2445. return
  2446. }
  2447. return *m.id, true
  2448. }
  2449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2450. // That means, if the mutation is applied within a transaction with an isolation level such
  2451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2452. // or updated by the mutation.
  2453. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2454. switch {
  2455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2456. id, exists := m.ID()
  2457. if exists {
  2458. return []uint64{id}, nil
  2459. }
  2460. fallthrough
  2461. case m.op.Is(OpUpdate | OpDelete):
  2462. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2463. default:
  2464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2465. }
  2466. }
  2467. // SetCreatedAt sets the "created_at" field.
  2468. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2469. m.created_at = &t
  2470. }
  2471. // CreatedAt returns the value of the "created_at" field in the mutation.
  2472. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2473. v := m.created_at
  2474. if v == nil {
  2475. return
  2476. }
  2477. return *v, true
  2478. }
  2479. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2480. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2482. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2483. if !m.op.Is(OpUpdateOne) {
  2484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2485. }
  2486. if m.id == nil || m.oldValue == nil {
  2487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2488. }
  2489. oldValue, err := m.oldValue(ctx)
  2490. if err != nil {
  2491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2492. }
  2493. return oldValue.CreatedAt, nil
  2494. }
  2495. // ResetCreatedAt resets all changes to the "created_at" field.
  2496. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2497. m.created_at = nil
  2498. }
  2499. // SetUpdatedAt sets the "updated_at" field.
  2500. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2501. m.updated_at = &t
  2502. }
  2503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2504. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2505. v := m.updated_at
  2506. if v == nil {
  2507. return
  2508. }
  2509. return *v, true
  2510. }
  2511. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2512. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2514. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2515. if !m.op.Is(OpUpdateOne) {
  2516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2517. }
  2518. if m.id == nil || m.oldValue == nil {
  2519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2520. }
  2521. oldValue, err := m.oldValue(ctx)
  2522. if err != nil {
  2523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2524. }
  2525. return oldValue.UpdatedAt, nil
  2526. }
  2527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2528. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2529. m.updated_at = nil
  2530. }
  2531. // SetDeletedAt sets the "deleted_at" field.
  2532. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2533. m.deleted_at = &t
  2534. }
  2535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2536. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2537. v := m.deleted_at
  2538. if v == nil {
  2539. return
  2540. }
  2541. return *v, true
  2542. }
  2543. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2544. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2546. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2547. if !m.op.Is(OpUpdateOne) {
  2548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2549. }
  2550. if m.id == nil || m.oldValue == nil {
  2551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2552. }
  2553. oldValue, err := m.oldValue(ctx)
  2554. if err != nil {
  2555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2556. }
  2557. return oldValue.DeletedAt, nil
  2558. }
  2559. // ClearDeletedAt clears the value of the "deleted_at" field.
  2560. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2561. m.deleted_at = nil
  2562. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2563. }
  2564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2565. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2566. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2567. return ok
  2568. }
  2569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2570. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2571. m.deleted_at = nil
  2572. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2573. }
  2574. // SetUserID sets the "user_id" field.
  2575. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2576. m.user_id = &u
  2577. m.adduser_id = nil
  2578. }
  2579. // UserID returns the value of the "user_id" field in the mutation.
  2580. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2581. v := m.user_id
  2582. if v == nil {
  2583. return
  2584. }
  2585. return *v, true
  2586. }
  2587. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2588. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2590. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2591. if !m.op.Is(OpUpdateOne) {
  2592. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2593. }
  2594. if m.id == nil || m.oldValue == nil {
  2595. return v, errors.New("OldUserID requires an ID field in the mutation")
  2596. }
  2597. oldValue, err := m.oldValue(ctx)
  2598. if err != nil {
  2599. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2600. }
  2601. return oldValue.UserID, nil
  2602. }
  2603. // AddUserID adds u to the "user_id" field.
  2604. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2605. if m.adduser_id != nil {
  2606. *m.adduser_id += u
  2607. } else {
  2608. m.adduser_id = &u
  2609. }
  2610. }
  2611. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2612. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2613. v := m.adduser_id
  2614. if v == nil {
  2615. return
  2616. }
  2617. return *v, true
  2618. }
  2619. // ResetUserID resets all changes to the "user_id" field.
  2620. func (m *AliyunAvatarMutation) ResetUserID() {
  2621. m.user_id = nil
  2622. m.adduser_id = nil
  2623. }
  2624. // SetBizID sets the "biz_id" field.
  2625. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2626. m.biz_id = &s
  2627. }
  2628. // BizID returns the value of the "biz_id" field in the mutation.
  2629. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2630. v := m.biz_id
  2631. if v == nil {
  2632. return
  2633. }
  2634. return *v, true
  2635. }
  2636. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2637. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2639. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2640. if !m.op.Is(OpUpdateOne) {
  2641. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2642. }
  2643. if m.id == nil || m.oldValue == nil {
  2644. return v, errors.New("OldBizID requires an ID field in the mutation")
  2645. }
  2646. oldValue, err := m.oldValue(ctx)
  2647. if err != nil {
  2648. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2649. }
  2650. return oldValue.BizID, nil
  2651. }
  2652. // ResetBizID resets all changes to the "biz_id" field.
  2653. func (m *AliyunAvatarMutation) ResetBizID() {
  2654. m.biz_id = nil
  2655. }
  2656. // SetAccessKeyID sets the "access_key_id" field.
  2657. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2658. m.access_key_id = &s
  2659. }
  2660. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2661. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2662. v := m.access_key_id
  2663. if v == nil {
  2664. return
  2665. }
  2666. return *v, true
  2667. }
  2668. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2669. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2671. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2672. if !m.op.Is(OpUpdateOne) {
  2673. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2674. }
  2675. if m.id == nil || m.oldValue == nil {
  2676. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2677. }
  2678. oldValue, err := m.oldValue(ctx)
  2679. if err != nil {
  2680. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2681. }
  2682. return oldValue.AccessKeyID, nil
  2683. }
  2684. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2685. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2686. m.access_key_id = nil
  2687. }
  2688. // SetAccessKeySecret sets the "access_key_secret" field.
  2689. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2690. m.access_key_secret = &s
  2691. }
  2692. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2693. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2694. v := m.access_key_secret
  2695. if v == nil {
  2696. return
  2697. }
  2698. return *v, true
  2699. }
  2700. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2701. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2703. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2704. if !m.op.Is(OpUpdateOne) {
  2705. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2706. }
  2707. if m.id == nil || m.oldValue == nil {
  2708. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2709. }
  2710. oldValue, err := m.oldValue(ctx)
  2711. if err != nil {
  2712. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2713. }
  2714. return oldValue.AccessKeySecret, nil
  2715. }
  2716. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2717. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2718. m.access_key_secret = nil
  2719. }
  2720. // SetAppID sets the "app_id" field.
  2721. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2722. m.app_id = &s
  2723. }
  2724. // AppID returns the value of the "app_id" field in the mutation.
  2725. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2726. v := m.app_id
  2727. if v == nil {
  2728. return
  2729. }
  2730. return *v, true
  2731. }
  2732. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2733. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2735. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2736. if !m.op.Is(OpUpdateOne) {
  2737. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2738. }
  2739. if m.id == nil || m.oldValue == nil {
  2740. return v, errors.New("OldAppID requires an ID field in the mutation")
  2741. }
  2742. oldValue, err := m.oldValue(ctx)
  2743. if err != nil {
  2744. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2745. }
  2746. return oldValue.AppID, nil
  2747. }
  2748. // ClearAppID clears the value of the "app_id" field.
  2749. func (m *AliyunAvatarMutation) ClearAppID() {
  2750. m.app_id = nil
  2751. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2752. }
  2753. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2754. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2755. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2756. return ok
  2757. }
  2758. // ResetAppID resets all changes to the "app_id" field.
  2759. func (m *AliyunAvatarMutation) ResetAppID() {
  2760. m.app_id = nil
  2761. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2762. }
  2763. // SetTenantID sets the "tenant_id" field.
  2764. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2765. m.tenant_id = &u
  2766. m.addtenant_id = nil
  2767. }
  2768. // TenantID returns the value of the "tenant_id" field in the mutation.
  2769. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2770. v := m.tenant_id
  2771. if v == nil {
  2772. return
  2773. }
  2774. return *v, true
  2775. }
  2776. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2777. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2779. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2780. if !m.op.Is(OpUpdateOne) {
  2781. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2782. }
  2783. if m.id == nil || m.oldValue == nil {
  2784. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2785. }
  2786. oldValue, err := m.oldValue(ctx)
  2787. if err != nil {
  2788. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2789. }
  2790. return oldValue.TenantID, nil
  2791. }
  2792. // AddTenantID adds u to the "tenant_id" field.
  2793. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2794. if m.addtenant_id != nil {
  2795. *m.addtenant_id += u
  2796. } else {
  2797. m.addtenant_id = &u
  2798. }
  2799. }
  2800. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2801. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2802. v := m.addtenant_id
  2803. if v == nil {
  2804. return
  2805. }
  2806. return *v, true
  2807. }
  2808. // ResetTenantID resets all changes to the "tenant_id" field.
  2809. func (m *AliyunAvatarMutation) ResetTenantID() {
  2810. m.tenant_id = nil
  2811. m.addtenant_id = nil
  2812. }
  2813. // SetResponse sets the "response" field.
  2814. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2815. m.response = &s
  2816. }
  2817. // Response returns the value of the "response" field in the mutation.
  2818. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2819. v := m.response
  2820. if v == nil {
  2821. return
  2822. }
  2823. return *v, true
  2824. }
  2825. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2826. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2828. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2829. if !m.op.Is(OpUpdateOne) {
  2830. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2831. }
  2832. if m.id == nil || m.oldValue == nil {
  2833. return v, errors.New("OldResponse requires an ID field in the mutation")
  2834. }
  2835. oldValue, err := m.oldValue(ctx)
  2836. if err != nil {
  2837. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2838. }
  2839. return oldValue.Response, nil
  2840. }
  2841. // ResetResponse resets all changes to the "response" field.
  2842. func (m *AliyunAvatarMutation) ResetResponse() {
  2843. m.response = nil
  2844. }
  2845. // SetToken sets the "token" field.
  2846. func (m *AliyunAvatarMutation) SetToken(s string) {
  2847. m.token = &s
  2848. }
  2849. // Token returns the value of the "token" field in the mutation.
  2850. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2851. v := m.token
  2852. if v == nil {
  2853. return
  2854. }
  2855. return *v, true
  2856. }
  2857. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2858. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2860. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2861. if !m.op.Is(OpUpdateOne) {
  2862. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2863. }
  2864. if m.id == nil || m.oldValue == nil {
  2865. return v, errors.New("OldToken requires an ID field in the mutation")
  2866. }
  2867. oldValue, err := m.oldValue(ctx)
  2868. if err != nil {
  2869. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2870. }
  2871. return oldValue.Token, nil
  2872. }
  2873. // ResetToken resets all changes to the "token" field.
  2874. func (m *AliyunAvatarMutation) ResetToken() {
  2875. m.token = nil
  2876. }
  2877. // SetSessionID sets the "session_id" field.
  2878. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2879. m.session_id = &s
  2880. }
  2881. // SessionID returns the value of the "session_id" field in the mutation.
  2882. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2883. v := m.session_id
  2884. if v == nil {
  2885. return
  2886. }
  2887. return *v, true
  2888. }
  2889. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2890. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2892. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2893. if !m.op.Is(OpUpdateOne) {
  2894. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2895. }
  2896. if m.id == nil || m.oldValue == nil {
  2897. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2898. }
  2899. oldValue, err := m.oldValue(ctx)
  2900. if err != nil {
  2901. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2902. }
  2903. return oldValue.SessionID, nil
  2904. }
  2905. // ResetSessionID resets all changes to the "session_id" field.
  2906. func (m *AliyunAvatarMutation) ResetSessionID() {
  2907. m.session_id = nil
  2908. }
  2909. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2910. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2911. m.predicates = append(m.predicates, ps...)
  2912. }
  2913. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2914. // users can use type-assertion to append predicates that do not depend on any generated package.
  2915. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2916. p := make([]predicate.AliyunAvatar, len(ps))
  2917. for i := range ps {
  2918. p[i] = ps[i]
  2919. }
  2920. m.Where(p...)
  2921. }
  2922. // Op returns the operation name.
  2923. func (m *AliyunAvatarMutation) Op() Op {
  2924. return m.op
  2925. }
  2926. // SetOp allows setting the mutation operation.
  2927. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2928. m.op = op
  2929. }
  2930. // Type returns the node type of this mutation (AliyunAvatar).
  2931. func (m *AliyunAvatarMutation) Type() string {
  2932. return m.typ
  2933. }
  2934. // Fields returns all fields that were changed during this mutation. Note that in
  2935. // order to get all numeric fields that were incremented/decremented, call
  2936. // AddedFields().
  2937. func (m *AliyunAvatarMutation) Fields() []string {
  2938. fields := make([]string, 0, 12)
  2939. if m.created_at != nil {
  2940. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2941. }
  2942. if m.updated_at != nil {
  2943. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2944. }
  2945. if m.deleted_at != nil {
  2946. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2947. }
  2948. if m.user_id != nil {
  2949. fields = append(fields, aliyunavatar.FieldUserID)
  2950. }
  2951. if m.biz_id != nil {
  2952. fields = append(fields, aliyunavatar.FieldBizID)
  2953. }
  2954. if m.access_key_id != nil {
  2955. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2956. }
  2957. if m.access_key_secret != nil {
  2958. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2959. }
  2960. if m.app_id != nil {
  2961. fields = append(fields, aliyunavatar.FieldAppID)
  2962. }
  2963. if m.tenant_id != nil {
  2964. fields = append(fields, aliyunavatar.FieldTenantID)
  2965. }
  2966. if m.response != nil {
  2967. fields = append(fields, aliyunavatar.FieldResponse)
  2968. }
  2969. if m.token != nil {
  2970. fields = append(fields, aliyunavatar.FieldToken)
  2971. }
  2972. if m.session_id != nil {
  2973. fields = append(fields, aliyunavatar.FieldSessionID)
  2974. }
  2975. return fields
  2976. }
  2977. // Field returns the value of a field with the given name. The second boolean
  2978. // return value indicates that this field was not set, or was not defined in the
  2979. // schema.
  2980. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2981. switch name {
  2982. case aliyunavatar.FieldCreatedAt:
  2983. return m.CreatedAt()
  2984. case aliyunavatar.FieldUpdatedAt:
  2985. return m.UpdatedAt()
  2986. case aliyunavatar.FieldDeletedAt:
  2987. return m.DeletedAt()
  2988. case aliyunavatar.FieldUserID:
  2989. return m.UserID()
  2990. case aliyunavatar.FieldBizID:
  2991. return m.BizID()
  2992. case aliyunavatar.FieldAccessKeyID:
  2993. return m.AccessKeyID()
  2994. case aliyunavatar.FieldAccessKeySecret:
  2995. return m.AccessKeySecret()
  2996. case aliyunavatar.FieldAppID:
  2997. return m.AppID()
  2998. case aliyunavatar.FieldTenantID:
  2999. return m.TenantID()
  3000. case aliyunavatar.FieldResponse:
  3001. return m.Response()
  3002. case aliyunavatar.FieldToken:
  3003. return m.Token()
  3004. case aliyunavatar.FieldSessionID:
  3005. return m.SessionID()
  3006. }
  3007. return nil, false
  3008. }
  3009. // OldField returns the old value of the field from the database. An error is
  3010. // returned if the mutation operation is not UpdateOne, or the query to the
  3011. // database failed.
  3012. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3013. switch name {
  3014. case aliyunavatar.FieldCreatedAt:
  3015. return m.OldCreatedAt(ctx)
  3016. case aliyunavatar.FieldUpdatedAt:
  3017. return m.OldUpdatedAt(ctx)
  3018. case aliyunavatar.FieldDeletedAt:
  3019. return m.OldDeletedAt(ctx)
  3020. case aliyunavatar.FieldUserID:
  3021. return m.OldUserID(ctx)
  3022. case aliyunavatar.FieldBizID:
  3023. return m.OldBizID(ctx)
  3024. case aliyunavatar.FieldAccessKeyID:
  3025. return m.OldAccessKeyID(ctx)
  3026. case aliyunavatar.FieldAccessKeySecret:
  3027. return m.OldAccessKeySecret(ctx)
  3028. case aliyunavatar.FieldAppID:
  3029. return m.OldAppID(ctx)
  3030. case aliyunavatar.FieldTenantID:
  3031. return m.OldTenantID(ctx)
  3032. case aliyunavatar.FieldResponse:
  3033. return m.OldResponse(ctx)
  3034. case aliyunavatar.FieldToken:
  3035. return m.OldToken(ctx)
  3036. case aliyunavatar.FieldSessionID:
  3037. return m.OldSessionID(ctx)
  3038. }
  3039. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3040. }
  3041. // SetField sets the value of a field with the given name. It returns an error if
  3042. // the field is not defined in the schema, or if the type mismatched the field
  3043. // type.
  3044. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3045. switch name {
  3046. case aliyunavatar.FieldCreatedAt:
  3047. v, ok := value.(time.Time)
  3048. if !ok {
  3049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3050. }
  3051. m.SetCreatedAt(v)
  3052. return nil
  3053. case aliyunavatar.FieldUpdatedAt:
  3054. v, ok := value.(time.Time)
  3055. if !ok {
  3056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3057. }
  3058. m.SetUpdatedAt(v)
  3059. return nil
  3060. case aliyunavatar.FieldDeletedAt:
  3061. v, ok := value.(time.Time)
  3062. if !ok {
  3063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3064. }
  3065. m.SetDeletedAt(v)
  3066. return nil
  3067. case aliyunavatar.FieldUserID:
  3068. v, ok := value.(uint64)
  3069. if !ok {
  3070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3071. }
  3072. m.SetUserID(v)
  3073. return nil
  3074. case aliyunavatar.FieldBizID:
  3075. v, ok := value.(string)
  3076. if !ok {
  3077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3078. }
  3079. m.SetBizID(v)
  3080. return nil
  3081. case aliyunavatar.FieldAccessKeyID:
  3082. v, ok := value.(string)
  3083. if !ok {
  3084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3085. }
  3086. m.SetAccessKeyID(v)
  3087. return nil
  3088. case aliyunavatar.FieldAccessKeySecret:
  3089. v, ok := value.(string)
  3090. if !ok {
  3091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3092. }
  3093. m.SetAccessKeySecret(v)
  3094. return nil
  3095. case aliyunavatar.FieldAppID:
  3096. v, ok := value.(string)
  3097. if !ok {
  3098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3099. }
  3100. m.SetAppID(v)
  3101. return nil
  3102. case aliyunavatar.FieldTenantID:
  3103. v, ok := value.(uint64)
  3104. if !ok {
  3105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3106. }
  3107. m.SetTenantID(v)
  3108. return nil
  3109. case aliyunavatar.FieldResponse:
  3110. v, ok := value.(string)
  3111. if !ok {
  3112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3113. }
  3114. m.SetResponse(v)
  3115. return nil
  3116. case aliyunavatar.FieldToken:
  3117. v, ok := value.(string)
  3118. if !ok {
  3119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3120. }
  3121. m.SetToken(v)
  3122. return nil
  3123. case aliyunavatar.FieldSessionID:
  3124. v, ok := value.(string)
  3125. if !ok {
  3126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3127. }
  3128. m.SetSessionID(v)
  3129. return nil
  3130. }
  3131. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3132. }
  3133. // AddedFields returns all numeric fields that were incremented/decremented during
  3134. // this mutation.
  3135. func (m *AliyunAvatarMutation) AddedFields() []string {
  3136. var fields []string
  3137. if m.adduser_id != nil {
  3138. fields = append(fields, aliyunavatar.FieldUserID)
  3139. }
  3140. if m.addtenant_id != nil {
  3141. fields = append(fields, aliyunavatar.FieldTenantID)
  3142. }
  3143. return fields
  3144. }
  3145. // AddedField returns the numeric value that was incremented/decremented on a field
  3146. // with the given name. The second boolean return value indicates that this field
  3147. // was not set, or was not defined in the schema.
  3148. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3149. switch name {
  3150. case aliyunavatar.FieldUserID:
  3151. return m.AddedUserID()
  3152. case aliyunavatar.FieldTenantID:
  3153. return m.AddedTenantID()
  3154. }
  3155. return nil, false
  3156. }
  3157. // AddField adds the value to the field with the given name. It returns an error if
  3158. // the field is not defined in the schema, or if the type mismatched the field
  3159. // type.
  3160. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3161. switch name {
  3162. case aliyunavatar.FieldUserID:
  3163. v, ok := value.(int64)
  3164. if !ok {
  3165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3166. }
  3167. m.AddUserID(v)
  3168. return nil
  3169. case aliyunavatar.FieldTenantID:
  3170. v, ok := value.(int64)
  3171. if !ok {
  3172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3173. }
  3174. m.AddTenantID(v)
  3175. return nil
  3176. }
  3177. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3178. }
  3179. // ClearedFields returns all nullable fields that were cleared during this
  3180. // mutation.
  3181. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3182. var fields []string
  3183. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3184. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3185. }
  3186. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3187. fields = append(fields, aliyunavatar.FieldAppID)
  3188. }
  3189. return fields
  3190. }
  3191. // FieldCleared returns a boolean indicating if a field with the given name was
  3192. // cleared in this mutation.
  3193. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3194. _, ok := m.clearedFields[name]
  3195. return ok
  3196. }
  3197. // ClearField clears the value of the field with the given name. It returns an
  3198. // error if the field is not defined in the schema.
  3199. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3200. switch name {
  3201. case aliyunavatar.FieldDeletedAt:
  3202. m.ClearDeletedAt()
  3203. return nil
  3204. case aliyunavatar.FieldAppID:
  3205. m.ClearAppID()
  3206. return nil
  3207. }
  3208. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3209. }
  3210. // ResetField resets all changes in the mutation for the field with the given name.
  3211. // It returns an error if the field is not defined in the schema.
  3212. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3213. switch name {
  3214. case aliyunavatar.FieldCreatedAt:
  3215. m.ResetCreatedAt()
  3216. return nil
  3217. case aliyunavatar.FieldUpdatedAt:
  3218. m.ResetUpdatedAt()
  3219. return nil
  3220. case aliyunavatar.FieldDeletedAt:
  3221. m.ResetDeletedAt()
  3222. return nil
  3223. case aliyunavatar.FieldUserID:
  3224. m.ResetUserID()
  3225. return nil
  3226. case aliyunavatar.FieldBizID:
  3227. m.ResetBizID()
  3228. return nil
  3229. case aliyunavatar.FieldAccessKeyID:
  3230. m.ResetAccessKeyID()
  3231. return nil
  3232. case aliyunavatar.FieldAccessKeySecret:
  3233. m.ResetAccessKeySecret()
  3234. return nil
  3235. case aliyunavatar.FieldAppID:
  3236. m.ResetAppID()
  3237. return nil
  3238. case aliyunavatar.FieldTenantID:
  3239. m.ResetTenantID()
  3240. return nil
  3241. case aliyunavatar.FieldResponse:
  3242. m.ResetResponse()
  3243. return nil
  3244. case aliyunavatar.FieldToken:
  3245. m.ResetToken()
  3246. return nil
  3247. case aliyunavatar.FieldSessionID:
  3248. m.ResetSessionID()
  3249. return nil
  3250. }
  3251. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3252. }
  3253. // AddedEdges returns all edge names that were set/added in this mutation.
  3254. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3255. edges := make([]string, 0, 0)
  3256. return edges
  3257. }
  3258. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3259. // name in this mutation.
  3260. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3261. return nil
  3262. }
  3263. // RemovedEdges returns all edge names that were removed in this mutation.
  3264. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3265. edges := make([]string, 0, 0)
  3266. return edges
  3267. }
  3268. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3269. // the given name in this mutation.
  3270. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3271. return nil
  3272. }
  3273. // ClearedEdges returns all edge names that were cleared in this mutation.
  3274. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3275. edges := make([]string, 0, 0)
  3276. return edges
  3277. }
  3278. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3279. // was cleared in this mutation.
  3280. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3281. return false
  3282. }
  3283. // ClearEdge clears the value of the edge with the given name. It returns an error
  3284. // if that edge is not defined in the schema.
  3285. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3286. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3287. }
  3288. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3289. // It returns an error if the edge is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3291. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3292. }
  3293. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3294. type AllocAgentMutation struct {
  3295. config
  3296. op Op
  3297. typ string
  3298. id *uint64
  3299. created_at *time.Time
  3300. updated_at *time.Time
  3301. deleted_at *time.Time
  3302. user_id *string
  3303. organization_id *uint64
  3304. addorganization_id *int64
  3305. agents *[]uint64
  3306. appendagents []uint64
  3307. status *int
  3308. addstatus *int
  3309. clearedFields map[string]struct{}
  3310. done bool
  3311. oldValue func(context.Context) (*AllocAgent, error)
  3312. predicates []predicate.AllocAgent
  3313. }
  3314. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3315. // allocagentOption allows management of the mutation configuration using functional options.
  3316. type allocagentOption func(*AllocAgentMutation)
  3317. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3318. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3319. m := &AllocAgentMutation{
  3320. config: c,
  3321. op: op,
  3322. typ: TypeAllocAgent,
  3323. clearedFields: make(map[string]struct{}),
  3324. }
  3325. for _, opt := range opts {
  3326. opt(m)
  3327. }
  3328. return m
  3329. }
  3330. // withAllocAgentID sets the ID field of the mutation.
  3331. func withAllocAgentID(id uint64) allocagentOption {
  3332. return func(m *AllocAgentMutation) {
  3333. var (
  3334. err error
  3335. once sync.Once
  3336. value *AllocAgent
  3337. )
  3338. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3339. once.Do(func() {
  3340. if m.done {
  3341. err = errors.New("querying old values post mutation is not allowed")
  3342. } else {
  3343. value, err = m.Client().AllocAgent.Get(ctx, id)
  3344. }
  3345. })
  3346. return value, err
  3347. }
  3348. m.id = &id
  3349. }
  3350. }
  3351. // withAllocAgent sets the old AllocAgent of the mutation.
  3352. func withAllocAgent(node *AllocAgent) allocagentOption {
  3353. return func(m *AllocAgentMutation) {
  3354. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3355. return node, nil
  3356. }
  3357. m.id = &node.ID
  3358. }
  3359. }
  3360. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3361. // executed in a transaction (ent.Tx), a transactional client is returned.
  3362. func (m AllocAgentMutation) Client() *Client {
  3363. client := &Client{config: m.config}
  3364. client.init()
  3365. return client
  3366. }
  3367. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3368. // it returns an error otherwise.
  3369. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3370. if _, ok := m.driver.(*txDriver); !ok {
  3371. return nil, errors.New("ent: mutation is not running in a transaction")
  3372. }
  3373. tx := &Tx{config: m.config}
  3374. tx.init()
  3375. return tx, nil
  3376. }
  3377. // SetID sets the value of the id field. Note that this
  3378. // operation is only accepted on creation of AllocAgent entities.
  3379. func (m *AllocAgentMutation) SetID(id uint64) {
  3380. m.id = &id
  3381. }
  3382. // ID returns the ID value in the mutation. Note that the ID is only available
  3383. // if it was provided to the builder or after it was returned from the database.
  3384. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3385. if m.id == nil {
  3386. return
  3387. }
  3388. return *m.id, true
  3389. }
  3390. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3391. // That means, if the mutation is applied within a transaction with an isolation level such
  3392. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3393. // or updated by the mutation.
  3394. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3395. switch {
  3396. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3397. id, exists := m.ID()
  3398. if exists {
  3399. return []uint64{id}, nil
  3400. }
  3401. fallthrough
  3402. case m.op.Is(OpUpdate | OpDelete):
  3403. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3404. default:
  3405. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3406. }
  3407. }
  3408. // SetCreatedAt sets the "created_at" field.
  3409. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3410. m.created_at = &t
  3411. }
  3412. // CreatedAt returns the value of the "created_at" field in the mutation.
  3413. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3414. v := m.created_at
  3415. if v == nil {
  3416. return
  3417. }
  3418. return *v, true
  3419. }
  3420. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3421. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3423. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3424. if !m.op.Is(OpUpdateOne) {
  3425. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3426. }
  3427. if m.id == nil || m.oldValue == nil {
  3428. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3429. }
  3430. oldValue, err := m.oldValue(ctx)
  3431. if err != nil {
  3432. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3433. }
  3434. return oldValue.CreatedAt, nil
  3435. }
  3436. // ResetCreatedAt resets all changes to the "created_at" field.
  3437. func (m *AllocAgentMutation) ResetCreatedAt() {
  3438. m.created_at = nil
  3439. }
  3440. // SetUpdatedAt sets the "updated_at" field.
  3441. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3442. m.updated_at = &t
  3443. }
  3444. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3445. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3446. v := m.updated_at
  3447. if v == nil {
  3448. return
  3449. }
  3450. return *v, true
  3451. }
  3452. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3453. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3455. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3456. if !m.op.Is(OpUpdateOne) {
  3457. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3458. }
  3459. if m.id == nil || m.oldValue == nil {
  3460. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3461. }
  3462. oldValue, err := m.oldValue(ctx)
  3463. if err != nil {
  3464. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3465. }
  3466. return oldValue.UpdatedAt, nil
  3467. }
  3468. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3469. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3470. m.updated_at = nil
  3471. }
  3472. // SetDeletedAt sets the "deleted_at" field.
  3473. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3474. m.deleted_at = &t
  3475. }
  3476. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3477. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3478. v := m.deleted_at
  3479. if v == nil {
  3480. return
  3481. }
  3482. return *v, true
  3483. }
  3484. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3485. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3487. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3488. if !m.op.Is(OpUpdateOne) {
  3489. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3490. }
  3491. if m.id == nil || m.oldValue == nil {
  3492. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3493. }
  3494. oldValue, err := m.oldValue(ctx)
  3495. if err != nil {
  3496. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3497. }
  3498. return oldValue.DeletedAt, nil
  3499. }
  3500. // ClearDeletedAt clears the value of the "deleted_at" field.
  3501. func (m *AllocAgentMutation) ClearDeletedAt() {
  3502. m.deleted_at = nil
  3503. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3504. }
  3505. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3506. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3507. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3508. return ok
  3509. }
  3510. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3511. func (m *AllocAgentMutation) ResetDeletedAt() {
  3512. m.deleted_at = nil
  3513. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3514. }
  3515. // SetUserID sets the "user_id" field.
  3516. func (m *AllocAgentMutation) SetUserID(s string) {
  3517. m.user_id = &s
  3518. }
  3519. // UserID returns the value of the "user_id" field in the mutation.
  3520. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3521. v := m.user_id
  3522. if v == nil {
  3523. return
  3524. }
  3525. return *v, true
  3526. }
  3527. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3528. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3530. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3531. if !m.op.Is(OpUpdateOne) {
  3532. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3533. }
  3534. if m.id == nil || m.oldValue == nil {
  3535. return v, errors.New("OldUserID requires an ID field in the mutation")
  3536. }
  3537. oldValue, err := m.oldValue(ctx)
  3538. if err != nil {
  3539. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3540. }
  3541. return oldValue.UserID, nil
  3542. }
  3543. // ClearUserID clears the value of the "user_id" field.
  3544. func (m *AllocAgentMutation) ClearUserID() {
  3545. m.user_id = nil
  3546. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3547. }
  3548. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3549. func (m *AllocAgentMutation) UserIDCleared() bool {
  3550. _, ok := m.clearedFields[allocagent.FieldUserID]
  3551. return ok
  3552. }
  3553. // ResetUserID resets all changes to the "user_id" field.
  3554. func (m *AllocAgentMutation) ResetUserID() {
  3555. m.user_id = nil
  3556. delete(m.clearedFields, allocagent.FieldUserID)
  3557. }
  3558. // SetOrganizationID sets the "organization_id" field.
  3559. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3560. m.organization_id = &u
  3561. m.addorganization_id = nil
  3562. }
  3563. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3564. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3565. v := m.organization_id
  3566. if v == nil {
  3567. return
  3568. }
  3569. return *v, true
  3570. }
  3571. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3572. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3574. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3575. if !m.op.Is(OpUpdateOne) {
  3576. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3577. }
  3578. if m.id == nil || m.oldValue == nil {
  3579. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3580. }
  3581. oldValue, err := m.oldValue(ctx)
  3582. if err != nil {
  3583. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3584. }
  3585. return oldValue.OrganizationID, nil
  3586. }
  3587. // AddOrganizationID adds u to the "organization_id" field.
  3588. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3589. if m.addorganization_id != nil {
  3590. *m.addorganization_id += u
  3591. } else {
  3592. m.addorganization_id = &u
  3593. }
  3594. }
  3595. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3596. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3597. v := m.addorganization_id
  3598. if v == nil {
  3599. return
  3600. }
  3601. return *v, true
  3602. }
  3603. // ClearOrganizationID clears the value of the "organization_id" field.
  3604. func (m *AllocAgentMutation) ClearOrganizationID() {
  3605. m.organization_id = nil
  3606. m.addorganization_id = nil
  3607. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3608. }
  3609. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3610. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3611. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3612. return ok
  3613. }
  3614. // ResetOrganizationID resets all changes to the "organization_id" field.
  3615. func (m *AllocAgentMutation) ResetOrganizationID() {
  3616. m.organization_id = nil
  3617. m.addorganization_id = nil
  3618. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3619. }
  3620. // SetAgents sets the "agents" field.
  3621. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3622. m.agents = &u
  3623. m.appendagents = nil
  3624. }
  3625. // Agents returns the value of the "agents" field in the mutation.
  3626. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3627. v := m.agents
  3628. if v == nil {
  3629. return
  3630. }
  3631. return *v, true
  3632. }
  3633. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3634. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3636. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3637. if !m.op.Is(OpUpdateOne) {
  3638. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3639. }
  3640. if m.id == nil || m.oldValue == nil {
  3641. return v, errors.New("OldAgents requires an ID field in the mutation")
  3642. }
  3643. oldValue, err := m.oldValue(ctx)
  3644. if err != nil {
  3645. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3646. }
  3647. return oldValue.Agents, nil
  3648. }
  3649. // AppendAgents adds u to the "agents" field.
  3650. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3651. m.appendagents = append(m.appendagents, u...)
  3652. }
  3653. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3654. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3655. if len(m.appendagents) == 0 {
  3656. return nil, false
  3657. }
  3658. return m.appendagents, true
  3659. }
  3660. // ResetAgents resets all changes to the "agents" field.
  3661. func (m *AllocAgentMutation) ResetAgents() {
  3662. m.agents = nil
  3663. m.appendagents = nil
  3664. }
  3665. // SetStatus sets the "status" field.
  3666. func (m *AllocAgentMutation) SetStatus(i int) {
  3667. m.status = &i
  3668. m.addstatus = nil
  3669. }
  3670. // Status returns the value of the "status" field in the mutation.
  3671. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3672. v := m.status
  3673. if v == nil {
  3674. return
  3675. }
  3676. return *v, true
  3677. }
  3678. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3679. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3681. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3682. if !m.op.Is(OpUpdateOne) {
  3683. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3684. }
  3685. if m.id == nil || m.oldValue == nil {
  3686. return v, errors.New("OldStatus requires an ID field in the mutation")
  3687. }
  3688. oldValue, err := m.oldValue(ctx)
  3689. if err != nil {
  3690. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3691. }
  3692. return oldValue.Status, nil
  3693. }
  3694. // AddStatus adds i to the "status" field.
  3695. func (m *AllocAgentMutation) AddStatus(i int) {
  3696. if m.addstatus != nil {
  3697. *m.addstatus += i
  3698. } else {
  3699. m.addstatus = &i
  3700. }
  3701. }
  3702. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3703. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3704. v := m.addstatus
  3705. if v == nil {
  3706. return
  3707. }
  3708. return *v, true
  3709. }
  3710. // ClearStatus clears the value of the "status" field.
  3711. func (m *AllocAgentMutation) ClearStatus() {
  3712. m.status = nil
  3713. m.addstatus = nil
  3714. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3715. }
  3716. // StatusCleared returns if the "status" field was cleared in this mutation.
  3717. func (m *AllocAgentMutation) StatusCleared() bool {
  3718. _, ok := m.clearedFields[allocagent.FieldStatus]
  3719. return ok
  3720. }
  3721. // ResetStatus resets all changes to the "status" field.
  3722. func (m *AllocAgentMutation) ResetStatus() {
  3723. m.status = nil
  3724. m.addstatus = nil
  3725. delete(m.clearedFields, allocagent.FieldStatus)
  3726. }
  3727. // Where appends a list predicates to the AllocAgentMutation builder.
  3728. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3729. m.predicates = append(m.predicates, ps...)
  3730. }
  3731. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3732. // users can use type-assertion to append predicates that do not depend on any generated package.
  3733. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3734. p := make([]predicate.AllocAgent, len(ps))
  3735. for i := range ps {
  3736. p[i] = ps[i]
  3737. }
  3738. m.Where(p...)
  3739. }
  3740. // Op returns the operation name.
  3741. func (m *AllocAgentMutation) Op() Op {
  3742. return m.op
  3743. }
  3744. // SetOp allows setting the mutation operation.
  3745. func (m *AllocAgentMutation) SetOp(op Op) {
  3746. m.op = op
  3747. }
  3748. // Type returns the node type of this mutation (AllocAgent).
  3749. func (m *AllocAgentMutation) Type() string {
  3750. return m.typ
  3751. }
  3752. // Fields returns all fields that were changed during this mutation. Note that in
  3753. // order to get all numeric fields that were incremented/decremented, call
  3754. // AddedFields().
  3755. func (m *AllocAgentMutation) Fields() []string {
  3756. fields := make([]string, 0, 7)
  3757. if m.created_at != nil {
  3758. fields = append(fields, allocagent.FieldCreatedAt)
  3759. }
  3760. if m.updated_at != nil {
  3761. fields = append(fields, allocagent.FieldUpdatedAt)
  3762. }
  3763. if m.deleted_at != nil {
  3764. fields = append(fields, allocagent.FieldDeletedAt)
  3765. }
  3766. if m.user_id != nil {
  3767. fields = append(fields, allocagent.FieldUserID)
  3768. }
  3769. if m.organization_id != nil {
  3770. fields = append(fields, allocagent.FieldOrganizationID)
  3771. }
  3772. if m.agents != nil {
  3773. fields = append(fields, allocagent.FieldAgents)
  3774. }
  3775. if m.status != nil {
  3776. fields = append(fields, allocagent.FieldStatus)
  3777. }
  3778. return fields
  3779. }
  3780. // Field returns the value of a field with the given name. The second boolean
  3781. // return value indicates that this field was not set, or was not defined in the
  3782. // schema.
  3783. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3784. switch name {
  3785. case allocagent.FieldCreatedAt:
  3786. return m.CreatedAt()
  3787. case allocagent.FieldUpdatedAt:
  3788. return m.UpdatedAt()
  3789. case allocagent.FieldDeletedAt:
  3790. return m.DeletedAt()
  3791. case allocagent.FieldUserID:
  3792. return m.UserID()
  3793. case allocagent.FieldOrganizationID:
  3794. return m.OrganizationID()
  3795. case allocagent.FieldAgents:
  3796. return m.Agents()
  3797. case allocagent.FieldStatus:
  3798. return m.Status()
  3799. }
  3800. return nil, false
  3801. }
  3802. // OldField returns the old value of the field from the database. An error is
  3803. // returned if the mutation operation is not UpdateOne, or the query to the
  3804. // database failed.
  3805. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3806. switch name {
  3807. case allocagent.FieldCreatedAt:
  3808. return m.OldCreatedAt(ctx)
  3809. case allocagent.FieldUpdatedAt:
  3810. return m.OldUpdatedAt(ctx)
  3811. case allocagent.FieldDeletedAt:
  3812. return m.OldDeletedAt(ctx)
  3813. case allocagent.FieldUserID:
  3814. return m.OldUserID(ctx)
  3815. case allocagent.FieldOrganizationID:
  3816. return m.OldOrganizationID(ctx)
  3817. case allocagent.FieldAgents:
  3818. return m.OldAgents(ctx)
  3819. case allocagent.FieldStatus:
  3820. return m.OldStatus(ctx)
  3821. }
  3822. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3823. }
  3824. // SetField sets the value of a field with the given name. It returns an error if
  3825. // the field is not defined in the schema, or if the type mismatched the field
  3826. // type.
  3827. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3828. switch name {
  3829. case allocagent.FieldCreatedAt:
  3830. v, ok := value.(time.Time)
  3831. if !ok {
  3832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3833. }
  3834. m.SetCreatedAt(v)
  3835. return nil
  3836. case allocagent.FieldUpdatedAt:
  3837. v, ok := value.(time.Time)
  3838. if !ok {
  3839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3840. }
  3841. m.SetUpdatedAt(v)
  3842. return nil
  3843. case allocagent.FieldDeletedAt:
  3844. v, ok := value.(time.Time)
  3845. if !ok {
  3846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3847. }
  3848. m.SetDeletedAt(v)
  3849. return nil
  3850. case allocagent.FieldUserID:
  3851. v, ok := value.(string)
  3852. if !ok {
  3853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3854. }
  3855. m.SetUserID(v)
  3856. return nil
  3857. case allocagent.FieldOrganizationID:
  3858. v, ok := value.(uint64)
  3859. if !ok {
  3860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3861. }
  3862. m.SetOrganizationID(v)
  3863. return nil
  3864. case allocagent.FieldAgents:
  3865. v, ok := value.([]uint64)
  3866. if !ok {
  3867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3868. }
  3869. m.SetAgents(v)
  3870. return nil
  3871. case allocagent.FieldStatus:
  3872. v, ok := value.(int)
  3873. if !ok {
  3874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3875. }
  3876. m.SetStatus(v)
  3877. return nil
  3878. }
  3879. return fmt.Errorf("unknown AllocAgent field %s", name)
  3880. }
  3881. // AddedFields returns all numeric fields that were incremented/decremented during
  3882. // this mutation.
  3883. func (m *AllocAgentMutation) AddedFields() []string {
  3884. var fields []string
  3885. if m.addorganization_id != nil {
  3886. fields = append(fields, allocagent.FieldOrganizationID)
  3887. }
  3888. if m.addstatus != nil {
  3889. fields = append(fields, allocagent.FieldStatus)
  3890. }
  3891. return fields
  3892. }
  3893. // AddedField returns the numeric value that was incremented/decremented on a field
  3894. // with the given name. The second boolean return value indicates that this field
  3895. // was not set, or was not defined in the schema.
  3896. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3897. switch name {
  3898. case allocagent.FieldOrganizationID:
  3899. return m.AddedOrganizationID()
  3900. case allocagent.FieldStatus:
  3901. return m.AddedStatus()
  3902. }
  3903. return nil, false
  3904. }
  3905. // AddField adds the value to the field with the given name. It returns an error if
  3906. // the field is not defined in the schema, or if the type mismatched the field
  3907. // type.
  3908. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3909. switch name {
  3910. case allocagent.FieldOrganizationID:
  3911. v, ok := value.(int64)
  3912. if !ok {
  3913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3914. }
  3915. m.AddOrganizationID(v)
  3916. return nil
  3917. case allocagent.FieldStatus:
  3918. v, ok := value.(int)
  3919. if !ok {
  3920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3921. }
  3922. m.AddStatus(v)
  3923. return nil
  3924. }
  3925. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3926. }
  3927. // ClearedFields returns all nullable fields that were cleared during this
  3928. // mutation.
  3929. func (m *AllocAgentMutation) ClearedFields() []string {
  3930. var fields []string
  3931. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3932. fields = append(fields, allocagent.FieldDeletedAt)
  3933. }
  3934. if m.FieldCleared(allocagent.FieldUserID) {
  3935. fields = append(fields, allocagent.FieldUserID)
  3936. }
  3937. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3938. fields = append(fields, allocagent.FieldOrganizationID)
  3939. }
  3940. if m.FieldCleared(allocagent.FieldStatus) {
  3941. fields = append(fields, allocagent.FieldStatus)
  3942. }
  3943. return fields
  3944. }
  3945. // FieldCleared returns a boolean indicating if a field with the given name was
  3946. // cleared in this mutation.
  3947. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3948. _, ok := m.clearedFields[name]
  3949. return ok
  3950. }
  3951. // ClearField clears the value of the field with the given name. It returns an
  3952. // error if the field is not defined in the schema.
  3953. func (m *AllocAgentMutation) ClearField(name string) error {
  3954. switch name {
  3955. case allocagent.FieldDeletedAt:
  3956. m.ClearDeletedAt()
  3957. return nil
  3958. case allocagent.FieldUserID:
  3959. m.ClearUserID()
  3960. return nil
  3961. case allocagent.FieldOrganizationID:
  3962. m.ClearOrganizationID()
  3963. return nil
  3964. case allocagent.FieldStatus:
  3965. m.ClearStatus()
  3966. return nil
  3967. }
  3968. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3969. }
  3970. // ResetField resets all changes in the mutation for the field with the given name.
  3971. // It returns an error if the field is not defined in the schema.
  3972. func (m *AllocAgentMutation) ResetField(name string) error {
  3973. switch name {
  3974. case allocagent.FieldCreatedAt:
  3975. m.ResetCreatedAt()
  3976. return nil
  3977. case allocagent.FieldUpdatedAt:
  3978. m.ResetUpdatedAt()
  3979. return nil
  3980. case allocagent.FieldDeletedAt:
  3981. m.ResetDeletedAt()
  3982. return nil
  3983. case allocagent.FieldUserID:
  3984. m.ResetUserID()
  3985. return nil
  3986. case allocagent.FieldOrganizationID:
  3987. m.ResetOrganizationID()
  3988. return nil
  3989. case allocagent.FieldAgents:
  3990. m.ResetAgents()
  3991. return nil
  3992. case allocagent.FieldStatus:
  3993. m.ResetStatus()
  3994. return nil
  3995. }
  3996. return fmt.Errorf("unknown AllocAgent field %s", name)
  3997. }
  3998. // AddedEdges returns all edge names that were set/added in this mutation.
  3999. func (m *AllocAgentMutation) AddedEdges() []string {
  4000. edges := make([]string, 0, 0)
  4001. return edges
  4002. }
  4003. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4004. // name in this mutation.
  4005. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4006. return nil
  4007. }
  4008. // RemovedEdges returns all edge names that were removed in this mutation.
  4009. func (m *AllocAgentMutation) RemovedEdges() []string {
  4010. edges := make([]string, 0, 0)
  4011. return edges
  4012. }
  4013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4014. // the given name in this mutation.
  4015. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4016. return nil
  4017. }
  4018. // ClearedEdges returns all edge names that were cleared in this mutation.
  4019. func (m *AllocAgentMutation) ClearedEdges() []string {
  4020. edges := make([]string, 0, 0)
  4021. return edges
  4022. }
  4023. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4024. // was cleared in this mutation.
  4025. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4026. return false
  4027. }
  4028. // ClearEdge clears the value of the edge with the given name. It returns an error
  4029. // if that edge is not defined in the schema.
  4030. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4031. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4032. }
  4033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4034. // It returns an error if the edge is not defined in the schema.
  4035. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4036. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4037. }
  4038. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  4039. type BatchMsgMutation struct {
  4040. config
  4041. op Op
  4042. typ string
  4043. id *uint64
  4044. created_at *time.Time
  4045. updated_at *time.Time
  4046. deleted_at *time.Time
  4047. status *uint8
  4048. addstatus *int8
  4049. batch_no *string
  4050. task_name *string
  4051. fromwxid *string
  4052. msg *string
  4053. tag *string
  4054. tagids *string
  4055. total *int32
  4056. addtotal *int32
  4057. success *int32
  4058. addsuccess *int32
  4059. fail *int32
  4060. addfail *int32
  4061. start_time *time.Time
  4062. stop_time *time.Time
  4063. send_time *time.Time
  4064. _type *int32
  4065. add_type *int32
  4066. organization_id *uint64
  4067. addorganization_id *int64
  4068. ctype *uint64
  4069. addctype *int64
  4070. cc *string
  4071. phone *string
  4072. template_name *string
  4073. template_code *string
  4074. lang *string
  4075. clearedFields map[string]struct{}
  4076. done bool
  4077. oldValue func(context.Context) (*BatchMsg, error)
  4078. predicates []predicate.BatchMsg
  4079. }
  4080. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  4081. // batchmsgOption allows management of the mutation configuration using functional options.
  4082. type batchmsgOption func(*BatchMsgMutation)
  4083. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  4084. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  4085. m := &BatchMsgMutation{
  4086. config: c,
  4087. op: op,
  4088. typ: TypeBatchMsg,
  4089. clearedFields: make(map[string]struct{}),
  4090. }
  4091. for _, opt := range opts {
  4092. opt(m)
  4093. }
  4094. return m
  4095. }
  4096. // withBatchMsgID sets the ID field of the mutation.
  4097. func withBatchMsgID(id uint64) batchmsgOption {
  4098. return func(m *BatchMsgMutation) {
  4099. var (
  4100. err error
  4101. once sync.Once
  4102. value *BatchMsg
  4103. )
  4104. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4105. once.Do(func() {
  4106. if m.done {
  4107. err = errors.New("querying old values post mutation is not allowed")
  4108. } else {
  4109. value, err = m.Client().BatchMsg.Get(ctx, id)
  4110. }
  4111. })
  4112. return value, err
  4113. }
  4114. m.id = &id
  4115. }
  4116. }
  4117. // withBatchMsg sets the old BatchMsg of the mutation.
  4118. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4119. return func(m *BatchMsgMutation) {
  4120. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4121. return node, nil
  4122. }
  4123. m.id = &node.ID
  4124. }
  4125. }
  4126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4127. // executed in a transaction (ent.Tx), a transactional client is returned.
  4128. func (m BatchMsgMutation) Client() *Client {
  4129. client := &Client{config: m.config}
  4130. client.init()
  4131. return client
  4132. }
  4133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4134. // it returns an error otherwise.
  4135. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4136. if _, ok := m.driver.(*txDriver); !ok {
  4137. return nil, errors.New("ent: mutation is not running in a transaction")
  4138. }
  4139. tx := &Tx{config: m.config}
  4140. tx.init()
  4141. return tx, nil
  4142. }
  4143. // SetID sets the value of the id field. Note that this
  4144. // operation is only accepted on creation of BatchMsg entities.
  4145. func (m *BatchMsgMutation) SetID(id uint64) {
  4146. m.id = &id
  4147. }
  4148. // ID returns the ID value in the mutation. Note that the ID is only available
  4149. // if it was provided to the builder or after it was returned from the database.
  4150. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4151. if m.id == nil {
  4152. return
  4153. }
  4154. return *m.id, true
  4155. }
  4156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4157. // That means, if the mutation is applied within a transaction with an isolation level such
  4158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4159. // or updated by the mutation.
  4160. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4161. switch {
  4162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4163. id, exists := m.ID()
  4164. if exists {
  4165. return []uint64{id}, nil
  4166. }
  4167. fallthrough
  4168. case m.op.Is(OpUpdate | OpDelete):
  4169. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4170. default:
  4171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4172. }
  4173. }
  4174. // SetCreatedAt sets the "created_at" field.
  4175. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4176. m.created_at = &t
  4177. }
  4178. // CreatedAt returns the value of the "created_at" field in the mutation.
  4179. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4180. v := m.created_at
  4181. if v == nil {
  4182. return
  4183. }
  4184. return *v, true
  4185. }
  4186. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4187. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4189. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4190. if !m.op.Is(OpUpdateOne) {
  4191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4192. }
  4193. if m.id == nil || m.oldValue == nil {
  4194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4195. }
  4196. oldValue, err := m.oldValue(ctx)
  4197. if err != nil {
  4198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4199. }
  4200. return oldValue.CreatedAt, nil
  4201. }
  4202. // ResetCreatedAt resets all changes to the "created_at" field.
  4203. func (m *BatchMsgMutation) ResetCreatedAt() {
  4204. m.created_at = nil
  4205. }
  4206. // SetUpdatedAt sets the "updated_at" field.
  4207. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4208. m.updated_at = &t
  4209. }
  4210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4211. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4212. v := m.updated_at
  4213. if v == nil {
  4214. return
  4215. }
  4216. return *v, true
  4217. }
  4218. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4219. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4221. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4222. if !m.op.Is(OpUpdateOne) {
  4223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4224. }
  4225. if m.id == nil || m.oldValue == nil {
  4226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4227. }
  4228. oldValue, err := m.oldValue(ctx)
  4229. if err != nil {
  4230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4231. }
  4232. return oldValue.UpdatedAt, nil
  4233. }
  4234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4235. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4236. m.updated_at = nil
  4237. }
  4238. // SetDeletedAt sets the "deleted_at" field.
  4239. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4240. m.deleted_at = &t
  4241. }
  4242. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4243. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4244. v := m.deleted_at
  4245. if v == nil {
  4246. return
  4247. }
  4248. return *v, true
  4249. }
  4250. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4251. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4253. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4254. if !m.op.Is(OpUpdateOne) {
  4255. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4256. }
  4257. if m.id == nil || m.oldValue == nil {
  4258. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4259. }
  4260. oldValue, err := m.oldValue(ctx)
  4261. if err != nil {
  4262. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4263. }
  4264. return oldValue.DeletedAt, nil
  4265. }
  4266. // ClearDeletedAt clears the value of the "deleted_at" field.
  4267. func (m *BatchMsgMutation) ClearDeletedAt() {
  4268. m.deleted_at = nil
  4269. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4270. }
  4271. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4272. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4273. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4274. return ok
  4275. }
  4276. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4277. func (m *BatchMsgMutation) ResetDeletedAt() {
  4278. m.deleted_at = nil
  4279. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4280. }
  4281. // SetStatus sets the "status" field.
  4282. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4283. m.status = &u
  4284. m.addstatus = nil
  4285. }
  4286. // Status returns the value of the "status" field in the mutation.
  4287. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4288. v := m.status
  4289. if v == nil {
  4290. return
  4291. }
  4292. return *v, true
  4293. }
  4294. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4295. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4297. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4298. if !m.op.Is(OpUpdateOne) {
  4299. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4300. }
  4301. if m.id == nil || m.oldValue == nil {
  4302. return v, errors.New("OldStatus requires an ID field in the mutation")
  4303. }
  4304. oldValue, err := m.oldValue(ctx)
  4305. if err != nil {
  4306. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4307. }
  4308. return oldValue.Status, nil
  4309. }
  4310. // AddStatus adds u to the "status" field.
  4311. func (m *BatchMsgMutation) AddStatus(u int8) {
  4312. if m.addstatus != nil {
  4313. *m.addstatus += u
  4314. } else {
  4315. m.addstatus = &u
  4316. }
  4317. }
  4318. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4319. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4320. v := m.addstatus
  4321. if v == nil {
  4322. return
  4323. }
  4324. return *v, true
  4325. }
  4326. // ClearStatus clears the value of the "status" field.
  4327. func (m *BatchMsgMutation) ClearStatus() {
  4328. m.status = nil
  4329. m.addstatus = nil
  4330. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4331. }
  4332. // StatusCleared returns if the "status" field was cleared in this mutation.
  4333. func (m *BatchMsgMutation) StatusCleared() bool {
  4334. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4335. return ok
  4336. }
  4337. // ResetStatus resets all changes to the "status" field.
  4338. func (m *BatchMsgMutation) ResetStatus() {
  4339. m.status = nil
  4340. m.addstatus = nil
  4341. delete(m.clearedFields, batchmsg.FieldStatus)
  4342. }
  4343. // SetBatchNo sets the "batch_no" field.
  4344. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4345. m.batch_no = &s
  4346. }
  4347. // BatchNo returns the value of the "batch_no" field in the mutation.
  4348. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4349. v := m.batch_no
  4350. if v == nil {
  4351. return
  4352. }
  4353. return *v, true
  4354. }
  4355. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4356. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4358. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4359. if !m.op.Is(OpUpdateOne) {
  4360. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4361. }
  4362. if m.id == nil || m.oldValue == nil {
  4363. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4364. }
  4365. oldValue, err := m.oldValue(ctx)
  4366. if err != nil {
  4367. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4368. }
  4369. return oldValue.BatchNo, nil
  4370. }
  4371. // ClearBatchNo clears the value of the "batch_no" field.
  4372. func (m *BatchMsgMutation) ClearBatchNo() {
  4373. m.batch_no = nil
  4374. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4375. }
  4376. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4377. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4378. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4379. return ok
  4380. }
  4381. // ResetBatchNo resets all changes to the "batch_no" field.
  4382. func (m *BatchMsgMutation) ResetBatchNo() {
  4383. m.batch_no = nil
  4384. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4385. }
  4386. // SetTaskName sets the "task_name" field.
  4387. func (m *BatchMsgMutation) SetTaskName(s string) {
  4388. m.task_name = &s
  4389. }
  4390. // TaskName returns the value of the "task_name" field in the mutation.
  4391. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4392. v := m.task_name
  4393. if v == nil {
  4394. return
  4395. }
  4396. return *v, true
  4397. }
  4398. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4399. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4401. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4402. if !m.op.Is(OpUpdateOne) {
  4403. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4404. }
  4405. if m.id == nil || m.oldValue == nil {
  4406. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4407. }
  4408. oldValue, err := m.oldValue(ctx)
  4409. if err != nil {
  4410. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4411. }
  4412. return oldValue.TaskName, nil
  4413. }
  4414. // ClearTaskName clears the value of the "task_name" field.
  4415. func (m *BatchMsgMutation) ClearTaskName() {
  4416. m.task_name = nil
  4417. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4418. }
  4419. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4420. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4421. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4422. return ok
  4423. }
  4424. // ResetTaskName resets all changes to the "task_name" field.
  4425. func (m *BatchMsgMutation) ResetTaskName() {
  4426. m.task_name = nil
  4427. delete(m.clearedFields, batchmsg.FieldTaskName)
  4428. }
  4429. // SetFromwxid sets the "fromwxid" field.
  4430. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4431. m.fromwxid = &s
  4432. }
  4433. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4434. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4435. v := m.fromwxid
  4436. if v == nil {
  4437. return
  4438. }
  4439. return *v, true
  4440. }
  4441. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4442. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4444. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4445. if !m.op.Is(OpUpdateOne) {
  4446. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4447. }
  4448. if m.id == nil || m.oldValue == nil {
  4449. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4450. }
  4451. oldValue, err := m.oldValue(ctx)
  4452. if err != nil {
  4453. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4454. }
  4455. return oldValue.Fromwxid, nil
  4456. }
  4457. // ClearFromwxid clears the value of the "fromwxid" field.
  4458. func (m *BatchMsgMutation) ClearFromwxid() {
  4459. m.fromwxid = nil
  4460. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4461. }
  4462. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4463. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4464. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4465. return ok
  4466. }
  4467. // ResetFromwxid resets all changes to the "fromwxid" field.
  4468. func (m *BatchMsgMutation) ResetFromwxid() {
  4469. m.fromwxid = nil
  4470. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4471. }
  4472. // SetMsg sets the "msg" field.
  4473. func (m *BatchMsgMutation) SetMsg(s string) {
  4474. m.msg = &s
  4475. }
  4476. // Msg returns the value of the "msg" field in the mutation.
  4477. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4478. v := m.msg
  4479. if v == nil {
  4480. return
  4481. }
  4482. return *v, true
  4483. }
  4484. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4485. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4487. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4488. if !m.op.Is(OpUpdateOne) {
  4489. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4490. }
  4491. if m.id == nil || m.oldValue == nil {
  4492. return v, errors.New("OldMsg requires an ID field in the mutation")
  4493. }
  4494. oldValue, err := m.oldValue(ctx)
  4495. if err != nil {
  4496. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4497. }
  4498. return oldValue.Msg, nil
  4499. }
  4500. // ClearMsg clears the value of the "msg" field.
  4501. func (m *BatchMsgMutation) ClearMsg() {
  4502. m.msg = nil
  4503. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4504. }
  4505. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4506. func (m *BatchMsgMutation) MsgCleared() bool {
  4507. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4508. return ok
  4509. }
  4510. // ResetMsg resets all changes to the "msg" field.
  4511. func (m *BatchMsgMutation) ResetMsg() {
  4512. m.msg = nil
  4513. delete(m.clearedFields, batchmsg.FieldMsg)
  4514. }
  4515. // SetTag sets the "tag" field.
  4516. func (m *BatchMsgMutation) SetTag(s string) {
  4517. m.tag = &s
  4518. }
  4519. // Tag returns the value of the "tag" field in the mutation.
  4520. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4521. v := m.tag
  4522. if v == nil {
  4523. return
  4524. }
  4525. return *v, true
  4526. }
  4527. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4528. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4530. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4531. if !m.op.Is(OpUpdateOne) {
  4532. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4533. }
  4534. if m.id == nil || m.oldValue == nil {
  4535. return v, errors.New("OldTag requires an ID field in the mutation")
  4536. }
  4537. oldValue, err := m.oldValue(ctx)
  4538. if err != nil {
  4539. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4540. }
  4541. return oldValue.Tag, nil
  4542. }
  4543. // ClearTag clears the value of the "tag" field.
  4544. func (m *BatchMsgMutation) ClearTag() {
  4545. m.tag = nil
  4546. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4547. }
  4548. // TagCleared returns if the "tag" field was cleared in this mutation.
  4549. func (m *BatchMsgMutation) TagCleared() bool {
  4550. _, ok := m.clearedFields[batchmsg.FieldTag]
  4551. return ok
  4552. }
  4553. // ResetTag resets all changes to the "tag" field.
  4554. func (m *BatchMsgMutation) ResetTag() {
  4555. m.tag = nil
  4556. delete(m.clearedFields, batchmsg.FieldTag)
  4557. }
  4558. // SetTagids sets the "tagids" field.
  4559. func (m *BatchMsgMutation) SetTagids(s string) {
  4560. m.tagids = &s
  4561. }
  4562. // Tagids returns the value of the "tagids" field in the mutation.
  4563. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4564. v := m.tagids
  4565. if v == nil {
  4566. return
  4567. }
  4568. return *v, true
  4569. }
  4570. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4571. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4573. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4574. if !m.op.Is(OpUpdateOne) {
  4575. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4576. }
  4577. if m.id == nil || m.oldValue == nil {
  4578. return v, errors.New("OldTagids requires an ID field in the mutation")
  4579. }
  4580. oldValue, err := m.oldValue(ctx)
  4581. if err != nil {
  4582. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4583. }
  4584. return oldValue.Tagids, nil
  4585. }
  4586. // ClearTagids clears the value of the "tagids" field.
  4587. func (m *BatchMsgMutation) ClearTagids() {
  4588. m.tagids = nil
  4589. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4590. }
  4591. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4592. func (m *BatchMsgMutation) TagidsCleared() bool {
  4593. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4594. return ok
  4595. }
  4596. // ResetTagids resets all changes to the "tagids" field.
  4597. func (m *BatchMsgMutation) ResetTagids() {
  4598. m.tagids = nil
  4599. delete(m.clearedFields, batchmsg.FieldTagids)
  4600. }
  4601. // SetTotal sets the "total" field.
  4602. func (m *BatchMsgMutation) SetTotal(i int32) {
  4603. m.total = &i
  4604. m.addtotal = nil
  4605. }
  4606. // Total returns the value of the "total" field in the mutation.
  4607. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4608. v := m.total
  4609. if v == nil {
  4610. return
  4611. }
  4612. return *v, true
  4613. }
  4614. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4615. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4617. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4618. if !m.op.Is(OpUpdateOne) {
  4619. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4620. }
  4621. if m.id == nil || m.oldValue == nil {
  4622. return v, errors.New("OldTotal requires an ID field in the mutation")
  4623. }
  4624. oldValue, err := m.oldValue(ctx)
  4625. if err != nil {
  4626. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4627. }
  4628. return oldValue.Total, nil
  4629. }
  4630. // AddTotal adds i to the "total" field.
  4631. func (m *BatchMsgMutation) AddTotal(i int32) {
  4632. if m.addtotal != nil {
  4633. *m.addtotal += i
  4634. } else {
  4635. m.addtotal = &i
  4636. }
  4637. }
  4638. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4639. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4640. v := m.addtotal
  4641. if v == nil {
  4642. return
  4643. }
  4644. return *v, true
  4645. }
  4646. // ClearTotal clears the value of the "total" field.
  4647. func (m *BatchMsgMutation) ClearTotal() {
  4648. m.total = nil
  4649. m.addtotal = nil
  4650. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4651. }
  4652. // TotalCleared returns if the "total" field was cleared in this mutation.
  4653. func (m *BatchMsgMutation) TotalCleared() bool {
  4654. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4655. return ok
  4656. }
  4657. // ResetTotal resets all changes to the "total" field.
  4658. func (m *BatchMsgMutation) ResetTotal() {
  4659. m.total = nil
  4660. m.addtotal = nil
  4661. delete(m.clearedFields, batchmsg.FieldTotal)
  4662. }
  4663. // SetSuccess sets the "success" field.
  4664. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4665. m.success = &i
  4666. m.addsuccess = nil
  4667. }
  4668. // Success returns the value of the "success" field in the mutation.
  4669. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4670. v := m.success
  4671. if v == nil {
  4672. return
  4673. }
  4674. return *v, true
  4675. }
  4676. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4677. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4679. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4680. if !m.op.Is(OpUpdateOne) {
  4681. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4682. }
  4683. if m.id == nil || m.oldValue == nil {
  4684. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4685. }
  4686. oldValue, err := m.oldValue(ctx)
  4687. if err != nil {
  4688. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4689. }
  4690. return oldValue.Success, nil
  4691. }
  4692. // AddSuccess adds i to the "success" field.
  4693. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4694. if m.addsuccess != nil {
  4695. *m.addsuccess += i
  4696. } else {
  4697. m.addsuccess = &i
  4698. }
  4699. }
  4700. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4701. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4702. v := m.addsuccess
  4703. if v == nil {
  4704. return
  4705. }
  4706. return *v, true
  4707. }
  4708. // ClearSuccess clears the value of the "success" field.
  4709. func (m *BatchMsgMutation) ClearSuccess() {
  4710. m.success = nil
  4711. m.addsuccess = nil
  4712. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4713. }
  4714. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4715. func (m *BatchMsgMutation) SuccessCleared() bool {
  4716. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4717. return ok
  4718. }
  4719. // ResetSuccess resets all changes to the "success" field.
  4720. func (m *BatchMsgMutation) ResetSuccess() {
  4721. m.success = nil
  4722. m.addsuccess = nil
  4723. delete(m.clearedFields, batchmsg.FieldSuccess)
  4724. }
  4725. // SetFail sets the "fail" field.
  4726. func (m *BatchMsgMutation) SetFail(i int32) {
  4727. m.fail = &i
  4728. m.addfail = nil
  4729. }
  4730. // Fail returns the value of the "fail" field in the mutation.
  4731. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4732. v := m.fail
  4733. if v == nil {
  4734. return
  4735. }
  4736. return *v, true
  4737. }
  4738. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4739. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4741. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4742. if !m.op.Is(OpUpdateOne) {
  4743. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4744. }
  4745. if m.id == nil || m.oldValue == nil {
  4746. return v, errors.New("OldFail requires an ID field in the mutation")
  4747. }
  4748. oldValue, err := m.oldValue(ctx)
  4749. if err != nil {
  4750. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4751. }
  4752. return oldValue.Fail, nil
  4753. }
  4754. // AddFail adds i to the "fail" field.
  4755. func (m *BatchMsgMutation) AddFail(i int32) {
  4756. if m.addfail != nil {
  4757. *m.addfail += i
  4758. } else {
  4759. m.addfail = &i
  4760. }
  4761. }
  4762. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4763. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4764. v := m.addfail
  4765. if v == nil {
  4766. return
  4767. }
  4768. return *v, true
  4769. }
  4770. // ClearFail clears the value of the "fail" field.
  4771. func (m *BatchMsgMutation) ClearFail() {
  4772. m.fail = nil
  4773. m.addfail = nil
  4774. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4775. }
  4776. // FailCleared returns if the "fail" field was cleared in this mutation.
  4777. func (m *BatchMsgMutation) FailCleared() bool {
  4778. _, ok := m.clearedFields[batchmsg.FieldFail]
  4779. return ok
  4780. }
  4781. // ResetFail resets all changes to the "fail" field.
  4782. func (m *BatchMsgMutation) ResetFail() {
  4783. m.fail = nil
  4784. m.addfail = nil
  4785. delete(m.clearedFields, batchmsg.FieldFail)
  4786. }
  4787. // SetStartTime sets the "start_time" field.
  4788. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4789. m.start_time = &t
  4790. }
  4791. // StartTime returns the value of the "start_time" field in the mutation.
  4792. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4793. v := m.start_time
  4794. if v == nil {
  4795. return
  4796. }
  4797. return *v, true
  4798. }
  4799. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4800. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4802. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4803. if !m.op.Is(OpUpdateOne) {
  4804. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4805. }
  4806. if m.id == nil || m.oldValue == nil {
  4807. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4808. }
  4809. oldValue, err := m.oldValue(ctx)
  4810. if err != nil {
  4811. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4812. }
  4813. return oldValue.StartTime, nil
  4814. }
  4815. // ClearStartTime clears the value of the "start_time" field.
  4816. func (m *BatchMsgMutation) ClearStartTime() {
  4817. m.start_time = nil
  4818. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4819. }
  4820. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4821. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4822. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4823. return ok
  4824. }
  4825. // ResetStartTime resets all changes to the "start_time" field.
  4826. func (m *BatchMsgMutation) ResetStartTime() {
  4827. m.start_time = nil
  4828. delete(m.clearedFields, batchmsg.FieldStartTime)
  4829. }
  4830. // SetStopTime sets the "stop_time" field.
  4831. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4832. m.stop_time = &t
  4833. }
  4834. // StopTime returns the value of the "stop_time" field in the mutation.
  4835. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4836. v := m.stop_time
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4843. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4845. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4846. if !m.op.Is(OpUpdateOne) {
  4847. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4848. }
  4849. if m.id == nil || m.oldValue == nil {
  4850. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4851. }
  4852. oldValue, err := m.oldValue(ctx)
  4853. if err != nil {
  4854. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4855. }
  4856. return oldValue.StopTime, nil
  4857. }
  4858. // ClearStopTime clears the value of the "stop_time" field.
  4859. func (m *BatchMsgMutation) ClearStopTime() {
  4860. m.stop_time = nil
  4861. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4862. }
  4863. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4864. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4865. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4866. return ok
  4867. }
  4868. // ResetStopTime resets all changes to the "stop_time" field.
  4869. func (m *BatchMsgMutation) ResetStopTime() {
  4870. m.stop_time = nil
  4871. delete(m.clearedFields, batchmsg.FieldStopTime)
  4872. }
  4873. // SetSendTime sets the "send_time" field.
  4874. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4875. m.send_time = &t
  4876. }
  4877. // SendTime returns the value of the "send_time" field in the mutation.
  4878. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4879. v := m.send_time
  4880. if v == nil {
  4881. return
  4882. }
  4883. return *v, true
  4884. }
  4885. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4886. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4888. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4889. if !m.op.Is(OpUpdateOne) {
  4890. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4891. }
  4892. if m.id == nil || m.oldValue == nil {
  4893. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4894. }
  4895. oldValue, err := m.oldValue(ctx)
  4896. if err != nil {
  4897. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4898. }
  4899. return oldValue.SendTime, nil
  4900. }
  4901. // ClearSendTime clears the value of the "send_time" field.
  4902. func (m *BatchMsgMutation) ClearSendTime() {
  4903. m.send_time = nil
  4904. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4905. }
  4906. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4907. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4908. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4909. return ok
  4910. }
  4911. // ResetSendTime resets all changes to the "send_time" field.
  4912. func (m *BatchMsgMutation) ResetSendTime() {
  4913. m.send_time = nil
  4914. delete(m.clearedFields, batchmsg.FieldSendTime)
  4915. }
  4916. // SetType sets the "type" field.
  4917. func (m *BatchMsgMutation) SetType(i int32) {
  4918. m._type = &i
  4919. m.add_type = nil
  4920. }
  4921. // GetType returns the value of the "type" field in the mutation.
  4922. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4923. v := m._type
  4924. if v == nil {
  4925. return
  4926. }
  4927. return *v, true
  4928. }
  4929. // OldType returns the old "type" field's value of the BatchMsg entity.
  4930. // If the BatchMsg 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 *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4933. if !m.op.Is(OpUpdateOne) {
  4934. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4935. }
  4936. if m.id == nil || m.oldValue == nil {
  4937. return v, errors.New("OldType 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 OldType: %w", err)
  4942. }
  4943. return oldValue.Type, nil
  4944. }
  4945. // AddType adds i to the "type" field.
  4946. func (m *BatchMsgMutation) AddType(i int32) {
  4947. if m.add_type != nil {
  4948. *m.add_type += i
  4949. } else {
  4950. m.add_type = &i
  4951. }
  4952. }
  4953. // AddedType returns the value that was added to the "type" field in this mutation.
  4954. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4955. v := m.add_type
  4956. if v == nil {
  4957. return
  4958. }
  4959. return *v, true
  4960. }
  4961. // ClearType clears the value of the "type" field.
  4962. func (m *BatchMsgMutation) ClearType() {
  4963. m._type = nil
  4964. m.add_type = nil
  4965. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4966. }
  4967. // TypeCleared returns if the "type" field was cleared in this mutation.
  4968. func (m *BatchMsgMutation) TypeCleared() bool {
  4969. _, ok := m.clearedFields[batchmsg.FieldType]
  4970. return ok
  4971. }
  4972. // ResetType resets all changes to the "type" field.
  4973. func (m *BatchMsgMutation) ResetType() {
  4974. m._type = nil
  4975. m.add_type = nil
  4976. delete(m.clearedFields, batchmsg.FieldType)
  4977. }
  4978. // SetOrganizationID sets the "organization_id" field.
  4979. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4980. m.organization_id = &u
  4981. m.addorganization_id = nil
  4982. }
  4983. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4984. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4985. v := m.organization_id
  4986. if v == nil {
  4987. return
  4988. }
  4989. return *v, true
  4990. }
  4991. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4992. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4994. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4995. if !m.op.Is(OpUpdateOne) {
  4996. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4997. }
  4998. if m.id == nil || m.oldValue == nil {
  4999. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5000. }
  5001. oldValue, err := m.oldValue(ctx)
  5002. if err != nil {
  5003. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5004. }
  5005. return oldValue.OrganizationID, nil
  5006. }
  5007. // AddOrganizationID adds u to the "organization_id" field.
  5008. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  5009. if m.addorganization_id != nil {
  5010. *m.addorganization_id += u
  5011. } else {
  5012. m.addorganization_id = &u
  5013. }
  5014. }
  5015. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5016. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  5017. v := m.addorganization_id
  5018. if v == nil {
  5019. return
  5020. }
  5021. return *v, true
  5022. }
  5023. // ResetOrganizationID resets all changes to the "organization_id" field.
  5024. func (m *BatchMsgMutation) ResetOrganizationID() {
  5025. m.organization_id = nil
  5026. m.addorganization_id = nil
  5027. }
  5028. // SetCtype sets the "ctype" field.
  5029. func (m *BatchMsgMutation) SetCtype(u uint64) {
  5030. m.ctype = &u
  5031. m.addctype = nil
  5032. }
  5033. // Ctype returns the value of the "ctype" field in the mutation.
  5034. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  5035. v := m.ctype
  5036. if v == nil {
  5037. return
  5038. }
  5039. return *v, true
  5040. }
  5041. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  5042. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5044. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  5045. if !m.op.Is(OpUpdateOne) {
  5046. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  5047. }
  5048. if m.id == nil || m.oldValue == nil {
  5049. return v, errors.New("OldCtype requires an ID field in the mutation")
  5050. }
  5051. oldValue, err := m.oldValue(ctx)
  5052. if err != nil {
  5053. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  5054. }
  5055. return oldValue.Ctype, nil
  5056. }
  5057. // AddCtype adds u to the "ctype" field.
  5058. func (m *BatchMsgMutation) AddCtype(u int64) {
  5059. if m.addctype != nil {
  5060. *m.addctype += u
  5061. } else {
  5062. m.addctype = &u
  5063. }
  5064. }
  5065. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  5066. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  5067. v := m.addctype
  5068. if v == nil {
  5069. return
  5070. }
  5071. return *v, true
  5072. }
  5073. // ResetCtype resets all changes to the "ctype" field.
  5074. func (m *BatchMsgMutation) ResetCtype() {
  5075. m.ctype = nil
  5076. m.addctype = nil
  5077. }
  5078. // SetCc sets the "cc" field.
  5079. func (m *BatchMsgMutation) SetCc(s string) {
  5080. m.cc = &s
  5081. }
  5082. // Cc returns the value of the "cc" field in the mutation.
  5083. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  5084. v := m.cc
  5085. if v == nil {
  5086. return
  5087. }
  5088. return *v, true
  5089. }
  5090. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  5091. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5093. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  5094. if !m.op.Is(OpUpdateOne) {
  5095. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  5096. }
  5097. if m.id == nil || m.oldValue == nil {
  5098. return v, errors.New("OldCc requires an ID field in the mutation")
  5099. }
  5100. oldValue, err := m.oldValue(ctx)
  5101. if err != nil {
  5102. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  5103. }
  5104. return oldValue.Cc, nil
  5105. }
  5106. // ClearCc clears the value of the "cc" field.
  5107. func (m *BatchMsgMutation) ClearCc() {
  5108. m.cc = nil
  5109. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  5110. }
  5111. // CcCleared returns if the "cc" field was cleared in this mutation.
  5112. func (m *BatchMsgMutation) CcCleared() bool {
  5113. _, ok := m.clearedFields[batchmsg.FieldCc]
  5114. return ok
  5115. }
  5116. // ResetCc resets all changes to the "cc" field.
  5117. func (m *BatchMsgMutation) ResetCc() {
  5118. m.cc = nil
  5119. delete(m.clearedFields, batchmsg.FieldCc)
  5120. }
  5121. // SetPhone sets the "phone" field.
  5122. func (m *BatchMsgMutation) SetPhone(s string) {
  5123. m.phone = &s
  5124. }
  5125. // Phone returns the value of the "phone" field in the mutation.
  5126. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  5127. v := m.phone
  5128. if v == nil {
  5129. return
  5130. }
  5131. return *v, true
  5132. }
  5133. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  5134. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5136. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  5137. if !m.op.Is(OpUpdateOne) {
  5138. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  5139. }
  5140. if m.id == nil || m.oldValue == nil {
  5141. return v, errors.New("OldPhone requires an ID field in the mutation")
  5142. }
  5143. oldValue, err := m.oldValue(ctx)
  5144. if err != nil {
  5145. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  5146. }
  5147. return oldValue.Phone, nil
  5148. }
  5149. // ClearPhone clears the value of the "phone" field.
  5150. func (m *BatchMsgMutation) ClearPhone() {
  5151. m.phone = nil
  5152. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  5153. }
  5154. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  5155. func (m *BatchMsgMutation) PhoneCleared() bool {
  5156. _, ok := m.clearedFields[batchmsg.FieldPhone]
  5157. return ok
  5158. }
  5159. // ResetPhone resets all changes to the "phone" field.
  5160. func (m *BatchMsgMutation) ResetPhone() {
  5161. m.phone = nil
  5162. delete(m.clearedFields, batchmsg.FieldPhone)
  5163. }
  5164. // SetTemplateName sets the "template_name" field.
  5165. func (m *BatchMsgMutation) SetTemplateName(s string) {
  5166. m.template_name = &s
  5167. }
  5168. // TemplateName returns the value of the "template_name" field in the mutation.
  5169. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  5170. v := m.template_name
  5171. if v == nil {
  5172. return
  5173. }
  5174. return *v, true
  5175. }
  5176. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  5177. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5179. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  5180. if !m.op.Is(OpUpdateOne) {
  5181. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  5182. }
  5183. if m.id == nil || m.oldValue == nil {
  5184. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  5185. }
  5186. oldValue, err := m.oldValue(ctx)
  5187. if err != nil {
  5188. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  5189. }
  5190. return oldValue.TemplateName, nil
  5191. }
  5192. // ClearTemplateName clears the value of the "template_name" field.
  5193. func (m *BatchMsgMutation) ClearTemplateName() {
  5194. m.template_name = nil
  5195. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  5196. }
  5197. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  5198. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  5199. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  5200. return ok
  5201. }
  5202. // ResetTemplateName resets all changes to the "template_name" field.
  5203. func (m *BatchMsgMutation) ResetTemplateName() {
  5204. m.template_name = nil
  5205. delete(m.clearedFields, batchmsg.FieldTemplateName)
  5206. }
  5207. // SetTemplateCode sets the "template_code" field.
  5208. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  5209. m.template_code = &s
  5210. }
  5211. // TemplateCode returns the value of the "template_code" field in the mutation.
  5212. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  5213. v := m.template_code
  5214. if v == nil {
  5215. return
  5216. }
  5217. return *v, true
  5218. }
  5219. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  5220. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5222. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  5223. if !m.op.Is(OpUpdateOne) {
  5224. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  5225. }
  5226. if m.id == nil || m.oldValue == nil {
  5227. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  5228. }
  5229. oldValue, err := m.oldValue(ctx)
  5230. if err != nil {
  5231. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  5232. }
  5233. return oldValue.TemplateCode, nil
  5234. }
  5235. // ClearTemplateCode clears the value of the "template_code" field.
  5236. func (m *BatchMsgMutation) ClearTemplateCode() {
  5237. m.template_code = nil
  5238. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  5239. }
  5240. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  5241. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  5242. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  5243. return ok
  5244. }
  5245. // ResetTemplateCode resets all changes to the "template_code" field.
  5246. func (m *BatchMsgMutation) ResetTemplateCode() {
  5247. m.template_code = nil
  5248. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  5249. }
  5250. // SetLang sets the "lang" field.
  5251. func (m *BatchMsgMutation) SetLang(s string) {
  5252. m.lang = &s
  5253. }
  5254. // Lang returns the value of the "lang" field in the mutation.
  5255. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  5256. v := m.lang
  5257. if v == nil {
  5258. return
  5259. }
  5260. return *v, true
  5261. }
  5262. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  5263. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5265. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  5266. if !m.op.Is(OpUpdateOne) {
  5267. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  5268. }
  5269. if m.id == nil || m.oldValue == nil {
  5270. return v, errors.New("OldLang requires an ID field in the mutation")
  5271. }
  5272. oldValue, err := m.oldValue(ctx)
  5273. if err != nil {
  5274. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  5275. }
  5276. return oldValue.Lang, nil
  5277. }
  5278. // ClearLang clears the value of the "lang" field.
  5279. func (m *BatchMsgMutation) ClearLang() {
  5280. m.lang = nil
  5281. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  5282. }
  5283. // LangCleared returns if the "lang" field was cleared in this mutation.
  5284. func (m *BatchMsgMutation) LangCleared() bool {
  5285. _, ok := m.clearedFields[batchmsg.FieldLang]
  5286. return ok
  5287. }
  5288. // ResetLang resets all changes to the "lang" field.
  5289. func (m *BatchMsgMutation) ResetLang() {
  5290. m.lang = nil
  5291. delete(m.clearedFields, batchmsg.FieldLang)
  5292. }
  5293. // Where appends a list predicates to the BatchMsgMutation builder.
  5294. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  5295. m.predicates = append(m.predicates, ps...)
  5296. }
  5297. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  5298. // users can use type-assertion to append predicates that do not depend on any generated package.
  5299. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  5300. p := make([]predicate.BatchMsg, len(ps))
  5301. for i := range ps {
  5302. p[i] = ps[i]
  5303. }
  5304. m.Where(p...)
  5305. }
  5306. // Op returns the operation name.
  5307. func (m *BatchMsgMutation) Op() Op {
  5308. return m.op
  5309. }
  5310. // SetOp allows setting the mutation operation.
  5311. func (m *BatchMsgMutation) SetOp(op Op) {
  5312. m.op = op
  5313. }
  5314. // Type returns the node type of this mutation (BatchMsg).
  5315. func (m *BatchMsgMutation) Type() string {
  5316. return m.typ
  5317. }
  5318. // Fields returns all fields that were changed during this mutation. Note that in
  5319. // order to get all numeric fields that were incremented/decremented, call
  5320. // AddedFields().
  5321. func (m *BatchMsgMutation) Fields() []string {
  5322. fields := make([]string, 0, 24)
  5323. if m.created_at != nil {
  5324. fields = append(fields, batchmsg.FieldCreatedAt)
  5325. }
  5326. if m.updated_at != nil {
  5327. fields = append(fields, batchmsg.FieldUpdatedAt)
  5328. }
  5329. if m.deleted_at != nil {
  5330. fields = append(fields, batchmsg.FieldDeletedAt)
  5331. }
  5332. if m.status != nil {
  5333. fields = append(fields, batchmsg.FieldStatus)
  5334. }
  5335. if m.batch_no != nil {
  5336. fields = append(fields, batchmsg.FieldBatchNo)
  5337. }
  5338. if m.task_name != nil {
  5339. fields = append(fields, batchmsg.FieldTaskName)
  5340. }
  5341. if m.fromwxid != nil {
  5342. fields = append(fields, batchmsg.FieldFromwxid)
  5343. }
  5344. if m.msg != nil {
  5345. fields = append(fields, batchmsg.FieldMsg)
  5346. }
  5347. if m.tag != nil {
  5348. fields = append(fields, batchmsg.FieldTag)
  5349. }
  5350. if m.tagids != nil {
  5351. fields = append(fields, batchmsg.FieldTagids)
  5352. }
  5353. if m.total != nil {
  5354. fields = append(fields, batchmsg.FieldTotal)
  5355. }
  5356. if m.success != nil {
  5357. fields = append(fields, batchmsg.FieldSuccess)
  5358. }
  5359. if m.fail != nil {
  5360. fields = append(fields, batchmsg.FieldFail)
  5361. }
  5362. if m.start_time != nil {
  5363. fields = append(fields, batchmsg.FieldStartTime)
  5364. }
  5365. if m.stop_time != nil {
  5366. fields = append(fields, batchmsg.FieldStopTime)
  5367. }
  5368. if m.send_time != nil {
  5369. fields = append(fields, batchmsg.FieldSendTime)
  5370. }
  5371. if m._type != nil {
  5372. fields = append(fields, batchmsg.FieldType)
  5373. }
  5374. if m.organization_id != nil {
  5375. fields = append(fields, batchmsg.FieldOrganizationID)
  5376. }
  5377. if m.ctype != nil {
  5378. fields = append(fields, batchmsg.FieldCtype)
  5379. }
  5380. if m.cc != nil {
  5381. fields = append(fields, batchmsg.FieldCc)
  5382. }
  5383. if m.phone != nil {
  5384. fields = append(fields, batchmsg.FieldPhone)
  5385. }
  5386. if m.template_name != nil {
  5387. fields = append(fields, batchmsg.FieldTemplateName)
  5388. }
  5389. if m.template_code != nil {
  5390. fields = append(fields, batchmsg.FieldTemplateCode)
  5391. }
  5392. if m.lang != nil {
  5393. fields = append(fields, batchmsg.FieldLang)
  5394. }
  5395. return fields
  5396. }
  5397. // Field returns the value of a field with the given name. The second boolean
  5398. // return value indicates that this field was not set, or was not defined in the
  5399. // schema.
  5400. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5401. switch name {
  5402. case batchmsg.FieldCreatedAt:
  5403. return m.CreatedAt()
  5404. case batchmsg.FieldUpdatedAt:
  5405. return m.UpdatedAt()
  5406. case batchmsg.FieldDeletedAt:
  5407. return m.DeletedAt()
  5408. case batchmsg.FieldStatus:
  5409. return m.Status()
  5410. case batchmsg.FieldBatchNo:
  5411. return m.BatchNo()
  5412. case batchmsg.FieldTaskName:
  5413. return m.TaskName()
  5414. case batchmsg.FieldFromwxid:
  5415. return m.Fromwxid()
  5416. case batchmsg.FieldMsg:
  5417. return m.Msg()
  5418. case batchmsg.FieldTag:
  5419. return m.Tag()
  5420. case batchmsg.FieldTagids:
  5421. return m.Tagids()
  5422. case batchmsg.FieldTotal:
  5423. return m.Total()
  5424. case batchmsg.FieldSuccess:
  5425. return m.Success()
  5426. case batchmsg.FieldFail:
  5427. return m.Fail()
  5428. case batchmsg.FieldStartTime:
  5429. return m.StartTime()
  5430. case batchmsg.FieldStopTime:
  5431. return m.StopTime()
  5432. case batchmsg.FieldSendTime:
  5433. return m.SendTime()
  5434. case batchmsg.FieldType:
  5435. return m.GetType()
  5436. case batchmsg.FieldOrganizationID:
  5437. return m.OrganizationID()
  5438. case batchmsg.FieldCtype:
  5439. return m.Ctype()
  5440. case batchmsg.FieldCc:
  5441. return m.Cc()
  5442. case batchmsg.FieldPhone:
  5443. return m.Phone()
  5444. case batchmsg.FieldTemplateName:
  5445. return m.TemplateName()
  5446. case batchmsg.FieldTemplateCode:
  5447. return m.TemplateCode()
  5448. case batchmsg.FieldLang:
  5449. return m.Lang()
  5450. }
  5451. return nil, false
  5452. }
  5453. // OldField returns the old value of the field from the database. An error is
  5454. // returned if the mutation operation is not UpdateOne, or the query to the
  5455. // database failed.
  5456. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5457. switch name {
  5458. case batchmsg.FieldCreatedAt:
  5459. return m.OldCreatedAt(ctx)
  5460. case batchmsg.FieldUpdatedAt:
  5461. return m.OldUpdatedAt(ctx)
  5462. case batchmsg.FieldDeletedAt:
  5463. return m.OldDeletedAt(ctx)
  5464. case batchmsg.FieldStatus:
  5465. return m.OldStatus(ctx)
  5466. case batchmsg.FieldBatchNo:
  5467. return m.OldBatchNo(ctx)
  5468. case batchmsg.FieldTaskName:
  5469. return m.OldTaskName(ctx)
  5470. case batchmsg.FieldFromwxid:
  5471. return m.OldFromwxid(ctx)
  5472. case batchmsg.FieldMsg:
  5473. return m.OldMsg(ctx)
  5474. case batchmsg.FieldTag:
  5475. return m.OldTag(ctx)
  5476. case batchmsg.FieldTagids:
  5477. return m.OldTagids(ctx)
  5478. case batchmsg.FieldTotal:
  5479. return m.OldTotal(ctx)
  5480. case batchmsg.FieldSuccess:
  5481. return m.OldSuccess(ctx)
  5482. case batchmsg.FieldFail:
  5483. return m.OldFail(ctx)
  5484. case batchmsg.FieldStartTime:
  5485. return m.OldStartTime(ctx)
  5486. case batchmsg.FieldStopTime:
  5487. return m.OldStopTime(ctx)
  5488. case batchmsg.FieldSendTime:
  5489. return m.OldSendTime(ctx)
  5490. case batchmsg.FieldType:
  5491. return m.OldType(ctx)
  5492. case batchmsg.FieldOrganizationID:
  5493. return m.OldOrganizationID(ctx)
  5494. case batchmsg.FieldCtype:
  5495. return m.OldCtype(ctx)
  5496. case batchmsg.FieldCc:
  5497. return m.OldCc(ctx)
  5498. case batchmsg.FieldPhone:
  5499. return m.OldPhone(ctx)
  5500. case batchmsg.FieldTemplateName:
  5501. return m.OldTemplateName(ctx)
  5502. case batchmsg.FieldTemplateCode:
  5503. return m.OldTemplateCode(ctx)
  5504. case batchmsg.FieldLang:
  5505. return m.OldLang(ctx)
  5506. }
  5507. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5508. }
  5509. // SetField sets the value of a field with the given name. It returns an error if
  5510. // the field is not defined in the schema, or if the type mismatched the field
  5511. // type.
  5512. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5513. switch name {
  5514. case batchmsg.FieldCreatedAt:
  5515. v, ok := value.(time.Time)
  5516. if !ok {
  5517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5518. }
  5519. m.SetCreatedAt(v)
  5520. return nil
  5521. case batchmsg.FieldUpdatedAt:
  5522. v, ok := value.(time.Time)
  5523. if !ok {
  5524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5525. }
  5526. m.SetUpdatedAt(v)
  5527. return nil
  5528. case batchmsg.FieldDeletedAt:
  5529. v, ok := value.(time.Time)
  5530. if !ok {
  5531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5532. }
  5533. m.SetDeletedAt(v)
  5534. return nil
  5535. case batchmsg.FieldStatus:
  5536. v, ok := value.(uint8)
  5537. if !ok {
  5538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5539. }
  5540. m.SetStatus(v)
  5541. return nil
  5542. case batchmsg.FieldBatchNo:
  5543. v, ok := value.(string)
  5544. if !ok {
  5545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5546. }
  5547. m.SetBatchNo(v)
  5548. return nil
  5549. case batchmsg.FieldTaskName:
  5550. v, ok := value.(string)
  5551. if !ok {
  5552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5553. }
  5554. m.SetTaskName(v)
  5555. return nil
  5556. case batchmsg.FieldFromwxid:
  5557. v, ok := value.(string)
  5558. if !ok {
  5559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5560. }
  5561. m.SetFromwxid(v)
  5562. return nil
  5563. case batchmsg.FieldMsg:
  5564. v, ok := value.(string)
  5565. if !ok {
  5566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5567. }
  5568. m.SetMsg(v)
  5569. return nil
  5570. case batchmsg.FieldTag:
  5571. v, ok := value.(string)
  5572. if !ok {
  5573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5574. }
  5575. m.SetTag(v)
  5576. return nil
  5577. case batchmsg.FieldTagids:
  5578. v, ok := value.(string)
  5579. if !ok {
  5580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5581. }
  5582. m.SetTagids(v)
  5583. return nil
  5584. case batchmsg.FieldTotal:
  5585. v, ok := value.(int32)
  5586. if !ok {
  5587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5588. }
  5589. m.SetTotal(v)
  5590. return nil
  5591. case batchmsg.FieldSuccess:
  5592. v, ok := value.(int32)
  5593. if !ok {
  5594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5595. }
  5596. m.SetSuccess(v)
  5597. return nil
  5598. case batchmsg.FieldFail:
  5599. v, ok := value.(int32)
  5600. if !ok {
  5601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5602. }
  5603. m.SetFail(v)
  5604. return nil
  5605. case batchmsg.FieldStartTime:
  5606. v, ok := value.(time.Time)
  5607. if !ok {
  5608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5609. }
  5610. m.SetStartTime(v)
  5611. return nil
  5612. case batchmsg.FieldStopTime:
  5613. v, ok := value.(time.Time)
  5614. if !ok {
  5615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5616. }
  5617. m.SetStopTime(v)
  5618. return nil
  5619. case batchmsg.FieldSendTime:
  5620. v, ok := value.(time.Time)
  5621. if !ok {
  5622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5623. }
  5624. m.SetSendTime(v)
  5625. return nil
  5626. case batchmsg.FieldType:
  5627. v, ok := value.(int32)
  5628. if !ok {
  5629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5630. }
  5631. m.SetType(v)
  5632. return nil
  5633. case batchmsg.FieldOrganizationID:
  5634. v, ok := value.(uint64)
  5635. if !ok {
  5636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5637. }
  5638. m.SetOrganizationID(v)
  5639. return nil
  5640. case batchmsg.FieldCtype:
  5641. v, ok := value.(uint64)
  5642. if !ok {
  5643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5644. }
  5645. m.SetCtype(v)
  5646. return nil
  5647. case batchmsg.FieldCc:
  5648. v, ok := value.(string)
  5649. if !ok {
  5650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5651. }
  5652. m.SetCc(v)
  5653. return nil
  5654. case batchmsg.FieldPhone:
  5655. v, ok := value.(string)
  5656. if !ok {
  5657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5658. }
  5659. m.SetPhone(v)
  5660. return nil
  5661. case batchmsg.FieldTemplateName:
  5662. v, ok := value.(string)
  5663. if !ok {
  5664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5665. }
  5666. m.SetTemplateName(v)
  5667. return nil
  5668. case batchmsg.FieldTemplateCode:
  5669. v, ok := value.(string)
  5670. if !ok {
  5671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5672. }
  5673. m.SetTemplateCode(v)
  5674. return nil
  5675. case batchmsg.FieldLang:
  5676. v, ok := value.(string)
  5677. if !ok {
  5678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5679. }
  5680. m.SetLang(v)
  5681. return nil
  5682. }
  5683. return fmt.Errorf("unknown BatchMsg field %s", name)
  5684. }
  5685. // AddedFields returns all numeric fields that were incremented/decremented during
  5686. // this mutation.
  5687. func (m *BatchMsgMutation) AddedFields() []string {
  5688. var fields []string
  5689. if m.addstatus != nil {
  5690. fields = append(fields, batchmsg.FieldStatus)
  5691. }
  5692. if m.addtotal != nil {
  5693. fields = append(fields, batchmsg.FieldTotal)
  5694. }
  5695. if m.addsuccess != nil {
  5696. fields = append(fields, batchmsg.FieldSuccess)
  5697. }
  5698. if m.addfail != nil {
  5699. fields = append(fields, batchmsg.FieldFail)
  5700. }
  5701. if m.add_type != nil {
  5702. fields = append(fields, batchmsg.FieldType)
  5703. }
  5704. if m.addorganization_id != nil {
  5705. fields = append(fields, batchmsg.FieldOrganizationID)
  5706. }
  5707. if m.addctype != nil {
  5708. fields = append(fields, batchmsg.FieldCtype)
  5709. }
  5710. return fields
  5711. }
  5712. // AddedField returns the numeric value that was incremented/decremented on a field
  5713. // with the given name. The second boolean return value indicates that this field
  5714. // was not set, or was not defined in the schema.
  5715. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5716. switch name {
  5717. case batchmsg.FieldStatus:
  5718. return m.AddedStatus()
  5719. case batchmsg.FieldTotal:
  5720. return m.AddedTotal()
  5721. case batchmsg.FieldSuccess:
  5722. return m.AddedSuccess()
  5723. case batchmsg.FieldFail:
  5724. return m.AddedFail()
  5725. case batchmsg.FieldType:
  5726. return m.AddedType()
  5727. case batchmsg.FieldOrganizationID:
  5728. return m.AddedOrganizationID()
  5729. case batchmsg.FieldCtype:
  5730. return m.AddedCtype()
  5731. }
  5732. return nil, false
  5733. }
  5734. // AddField adds the value to the field with the given name. It returns an error if
  5735. // the field is not defined in the schema, or if the type mismatched the field
  5736. // type.
  5737. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5738. switch name {
  5739. case batchmsg.FieldStatus:
  5740. v, ok := value.(int8)
  5741. if !ok {
  5742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5743. }
  5744. m.AddStatus(v)
  5745. return nil
  5746. case batchmsg.FieldTotal:
  5747. v, ok := value.(int32)
  5748. if !ok {
  5749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5750. }
  5751. m.AddTotal(v)
  5752. return nil
  5753. case batchmsg.FieldSuccess:
  5754. v, ok := value.(int32)
  5755. if !ok {
  5756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5757. }
  5758. m.AddSuccess(v)
  5759. return nil
  5760. case batchmsg.FieldFail:
  5761. v, ok := value.(int32)
  5762. if !ok {
  5763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5764. }
  5765. m.AddFail(v)
  5766. return nil
  5767. case batchmsg.FieldType:
  5768. v, ok := value.(int32)
  5769. if !ok {
  5770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5771. }
  5772. m.AddType(v)
  5773. return nil
  5774. case batchmsg.FieldOrganizationID:
  5775. v, ok := value.(int64)
  5776. if !ok {
  5777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5778. }
  5779. m.AddOrganizationID(v)
  5780. return nil
  5781. case batchmsg.FieldCtype:
  5782. v, ok := value.(int64)
  5783. if !ok {
  5784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5785. }
  5786. m.AddCtype(v)
  5787. return nil
  5788. }
  5789. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5790. }
  5791. // ClearedFields returns all nullable fields that were cleared during this
  5792. // mutation.
  5793. func (m *BatchMsgMutation) ClearedFields() []string {
  5794. var fields []string
  5795. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5796. fields = append(fields, batchmsg.FieldDeletedAt)
  5797. }
  5798. if m.FieldCleared(batchmsg.FieldStatus) {
  5799. fields = append(fields, batchmsg.FieldStatus)
  5800. }
  5801. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5802. fields = append(fields, batchmsg.FieldBatchNo)
  5803. }
  5804. if m.FieldCleared(batchmsg.FieldTaskName) {
  5805. fields = append(fields, batchmsg.FieldTaskName)
  5806. }
  5807. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5808. fields = append(fields, batchmsg.FieldFromwxid)
  5809. }
  5810. if m.FieldCleared(batchmsg.FieldMsg) {
  5811. fields = append(fields, batchmsg.FieldMsg)
  5812. }
  5813. if m.FieldCleared(batchmsg.FieldTag) {
  5814. fields = append(fields, batchmsg.FieldTag)
  5815. }
  5816. if m.FieldCleared(batchmsg.FieldTagids) {
  5817. fields = append(fields, batchmsg.FieldTagids)
  5818. }
  5819. if m.FieldCleared(batchmsg.FieldTotal) {
  5820. fields = append(fields, batchmsg.FieldTotal)
  5821. }
  5822. if m.FieldCleared(batchmsg.FieldSuccess) {
  5823. fields = append(fields, batchmsg.FieldSuccess)
  5824. }
  5825. if m.FieldCleared(batchmsg.FieldFail) {
  5826. fields = append(fields, batchmsg.FieldFail)
  5827. }
  5828. if m.FieldCleared(batchmsg.FieldStartTime) {
  5829. fields = append(fields, batchmsg.FieldStartTime)
  5830. }
  5831. if m.FieldCleared(batchmsg.FieldStopTime) {
  5832. fields = append(fields, batchmsg.FieldStopTime)
  5833. }
  5834. if m.FieldCleared(batchmsg.FieldSendTime) {
  5835. fields = append(fields, batchmsg.FieldSendTime)
  5836. }
  5837. if m.FieldCleared(batchmsg.FieldType) {
  5838. fields = append(fields, batchmsg.FieldType)
  5839. }
  5840. if m.FieldCleared(batchmsg.FieldCc) {
  5841. fields = append(fields, batchmsg.FieldCc)
  5842. }
  5843. if m.FieldCleared(batchmsg.FieldPhone) {
  5844. fields = append(fields, batchmsg.FieldPhone)
  5845. }
  5846. if m.FieldCleared(batchmsg.FieldTemplateName) {
  5847. fields = append(fields, batchmsg.FieldTemplateName)
  5848. }
  5849. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  5850. fields = append(fields, batchmsg.FieldTemplateCode)
  5851. }
  5852. if m.FieldCleared(batchmsg.FieldLang) {
  5853. fields = append(fields, batchmsg.FieldLang)
  5854. }
  5855. return fields
  5856. }
  5857. // FieldCleared returns a boolean indicating if a field with the given name was
  5858. // cleared in this mutation.
  5859. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5860. _, ok := m.clearedFields[name]
  5861. return ok
  5862. }
  5863. // ClearField clears the value of the field with the given name. It returns an
  5864. // error if the field is not defined in the schema.
  5865. func (m *BatchMsgMutation) ClearField(name string) error {
  5866. switch name {
  5867. case batchmsg.FieldDeletedAt:
  5868. m.ClearDeletedAt()
  5869. return nil
  5870. case batchmsg.FieldStatus:
  5871. m.ClearStatus()
  5872. return nil
  5873. case batchmsg.FieldBatchNo:
  5874. m.ClearBatchNo()
  5875. return nil
  5876. case batchmsg.FieldTaskName:
  5877. m.ClearTaskName()
  5878. return nil
  5879. case batchmsg.FieldFromwxid:
  5880. m.ClearFromwxid()
  5881. return nil
  5882. case batchmsg.FieldMsg:
  5883. m.ClearMsg()
  5884. return nil
  5885. case batchmsg.FieldTag:
  5886. m.ClearTag()
  5887. return nil
  5888. case batchmsg.FieldTagids:
  5889. m.ClearTagids()
  5890. return nil
  5891. case batchmsg.FieldTotal:
  5892. m.ClearTotal()
  5893. return nil
  5894. case batchmsg.FieldSuccess:
  5895. m.ClearSuccess()
  5896. return nil
  5897. case batchmsg.FieldFail:
  5898. m.ClearFail()
  5899. return nil
  5900. case batchmsg.FieldStartTime:
  5901. m.ClearStartTime()
  5902. return nil
  5903. case batchmsg.FieldStopTime:
  5904. m.ClearStopTime()
  5905. return nil
  5906. case batchmsg.FieldSendTime:
  5907. m.ClearSendTime()
  5908. return nil
  5909. case batchmsg.FieldType:
  5910. m.ClearType()
  5911. return nil
  5912. case batchmsg.FieldCc:
  5913. m.ClearCc()
  5914. return nil
  5915. case batchmsg.FieldPhone:
  5916. m.ClearPhone()
  5917. return nil
  5918. case batchmsg.FieldTemplateName:
  5919. m.ClearTemplateName()
  5920. return nil
  5921. case batchmsg.FieldTemplateCode:
  5922. m.ClearTemplateCode()
  5923. return nil
  5924. case batchmsg.FieldLang:
  5925. m.ClearLang()
  5926. return nil
  5927. }
  5928. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5929. }
  5930. // ResetField resets all changes in the mutation for the field with the given name.
  5931. // It returns an error if the field is not defined in the schema.
  5932. func (m *BatchMsgMutation) ResetField(name string) error {
  5933. switch name {
  5934. case batchmsg.FieldCreatedAt:
  5935. m.ResetCreatedAt()
  5936. return nil
  5937. case batchmsg.FieldUpdatedAt:
  5938. m.ResetUpdatedAt()
  5939. return nil
  5940. case batchmsg.FieldDeletedAt:
  5941. m.ResetDeletedAt()
  5942. return nil
  5943. case batchmsg.FieldStatus:
  5944. m.ResetStatus()
  5945. return nil
  5946. case batchmsg.FieldBatchNo:
  5947. m.ResetBatchNo()
  5948. return nil
  5949. case batchmsg.FieldTaskName:
  5950. m.ResetTaskName()
  5951. return nil
  5952. case batchmsg.FieldFromwxid:
  5953. m.ResetFromwxid()
  5954. return nil
  5955. case batchmsg.FieldMsg:
  5956. m.ResetMsg()
  5957. return nil
  5958. case batchmsg.FieldTag:
  5959. m.ResetTag()
  5960. return nil
  5961. case batchmsg.FieldTagids:
  5962. m.ResetTagids()
  5963. return nil
  5964. case batchmsg.FieldTotal:
  5965. m.ResetTotal()
  5966. return nil
  5967. case batchmsg.FieldSuccess:
  5968. m.ResetSuccess()
  5969. return nil
  5970. case batchmsg.FieldFail:
  5971. m.ResetFail()
  5972. return nil
  5973. case batchmsg.FieldStartTime:
  5974. m.ResetStartTime()
  5975. return nil
  5976. case batchmsg.FieldStopTime:
  5977. m.ResetStopTime()
  5978. return nil
  5979. case batchmsg.FieldSendTime:
  5980. m.ResetSendTime()
  5981. return nil
  5982. case batchmsg.FieldType:
  5983. m.ResetType()
  5984. return nil
  5985. case batchmsg.FieldOrganizationID:
  5986. m.ResetOrganizationID()
  5987. return nil
  5988. case batchmsg.FieldCtype:
  5989. m.ResetCtype()
  5990. return nil
  5991. case batchmsg.FieldCc:
  5992. m.ResetCc()
  5993. return nil
  5994. case batchmsg.FieldPhone:
  5995. m.ResetPhone()
  5996. return nil
  5997. case batchmsg.FieldTemplateName:
  5998. m.ResetTemplateName()
  5999. return nil
  6000. case batchmsg.FieldTemplateCode:
  6001. m.ResetTemplateCode()
  6002. return nil
  6003. case batchmsg.FieldLang:
  6004. m.ResetLang()
  6005. return nil
  6006. }
  6007. return fmt.Errorf("unknown BatchMsg field %s", name)
  6008. }
  6009. // AddedEdges returns all edge names that were set/added in this mutation.
  6010. func (m *BatchMsgMutation) AddedEdges() []string {
  6011. edges := make([]string, 0, 0)
  6012. return edges
  6013. }
  6014. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6015. // name in this mutation.
  6016. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  6017. return nil
  6018. }
  6019. // RemovedEdges returns all edge names that were removed in this mutation.
  6020. func (m *BatchMsgMutation) RemovedEdges() []string {
  6021. edges := make([]string, 0, 0)
  6022. return edges
  6023. }
  6024. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6025. // the given name in this mutation.
  6026. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  6027. return nil
  6028. }
  6029. // ClearedEdges returns all edge names that were cleared in this mutation.
  6030. func (m *BatchMsgMutation) ClearedEdges() []string {
  6031. edges := make([]string, 0, 0)
  6032. return edges
  6033. }
  6034. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6035. // was cleared in this mutation.
  6036. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  6037. return false
  6038. }
  6039. // ClearEdge clears the value of the edge with the given name. It returns an error
  6040. // if that edge is not defined in the schema.
  6041. func (m *BatchMsgMutation) ClearEdge(name string) error {
  6042. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  6043. }
  6044. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6045. // It returns an error if the edge is not defined in the schema.
  6046. func (m *BatchMsgMutation) ResetEdge(name string) error {
  6047. return fmt.Errorf("unknown BatchMsg edge %s", name)
  6048. }
  6049. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  6050. type CategoryMutation struct {
  6051. config
  6052. op Op
  6053. typ string
  6054. id *uint64
  6055. created_at *time.Time
  6056. updated_at *time.Time
  6057. deleted_at *time.Time
  6058. name *string
  6059. organization_id *uint64
  6060. addorganization_id *int64
  6061. clearedFields map[string]struct{}
  6062. done bool
  6063. oldValue func(context.Context) (*Category, error)
  6064. predicates []predicate.Category
  6065. }
  6066. var _ ent.Mutation = (*CategoryMutation)(nil)
  6067. // categoryOption allows management of the mutation configuration using functional options.
  6068. type categoryOption func(*CategoryMutation)
  6069. // newCategoryMutation creates new mutation for the Category entity.
  6070. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  6071. m := &CategoryMutation{
  6072. config: c,
  6073. op: op,
  6074. typ: TypeCategory,
  6075. clearedFields: make(map[string]struct{}),
  6076. }
  6077. for _, opt := range opts {
  6078. opt(m)
  6079. }
  6080. return m
  6081. }
  6082. // withCategoryID sets the ID field of the mutation.
  6083. func withCategoryID(id uint64) categoryOption {
  6084. return func(m *CategoryMutation) {
  6085. var (
  6086. err error
  6087. once sync.Once
  6088. value *Category
  6089. )
  6090. m.oldValue = func(ctx context.Context) (*Category, error) {
  6091. once.Do(func() {
  6092. if m.done {
  6093. err = errors.New("querying old values post mutation is not allowed")
  6094. } else {
  6095. value, err = m.Client().Category.Get(ctx, id)
  6096. }
  6097. })
  6098. return value, err
  6099. }
  6100. m.id = &id
  6101. }
  6102. }
  6103. // withCategory sets the old Category of the mutation.
  6104. func withCategory(node *Category) categoryOption {
  6105. return func(m *CategoryMutation) {
  6106. m.oldValue = func(context.Context) (*Category, error) {
  6107. return node, nil
  6108. }
  6109. m.id = &node.ID
  6110. }
  6111. }
  6112. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6113. // executed in a transaction (ent.Tx), a transactional client is returned.
  6114. func (m CategoryMutation) Client() *Client {
  6115. client := &Client{config: m.config}
  6116. client.init()
  6117. return client
  6118. }
  6119. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6120. // it returns an error otherwise.
  6121. func (m CategoryMutation) Tx() (*Tx, error) {
  6122. if _, ok := m.driver.(*txDriver); !ok {
  6123. return nil, errors.New("ent: mutation is not running in a transaction")
  6124. }
  6125. tx := &Tx{config: m.config}
  6126. tx.init()
  6127. return tx, nil
  6128. }
  6129. // SetID sets the value of the id field. Note that this
  6130. // operation is only accepted on creation of Category entities.
  6131. func (m *CategoryMutation) SetID(id uint64) {
  6132. m.id = &id
  6133. }
  6134. // ID returns the ID value in the mutation. Note that the ID is only available
  6135. // if it was provided to the builder or after it was returned from the database.
  6136. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  6137. if m.id == nil {
  6138. return
  6139. }
  6140. return *m.id, true
  6141. }
  6142. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6143. // That means, if the mutation is applied within a transaction with an isolation level such
  6144. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6145. // or updated by the mutation.
  6146. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  6147. switch {
  6148. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6149. id, exists := m.ID()
  6150. if exists {
  6151. return []uint64{id}, nil
  6152. }
  6153. fallthrough
  6154. case m.op.Is(OpUpdate | OpDelete):
  6155. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  6156. default:
  6157. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6158. }
  6159. }
  6160. // SetCreatedAt sets the "created_at" field.
  6161. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  6162. m.created_at = &t
  6163. }
  6164. // CreatedAt returns the value of the "created_at" field in the mutation.
  6165. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  6166. v := m.created_at
  6167. if v == nil {
  6168. return
  6169. }
  6170. return *v, true
  6171. }
  6172. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  6173. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6175. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6176. if !m.op.Is(OpUpdateOne) {
  6177. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6178. }
  6179. if m.id == nil || m.oldValue == nil {
  6180. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6181. }
  6182. oldValue, err := m.oldValue(ctx)
  6183. if err != nil {
  6184. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6185. }
  6186. return oldValue.CreatedAt, nil
  6187. }
  6188. // ResetCreatedAt resets all changes to the "created_at" field.
  6189. func (m *CategoryMutation) ResetCreatedAt() {
  6190. m.created_at = nil
  6191. }
  6192. // SetUpdatedAt sets the "updated_at" field.
  6193. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  6194. m.updated_at = &t
  6195. }
  6196. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6197. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  6198. v := m.updated_at
  6199. if v == nil {
  6200. return
  6201. }
  6202. return *v, true
  6203. }
  6204. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  6205. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6207. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6208. if !m.op.Is(OpUpdateOne) {
  6209. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6210. }
  6211. if m.id == nil || m.oldValue == nil {
  6212. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6213. }
  6214. oldValue, err := m.oldValue(ctx)
  6215. if err != nil {
  6216. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6217. }
  6218. return oldValue.UpdatedAt, nil
  6219. }
  6220. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6221. func (m *CategoryMutation) ResetUpdatedAt() {
  6222. m.updated_at = nil
  6223. }
  6224. // SetDeletedAt sets the "deleted_at" field.
  6225. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  6226. m.deleted_at = &t
  6227. }
  6228. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6229. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  6230. v := m.deleted_at
  6231. if v == nil {
  6232. return
  6233. }
  6234. return *v, true
  6235. }
  6236. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  6237. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6239. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6240. if !m.op.Is(OpUpdateOne) {
  6241. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6242. }
  6243. if m.id == nil || m.oldValue == nil {
  6244. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6245. }
  6246. oldValue, err := m.oldValue(ctx)
  6247. if err != nil {
  6248. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6249. }
  6250. return oldValue.DeletedAt, nil
  6251. }
  6252. // ClearDeletedAt clears the value of the "deleted_at" field.
  6253. func (m *CategoryMutation) ClearDeletedAt() {
  6254. m.deleted_at = nil
  6255. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  6256. }
  6257. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6258. func (m *CategoryMutation) DeletedAtCleared() bool {
  6259. _, ok := m.clearedFields[category.FieldDeletedAt]
  6260. return ok
  6261. }
  6262. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6263. func (m *CategoryMutation) ResetDeletedAt() {
  6264. m.deleted_at = nil
  6265. delete(m.clearedFields, category.FieldDeletedAt)
  6266. }
  6267. // SetName sets the "name" field.
  6268. func (m *CategoryMutation) SetName(s string) {
  6269. m.name = &s
  6270. }
  6271. // Name returns the value of the "name" field in the mutation.
  6272. func (m *CategoryMutation) Name() (r string, exists bool) {
  6273. v := m.name
  6274. if v == nil {
  6275. return
  6276. }
  6277. return *v, true
  6278. }
  6279. // OldName returns the old "name" field's value of the Category entity.
  6280. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6282. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  6283. if !m.op.Is(OpUpdateOne) {
  6284. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6285. }
  6286. if m.id == nil || m.oldValue == nil {
  6287. return v, errors.New("OldName requires an ID field in the mutation")
  6288. }
  6289. oldValue, err := m.oldValue(ctx)
  6290. if err != nil {
  6291. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6292. }
  6293. return oldValue.Name, nil
  6294. }
  6295. // ResetName resets all changes to the "name" field.
  6296. func (m *CategoryMutation) ResetName() {
  6297. m.name = nil
  6298. }
  6299. // SetOrganizationID sets the "organization_id" field.
  6300. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  6301. m.organization_id = &u
  6302. m.addorganization_id = nil
  6303. }
  6304. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6305. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  6306. v := m.organization_id
  6307. if v == nil {
  6308. return
  6309. }
  6310. return *v, true
  6311. }
  6312. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  6313. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6315. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6316. if !m.op.Is(OpUpdateOne) {
  6317. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6318. }
  6319. if m.id == nil || m.oldValue == nil {
  6320. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6321. }
  6322. oldValue, err := m.oldValue(ctx)
  6323. if err != nil {
  6324. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6325. }
  6326. return oldValue.OrganizationID, nil
  6327. }
  6328. // AddOrganizationID adds u to the "organization_id" field.
  6329. func (m *CategoryMutation) AddOrganizationID(u int64) {
  6330. if m.addorganization_id != nil {
  6331. *m.addorganization_id += u
  6332. } else {
  6333. m.addorganization_id = &u
  6334. }
  6335. }
  6336. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6337. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  6338. v := m.addorganization_id
  6339. if v == nil {
  6340. return
  6341. }
  6342. return *v, true
  6343. }
  6344. // ResetOrganizationID resets all changes to the "organization_id" field.
  6345. func (m *CategoryMutation) ResetOrganizationID() {
  6346. m.organization_id = nil
  6347. m.addorganization_id = nil
  6348. }
  6349. // Where appends a list predicates to the CategoryMutation builder.
  6350. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  6351. m.predicates = append(m.predicates, ps...)
  6352. }
  6353. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  6354. // users can use type-assertion to append predicates that do not depend on any generated package.
  6355. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  6356. p := make([]predicate.Category, len(ps))
  6357. for i := range ps {
  6358. p[i] = ps[i]
  6359. }
  6360. m.Where(p...)
  6361. }
  6362. // Op returns the operation name.
  6363. func (m *CategoryMutation) Op() Op {
  6364. return m.op
  6365. }
  6366. // SetOp allows setting the mutation operation.
  6367. func (m *CategoryMutation) SetOp(op Op) {
  6368. m.op = op
  6369. }
  6370. // Type returns the node type of this mutation (Category).
  6371. func (m *CategoryMutation) Type() string {
  6372. return m.typ
  6373. }
  6374. // Fields returns all fields that were changed during this mutation. Note that in
  6375. // order to get all numeric fields that were incremented/decremented, call
  6376. // AddedFields().
  6377. func (m *CategoryMutation) Fields() []string {
  6378. fields := make([]string, 0, 5)
  6379. if m.created_at != nil {
  6380. fields = append(fields, category.FieldCreatedAt)
  6381. }
  6382. if m.updated_at != nil {
  6383. fields = append(fields, category.FieldUpdatedAt)
  6384. }
  6385. if m.deleted_at != nil {
  6386. fields = append(fields, category.FieldDeletedAt)
  6387. }
  6388. if m.name != nil {
  6389. fields = append(fields, category.FieldName)
  6390. }
  6391. if m.organization_id != nil {
  6392. fields = append(fields, category.FieldOrganizationID)
  6393. }
  6394. return fields
  6395. }
  6396. // Field returns the value of a field with the given name. The second boolean
  6397. // return value indicates that this field was not set, or was not defined in the
  6398. // schema.
  6399. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  6400. switch name {
  6401. case category.FieldCreatedAt:
  6402. return m.CreatedAt()
  6403. case category.FieldUpdatedAt:
  6404. return m.UpdatedAt()
  6405. case category.FieldDeletedAt:
  6406. return m.DeletedAt()
  6407. case category.FieldName:
  6408. return m.Name()
  6409. case category.FieldOrganizationID:
  6410. return m.OrganizationID()
  6411. }
  6412. return nil, false
  6413. }
  6414. // OldField returns the old value of the field from the database. An error is
  6415. // returned if the mutation operation is not UpdateOne, or the query to the
  6416. // database failed.
  6417. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6418. switch name {
  6419. case category.FieldCreatedAt:
  6420. return m.OldCreatedAt(ctx)
  6421. case category.FieldUpdatedAt:
  6422. return m.OldUpdatedAt(ctx)
  6423. case category.FieldDeletedAt:
  6424. return m.OldDeletedAt(ctx)
  6425. case category.FieldName:
  6426. return m.OldName(ctx)
  6427. case category.FieldOrganizationID:
  6428. return m.OldOrganizationID(ctx)
  6429. }
  6430. return nil, fmt.Errorf("unknown Category field %s", name)
  6431. }
  6432. // SetField sets the value of a field with the given name. It returns an error if
  6433. // the field is not defined in the schema, or if the type mismatched the field
  6434. // type.
  6435. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  6436. switch name {
  6437. case category.FieldCreatedAt:
  6438. v, ok := value.(time.Time)
  6439. if !ok {
  6440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6441. }
  6442. m.SetCreatedAt(v)
  6443. return nil
  6444. case category.FieldUpdatedAt:
  6445. v, ok := value.(time.Time)
  6446. if !ok {
  6447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6448. }
  6449. m.SetUpdatedAt(v)
  6450. return nil
  6451. case category.FieldDeletedAt:
  6452. v, ok := value.(time.Time)
  6453. if !ok {
  6454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6455. }
  6456. m.SetDeletedAt(v)
  6457. return nil
  6458. case category.FieldName:
  6459. v, ok := value.(string)
  6460. if !ok {
  6461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6462. }
  6463. m.SetName(v)
  6464. return nil
  6465. case category.FieldOrganizationID:
  6466. v, ok := value.(uint64)
  6467. if !ok {
  6468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6469. }
  6470. m.SetOrganizationID(v)
  6471. return nil
  6472. }
  6473. return fmt.Errorf("unknown Category field %s", name)
  6474. }
  6475. // AddedFields returns all numeric fields that were incremented/decremented during
  6476. // this mutation.
  6477. func (m *CategoryMutation) AddedFields() []string {
  6478. var fields []string
  6479. if m.addorganization_id != nil {
  6480. fields = append(fields, category.FieldOrganizationID)
  6481. }
  6482. return fields
  6483. }
  6484. // AddedField returns the numeric value that was incremented/decremented on a field
  6485. // with the given name. The second boolean return value indicates that this field
  6486. // was not set, or was not defined in the schema.
  6487. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  6488. switch name {
  6489. case category.FieldOrganizationID:
  6490. return m.AddedOrganizationID()
  6491. }
  6492. return nil, false
  6493. }
  6494. // AddField adds the value to the field with the given name. It returns an error if
  6495. // the field is not defined in the schema, or if the type mismatched the field
  6496. // type.
  6497. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6498. switch name {
  6499. case category.FieldOrganizationID:
  6500. v, ok := value.(int64)
  6501. if !ok {
  6502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6503. }
  6504. m.AddOrganizationID(v)
  6505. return nil
  6506. }
  6507. return fmt.Errorf("unknown Category numeric field %s", name)
  6508. }
  6509. // ClearedFields returns all nullable fields that were cleared during this
  6510. // mutation.
  6511. func (m *CategoryMutation) ClearedFields() []string {
  6512. var fields []string
  6513. if m.FieldCleared(category.FieldDeletedAt) {
  6514. fields = append(fields, category.FieldDeletedAt)
  6515. }
  6516. return fields
  6517. }
  6518. // FieldCleared returns a boolean indicating if a field with the given name was
  6519. // cleared in this mutation.
  6520. func (m *CategoryMutation) FieldCleared(name string) bool {
  6521. _, ok := m.clearedFields[name]
  6522. return ok
  6523. }
  6524. // ClearField clears the value of the field with the given name. It returns an
  6525. // error if the field is not defined in the schema.
  6526. func (m *CategoryMutation) ClearField(name string) error {
  6527. switch name {
  6528. case category.FieldDeletedAt:
  6529. m.ClearDeletedAt()
  6530. return nil
  6531. }
  6532. return fmt.Errorf("unknown Category nullable field %s", name)
  6533. }
  6534. // ResetField resets all changes in the mutation for the field with the given name.
  6535. // It returns an error if the field is not defined in the schema.
  6536. func (m *CategoryMutation) ResetField(name string) error {
  6537. switch name {
  6538. case category.FieldCreatedAt:
  6539. m.ResetCreatedAt()
  6540. return nil
  6541. case category.FieldUpdatedAt:
  6542. m.ResetUpdatedAt()
  6543. return nil
  6544. case category.FieldDeletedAt:
  6545. m.ResetDeletedAt()
  6546. return nil
  6547. case category.FieldName:
  6548. m.ResetName()
  6549. return nil
  6550. case category.FieldOrganizationID:
  6551. m.ResetOrganizationID()
  6552. return nil
  6553. }
  6554. return fmt.Errorf("unknown Category field %s", name)
  6555. }
  6556. // AddedEdges returns all edge names that were set/added in this mutation.
  6557. func (m *CategoryMutation) AddedEdges() []string {
  6558. edges := make([]string, 0, 0)
  6559. return edges
  6560. }
  6561. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6562. // name in this mutation.
  6563. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6564. return nil
  6565. }
  6566. // RemovedEdges returns all edge names that were removed in this mutation.
  6567. func (m *CategoryMutation) RemovedEdges() []string {
  6568. edges := make([]string, 0, 0)
  6569. return edges
  6570. }
  6571. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6572. // the given name in this mutation.
  6573. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6574. return nil
  6575. }
  6576. // ClearedEdges returns all edge names that were cleared in this mutation.
  6577. func (m *CategoryMutation) ClearedEdges() []string {
  6578. edges := make([]string, 0, 0)
  6579. return edges
  6580. }
  6581. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6582. // was cleared in this mutation.
  6583. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6584. return false
  6585. }
  6586. // ClearEdge clears the value of the edge with the given name. It returns an error
  6587. // if that edge is not defined in the schema.
  6588. func (m *CategoryMutation) ClearEdge(name string) error {
  6589. return fmt.Errorf("unknown Category unique edge %s", name)
  6590. }
  6591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6592. // It returns an error if the edge is not defined in the schema.
  6593. func (m *CategoryMutation) ResetEdge(name string) error {
  6594. return fmt.Errorf("unknown Category edge %s", name)
  6595. }
  6596. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6597. type ChatRecordsMutation struct {
  6598. config
  6599. op Op
  6600. typ string
  6601. id *uint64
  6602. created_at *time.Time
  6603. updated_at *time.Time
  6604. deleted_at *time.Time
  6605. content *string
  6606. content_type *uint8
  6607. addcontent_type *int8
  6608. session_id *uint64
  6609. addsession_id *int64
  6610. user_id *uint64
  6611. adduser_id *int64
  6612. bot_id *uint64
  6613. addbot_id *int64
  6614. bot_type *uint8
  6615. addbot_type *int8
  6616. clearedFields map[string]struct{}
  6617. done bool
  6618. oldValue func(context.Context) (*ChatRecords, error)
  6619. predicates []predicate.ChatRecords
  6620. }
  6621. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6622. // chatrecordsOption allows management of the mutation configuration using functional options.
  6623. type chatrecordsOption func(*ChatRecordsMutation)
  6624. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6625. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6626. m := &ChatRecordsMutation{
  6627. config: c,
  6628. op: op,
  6629. typ: TypeChatRecords,
  6630. clearedFields: make(map[string]struct{}),
  6631. }
  6632. for _, opt := range opts {
  6633. opt(m)
  6634. }
  6635. return m
  6636. }
  6637. // withChatRecordsID sets the ID field of the mutation.
  6638. func withChatRecordsID(id uint64) chatrecordsOption {
  6639. return func(m *ChatRecordsMutation) {
  6640. var (
  6641. err error
  6642. once sync.Once
  6643. value *ChatRecords
  6644. )
  6645. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6646. once.Do(func() {
  6647. if m.done {
  6648. err = errors.New("querying old values post mutation is not allowed")
  6649. } else {
  6650. value, err = m.Client().ChatRecords.Get(ctx, id)
  6651. }
  6652. })
  6653. return value, err
  6654. }
  6655. m.id = &id
  6656. }
  6657. }
  6658. // withChatRecords sets the old ChatRecords of the mutation.
  6659. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6660. return func(m *ChatRecordsMutation) {
  6661. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6662. return node, nil
  6663. }
  6664. m.id = &node.ID
  6665. }
  6666. }
  6667. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6668. // executed in a transaction (ent.Tx), a transactional client is returned.
  6669. func (m ChatRecordsMutation) Client() *Client {
  6670. client := &Client{config: m.config}
  6671. client.init()
  6672. return client
  6673. }
  6674. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6675. // it returns an error otherwise.
  6676. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6677. if _, ok := m.driver.(*txDriver); !ok {
  6678. return nil, errors.New("ent: mutation is not running in a transaction")
  6679. }
  6680. tx := &Tx{config: m.config}
  6681. tx.init()
  6682. return tx, nil
  6683. }
  6684. // SetID sets the value of the id field. Note that this
  6685. // operation is only accepted on creation of ChatRecords entities.
  6686. func (m *ChatRecordsMutation) SetID(id uint64) {
  6687. m.id = &id
  6688. }
  6689. // ID returns the ID value in the mutation. Note that the ID is only available
  6690. // if it was provided to the builder or after it was returned from the database.
  6691. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6692. if m.id == nil {
  6693. return
  6694. }
  6695. return *m.id, true
  6696. }
  6697. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6698. // That means, if the mutation is applied within a transaction with an isolation level such
  6699. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6700. // or updated by the mutation.
  6701. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6702. switch {
  6703. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6704. id, exists := m.ID()
  6705. if exists {
  6706. return []uint64{id}, nil
  6707. }
  6708. fallthrough
  6709. case m.op.Is(OpUpdate | OpDelete):
  6710. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6711. default:
  6712. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6713. }
  6714. }
  6715. // SetCreatedAt sets the "created_at" field.
  6716. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6717. m.created_at = &t
  6718. }
  6719. // CreatedAt returns the value of the "created_at" field in the mutation.
  6720. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6721. v := m.created_at
  6722. if v == nil {
  6723. return
  6724. }
  6725. return *v, true
  6726. }
  6727. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6728. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6730. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6731. if !m.op.Is(OpUpdateOne) {
  6732. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6733. }
  6734. if m.id == nil || m.oldValue == nil {
  6735. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6736. }
  6737. oldValue, err := m.oldValue(ctx)
  6738. if err != nil {
  6739. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6740. }
  6741. return oldValue.CreatedAt, nil
  6742. }
  6743. // ResetCreatedAt resets all changes to the "created_at" field.
  6744. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6745. m.created_at = nil
  6746. }
  6747. // SetUpdatedAt sets the "updated_at" field.
  6748. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6749. m.updated_at = &t
  6750. }
  6751. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6752. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6753. v := m.updated_at
  6754. if v == nil {
  6755. return
  6756. }
  6757. return *v, true
  6758. }
  6759. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6760. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6762. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6763. if !m.op.Is(OpUpdateOne) {
  6764. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6765. }
  6766. if m.id == nil || m.oldValue == nil {
  6767. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6768. }
  6769. oldValue, err := m.oldValue(ctx)
  6770. if err != nil {
  6771. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6772. }
  6773. return oldValue.UpdatedAt, nil
  6774. }
  6775. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6776. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6777. m.updated_at = nil
  6778. }
  6779. // SetDeletedAt sets the "deleted_at" field.
  6780. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6781. m.deleted_at = &t
  6782. }
  6783. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6784. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6785. v := m.deleted_at
  6786. if v == nil {
  6787. return
  6788. }
  6789. return *v, true
  6790. }
  6791. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6792. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6794. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6795. if !m.op.Is(OpUpdateOne) {
  6796. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6797. }
  6798. if m.id == nil || m.oldValue == nil {
  6799. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6800. }
  6801. oldValue, err := m.oldValue(ctx)
  6802. if err != nil {
  6803. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6804. }
  6805. return oldValue.DeletedAt, nil
  6806. }
  6807. // ClearDeletedAt clears the value of the "deleted_at" field.
  6808. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6809. m.deleted_at = nil
  6810. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6811. }
  6812. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6813. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6814. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6815. return ok
  6816. }
  6817. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6818. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6819. m.deleted_at = nil
  6820. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6821. }
  6822. // SetContent sets the "content" field.
  6823. func (m *ChatRecordsMutation) SetContent(s string) {
  6824. m.content = &s
  6825. }
  6826. // Content returns the value of the "content" field in the mutation.
  6827. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6828. v := m.content
  6829. if v == nil {
  6830. return
  6831. }
  6832. return *v, true
  6833. }
  6834. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6835. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6837. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6838. if !m.op.Is(OpUpdateOne) {
  6839. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6840. }
  6841. if m.id == nil || m.oldValue == nil {
  6842. return v, errors.New("OldContent requires an ID field in the mutation")
  6843. }
  6844. oldValue, err := m.oldValue(ctx)
  6845. if err != nil {
  6846. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6847. }
  6848. return oldValue.Content, nil
  6849. }
  6850. // ResetContent resets all changes to the "content" field.
  6851. func (m *ChatRecordsMutation) ResetContent() {
  6852. m.content = nil
  6853. }
  6854. // SetContentType sets the "content_type" field.
  6855. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6856. m.content_type = &u
  6857. m.addcontent_type = nil
  6858. }
  6859. // ContentType returns the value of the "content_type" field in the mutation.
  6860. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6861. v := m.content_type
  6862. if v == nil {
  6863. return
  6864. }
  6865. return *v, true
  6866. }
  6867. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6868. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6870. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6871. if !m.op.Is(OpUpdateOne) {
  6872. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6873. }
  6874. if m.id == nil || m.oldValue == nil {
  6875. return v, errors.New("OldContentType requires an ID field in the mutation")
  6876. }
  6877. oldValue, err := m.oldValue(ctx)
  6878. if err != nil {
  6879. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6880. }
  6881. return oldValue.ContentType, nil
  6882. }
  6883. // AddContentType adds u to the "content_type" field.
  6884. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6885. if m.addcontent_type != nil {
  6886. *m.addcontent_type += u
  6887. } else {
  6888. m.addcontent_type = &u
  6889. }
  6890. }
  6891. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6892. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6893. v := m.addcontent_type
  6894. if v == nil {
  6895. return
  6896. }
  6897. return *v, true
  6898. }
  6899. // ResetContentType resets all changes to the "content_type" field.
  6900. func (m *ChatRecordsMutation) ResetContentType() {
  6901. m.content_type = nil
  6902. m.addcontent_type = nil
  6903. }
  6904. // SetSessionID sets the "session_id" field.
  6905. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6906. m.session_id = &u
  6907. m.addsession_id = nil
  6908. }
  6909. // SessionID returns the value of the "session_id" field in the mutation.
  6910. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6911. v := m.session_id
  6912. if v == nil {
  6913. return
  6914. }
  6915. return *v, true
  6916. }
  6917. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6918. // If the ChatRecords 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 *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6921. if !m.op.Is(OpUpdateOne) {
  6922. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6923. }
  6924. if m.id == nil || m.oldValue == nil {
  6925. return v, errors.New("OldSessionID 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 OldSessionID: %w", err)
  6930. }
  6931. return oldValue.SessionID, nil
  6932. }
  6933. // AddSessionID adds u to the "session_id" field.
  6934. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6935. if m.addsession_id != nil {
  6936. *m.addsession_id += u
  6937. } else {
  6938. m.addsession_id = &u
  6939. }
  6940. }
  6941. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6942. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6943. v := m.addsession_id
  6944. if v == nil {
  6945. return
  6946. }
  6947. return *v, true
  6948. }
  6949. // ResetSessionID resets all changes to the "session_id" field.
  6950. func (m *ChatRecordsMutation) ResetSessionID() {
  6951. m.session_id = nil
  6952. m.addsession_id = nil
  6953. }
  6954. // SetUserID sets the "user_id" field.
  6955. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6956. m.user_id = &u
  6957. m.adduser_id = nil
  6958. }
  6959. // UserID returns the value of the "user_id" field in the mutation.
  6960. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6961. v := m.user_id
  6962. if v == nil {
  6963. return
  6964. }
  6965. return *v, true
  6966. }
  6967. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6968. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6970. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6971. if !m.op.Is(OpUpdateOne) {
  6972. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6973. }
  6974. if m.id == nil || m.oldValue == nil {
  6975. return v, errors.New("OldUserID requires an ID field in the mutation")
  6976. }
  6977. oldValue, err := m.oldValue(ctx)
  6978. if err != nil {
  6979. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6980. }
  6981. return oldValue.UserID, nil
  6982. }
  6983. // AddUserID adds u to the "user_id" field.
  6984. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6985. if m.adduser_id != nil {
  6986. *m.adduser_id += u
  6987. } else {
  6988. m.adduser_id = &u
  6989. }
  6990. }
  6991. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6992. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6993. v := m.adduser_id
  6994. if v == nil {
  6995. return
  6996. }
  6997. return *v, true
  6998. }
  6999. // ResetUserID resets all changes to the "user_id" field.
  7000. func (m *ChatRecordsMutation) ResetUserID() {
  7001. m.user_id = nil
  7002. m.adduser_id = nil
  7003. }
  7004. // SetBotID sets the "bot_id" field.
  7005. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  7006. m.bot_id = &u
  7007. m.addbot_id = nil
  7008. }
  7009. // BotID returns the value of the "bot_id" field in the mutation.
  7010. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  7011. v := m.bot_id
  7012. if v == nil {
  7013. return
  7014. }
  7015. return *v, true
  7016. }
  7017. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  7018. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7020. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7021. if !m.op.Is(OpUpdateOne) {
  7022. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7023. }
  7024. if m.id == nil || m.oldValue == nil {
  7025. return v, errors.New("OldBotID requires an ID field in the mutation")
  7026. }
  7027. oldValue, err := m.oldValue(ctx)
  7028. if err != nil {
  7029. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7030. }
  7031. return oldValue.BotID, nil
  7032. }
  7033. // AddBotID adds u to the "bot_id" field.
  7034. func (m *ChatRecordsMutation) AddBotID(u int64) {
  7035. if m.addbot_id != nil {
  7036. *m.addbot_id += u
  7037. } else {
  7038. m.addbot_id = &u
  7039. }
  7040. }
  7041. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7042. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  7043. v := m.addbot_id
  7044. if v == nil {
  7045. return
  7046. }
  7047. return *v, true
  7048. }
  7049. // ResetBotID resets all changes to the "bot_id" field.
  7050. func (m *ChatRecordsMutation) ResetBotID() {
  7051. m.bot_id = nil
  7052. m.addbot_id = nil
  7053. }
  7054. // SetBotType sets the "bot_type" field.
  7055. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  7056. m.bot_type = &u
  7057. m.addbot_type = nil
  7058. }
  7059. // BotType returns the value of the "bot_type" field in the mutation.
  7060. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  7061. v := m.bot_type
  7062. if v == nil {
  7063. return
  7064. }
  7065. return *v, true
  7066. }
  7067. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  7068. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7070. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7071. if !m.op.Is(OpUpdateOne) {
  7072. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7073. }
  7074. if m.id == nil || m.oldValue == nil {
  7075. return v, errors.New("OldBotType requires an ID field in the mutation")
  7076. }
  7077. oldValue, err := m.oldValue(ctx)
  7078. if err != nil {
  7079. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7080. }
  7081. return oldValue.BotType, nil
  7082. }
  7083. // AddBotType adds u to the "bot_type" field.
  7084. func (m *ChatRecordsMutation) AddBotType(u int8) {
  7085. if m.addbot_type != nil {
  7086. *m.addbot_type += u
  7087. } else {
  7088. m.addbot_type = &u
  7089. }
  7090. }
  7091. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7092. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  7093. v := m.addbot_type
  7094. if v == nil {
  7095. return
  7096. }
  7097. return *v, true
  7098. }
  7099. // ResetBotType resets all changes to the "bot_type" field.
  7100. func (m *ChatRecordsMutation) ResetBotType() {
  7101. m.bot_type = nil
  7102. m.addbot_type = nil
  7103. }
  7104. // Where appends a list predicates to the ChatRecordsMutation builder.
  7105. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  7106. m.predicates = append(m.predicates, ps...)
  7107. }
  7108. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  7109. // users can use type-assertion to append predicates that do not depend on any generated package.
  7110. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7111. p := make([]predicate.ChatRecords, len(ps))
  7112. for i := range ps {
  7113. p[i] = ps[i]
  7114. }
  7115. m.Where(p...)
  7116. }
  7117. // Op returns the operation name.
  7118. func (m *ChatRecordsMutation) Op() Op {
  7119. return m.op
  7120. }
  7121. // SetOp allows setting the mutation operation.
  7122. func (m *ChatRecordsMutation) SetOp(op Op) {
  7123. m.op = op
  7124. }
  7125. // Type returns the node type of this mutation (ChatRecords).
  7126. func (m *ChatRecordsMutation) Type() string {
  7127. return m.typ
  7128. }
  7129. // Fields returns all fields that were changed during this mutation. Note that in
  7130. // order to get all numeric fields that were incremented/decremented, call
  7131. // AddedFields().
  7132. func (m *ChatRecordsMutation) Fields() []string {
  7133. fields := make([]string, 0, 9)
  7134. if m.created_at != nil {
  7135. fields = append(fields, chatrecords.FieldCreatedAt)
  7136. }
  7137. if m.updated_at != nil {
  7138. fields = append(fields, chatrecords.FieldUpdatedAt)
  7139. }
  7140. if m.deleted_at != nil {
  7141. fields = append(fields, chatrecords.FieldDeletedAt)
  7142. }
  7143. if m.content != nil {
  7144. fields = append(fields, chatrecords.FieldContent)
  7145. }
  7146. if m.content_type != nil {
  7147. fields = append(fields, chatrecords.FieldContentType)
  7148. }
  7149. if m.session_id != nil {
  7150. fields = append(fields, chatrecords.FieldSessionID)
  7151. }
  7152. if m.user_id != nil {
  7153. fields = append(fields, chatrecords.FieldUserID)
  7154. }
  7155. if m.bot_id != nil {
  7156. fields = append(fields, chatrecords.FieldBotID)
  7157. }
  7158. if m.bot_type != nil {
  7159. fields = append(fields, chatrecords.FieldBotType)
  7160. }
  7161. return fields
  7162. }
  7163. // Field returns the value of a field with the given name. The second boolean
  7164. // return value indicates that this field was not set, or was not defined in the
  7165. // schema.
  7166. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  7167. switch name {
  7168. case chatrecords.FieldCreatedAt:
  7169. return m.CreatedAt()
  7170. case chatrecords.FieldUpdatedAt:
  7171. return m.UpdatedAt()
  7172. case chatrecords.FieldDeletedAt:
  7173. return m.DeletedAt()
  7174. case chatrecords.FieldContent:
  7175. return m.Content()
  7176. case chatrecords.FieldContentType:
  7177. return m.ContentType()
  7178. case chatrecords.FieldSessionID:
  7179. return m.SessionID()
  7180. case chatrecords.FieldUserID:
  7181. return m.UserID()
  7182. case chatrecords.FieldBotID:
  7183. return m.BotID()
  7184. case chatrecords.FieldBotType:
  7185. return m.BotType()
  7186. }
  7187. return nil, false
  7188. }
  7189. // OldField returns the old value of the field from the database. An error is
  7190. // returned if the mutation operation is not UpdateOne, or the query to the
  7191. // database failed.
  7192. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7193. switch name {
  7194. case chatrecords.FieldCreatedAt:
  7195. return m.OldCreatedAt(ctx)
  7196. case chatrecords.FieldUpdatedAt:
  7197. return m.OldUpdatedAt(ctx)
  7198. case chatrecords.FieldDeletedAt:
  7199. return m.OldDeletedAt(ctx)
  7200. case chatrecords.FieldContent:
  7201. return m.OldContent(ctx)
  7202. case chatrecords.FieldContentType:
  7203. return m.OldContentType(ctx)
  7204. case chatrecords.FieldSessionID:
  7205. return m.OldSessionID(ctx)
  7206. case chatrecords.FieldUserID:
  7207. return m.OldUserID(ctx)
  7208. case chatrecords.FieldBotID:
  7209. return m.OldBotID(ctx)
  7210. case chatrecords.FieldBotType:
  7211. return m.OldBotType(ctx)
  7212. }
  7213. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  7214. }
  7215. // SetField sets the value of a field with the given name. It returns an error if
  7216. // the field is not defined in the schema, or if the type mismatched the field
  7217. // type.
  7218. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  7219. switch name {
  7220. case chatrecords.FieldCreatedAt:
  7221. v, ok := value.(time.Time)
  7222. if !ok {
  7223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7224. }
  7225. m.SetCreatedAt(v)
  7226. return nil
  7227. case chatrecords.FieldUpdatedAt:
  7228. v, ok := value.(time.Time)
  7229. if !ok {
  7230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7231. }
  7232. m.SetUpdatedAt(v)
  7233. return nil
  7234. case chatrecords.FieldDeletedAt:
  7235. v, ok := value.(time.Time)
  7236. if !ok {
  7237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7238. }
  7239. m.SetDeletedAt(v)
  7240. return nil
  7241. case chatrecords.FieldContent:
  7242. v, ok := value.(string)
  7243. if !ok {
  7244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7245. }
  7246. m.SetContent(v)
  7247. return nil
  7248. case chatrecords.FieldContentType:
  7249. v, ok := value.(uint8)
  7250. if !ok {
  7251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7252. }
  7253. m.SetContentType(v)
  7254. return nil
  7255. case chatrecords.FieldSessionID:
  7256. v, ok := value.(uint64)
  7257. if !ok {
  7258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7259. }
  7260. m.SetSessionID(v)
  7261. return nil
  7262. case chatrecords.FieldUserID:
  7263. v, ok := value.(uint64)
  7264. if !ok {
  7265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7266. }
  7267. m.SetUserID(v)
  7268. return nil
  7269. case chatrecords.FieldBotID:
  7270. v, ok := value.(uint64)
  7271. if !ok {
  7272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7273. }
  7274. m.SetBotID(v)
  7275. return nil
  7276. case chatrecords.FieldBotType:
  7277. v, ok := value.(uint8)
  7278. if !ok {
  7279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7280. }
  7281. m.SetBotType(v)
  7282. return nil
  7283. }
  7284. return fmt.Errorf("unknown ChatRecords field %s", name)
  7285. }
  7286. // AddedFields returns all numeric fields that were incremented/decremented during
  7287. // this mutation.
  7288. func (m *ChatRecordsMutation) AddedFields() []string {
  7289. var fields []string
  7290. if m.addcontent_type != nil {
  7291. fields = append(fields, chatrecords.FieldContentType)
  7292. }
  7293. if m.addsession_id != nil {
  7294. fields = append(fields, chatrecords.FieldSessionID)
  7295. }
  7296. if m.adduser_id != nil {
  7297. fields = append(fields, chatrecords.FieldUserID)
  7298. }
  7299. if m.addbot_id != nil {
  7300. fields = append(fields, chatrecords.FieldBotID)
  7301. }
  7302. if m.addbot_type != nil {
  7303. fields = append(fields, chatrecords.FieldBotType)
  7304. }
  7305. return fields
  7306. }
  7307. // AddedField returns the numeric value that was incremented/decremented on a field
  7308. // with the given name. The second boolean return value indicates that this field
  7309. // was not set, or was not defined in the schema.
  7310. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7311. switch name {
  7312. case chatrecords.FieldContentType:
  7313. return m.AddedContentType()
  7314. case chatrecords.FieldSessionID:
  7315. return m.AddedSessionID()
  7316. case chatrecords.FieldUserID:
  7317. return m.AddedUserID()
  7318. case chatrecords.FieldBotID:
  7319. return m.AddedBotID()
  7320. case chatrecords.FieldBotType:
  7321. return m.AddedBotType()
  7322. }
  7323. return nil, false
  7324. }
  7325. // AddField adds the value to the field with the given name. It returns an error if
  7326. // the field is not defined in the schema, or if the type mismatched the field
  7327. // type.
  7328. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  7329. switch name {
  7330. case chatrecords.FieldContentType:
  7331. v, ok := value.(int8)
  7332. if !ok {
  7333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7334. }
  7335. m.AddContentType(v)
  7336. return nil
  7337. case chatrecords.FieldSessionID:
  7338. v, ok := value.(int64)
  7339. if !ok {
  7340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7341. }
  7342. m.AddSessionID(v)
  7343. return nil
  7344. case chatrecords.FieldUserID:
  7345. v, ok := value.(int64)
  7346. if !ok {
  7347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7348. }
  7349. m.AddUserID(v)
  7350. return nil
  7351. case chatrecords.FieldBotID:
  7352. v, ok := value.(int64)
  7353. if !ok {
  7354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7355. }
  7356. m.AddBotID(v)
  7357. return nil
  7358. case chatrecords.FieldBotType:
  7359. v, ok := value.(int8)
  7360. if !ok {
  7361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7362. }
  7363. m.AddBotType(v)
  7364. return nil
  7365. }
  7366. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  7367. }
  7368. // ClearedFields returns all nullable fields that were cleared during this
  7369. // mutation.
  7370. func (m *ChatRecordsMutation) ClearedFields() []string {
  7371. var fields []string
  7372. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  7373. fields = append(fields, chatrecords.FieldDeletedAt)
  7374. }
  7375. return fields
  7376. }
  7377. // FieldCleared returns a boolean indicating if a field with the given name was
  7378. // cleared in this mutation.
  7379. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  7380. _, ok := m.clearedFields[name]
  7381. return ok
  7382. }
  7383. // ClearField clears the value of the field with the given name. It returns an
  7384. // error if the field is not defined in the schema.
  7385. func (m *ChatRecordsMutation) ClearField(name string) error {
  7386. switch name {
  7387. case chatrecords.FieldDeletedAt:
  7388. m.ClearDeletedAt()
  7389. return nil
  7390. }
  7391. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  7392. }
  7393. // ResetField resets all changes in the mutation for the field with the given name.
  7394. // It returns an error if the field is not defined in the schema.
  7395. func (m *ChatRecordsMutation) ResetField(name string) error {
  7396. switch name {
  7397. case chatrecords.FieldCreatedAt:
  7398. m.ResetCreatedAt()
  7399. return nil
  7400. case chatrecords.FieldUpdatedAt:
  7401. m.ResetUpdatedAt()
  7402. return nil
  7403. case chatrecords.FieldDeletedAt:
  7404. m.ResetDeletedAt()
  7405. return nil
  7406. case chatrecords.FieldContent:
  7407. m.ResetContent()
  7408. return nil
  7409. case chatrecords.FieldContentType:
  7410. m.ResetContentType()
  7411. return nil
  7412. case chatrecords.FieldSessionID:
  7413. m.ResetSessionID()
  7414. return nil
  7415. case chatrecords.FieldUserID:
  7416. m.ResetUserID()
  7417. return nil
  7418. case chatrecords.FieldBotID:
  7419. m.ResetBotID()
  7420. return nil
  7421. case chatrecords.FieldBotType:
  7422. m.ResetBotType()
  7423. return nil
  7424. }
  7425. return fmt.Errorf("unknown ChatRecords field %s", name)
  7426. }
  7427. // AddedEdges returns all edge names that were set/added in this mutation.
  7428. func (m *ChatRecordsMutation) AddedEdges() []string {
  7429. edges := make([]string, 0, 0)
  7430. return edges
  7431. }
  7432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7433. // name in this mutation.
  7434. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  7435. return nil
  7436. }
  7437. // RemovedEdges returns all edge names that were removed in this mutation.
  7438. func (m *ChatRecordsMutation) RemovedEdges() []string {
  7439. edges := make([]string, 0, 0)
  7440. return edges
  7441. }
  7442. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7443. // the given name in this mutation.
  7444. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  7445. return nil
  7446. }
  7447. // ClearedEdges returns all edge names that were cleared in this mutation.
  7448. func (m *ChatRecordsMutation) ClearedEdges() []string {
  7449. edges := make([]string, 0, 0)
  7450. return edges
  7451. }
  7452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7453. // was cleared in this mutation.
  7454. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  7455. return false
  7456. }
  7457. // ClearEdge clears the value of the edge with the given name. It returns an error
  7458. // if that edge is not defined in the schema.
  7459. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  7460. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  7461. }
  7462. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7463. // It returns an error if the edge is not defined in the schema.
  7464. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  7465. return fmt.Errorf("unknown ChatRecords edge %s", name)
  7466. }
  7467. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  7468. type ChatSessionMutation struct {
  7469. config
  7470. op Op
  7471. typ string
  7472. id *uint64
  7473. created_at *time.Time
  7474. updated_at *time.Time
  7475. deleted_at *time.Time
  7476. name *string
  7477. user_id *uint64
  7478. adduser_id *int64
  7479. bot_id *uint64
  7480. addbot_id *int64
  7481. bot_type *uint8
  7482. addbot_type *int8
  7483. clearedFields map[string]struct{}
  7484. done bool
  7485. oldValue func(context.Context) (*ChatSession, error)
  7486. predicates []predicate.ChatSession
  7487. }
  7488. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  7489. // chatsessionOption allows management of the mutation configuration using functional options.
  7490. type chatsessionOption func(*ChatSessionMutation)
  7491. // newChatSessionMutation creates new mutation for the ChatSession entity.
  7492. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  7493. m := &ChatSessionMutation{
  7494. config: c,
  7495. op: op,
  7496. typ: TypeChatSession,
  7497. clearedFields: make(map[string]struct{}),
  7498. }
  7499. for _, opt := range opts {
  7500. opt(m)
  7501. }
  7502. return m
  7503. }
  7504. // withChatSessionID sets the ID field of the mutation.
  7505. func withChatSessionID(id uint64) chatsessionOption {
  7506. return func(m *ChatSessionMutation) {
  7507. var (
  7508. err error
  7509. once sync.Once
  7510. value *ChatSession
  7511. )
  7512. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7513. once.Do(func() {
  7514. if m.done {
  7515. err = errors.New("querying old values post mutation is not allowed")
  7516. } else {
  7517. value, err = m.Client().ChatSession.Get(ctx, id)
  7518. }
  7519. })
  7520. return value, err
  7521. }
  7522. m.id = &id
  7523. }
  7524. }
  7525. // withChatSession sets the old ChatSession of the mutation.
  7526. func withChatSession(node *ChatSession) chatsessionOption {
  7527. return func(m *ChatSessionMutation) {
  7528. m.oldValue = func(context.Context) (*ChatSession, error) {
  7529. return node, nil
  7530. }
  7531. m.id = &node.ID
  7532. }
  7533. }
  7534. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7535. // executed in a transaction (ent.Tx), a transactional client is returned.
  7536. func (m ChatSessionMutation) Client() *Client {
  7537. client := &Client{config: m.config}
  7538. client.init()
  7539. return client
  7540. }
  7541. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7542. // it returns an error otherwise.
  7543. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7544. if _, ok := m.driver.(*txDriver); !ok {
  7545. return nil, errors.New("ent: mutation is not running in a transaction")
  7546. }
  7547. tx := &Tx{config: m.config}
  7548. tx.init()
  7549. return tx, nil
  7550. }
  7551. // SetID sets the value of the id field. Note that this
  7552. // operation is only accepted on creation of ChatSession entities.
  7553. func (m *ChatSessionMutation) SetID(id uint64) {
  7554. m.id = &id
  7555. }
  7556. // ID returns the ID value in the mutation. Note that the ID is only available
  7557. // if it was provided to the builder or after it was returned from the database.
  7558. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7559. if m.id == nil {
  7560. return
  7561. }
  7562. return *m.id, true
  7563. }
  7564. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7565. // That means, if the mutation is applied within a transaction with an isolation level such
  7566. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7567. // or updated by the mutation.
  7568. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7569. switch {
  7570. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7571. id, exists := m.ID()
  7572. if exists {
  7573. return []uint64{id}, nil
  7574. }
  7575. fallthrough
  7576. case m.op.Is(OpUpdate | OpDelete):
  7577. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7578. default:
  7579. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7580. }
  7581. }
  7582. // SetCreatedAt sets the "created_at" field.
  7583. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7584. m.created_at = &t
  7585. }
  7586. // CreatedAt returns the value of the "created_at" field in the mutation.
  7587. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7588. v := m.created_at
  7589. if v == nil {
  7590. return
  7591. }
  7592. return *v, true
  7593. }
  7594. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7595. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7597. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7598. if !m.op.Is(OpUpdateOne) {
  7599. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7600. }
  7601. if m.id == nil || m.oldValue == nil {
  7602. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7603. }
  7604. oldValue, err := m.oldValue(ctx)
  7605. if err != nil {
  7606. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7607. }
  7608. return oldValue.CreatedAt, nil
  7609. }
  7610. // ResetCreatedAt resets all changes to the "created_at" field.
  7611. func (m *ChatSessionMutation) ResetCreatedAt() {
  7612. m.created_at = nil
  7613. }
  7614. // SetUpdatedAt sets the "updated_at" field.
  7615. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7616. m.updated_at = &t
  7617. }
  7618. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7619. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7620. v := m.updated_at
  7621. if v == nil {
  7622. return
  7623. }
  7624. return *v, true
  7625. }
  7626. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7627. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7629. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7630. if !m.op.Is(OpUpdateOne) {
  7631. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7632. }
  7633. if m.id == nil || m.oldValue == nil {
  7634. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7635. }
  7636. oldValue, err := m.oldValue(ctx)
  7637. if err != nil {
  7638. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7639. }
  7640. return oldValue.UpdatedAt, nil
  7641. }
  7642. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7643. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7644. m.updated_at = nil
  7645. }
  7646. // SetDeletedAt sets the "deleted_at" field.
  7647. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7648. m.deleted_at = &t
  7649. }
  7650. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7651. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7652. v := m.deleted_at
  7653. if v == nil {
  7654. return
  7655. }
  7656. return *v, true
  7657. }
  7658. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7659. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7661. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7662. if !m.op.Is(OpUpdateOne) {
  7663. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7664. }
  7665. if m.id == nil || m.oldValue == nil {
  7666. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7667. }
  7668. oldValue, err := m.oldValue(ctx)
  7669. if err != nil {
  7670. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7671. }
  7672. return oldValue.DeletedAt, nil
  7673. }
  7674. // ClearDeletedAt clears the value of the "deleted_at" field.
  7675. func (m *ChatSessionMutation) ClearDeletedAt() {
  7676. m.deleted_at = nil
  7677. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7678. }
  7679. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7680. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7681. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7682. return ok
  7683. }
  7684. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7685. func (m *ChatSessionMutation) ResetDeletedAt() {
  7686. m.deleted_at = nil
  7687. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7688. }
  7689. // SetName sets the "name" field.
  7690. func (m *ChatSessionMutation) SetName(s string) {
  7691. m.name = &s
  7692. }
  7693. // Name returns the value of the "name" field in the mutation.
  7694. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7695. v := m.name
  7696. if v == nil {
  7697. return
  7698. }
  7699. return *v, true
  7700. }
  7701. // OldName returns the old "name" field's value of the ChatSession entity.
  7702. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7704. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7705. if !m.op.Is(OpUpdateOne) {
  7706. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7707. }
  7708. if m.id == nil || m.oldValue == nil {
  7709. return v, errors.New("OldName requires an ID field in the mutation")
  7710. }
  7711. oldValue, err := m.oldValue(ctx)
  7712. if err != nil {
  7713. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7714. }
  7715. return oldValue.Name, nil
  7716. }
  7717. // ResetName resets all changes to the "name" field.
  7718. func (m *ChatSessionMutation) ResetName() {
  7719. m.name = nil
  7720. }
  7721. // SetUserID sets the "user_id" field.
  7722. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7723. m.user_id = &u
  7724. m.adduser_id = nil
  7725. }
  7726. // UserID returns the value of the "user_id" field in the mutation.
  7727. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7728. v := m.user_id
  7729. if v == nil {
  7730. return
  7731. }
  7732. return *v, true
  7733. }
  7734. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7735. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7737. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7738. if !m.op.Is(OpUpdateOne) {
  7739. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7740. }
  7741. if m.id == nil || m.oldValue == nil {
  7742. return v, errors.New("OldUserID requires an ID field in the mutation")
  7743. }
  7744. oldValue, err := m.oldValue(ctx)
  7745. if err != nil {
  7746. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7747. }
  7748. return oldValue.UserID, nil
  7749. }
  7750. // AddUserID adds u to the "user_id" field.
  7751. func (m *ChatSessionMutation) AddUserID(u int64) {
  7752. if m.adduser_id != nil {
  7753. *m.adduser_id += u
  7754. } else {
  7755. m.adduser_id = &u
  7756. }
  7757. }
  7758. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7759. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7760. v := m.adduser_id
  7761. if v == nil {
  7762. return
  7763. }
  7764. return *v, true
  7765. }
  7766. // ResetUserID resets all changes to the "user_id" field.
  7767. func (m *ChatSessionMutation) ResetUserID() {
  7768. m.user_id = nil
  7769. m.adduser_id = nil
  7770. }
  7771. // SetBotID sets the "bot_id" field.
  7772. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7773. m.bot_id = &u
  7774. m.addbot_id = nil
  7775. }
  7776. // BotID returns the value of the "bot_id" field in the mutation.
  7777. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7778. v := m.bot_id
  7779. if v == nil {
  7780. return
  7781. }
  7782. return *v, true
  7783. }
  7784. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7785. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7787. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7788. if !m.op.Is(OpUpdateOne) {
  7789. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7790. }
  7791. if m.id == nil || m.oldValue == nil {
  7792. return v, errors.New("OldBotID requires an ID field in the mutation")
  7793. }
  7794. oldValue, err := m.oldValue(ctx)
  7795. if err != nil {
  7796. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7797. }
  7798. return oldValue.BotID, nil
  7799. }
  7800. // AddBotID adds u to the "bot_id" field.
  7801. func (m *ChatSessionMutation) AddBotID(u int64) {
  7802. if m.addbot_id != nil {
  7803. *m.addbot_id += u
  7804. } else {
  7805. m.addbot_id = &u
  7806. }
  7807. }
  7808. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7809. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7810. v := m.addbot_id
  7811. if v == nil {
  7812. return
  7813. }
  7814. return *v, true
  7815. }
  7816. // ResetBotID resets all changes to the "bot_id" field.
  7817. func (m *ChatSessionMutation) ResetBotID() {
  7818. m.bot_id = nil
  7819. m.addbot_id = nil
  7820. }
  7821. // SetBotType sets the "bot_type" field.
  7822. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7823. m.bot_type = &u
  7824. m.addbot_type = nil
  7825. }
  7826. // BotType returns the value of the "bot_type" field in the mutation.
  7827. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7828. v := m.bot_type
  7829. if v == nil {
  7830. return
  7831. }
  7832. return *v, true
  7833. }
  7834. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7835. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7837. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7838. if !m.op.Is(OpUpdateOne) {
  7839. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7840. }
  7841. if m.id == nil || m.oldValue == nil {
  7842. return v, errors.New("OldBotType requires an ID field in the mutation")
  7843. }
  7844. oldValue, err := m.oldValue(ctx)
  7845. if err != nil {
  7846. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7847. }
  7848. return oldValue.BotType, nil
  7849. }
  7850. // AddBotType adds u to the "bot_type" field.
  7851. func (m *ChatSessionMutation) AddBotType(u int8) {
  7852. if m.addbot_type != nil {
  7853. *m.addbot_type += u
  7854. } else {
  7855. m.addbot_type = &u
  7856. }
  7857. }
  7858. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7859. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7860. v := m.addbot_type
  7861. if v == nil {
  7862. return
  7863. }
  7864. return *v, true
  7865. }
  7866. // ResetBotType resets all changes to the "bot_type" field.
  7867. func (m *ChatSessionMutation) ResetBotType() {
  7868. m.bot_type = nil
  7869. m.addbot_type = nil
  7870. }
  7871. // Where appends a list predicates to the ChatSessionMutation builder.
  7872. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7873. m.predicates = append(m.predicates, ps...)
  7874. }
  7875. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7876. // users can use type-assertion to append predicates that do not depend on any generated package.
  7877. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7878. p := make([]predicate.ChatSession, len(ps))
  7879. for i := range ps {
  7880. p[i] = ps[i]
  7881. }
  7882. m.Where(p...)
  7883. }
  7884. // Op returns the operation name.
  7885. func (m *ChatSessionMutation) Op() Op {
  7886. return m.op
  7887. }
  7888. // SetOp allows setting the mutation operation.
  7889. func (m *ChatSessionMutation) SetOp(op Op) {
  7890. m.op = op
  7891. }
  7892. // Type returns the node type of this mutation (ChatSession).
  7893. func (m *ChatSessionMutation) Type() string {
  7894. return m.typ
  7895. }
  7896. // Fields returns all fields that were changed during this mutation. Note that in
  7897. // order to get all numeric fields that were incremented/decremented, call
  7898. // AddedFields().
  7899. func (m *ChatSessionMutation) Fields() []string {
  7900. fields := make([]string, 0, 7)
  7901. if m.created_at != nil {
  7902. fields = append(fields, chatsession.FieldCreatedAt)
  7903. }
  7904. if m.updated_at != nil {
  7905. fields = append(fields, chatsession.FieldUpdatedAt)
  7906. }
  7907. if m.deleted_at != nil {
  7908. fields = append(fields, chatsession.FieldDeletedAt)
  7909. }
  7910. if m.name != nil {
  7911. fields = append(fields, chatsession.FieldName)
  7912. }
  7913. if m.user_id != nil {
  7914. fields = append(fields, chatsession.FieldUserID)
  7915. }
  7916. if m.bot_id != nil {
  7917. fields = append(fields, chatsession.FieldBotID)
  7918. }
  7919. if m.bot_type != nil {
  7920. fields = append(fields, chatsession.FieldBotType)
  7921. }
  7922. return fields
  7923. }
  7924. // Field returns the value of a field with the given name. The second boolean
  7925. // return value indicates that this field was not set, or was not defined in the
  7926. // schema.
  7927. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7928. switch name {
  7929. case chatsession.FieldCreatedAt:
  7930. return m.CreatedAt()
  7931. case chatsession.FieldUpdatedAt:
  7932. return m.UpdatedAt()
  7933. case chatsession.FieldDeletedAt:
  7934. return m.DeletedAt()
  7935. case chatsession.FieldName:
  7936. return m.Name()
  7937. case chatsession.FieldUserID:
  7938. return m.UserID()
  7939. case chatsession.FieldBotID:
  7940. return m.BotID()
  7941. case chatsession.FieldBotType:
  7942. return m.BotType()
  7943. }
  7944. return nil, false
  7945. }
  7946. // OldField returns the old value of the field from the database. An error is
  7947. // returned if the mutation operation is not UpdateOne, or the query to the
  7948. // database failed.
  7949. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7950. switch name {
  7951. case chatsession.FieldCreatedAt:
  7952. return m.OldCreatedAt(ctx)
  7953. case chatsession.FieldUpdatedAt:
  7954. return m.OldUpdatedAt(ctx)
  7955. case chatsession.FieldDeletedAt:
  7956. return m.OldDeletedAt(ctx)
  7957. case chatsession.FieldName:
  7958. return m.OldName(ctx)
  7959. case chatsession.FieldUserID:
  7960. return m.OldUserID(ctx)
  7961. case chatsession.FieldBotID:
  7962. return m.OldBotID(ctx)
  7963. case chatsession.FieldBotType:
  7964. return m.OldBotType(ctx)
  7965. }
  7966. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7967. }
  7968. // SetField sets the value of a field with the given name. It returns an error if
  7969. // the field is not defined in the schema, or if the type mismatched the field
  7970. // type.
  7971. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7972. switch name {
  7973. case chatsession.FieldCreatedAt:
  7974. v, ok := value.(time.Time)
  7975. if !ok {
  7976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7977. }
  7978. m.SetCreatedAt(v)
  7979. return nil
  7980. case chatsession.FieldUpdatedAt:
  7981. v, ok := value.(time.Time)
  7982. if !ok {
  7983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7984. }
  7985. m.SetUpdatedAt(v)
  7986. return nil
  7987. case chatsession.FieldDeletedAt:
  7988. v, ok := value.(time.Time)
  7989. if !ok {
  7990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7991. }
  7992. m.SetDeletedAt(v)
  7993. return nil
  7994. case chatsession.FieldName:
  7995. v, ok := value.(string)
  7996. if !ok {
  7997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7998. }
  7999. m.SetName(v)
  8000. return nil
  8001. case chatsession.FieldUserID:
  8002. v, ok := value.(uint64)
  8003. if !ok {
  8004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8005. }
  8006. m.SetUserID(v)
  8007. return nil
  8008. case chatsession.FieldBotID:
  8009. v, ok := value.(uint64)
  8010. if !ok {
  8011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8012. }
  8013. m.SetBotID(v)
  8014. return nil
  8015. case chatsession.FieldBotType:
  8016. v, ok := value.(uint8)
  8017. if !ok {
  8018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8019. }
  8020. m.SetBotType(v)
  8021. return nil
  8022. }
  8023. return fmt.Errorf("unknown ChatSession field %s", name)
  8024. }
  8025. // AddedFields returns all numeric fields that were incremented/decremented during
  8026. // this mutation.
  8027. func (m *ChatSessionMutation) AddedFields() []string {
  8028. var fields []string
  8029. if m.adduser_id != nil {
  8030. fields = append(fields, chatsession.FieldUserID)
  8031. }
  8032. if m.addbot_id != nil {
  8033. fields = append(fields, chatsession.FieldBotID)
  8034. }
  8035. if m.addbot_type != nil {
  8036. fields = append(fields, chatsession.FieldBotType)
  8037. }
  8038. return fields
  8039. }
  8040. // AddedField returns the numeric value that was incremented/decremented on a field
  8041. // with the given name. The second boolean return value indicates that this field
  8042. // was not set, or was not defined in the schema.
  8043. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  8044. switch name {
  8045. case chatsession.FieldUserID:
  8046. return m.AddedUserID()
  8047. case chatsession.FieldBotID:
  8048. return m.AddedBotID()
  8049. case chatsession.FieldBotType:
  8050. return m.AddedBotType()
  8051. }
  8052. return nil, false
  8053. }
  8054. // AddField adds the value to the field with the given name. It returns an error if
  8055. // the field is not defined in the schema, or if the type mismatched the field
  8056. // type.
  8057. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  8058. switch name {
  8059. case chatsession.FieldUserID:
  8060. v, ok := value.(int64)
  8061. if !ok {
  8062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8063. }
  8064. m.AddUserID(v)
  8065. return nil
  8066. case chatsession.FieldBotID:
  8067. v, ok := value.(int64)
  8068. if !ok {
  8069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8070. }
  8071. m.AddBotID(v)
  8072. return nil
  8073. case chatsession.FieldBotType:
  8074. v, ok := value.(int8)
  8075. if !ok {
  8076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8077. }
  8078. m.AddBotType(v)
  8079. return nil
  8080. }
  8081. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  8082. }
  8083. // ClearedFields returns all nullable fields that were cleared during this
  8084. // mutation.
  8085. func (m *ChatSessionMutation) ClearedFields() []string {
  8086. var fields []string
  8087. if m.FieldCleared(chatsession.FieldDeletedAt) {
  8088. fields = append(fields, chatsession.FieldDeletedAt)
  8089. }
  8090. return fields
  8091. }
  8092. // FieldCleared returns a boolean indicating if a field with the given name was
  8093. // cleared in this mutation.
  8094. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  8095. _, ok := m.clearedFields[name]
  8096. return ok
  8097. }
  8098. // ClearField clears the value of the field with the given name. It returns an
  8099. // error if the field is not defined in the schema.
  8100. func (m *ChatSessionMutation) ClearField(name string) error {
  8101. switch name {
  8102. case chatsession.FieldDeletedAt:
  8103. m.ClearDeletedAt()
  8104. return nil
  8105. }
  8106. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  8107. }
  8108. // ResetField resets all changes in the mutation for the field with the given name.
  8109. // It returns an error if the field is not defined in the schema.
  8110. func (m *ChatSessionMutation) ResetField(name string) error {
  8111. switch name {
  8112. case chatsession.FieldCreatedAt:
  8113. m.ResetCreatedAt()
  8114. return nil
  8115. case chatsession.FieldUpdatedAt:
  8116. m.ResetUpdatedAt()
  8117. return nil
  8118. case chatsession.FieldDeletedAt:
  8119. m.ResetDeletedAt()
  8120. return nil
  8121. case chatsession.FieldName:
  8122. m.ResetName()
  8123. return nil
  8124. case chatsession.FieldUserID:
  8125. m.ResetUserID()
  8126. return nil
  8127. case chatsession.FieldBotID:
  8128. m.ResetBotID()
  8129. return nil
  8130. case chatsession.FieldBotType:
  8131. m.ResetBotType()
  8132. return nil
  8133. }
  8134. return fmt.Errorf("unknown ChatSession field %s", name)
  8135. }
  8136. // AddedEdges returns all edge names that were set/added in this mutation.
  8137. func (m *ChatSessionMutation) AddedEdges() []string {
  8138. edges := make([]string, 0, 0)
  8139. return edges
  8140. }
  8141. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8142. // name in this mutation.
  8143. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  8144. return nil
  8145. }
  8146. // RemovedEdges returns all edge names that were removed in this mutation.
  8147. func (m *ChatSessionMutation) RemovedEdges() []string {
  8148. edges := make([]string, 0, 0)
  8149. return edges
  8150. }
  8151. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8152. // the given name in this mutation.
  8153. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  8154. return nil
  8155. }
  8156. // ClearedEdges returns all edge names that were cleared in this mutation.
  8157. func (m *ChatSessionMutation) ClearedEdges() []string {
  8158. edges := make([]string, 0, 0)
  8159. return edges
  8160. }
  8161. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8162. // was cleared in this mutation.
  8163. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  8164. return false
  8165. }
  8166. // ClearEdge clears the value of the edge with the given name. It returns an error
  8167. // if that edge is not defined in the schema.
  8168. func (m *ChatSessionMutation) ClearEdge(name string) error {
  8169. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  8170. }
  8171. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8172. // It returns an error if the edge is not defined in the schema.
  8173. func (m *ChatSessionMutation) ResetEdge(name string) error {
  8174. return fmt.Errorf("unknown ChatSession edge %s", name)
  8175. }
  8176. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  8177. type ContactMutation struct {
  8178. config
  8179. op Op
  8180. typ string
  8181. id *uint64
  8182. created_at *time.Time
  8183. updated_at *time.Time
  8184. status *uint8
  8185. addstatus *int8
  8186. deleted_at *time.Time
  8187. wx_wxid *string
  8188. _type *int
  8189. add_type *int
  8190. wxid *string
  8191. account *string
  8192. nickname *string
  8193. markname *string
  8194. headimg *string
  8195. sex *int
  8196. addsex *int
  8197. starrole *string
  8198. dontseeit *int
  8199. adddontseeit *int
  8200. dontseeme *int
  8201. adddontseeme *int
  8202. lag *string
  8203. gid *string
  8204. gname *string
  8205. v3 *string
  8206. organization_id *uint64
  8207. addorganization_id *int64
  8208. ctype *uint64
  8209. addctype *int64
  8210. cage *int
  8211. addcage *int
  8212. cname *string
  8213. carea *string
  8214. cbirthday *string
  8215. cbirtharea *string
  8216. cidcard_no *string
  8217. ctitle *string
  8218. cc *string
  8219. phone *string
  8220. clearedFields map[string]struct{}
  8221. contact_relationships map[uint64]struct{}
  8222. removedcontact_relationships map[uint64]struct{}
  8223. clearedcontact_relationships bool
  8224. contact_messages map[uint64]struct{}
  8225. removedcontact_messages map[uint64]struct{}
  8226. clearedcontact_messages bool
  8227. done bool
  8228. oldValue func(context.Context) (*Contact, error)
  8229. predicates []predicate.Contact
  8230. }
  8231. var _ ent.Mutation = (*ContactMutation)(nil)
  8232. // contactOption allows management of the mutation configuration using functional options.
  8233. type contactOption func(*ContactMutation)
  8234. // newContactMutation creates new mutation for the Contact entity.
  8235. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  8236. m := &ContactMutation{
  8237. config: c,
  8238. op: op,
  8239. typ: TypeContact,
  8240. clearedFields: make(map[string]struct{}),
  8241. }
  8242. for _, opt := range opts {
  8243. opt(m)
  8244. }
  8245. return m
  8246. }
  8247. // withContactID sets the ID field of the mutation.
  8248. func withContactID(id uint64) contactOption {
  8249. return func(m *ContactMutation) {
  8250. var (
  8251. err error
  8252. once sync.Once
  8253. value *Contact
  8254. )
  8255. m.oldValue = func(ctx context.Context) (*Contact, error) {
  8256. once.Do(func() {
  8257. if m.done {
  8258. err = errors.New("querying old values post mutation is not allowed")
  8259. } else {
  8260. value, err = m.Client().Contact.Get(ctx, id)
  8261. }
  8262. })
  8263. return value, err
  8264. }
  8265. m.id = &id
  8266. }
  8267. }
  8268. // withContact sets the old Contact of the mutation.
  8269. func withContact(node *Contact) contactOption {
  8270. return func(m *ContactMutation) {
  8271. m.oldValue = func(context.Context) (*Contact, error) {
  8272. return node, nil
  8273. }
  8274. m.id = &node.ID
  8275. }
  8276. }
  8277. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8278. // executed in a transaction (ent.Tx), a transactional client is returned.
  8279. func (m ContactMutation) Client() *Client {
  8280. client := &Client{config: m.config}
  8281. client.init()
  8282. return client
  8283. }
  8284. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8285. // it returns an error otherwise.
  8286. func (m ContactMutation) Tx() (*Tx, error) {
  8287. if _, ok := m.driver.(*txDriver); !ok {
  8288. return nil, errors.New("ent: mutation is not running in a transaction")
  8289. }
  8290. tx := &Tx{config: m.config}
  8291. tx.init()
  8292. return tx, nil
  8293. }
  8294. // SetID sets the value of the id field. Note that this
  8295. // operation is only accepted on creation of Contact entities.
  8296. func (m *ContactMutation) SetID(id uint64) {
  8297. m.id = &id
  8298. }
  8299. // ID returns the ID value in the mutation. Note that the ID is only available
  8300. // if it was provided to the builder or after it was returned from the database.
  8301. func (m *ContactMutation) ID() (id uint64, exists bool) {
  8302. if m.id == nil {
  8303. return
  8304. }
  8305. return *m.id, true
  8306. }
  8307. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8308. // That means, if the mutation is applied within a transaction with an isolation level such
  8309. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8310. // or updated by the mutation.
  8311. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  8312. switch {
  8313. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8314. id, exists := m.ID()
  8315. if exists {
  8316. return []uint64{id}, nil
  8317. }
  8318. fallthrough
  8319. case m.op.Is(OpUpdate | OpDelete):
  8320. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  8321. default:
  8322. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8323. }
  8324. }
  8325. // SetCreatedAt sets the "created_at" field.
  8326. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  8327. m.created_at = &t
  8328. }
  8329. // CreatedAt returns the value of the "created_at" field in the mutation.
  8330. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  8331. v := m.created_at
  8332. if v == nil {
  8333. return
  8334. }
  8335. return *v, true
  8336. }
  8337. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  8338. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8340. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8341. if !m.op.Is(OpUpdateOne) {
  8342. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8343. }
  8344. if m.id == nil || m.oldValue == nil {
  8345. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8346. }
  8347. oldValue, err := m.oldValue(ctx)
  8348. if err != nil {
  8349. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8350. }
  8351. return oldValue.CreatedAt, nil
  8352. }
  8353. // ResetCreatedAt resets all changes to the "created_at" field.
  8354. func (m *ContactMutation) ResetCreatedAt() {
  8355. m.created_at = nil
  8356. }
  8357. // SetUpdatedAt sets the "updated_at" field.
  8358. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  8359. m.updated_at = &t
  8360. }
  8361. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8362. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  8363. v := m.updated_at
  8364. if v == nil {
  8365. return
  8366. }
  8367. return *v, true
  8368. }
  8369. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  8370. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8372. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8373. if !m.op.Is(OpUpdateOne) {
  8374. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8375. }
  8376. if m.id == nil || m.oldValue == nil {
  8377. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8378. }
  8379. oldValue, err := m.oldValue(ctx)
  8380. if err != nil {
  8381. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8382. }
  8383. return oldValue.UpdatedAt, nil
  8384. }
  8385. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8386. func (m *ContactMutation) ResetUpdatedAt() {
  8387. m.updated_at = nil
  8388. }
  8389. // SetStatus sets the "status" field.
  8390. func (m *ContactMutation) SetStatus(u uint8) {
  8391. m.status = &u
  8392. m.addstatus = nil
  8393. }
  8394. // Status returns the value of the "status" field in the mutation.
  8395. func (m *ContactMutation) Status() (r uint8, exists bool) {
  8396. v := m.status
  8397. if v == nil {
  8398. return
  8399. }
  8400. return *v, true
  8401. }
  8402. // OldStatus returns the old "status" field's value of the Contact entity.
  8403. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8405. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8406. if !m.op.Is(OpUpdateOne) {
  8407. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8408. }
  8409. if m.id == nil || m.oldValue == nil {
  8410. return v, errors.New("OldStatus requires an ID field in the mutation")
  8411. }
  8412. oldValue, err := m.oldValue(ctx)
  8413. if err != nil {
  8414. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8415. }
  8416. return oldValue.Status, nil
  8417. }
  8418. // AddStatus adds u to the "status" field.
  8419. func (m *ContactMutation) AddStatus(u int8) {
  8420. if m.addstatus != nil {
  8421. *m.addstatus += u
  8422. } else {
  8423. m.addstatus = &u
  8424. }
  8425. }
  8426. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8427. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  8428. v := m.addstatus
  8429. if v == nil {
  8430. return
  8431. }
  8432. return *v, true
  8433. }
  8434. // ClearStatus clears the value of the "status" field.
  8435. func (m *ContactMutation) ClearStatus() {
  8436. m.status = nil
  8437. m.addstatus = nil
  8438. m.clearedFields[contact.FieldStatus] = struct{}{}
  8439. }
  8440. // StatusCleared returns if the "status" field was cleared in this mutation.
  8441. func (m *ContactMutation) StatusCleared() bool {
  8442. _, ok := m.clearedFields[contact.FieldStatus]
  8443. return ok
  8444. }
  8445. // ResetStatus resets all changes to the "status" field.
  8446. func (m *ContactMutation) ResetStatus() {
  8447. m.status = nil
  8448. m.addstatus = nil
  8449. delete(m.clearedFields, contact.FieldStatus)
  8450. }
  8451. // SetDeletedAt sets the "deleted_at" field.
  8452. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  8453. m.deleted_at = &t
  8454. }
  8455. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8456. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  8457. v := m.deleted_at
  8458. if v == nil {
  8459. return
  8460. }
  8461. return *v, true
  8462. }
  8463. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  8464. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8466. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8467. if !m.op.Is(OpUpdateOne) {
  8468. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8469. }
  8470. if m.id == nil || m.oldValue == nil {
  8471. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8472. }
  8473. oldValue, err := m.oldValue(ctx)
  8474. if err != nil {
  8475. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8476. }
  8477. return oldValue.DeletedAt, nil
  8478. }
  8479. // ClearDeletedAt clears the value of the "deleted_at" field.
  8480. func (m *ContactMutation) ClearDeletedAt() {
  8481. m.deleted_at = nil
  8482. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  8483. }
  8484. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8485. func (m *ContactMutation) DeletedAtCleared() bool {
  8486. _, ok := m.clearedFields[contact.FieldDeletedAt]
  8487. return ok
  8488. }
  8489. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8490. func (m *ContactMutation) ResetDeletedAt() {
  8491. m.deleted_at = nil
  8492. delete(m.clearedFields, contact.FieldDeletedAt)
  8493. }
  8494. // SetWxWxid sets the "wx_wxid" field.
  8495. func (m *ContactMutation) SetWxWxid(s string) {
  8496. m.wx_wxid = &s
  8497. }
  8498. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8499. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  8500. v := m.wx_wxid
  8501. if v == nil {
  8502. return
  8503. }
  8504. return *v, true
  8505. }
  8506. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  8507. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8509. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8510. if !m.op.Is(OpUpdateOne) {
  8511. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8512. }
  8513. if m.id == nil || m.oldValue == nil {
  8514. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8515. }
  8516. oldValue, err := m.oldValue(ctx)
  8517. if err != nil {
  8518. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8519. }
  8520. return oldValue.WxWxid, nil
  8521. }
  8522. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8523. func (m *ContactMutation) ResetWxWxid() {
  8524. m.wx_wxid = nil
  8525. }
  8526. // SetType sets the "type" field.
  8527. func (m *ContactMutation) SetType(i int) {
  8528. m._type = &i
  8529. m.add_type = nil
  8530. }
  8531. // GetType returns the value of the "type" field in the mutation.
  8532. func (m *ContactMutation) GetType() (r int, exists bool) {
  8533. v := m._type
  8534. if v == nil {
  8535. return
  8536. }
  8537. return *v, true
  8538. }
  8539. // OldType returns the old "type" field's value of the Contact entity.
  8540. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8542. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8543. if !m.op.Is(OpUpdateOne) {
  8544. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8545. }
  8546. if m.id == nil || m.oldValue == nil {
  8547. return v, errors.New("OldType requires an ID field in the mutation")
  8548. }
  8549. oldValue, err := m.oldValue(ctx)
  8550. if err != nil {
  8551. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8552. }
  8553. return oldValue.Type, nil
  8554. }
  8555. // AddType adds i to the "type" field.
  8556. func (m *ContactMutation) AddType(i int) {
  8557. if m.add_type != nil {
  8558. *m.add_type += i
  8559. } else {
  8560. m.add_type = &i
  8561. }
  8562. }
  8563. // AddedType returns the value that was added to the "type" field in this mutation.
  8564. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8565. v := m.add_type
  8566. if v == nil {
  8567. return
  8568. }
  8569. return *v, true
  8570. }
  8571. // ClearType clears the value of the "type" field.
  8572. func (m *ContactMutation) ClearType() {
  8573. m._type = nil
  8574. m.add_type = nil
  8575. m.clearedFields[contact.FieldType] = struct{}{}
  8576. }
  8577. // TypeCleared returns if the "type" field was cleared in this mutation.
  8578. func (m *ContactMutation) TypeCleared() bool {
  8579. _, ok := m.clearedFields[contact.FieldType]
  8580. return ok
  8581. }
  8582. // ResetType resets all changes to the "type" field.
  8583. func (m *ContactMutation) ResetType() {
  8584. m._type = nil
  8585. m.add_type = nil
  8586. delete(m.clearedFields, contact.FieldType)
  8587. }
  8588. // SetWxid sets the "wxid" field.
  8589. func (m *ContactMutation) SetWxid(s string) {
  8590. m.wxid = &s
  8591. }
  8592. // Wxid returns the value of the "wxid" field in the mutation.
  8593. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8594. v := m.wxid
  8595. if v == nil {
  8596. return
  8597. }
  8598. return *v, true
  8599. }
  8600. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8601. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8603. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8604. if !m.op.Is(OpUpdateOne) {
  8605. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8606. }
  8607. if m.id == nil || m.oldValue == nil {
  8608. return v, errors.New("OldWxid requires an ID field in the mutation")
  8609. }
  8610. oldValue, err := m.oldValue(ctx)
  8611. if err != nil {
  8612. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8613. }
  8614. return oldValue.Wxid, nil
  8615. }
  8616. // ResetWxid resets all changes to the "wxid" field.
  8617. func (m *ContactMutation) ResetWxid() {
  8618. m.wxid = nil
  8619. }
  8620. // SetAccount sets the "account" field.
  8621. func (m *ContactMutation) SetAccount(s string) {
  8622. m.account = &s
  8623. }
  8624. // Account returns the value of the "account" field in the mutation.
  8625. func (m *ContactMutation) Account() (r string, exists bool) {
  8626. v := m.account
  8627. if v == nil {
  8628. return
  8629. }
  8630. return *v, true
  8631. }
  8632. // OldAccount returns the old "account" field's value of the Contact entity.
  8633. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8635. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8636. if !m.op.Is(OpUpdateOne) {
  8637. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8638. }
  8639. if m.id == nil || m.oldValue == nil {
  8640. return v, errors.New("OldAccount requires an ID field in the mutation")
  8641. }
  8642. oldValue, err := m.oldValue(ctx)
  8643. if err != nil {
  8644. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8645. }
  8646. return oldValue.Account, nil
  8647. }
  8648. // ResetAccount resets all changes to the "account" field.
  8649. func (m *ContactMutation) ResetAccount() {
  8650. m.account = nil
  8651. }
  8652. // SetNickname sets the "nickname" field.
  8653. func (m *ContactMutation) SetNickname(s string) {
  8654. m.nickname = &s
  8655. }
  8656. // Nickname returns the value of the "nickname" field in the mutation.
  8657. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8658. v := m.nickname
  8659. if v == nil {
  8660. return
  8661. }
  8662. return *v, true
  8663. }
  8664. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8665. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8667. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8668. if !m.op.Is(OpUpdateOne) {
  8669. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8670. }
  8671. if m.id == nil || m.oldValue == nil {
  8672. return v, errors.New("OldNickname requires an ID field in the mutation")
  8673. }
  8674. oldValue, err := m.oldValue(ctx)
  8675. if err != nil {
  8676. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8677. }
  8678. return oldValue.Nickname, nil
  8679. }
  8680. // ResetNickname resets all changes to the "nickname" field.
  8681. func (m *ContactMutation) ResetNickname() {
  8682. m.nickname = nil
  8683. }
  8684. // SetMarkname sets the "markname" field.
  8685. func (m *ContactMutation) SetMarkname(s string) {
  8686. m.markname = &s
  8687. }
  8688. // Markname returns the value of the "markname" field in the mutation.
  8689. func (m *ContactMutation) Markname() (r string, exists bool) {
  8690. v := m.markname
  8691. if v == nil {
  8692. return
  8693. }
  8694. return *v, true
  8695. }
  8696. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8697. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8699. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8700. if !m.op.Is(OpUpdateOne) {
  8701. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8702. }
  8703. if m.id == nil || m.oldValue == nil {
  8704. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8705. }
  8706. oldValue, err := m.oldValue(ctx)
  8707. if err != nil {
  8708. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8709. }
  8710. return oldValue.Markname, nil
  8711. }
  8712. // ResetMarkname resets all changes to the "markname" field.
  8713. func (m *ContactMutation) ResetMarkname() {
  8714. m.markname = nil
  8715. }
  8716. // SetHeadimg sets the "headimg" field.
  8717. func (m *ContactMutation) SetHeadimg(s string) {
  8718. m.headimg = &s
  8719. }
  8720. // Headimg returns the value of the "headimg" field in the mutation.
  8721. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8722. v := m.headimg
  8723. if v == nil {
  8724. return
  8725. }
  8726. return *v, true
  8727. }
  8728. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8729. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8731. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8732. if !m.op.Is(OpUpdateOne) {
  8733. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8734. }
  8735. if m.id == nil || m.oldValue == nil {
  8736. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8737. }
  8738. oldValue, err := m.oldValue(ctx)
  8739. if err != nil {
  8740. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8741. }
  8742. return oldValue.Headimg, nil
  8743. }
  8744. // ResetHeadimg resets all changes to the "headimg" field.
  8745. func (m *ContactMutation) ResetHeadimg() {
  8746. m.headimg = nil
  8747. }
  8748. // SetSex sets the "sex" field.
  8749. func (m *ContactMutation) SetSex(i int) {
  8750. m.sex = &i
  8751. m.addsex = nil
  8752. }
  8753. // Sex returns the value of the "sex" field in the mutation.
  8754. func (m *ContactMutation) Sex() (r int, exists bool) {
  8755. v := m.sex
  8756. if v == nil {
  8757. return
  8758. }
  8759. return *v, true
  8760. }
  8761. // OldSex returns the old "sex" field's value of the Contact entity.
  8762. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8764. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8765. if !m.op.Is(OpUpdateOne) {
  8766. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8767. }
  8768. if m.id == nil || m.oldValue == nil {
  8769. return v, errors.New("OldSex requires an ID field in the mutation")
  8770. }
  8771. oldValue, err := m.oldValue(ctx)
  8772. if err != nil {
  8773. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8774. }
  8775. return oldValue.Sex, nil
  8776. }
  8777. // AddSex adds i to the "sex" field.
  8778. func (m *ContactMutation) AddSex(i int) {
  8779. if m.addsex != nil {
  8780. *m.addsex += i
  8781. } else {
  8782. m.addsex = &i
  8783. }
  8784. }
  8785. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8786. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8787. v := m.addsex
  8788. if v == nil {
  8789. return
  8790. }
  8791. return *v, true
  8792. }
  8793. // ResetSex resets all changes to the "sex" field.
  8794. func (m *ContactMutation) ResetSex() {
  8795. m.sex = nil
  8796. m.addsex = nil
  8797. }
  8798. // SetStarrole sets the "starrole" field.
  8799. func (m *ContactMutation) SetStarrole(s string) {
  8800. m.starrole = &s
  8801. }
  8802. // Starrole returns the value of the "starrole" field in the mutation.
  8803. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8804. v := m.starrole
  8805. if v == nil {
  8806. return
  8807. }
  8808. return *v, true
  8809. }
  8810. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8811. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8813. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8814. if !m.op.Is(OpUpdateOne) {
  8815. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8816. }
  8817. if m.id == nil || m.oldValue == nil {
  8818. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8819. }
  8820. oldValue, err := m.oldValue(ctx)
  8821. if err != nil {
  8822. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8823. }
  8824. return oldValue.Starrole, nil
  8825. }
  8826. // ResetStarrole resets all changes to the "starrole" field.
  8827. func (m *ContactMutation) ResetStarrole() {
  8828. m.starrole = nil
  8829. }
  8830. // SetDontseeit sets the "dontseeit" field.
  8831. func (m *ContactMutation) SetDontseeit(i int) {
  8832. m.dontseeit = &i
  8833. m.adddontseeit = nil
  8834. }
  8835. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8836. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8837. v := m.dontseeit
  8838. if v == nil {
  8839. return
  8840. }
  8841. return *v, true
  8842. }
  8843. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8844. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8846. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8847. if !m.op.Is(OpUpdateOne) {
  8848. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8849. }
  8850. if m.id == nil || m.oldValue == nil {
  8851. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8852. }
  8853. oldValue, err := m.oldValue(ctx)
  8854. if err != nil {
  8855. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8856. }
  8857. return oldValue.Dontseeit, nil
  8858. }
  8859. // AddDontseeit adds i to the "dontseeit" field.
  8860. func (m *ContactMutation) AddDontseeit(i int) {
  8861. if m.adddontseeit != nil {
  8862. *m.adddontseeit += i
  8863. } else {
  8864. m.adddontseeit = &i
  8865. }
  8866. }
  8867. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8868. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8869. v := m.adddontseeit
  8870. if v == nil {
  8871. return
  8872. }
  8873. return *v, true
  8874. }
  8875. // ResetDontseeit resets all changes to the "dontseeit" field.
  8876. func (m *ContactMutation) ResetDontseeit() {
  8877. m.dontseeit = nil
  8878. m.adddontseeit = nil
  8879. }
  8880. // SetDontseeme sets the "dontseeme" field.
  8881. func (m *ContactMutation) SetDontseeme(i int) {
  8882. m.dontseeme = &i
  8883. m.adddontseeme = nil
  8884. }
  8885. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8886. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8887. v := m.dontseeme
  8888. if v == nil {
  8889. return
  8890. }
  8891. return *v, true
  8892. }
  8893. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8894. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8896. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8897. if !m.op.Is(OpUpdateOne) {
  8898. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8899. }
  8900. if m.id == nil || m.oldValue == nil {
  8901. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8902. }
  8903. oldValue, err := m.oldValue(ctx)
  8904. if err != nil {
  8905. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8906. }
  8907. return oldValue.Dontseeme, nil
  8908. }
  8909. // AddDontseeme adds i to the "dontseeme" field.
  8910. func (m *ContactMutation) AddDontseeme(i int) {
  8911. if m.adddontseeme != nil {
  8912. *m.adddontseeme += i
  8913. } else {
  8914. m.adddontseeme = &i
  8915. }
  8916. }
  8917. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8918. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8919. v := m.adddontseeme
  8920. if v == nil {
  8921. return
  8922. }
  8923. return *v, true
  8924. }
  8925. // ResetDontseeme resets all changes to the "dontseeme" field.
  8926. func (m *ContactMutation) ResetDontseeme() {
  8927. m.dontseeme = nil
  8928. m.adddontseeme = nil
  8929. }
  8930. // SetLag sets the "lag" field.
  8931. func (m *ContactMutation) SetLag(s string) {
  8932. m.lag = &s
  8933. }
  8934. // Lag returns the value of the "lag" field in the mutation.
  8935. func (m *ContactMutation) Lag() (r string, exists bool) {
  8936. v := m.lag
  8937. if v == nil {
  8938. return
  8939. }
  8940. return *v, true
  8941. }
  8942. // OldLag returns the old "lag" field's value of the Contact entity.
  8943. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8945. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8946. if !m.op.Is(OpUpdateOne) {
  8947. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8948. }
  8949. if m.id == nil || m.oldValue == nil {
  8950. return v, errors.New("OldLag requires an ID field in the mutation")
  8951. }
  8952. oldValue, err := m.oldValue(ctx)
  8953. if err != nil {
  8954. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8955. }
  8956. return oldValue.Lag, nil
  8957. }
  8958. // ResetLag resets all changes to the "lag" field.
  8959. func (m *ContactMutation) ResetLag() {
  8960. m.lag = nil
  8961. }
  8962. // SetGid sets the "gid" field.
  8963. func (m *ContactMutation) SetGid(s string) {
  8964. m.gid = &s
  8965. }
  8966. // Gid returns the value of the "gid" field in the mutation.
  8967. func (m *ContactMutation) Gid() (r string, exists bool) {
  8968. v := m.gid
  8969. if v == nil {
  8970. return
  8971. }
  8972. return *v, true
  8973. }
  8974. // OldGid returns the old "gid" field's value of the Contact entity.
  8975. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8977. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8978. if !m.op.Is(OpUpdateOne) {
  8979. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8980. }
  8981. if m.id == nil || m.oldValue == nil {
  8982. return v, errors.New("OldGid requires an ID field in the mutation")
  8983. }
  8984. oldValue, err := m.oldValue(ctx)
  8985. if err != nil {
  8986. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8987. }
  8988. return oldValue.Gid, nil
  8989. }
  8990. // ResetGid resets all changes to the "gid" field.
  8991. func (m *ContactMutation) ResetGid() {
  8992. m.gid = nil
  8993. }
  8994. // SetGname sets the "gname" field.
  8995. func (m *ContactMutation) SetGname(s string) {
  8996. m.gname = &s
  8997. }
  8998. // Gname returns the value of the "gname" field in the mutation.
  8999. func (m *ContactMutation) Gname() (r string, exists bool) {
  9000. v := m.gname
  9001. if v == nil {
  9002. return
  9003. }
  9004. return *v, true
  9005. }
  9006. // OldGname returns the old "gname" field's value of the Contact entity.
  9007. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9009. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  9010. if !m.op.Is(OpUpdateOne) {
  9011. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  9012. }
  9013. if m.id == nil || m.oldValue == nil {
  9014. return v, errors.New("OldGname requires an ID field in the mutation")
  9015. }
  9016. oldValue, err := m.oldValue(ctx)
  9017. if err != nil {
  9018. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  9019. }
  9020. return oldValue.Gname, nil
  9021. }
  9022. // ResetGname resets all changes to the "gname" field.
  9023. func (m *ContactMutation) ResetGname() {
  9024. m.gname = nil
  9025. }
  9026. // SetV3 sets the "v3" field.
  9027. func (m *ContactMutation) SetV3(s string) {
  9028. m.v3 = &s
  9029. }
  9030. // V3 returns the value of the "v3" field in the mutation.
  9031. func (m *ContactMutation) V3() (r string, exists bool) {
  9032. v := m.v3
  9033. if v == nil {
  9034. return
  9035. }
  9036. return *v, true
  9037. }
  9038. // OldV3 returns the old "v3" field's value of the Contact entity.
  9039. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9041. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  9042. if !m.op.Is(OpUpdateOne) {
  9043. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  9044. }
  9045. if m.id == nil || m.oldValue == nil {
  9046. return v, errors.New("OldV3 requires an ID field in the mutation")
  9047. }
  9048. oldValue, err := m.oldValue(ctx)
  9049. if err != nil {
  9050. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  9051. }
  9052. return oldValue.V3, nil
  9053. }
  9054. // ResetV3 resets all changes to the "v3" field.
  9055. func (m *ContactMutation) ResetV3() {
  9056. m.v3 = nil
  9057. }
  9058. // SetOrganizationID sets the "organization_id" field.
  9059. func (m *ContactMutation) SetOrganizationID(u uint64) {
  9060. m.organization_id = &u
  9061. m.addorganization_id = nil
  9062. }
  9063. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9064. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  9065. v := m.organization_id
  9066. if v == nil {
  9067. return
  9068. }
  9069. return *v, true
  9070. }
  9071. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  9072. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9074. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9075. if !m.op.Is(OpUpdateOne) {
  9076. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9077. }
  9078. if m.id == nil || m.oldValue == nil {
  9079. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9080. }
  9081. oldValue, err := m.oldValue(ctx)
  9082. if err != nil {
  9083. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9084. }
  9085. return oldValue.OrganizationID, nil
  9086. }
  9087. // AddOrganizationID adds u to the "organization_id" field.
  9088. func (m *ContactMutation) AddOrganizationID(u int64) {
  9089. if m.addorganization_id != nil {
  9090. *m.addorganization_id += u
  9091. } else {
  9092. m.addorganization_id = &u
  9093. }
  9094. }
  9095. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9096. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  9097. v := m.addorganization_id
  9098. if v == nil {
  9099. return
  9100. }
  9101. return *v, true
  9102. }
  9103. // ClearOrganizationID clears the value of the "organization_id" field.
  9104. func (m *ContactMutation) ClearOrganizationID() {
  9105. m.organization_id = nil
  9106. m.addorganization_id = nil
  9107. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  9108. }
  9109. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9110. func (m *ContactMutation) OrganizationIDCleared() bool {
  9111. _, ok := m.clearedFields[contact.FieldOrganizationID]
  9112. return ok
  9113. }
  9114. // ResetOrganizationID resets all changes to the "organization_id" field.
  9115. func (m *ContactMutation) ResetOrganizationID() {
  9116. m.organization_id = nil
  9117. m.addorganization_id = nil
  9118. delete(m.clearedFields, contact.FieldOrganizationID)
  9119. }
  9120. // SetCtype sets the "ctype" field.
  9121. func (m *ContactMutation) SetCtype(u uint64) {
  9122. m.ctype = &u
  9123. m.addctype = nil
  9124. }
  9125. // Ctype returns the value of the "ctype" field in the mutation.
  9126. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  9127. v := m.ctype
  9128. if v == nil {
  9129. return
  9130. }
  9131. return *v, true
  9132. }
  9133. // OldCtype returns the old "ctype" field's value of the Contact entity.
  9134. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9136. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  9137. if !m.op.Is(OpUpdateOne) {
  9138. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  9139. }
  9140. if m.id == nil || m.oldValue == nil {
  9141. return v, errors.New("OldCtype requires an ID field in the mutation")
  9142. }
  9143. oldValue, err := m.oldValue(ctx)
  9144. if err != nil {
  9145. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  9146. }
  9147. return oldValue.Ctype, nil
  9148. }
  9149. // AddCtype adds u to the "ctype" field.
  9150. func (m *ContactMutation) AddCtype(u int64) {
  9151. if m.addctype != nil {
  9152. *m.addctype += u
  9153. } else {
  9154. m.addctype = &u
  9155. }
  9156. }
  9157. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  9158. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  9159. v := m.addctype
  9160. if v == nil {
  9161. return
  9162. }
  9163. return *v, true
  9164. }
  9165. // ResetCtype resets all changes to the "ctype" field.
  9166. func (m *ContactMutation) ResetCtype() {
  9167. m.ctype = nil
  9168. m.addctype = nil
  9169. }
  9170. // SetCage sets the "cage" field.
  9171. func (m *ContactMutation) SetCage(i int) {
  9172. m.cage = &i
  9173. m.addcage = nil
  9174. }
  9175. // Cage returns the value of the "cage" field in the mutation.
  9176. func (m *ContactMutation) Cage() (r int, exists bool) {
  9177. v := m.cage
  9178. if v == nil {
  9179. return
  9180. }
  9181. return *v, true
  9182. }
  9183. // OldCage returns the old "cage" field's value of the Contact entity.
  9184. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9186. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  9187. if !m.op.Is(OpUpdateOne) {
  9188. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  9189. }
  9190. if m.id == nil || m.oldValue == nil {
  9191. return v, errors.New("OldCage requires an ID field in the mutation")
  9192. }
  9193. oldValue, err := m.oldValue(ctx)
  9194. if err != nil {
  9195. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  9196. }
  9197. return oldValue.Cage, nil
  9198. }
  9199. // AddCage adds i to the "cage" field.
  9200. func (m *ContactMutation) AddCage(i int) {
  9201. if m.addcage != nil {
  9202. *m.addcage += i
  9203. } else {
  9204. m.addcage = &i
  9205. }
  9206. }
  9207. // AddedCage returns the value that was added to the "cage" field in this mutation.
  9208. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  9209. v := m.addcage
  9210. if v == nil {
  9211. return
  9212. }
  9213. return *v, true
  9214. }
  9215. // ResetCage resets all changes to the "cage" field.
  9216. func (m *ContactMutation) ResetCage() {
  9217. m.cage = nil
  9218. m.addcage = nil
  9219. }
  9220. // SetCname sets the "cname" field.
  9221. func (m *ContactMutation) SetCname(s string) {
  9222. m.cname = &s
  9223. }
  9224. // Cname returns the value of the "cname" field in the mutation.
  9225. func (m *ContactMutation) Cname() (r string, exists bool) {
  9226. v := m.cname
  9227. if v == nil {
  9228. return
  9229. }
  9230. return *v, true
  9231. }
  9232. // OldCname returns the old "cname" field's value of the Contact entity.
  9233. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9235. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  9236. if !m.op.Is(OpUpdateOne) {
  9237. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  9238. }
  9239. if m.id == nil || m.oldValue == nil {
  9240. return v, errors.New("OldCname requires an ID field in the mutation")
  9241. }
  9242. oldValue, err := m.oldValue(ctx)
  9243. if err != nil {
  9244. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  9245. }
  9246. return oldValue.Cname, nil
  9247. }
  9248. // ResetCname resets all changes to the "cname" field.
  9249. func (m *ContactMutation) ResetCname() {
  9250. m.cname = nil
  9251. }
  9252. // SetCarea sets the "carea" field.
  9253. func (m *ContactMutation) SetCarea(s string) {
  9254. m.carea = &s
  9255. }
  9256. // Carea returns the value of the "carea" field in the mutation.
  9257. func (m *ContactMutation) Carea() (r string, exists bool) {
  9258. v := m.carea
  9259. if v == nil {
  9260. return
  9261. }
  9262. return *v, true
  9263. }
  9264. // OldCarea returns the old "carea" field's value of the Contact entity.
  9265. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9267. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  9268. if !m.op.Is(OpUpdateOne) {
  9269. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  9270. }
  9271. if m.id == nil || m.oldValue == nil {
  9272. return v, errors.New("OldCarea requires an ID field in the mutation")
  9273. }
  9274. oldValue, err := m.oldValue(ctx)
  9275. if err != nil {
  9276. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  9277. }
  9278. return oldValue.Carea, nil
  9279. }
  9280. // ResetCarea resets all changes to the "carea" field.
  9281. func (m *ContactMutation) ResetCarea() {
  9282. m.carea = nil
  9283. }
  9284. // SetCbirthday sets the "cbirthday" field.
  9285. func (m *ContactMutation) SetCbirthday(s string) {
  9286. m.cbirthday = &s
  9287. }
  9288. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  9289. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  9290. v := m.cbirthday
  9291. if v == nil {
  9292. return
  9293. }
  9294. return *v, true
  9295. }
  9296. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  9297. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9299. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  9300. if !m.op.Is(OpUpdateOne) {
  9301. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  9302. }
  9303. if m.id == nil || m.oldValue == nil {
  9304. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  9305. }
  9306. oldValue, err := m.oldValue(ctx)
  9307. if err != nil {
  9308. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  9309. }
  9310. return oldValue.Cbirthday, nil
  9311. }
  9312. // ResetCbirthday resets all changes to the "cbirthday" field.
  9313. func (m *ContactMutation) ResetCbirthday() {
  9314. m.cbirthday = nil
  9315. }
  9316. // SetCbirtharea sets the "cbirtharea" field.
  9317. func (m *ContactMutation) SetCbirtharea(s string) {
  9318. m.cbirtharea = &s
  9319. }
  9320. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  9321. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  9322. v := m.cbirtharea
  9323. if v == nil {
  9324. return
  9325. }
  9326. return *v, true
  9327. }
  9328. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  9329. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9331. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  9332. if !m.op.Is(OpUpdateOne) {
  9333. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  9334. }
  9335. if m.id == nil || m.oldValue == nil {
  9336. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  9337. }
  9338. oldValue, err := m.oldValue(ctx)
  9339. if err != nil {
  9340. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  9341. }
  9342. return oldValue.Cbirtharea, nil
  9343. }
  9344. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  9345. func (m *ContactMutation) ResetCbirtharea() {
  9346. m.cbirtharea = nil
  9347. }
  9348. // SetCidcardNo sets the "cidcard_no" field.
  9349. func (m *ContactMutation) SetCidcardNo(s string) {
  9350. m.cidcard_no = &s
  9351. }
  9352. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  9353. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  9354. v := m.cidcard_no
  9355. if v == nil {
  9356. return
  9357. }
  9358. return *v, true
  9359. }
  9360. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  9361. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9363. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  9364. if !m.op.Is(OpUpdateOne) {
  9365. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  9366. }
  9367. if m.id == nil || m.oldValue == nil {
  9368. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  9369. }
  9370. oldValue, err := m.oldValue(ctx)
  9371. if err != nil {
  9372. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  9373. }
  9374. return oldValue.CidcardNo, nil
  9375. }
  9376. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  9377. func (m *ContactMutation) ResetCidcardNo() {
  9378. m.cidcard_no = nil
  9379. }
  9380. // SetCtitle sets the "ctitle" field.
  9381. func (m *ContactMutation) SetCtitle(s string) {
  9382. m.ctitle = &s
  9383. }
  9384. // Ctitle returns the value of the "ctitle" field in the mutation.
  9385. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  9386. v := m.ctitle
  9387. if v == nil {
  9388. return
  9389. }
  9390. return *v, true
  9391. }
  9392. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  9393. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9395. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  9396. if !m.op.Is(OpUpdateOne) {
  9397. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  9398. }
  9399. if m.id == nil || m.oldValue == nil {
  9400. return v, errors.New("OldCtitle requires an ID field in the mutation")
  9401. }
  9402. oldValue, err := m.oldValue(ctx)
  9403. if err != nil {
  9404. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  9405. }
  9406. return oldValue.Ctitle, nil
  9407. }
  9408. // ResetCtitle resets all changes to the "ctitle" field.
  9409. func (m *ContactMutation) ResetCtitle() {
  9410. m.ctitle = nil
  9411. }
  9412. // SetCc sets the "cc" field.
  9413. func (m *ContactMutation) SetCc(s string) {
  9414. m.cc = &s
  9415. }
  9416. // Cc returns the value of the "cc" field in the mutation.
  9417. func (m *ContactMutation) Cc() (r string, exists bool) {
  9418. v := m.cc
  9419. if v == nil {
  9420. return
  9421. }
  9422. return *v, true
  9423. }
  9424. // OldCc returns the old "cc" field's value of the Contact entity.
  9425. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9427. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  9428. if !m.op.Is(OpUpdateOne) {
  9429. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  9430. }
  9431. if m.id == nil || m.oldValue == nil {
  9432. return v, errors.New("OldCc requires an ID field in the mutation")
  9433. }
  9434. oldValue, err := m.oldValue(ctx)
  9435. if err != nil {
  9436. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  9437. }
  9438. return oldValue.Cc, nil
  9439. }
  9440. // ResetCc resets all changes to the "cc" field.
  9441. func (m *ContactMutation) ResetCc() {
  9442. m.cc = nil
  9443. }
  9444. // SetPhone sets the "phone" field.
  9445. func (m *ContactMutation) SetPhone(s string) {
  9446. m.phone = &s
  9447. }
  9448. // Phone returns the value of the "phone" field in the mutation.
  9449. func (m *ContactMutation) Phone() (r string, exists bool) {
  9450. v := m.phone
  9451. if v == nil {
  9452. return
  9453. }
  9454. return *v, true
  9455. }
  9456. // OldPhone returns the old "phone" field's value of the Contact entity.
  9457. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9459. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  9460. if !m.op.Is(OpUpdateOne) {
  9461. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  9462. }
  9463. if m.id == nil || m.oldValue == nil {
  9464. return v, errors.New("OldPhone requires an ID field in the mutation")
  9465. }
  9466. oldValue, err := m.oldValue(ctx)
  9467. if err != nil {
  9468. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  9469. }
  9470. return oldValue.Phone, nil
  9471. }
  9472. // ResetPhone resets all changes to the "phone" field.
  9473. func (m *ContactMutation) ResetPhone() {
  9474. m.phone = nil
  9475. }
  9476. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  9477. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  9478. if m.contact_relationships == nil {
  9479. m.contact_relationships = make(map[uint64]struct{})
  9480. }
  9481. for i := range ids {
  9482. m.contact_relationships[ids[i]] = struct{}{}
  9483. }
  9484. }
  9485. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  9486. func (m *ContactMutation) ClearContactRelationships() {
  9487. m.clearedcontact_relationships = true
  9488. }
  9489. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  9490. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  9491. return m.clearedcontact_relationships
  9492. }
  9493. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  9494. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  9495. if m.removedcontact_relationships == nil {
  9496. m.removedcontact_relationships = make(map[uint64]struct{})
  9497. }
  9498. for i := range ids {
  9499. delete(m.contact_relationships, ids[i])
  9500. m.removedcontact_relationships[ids[i]] = struct{}{}
  9501. }
  9502. }
  9503. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  9504. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  9505. for id := range m.removedcontact_relationships {
  9506. ids = append(ids, id)
  9507. }
  9508. return
  9509. }
  9510. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  9511. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  9512. for id := range m.contact_relationships {
  9513. ids = append(ids, id)
  9514. }
  9515. return
  9516. }
  9517. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  9518. func (m *ContactMutation) ResetContactRelationships() {
  9519. m.contact_relationships = nil
  9520. m.clearedcontact_relationships = false
  9521. m.removedcontact_relationships = nil
  9522. }
  9523. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  9524. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  9525. if m.contact_messages == nil {
  9526. m.contact_messages = make(map[uint64]struct{})
  9527. }
  9528. for i := range ids {
  9529. m.contact_messages[ids[i]] = struct{}{}
  9530. }
  9531. }
  9532. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  9533. func (m *ContactMutation) ClearContactMessages() {
  9534. m.clearedcontact_messages = true
  9535. }
  9536. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  9537. func (m *ContactMutation) ContactMessagesCleared() bool {
  9538. return m.clearedcontact_messages
  9539. }
  9540. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  9541. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  9542. if m.removedcontact_messages == nil {
  9543. m.removedcontact_messages = make(map[uint64]struct{})
  9544. }
  9545. for i := range ids {
  9546. delete(m.contact_messages, ids[i])
  9547. m.removedcontact_messages[ids[i]] = struct{}{}
  9548. }
  9549. }
  9550. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  9551. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  9552. for id := range m.removedcontact_messages {
  9553. ids = append(ids, id)
  9554. }
  9555. return
  9556. }
  9557. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  9558. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  9559. for id := range m.contact_messages {
  9560. ids = append(ids, id)
  9561. }
  9562. return
  9563. }
  9564. // ResetContactMessages resets all changes to the "contact_messages" edge.
  9565. func (m *ContactMutation) ResetContactMessages() {
  9566. m.contact_messages = nil
  9567. m.clearedcontact_messages = false
  9568. m.removedcontact_messages = nil
  9569. }
  9570. // Where appends a list predicates to the ContactMutation builder.
  9571. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  9572. m.predicates = append(m.predicates, ps...)
  9573. }
  9574. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  9575. // users can use type-assertion to append predicates that do not depend on any generated package.
  9576. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  9577. p := make([]predicate.Contact, len(ps))
  9578. for i := range ps {
  9579. p[i] = ps[i]
  9580. }
  9581. m.Where(p...)
  9582. }
  9583. // Op returns the operation name.
  9584. func (m *ContactMutation) Op() Op {
  9585. return m.op
  9586. }
  9587. // SetOp allows setting the mutation operation.
  9588. func (m *ContactMutation) SetOp(op Op) {
  9589. m.op = op
  9590. }
  9591. // Type returns the node type of this mutation (Contact).
  9592. func (m *ContactMutation) Type() string {
  9593. return m.typ
  9594. }
  9595. // Fields returns all fields that were changed during this mutation. Note that in
  9596. // order to get all numeric fields that were incremented/decremented, call
  9597. // AddedFields().
  9598. func (m *ContactMutation) Fields() []string {
  9599. fields := make([]string, 0, 30)
  9600. if m.created_at != nil {
  9601. fields = append(fields, contact.FieldCreatedAt)
  9602. }
  9603. if m.updated_at != nil {
  9604. fields = append(fields, contact.FieldUpdatedAt)
  9605. }
  9606. if m.status != nil {
  9607. fields = append(fields, contact.FieldStatus)
  9608. }
  9609. if m.deleted_at != nil {
  9610. fields = append(fields, contact.FieldDeletedAt)
  9611. }
  9612. if m.wx_wxid != nil {
  9613. fields = append(fields, contact.FieldWxWxid)
  9614. }
  9615. if m._type != nil {
  9616. fields = append(fields, contact.FieldType)
  9617. }
  9618. if m.wxid != nil {
  9619. fields = append(fields, contact.FieldWxid)
  9620. }
  9621. if m.account != nil {
  9622. fields = append(fields, contact.FieldAccount)
  9623. }
  9624. if m.nickname != nil {
  9625. fields = append(fields, contact.FieldNickname)
  9626. }
  9627. if m.markname != nil {
  9628. fields = append(fields, contact.FieldMarkname)
  9629. }
  9630. if m.headimg != nil {
  9631. fields = append(fields, contact.FieldHeadimg)
  9632. }
  9633. if m.sex != nil {
  9634. fields = append(fields, contact.FieldSex)
  9635. }
  9636. if m.starrole != nil {
  9637. fields = append(fields, contact.FieldStarrole)
  9638. }
  9639. if m.dontseeit != nil {
  9640. fields = append(fields, contact.FieldDontseeit)
  9641. }
  9642. if m.dontseeme != nil {
  9643. fields = append(fields, contact.FieldDontseeme)
  9644. }
  9645. if m.lag != nil {
  9646. fields = append(fields, contact.FieldLag)
  9647. }
  9648. if m.gid != nil {
  9649. fields = append(fields, contact.FieldGid)
  9650. }
  9651. if m.gname != nil {
  9652. fields = append(fields, contact.FieldGname)
  9653. }
  9654. if m.v3 != nil {
  9655. fields = append(fields, contact.FieldV3)
  9656. }
  9657. if m.organization_id != nil {
  9658. fields = append(fields, contact.FieldOrganizationID)
  9659. }
  9660. if m.ctype != nil {
  9661. fields = append(fields, contact.FieldCtype)
  9662. }
  9663. if m.cage != nil {
  9664. fields = append(fields, contact.FieldCage)
  9665. }
  9666. if m.cname != nil {
  9667. fields = append(fields, contact.FieldCname)
  9668. }
  9669. if m.carea != nil {
  9670. fields = append(fields, contact.FieldCarea)
  9671. }
  9672. if m.cbirthday != nil {
  9673. fields = append(fields, contact.FieldCbirthday)
  9674. }
  9675. if m.cbirtharea != nil {
  9676. fields = append(fields, contact.FieldCbirtharea)
  9677. }
  9678. if m.cidcard_no != nil {
  9679. fields = append(fields, contact.FieldCidcardNo)
  9680. }
  9681. if m.ctitle != nil {
  9682. fields = append(fields, contact.FieldCtitle)
  9683. }
  9684. if m.cc != nil {
  9685. fields = append(fields, contact.FieldCc)
  9686. }
  9687. if m.phone != nil {
  9688. fields = append(fields, contact.FieldPhone)
  9689. }
  9690. return fields
  9691. }
  9692. // Field returns the value of a field with the given name. The second boolean
  9693. // return value indicates that this field was not set, or was not defined in the
  9694. // schema.
  9695. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  9696. switch name {
  9697. case contact.FieldCreatedAt:
  9698. return m.CreatedAt()
  9699. case contact.FieldUpdatedAt:
  9700. return m.UpdatedAt()
  9701. case contact.FieldStatus:
  9702. return m.Status()
  9703. case contact.FieldDeletedAt:
  9704. return m.DeletedAt()
  9705. case contact.FieldWxWxid:
  9706. return m.WxWxid()
  9707. case contact.FieldType:
  9708. return m.GetType()
  9709. case contact.FieldWxid:
  9710. return m.Wxid()
  9711. case contact.FieldAccount:
  9712. return m.Account()
  9713. case contact.FieldNickname:
  9714. return m.Nickname()
  9715. case contact.FieldMarkname:
  9716. return m.Markname()
  9717. case contact.FieldHeadimg:
  9718. return m.Headimg()
  9719. case contact.FieldSex:
  9720. return m.Sex()
  9721. case contact.FieldStarrole:
  9722. return m.Starrole()
  9723. case contact.FieldDontseeit:
  9724. return m.Dontseeit()
  9725. case contact.FieldDontseeme:
  9726. return m.Dontseeme()
  9727. case contact.FieldLag:
  9728. return m.Lag()
  9729. case contact.FieldGid:
  9730. return m.Gid()
  9731. case contact.FieldGname:
  9732. return m.Gname()
  9733. case contact.FieldV3:
  9734. return m.V3()
  9735. case contact.FieldOrganizationID:
  9736. return m.OrganizationID()
  9737. case contact.FieldCtype:
  9738. return m.Ctype()
  9739. case contact.FieldCage:
  9740. return m.Cage()
  9741. case contact.FieldCname:
  9742. return m.Cname()
  9743. case contact.FieldCarea:
  9744. return m.Carea()
  9745. case contact.FieldCbirthday:
  9746. return m.Cbirthday()
  9747. case contact.FieldCbirtharea:
  9748. return m.Cbirtharea()
  9749. case contact.FieldCidcardNo:
  9750. return m.CidcardNo()
  9751. case contact.FieldCtitle:
  9752. return m.Ctitle()
  9753. case contact.FieldCc:
  9754. return m.Cc()
  9755. case contact.FieldPhone:
  9756. return m.Phone()
  9757. }
  9758. return nil, false
  9759. }
  9760. // OldField returns the old value of the field from the database. An error is
  9761. // returned if the mutation operation is not UpdateOne, or the query to the
  9762. // database failed.
  9763. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9764. switch name {
  9765. case contact.FieldCreatedAt:
  9766. return m.OldCreatedAt(ctx)
  9767. case contact.FieldUpdatedAt:
  9768. return m.OldUpdatedAt(ctx)
  9769. case contact.FieldStatus:
  9770. return m.OldStatus(ctx)
  9771. case contact.FieldDeletedAt:
  9772. return m.OldDeletedAt(ctx)
  9773. case contact.FieldWxWxid:
  9774. return m.OldWxWxid(ctx)
  9775. case contact.FieldType:
  9776. return m.OldType(ctx)
  9777. case contact.FieldWxid:
  9778. return m.OldWxid(ctx)
  9779. case contact.FieldAccount:
  9780. return m.OldAccount(ctx)
  9781. case contact.FieldNickname:
  9782. return m.OldNickname(ctx)
  9783. case contact.FieldMarkname:
  9784. return m.OldMarkname(ctx)
  9785. case contact.FieldHeadimg:
  9786. return m.OldHeadimg(ctx)
  9787. case contact.FieldSex:
  9788. return m.OldSex(ctx)
  9789. case contact.FieldStarrole:
  9790. return m.OldStarrole(ctx)
  9791. case contact.FieldDontseeit:
  9792. return m.OldDontseeit(ctx)
  9793. case contact.FieldDontseeme:
  9794. return m.OldDontseeme(ctx)
  9795. case contact.FieldLag:
  9796. return m.OldLag(ctx)
  9797. case contact.FieldGid:
  9798. return m.OldGid(ctx)
  9799. case contact.FieldGname:
  9800. return m.OldGname(ctx)
  9801. case contact.FieldV3:
  9802. return m.OldV3(ctx)
  9803. case contact.FieldOrganizationID:
  9804. return m.OldOrganizationID(ctx)
  9805. case contact.FieldCtype:
  9806. return m.OldCtype(ctx)
  9807. case contact.FieldCage:
  9808. return m.OldCage(ctx)
  9809. case contact.FieldCname:
  9810. return m.OldCname(ctx)
  9811. case contact.FieldCarea:
  9812. return m.OldCarea(ctx)
  9813. case contact.FieldCbirthday:
  9814. return m.OldCbirthday(ctx)
  9815. case contact.FieldCbirtharea:
  9816. return m.OldCbirtharea(ctx)
  9817. case contact.FieldCidcardNo:
  9818. return m.OldCidcardNo(ctx)
  9819. case contact.FieldCtitle:
  9820. return m.OldCtitle(ctx)
  9821. case contact.FieldCc:
  9822. return m.OldCc(ctx)
  9823. case contact.FieldPhone:
  9824. return m.OldPhone(ctx)
  9825. }
  9826. return nil, fmt.Errorf("unknown Contact field %s", name)
  9827. }
  9828. // SetField sets the value of a field with the given name. It returns an error if
  9829. // the field is not defined in the schema, or if the type mismatched the field
  9830. // type.
  9831. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  9832. switch name {
  9833. case contact.FieldCreatedAt:
  9834. v, ok := value.(time.Time)
  9835. if !ok {
  9836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9837. }
  9838. m.SetCreatedAt(v)
  9839. return nil
  9840. case contact.FieldUpdatedAt:
  9841. v, ok := value.(time.Time)
  9842. if !ok {
  9843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9844. }
  9845. m.SetUpdatedAt(v)
  9846. return nil
  9847. case contact.FieldStatus:
  9848. v, ok := value.(uint8)
  9849. if !ok {
  9850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9851. }
  9852. m.SetStatus(v)
  9853. return nil
  9854. case contact.FieldDeletedAt:
  9855. v, ok := value.(time.Time)
  9856. if !ok {
  9857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9858. }
  9859. m.SetDeletedAt(v)
  9860. return nil
  9861. case contact.FieldWxWxid:
  9862. v, ok := value.(string)
  9863. if !ok {
  9864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9865. }
  9866. m.SetWxWxid(v)
  9867. return nil
  9868. case contact.FieldType:
  9869. v, ok := value.(int)
  9870. if !ok {
  9871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9872. }
  9873. m.SetType(v)
  9874. return nil
  9875. case contact.FieldWxid:
  9876. v, ok := value.(string)
  9877. if !ok {
  9878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9879. }
  9880. m.SetWxid(v)
  9881. return nil
  9882. case contact.FieldAccount:
  9883. v, ok := value.(string)
  9884. if !ok {
  9885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9886. }
  9887. m.SetAccount(v)
  9888. return nil
  9889. case contact.FieldNickname:
  9890. v, ok := value.(string)
  9891. if !ok {
  9892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9893. }
  9894. m.SetNickname(v)
  9895. return nil
  9896. case contact.FieldMarkname:
  9897. v, ok := value.(string)
  9898. if !ok {
  9899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9900. }
  9901. m.SetMarkname(v)
  9902. return nil
  9903. case contact.FieldHeadimg:
  9904. v, ok := value.(string)
  9905. if !ok {
  9906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9907. }
  9908. m.SetHeadimg(v)
  9909. return nil
  9910. case contact.FieldSex:
  9911. v, ok := value.(int)
  9912. if !ok {
  9913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9914. }
  9915. m.SetSex(v)
  9916. return nil
  9917. case contact.FieldStarrole:
  9918. v, ok := value.(string)
  9919. if !ok {
  9920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9921. }
  9922. m.SetStarrole(v)
  9923. return nil
  9924. case contact.FieldDontseeit:
  9925. v, ok := value.(int)
  9926. if !ok {
  9927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9928. }
  9929. m.SetDontseeit(v)
  9930. return nil
  9931. case contact.FieldDontseeme:
  9932. v, ok := value.(int)
  9933. if !ok {
  9934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9935. }
  9936. m.SetDontseeme(v)
  9937. return nil
  9938. case contact.FieldLag:
  9939. v, ok := value.(string)
  9940. if !ok {
  9941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9942. }
  9943. m.SetLag(v)
  9944. return nil
  9945. case contact.FieldGid:
  9946. v, ok := value.(string)
  9947. if !ok {
  9948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9949. }
  9950. m.SetGid(v)
  9951. return nil
  9952. case contact.FieldGname:
  9953. v, ok := value.(string)
  9954. if !ok {
  9955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9956. }
  9957. m.SetGname(v)
  9958. return nil
  9959. case contact.FieldV3:
  9960. v, ok := value.(string)
  9961. if !ok {
  9962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9963. }
  9964. m.SetV3(v)
  9965. return nil
  9966. case contact.FieldOrganizationID:
  9967. v, ok := value.(uint64)
  9968. if !ok {
  9969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9970. }
  9971. m.SetOrganizationID(v)
  9972. return nil
  9973. case contact.FieldCtype:
  9974. v, ok := value.(uint64)
  9975. if !ok {
  9976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9977. }
  9978. m.SetCtype(v)
  9979. return nil
  9980. case contact.FieldCage:
  9981. v, ok := value.(int)
  9982. if !ok {
  9983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9984. }
  9985. m.SetCage(v)
  9986. return nil
  9987. case contact.FieldCname:
  9988. v, ok := value.(string)
  9989. if !ok {
  9990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9991. }
  9992. m.SetCname(v)
  9993. return nil
  9994. case contact.FieldCarea:
  9995. v, ok := value.(string)
  9996. if !ok {
  9997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9998. }
  9999. m.SetCarea(v)
  10000. return nil
  10001. case contact.FieldCbirthday:
  10002. v, ok := value.(string)
  10003. if !ok {
  10004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10005. }
  10006. m.SetCbirthday(v)
  10007. return nil
  10008. case contact.FieldCbirtharea:
  10009. v, ok := value.(string)
  10010. if !ok {
  10011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10012. }
  10013. m.SetCbirtharea(v)
  10014. return nil
  10015. case contact.FieldCidcardNo:
  10016. v, ok := value.(string)
  10017. if !ok {
  10018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10019. }
  10020. m.SetCidcardNo(v)
  10021. return nil
  10022. case contact.FieldCtitle:
  10023. v, ok := value.(string)
  10024. if !ok {
  10025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10026. }
  10027. m.SetCtitle(v)
  10028. return nil
  10029. case contact.FieldCc:
  10030. v, ok := value.(string)
  10031. if !ok {
  10032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10033. }
  10034. m.SetCc(v)
  10035. return nil
  10036. case contact.FieldPhone:
  10037. v, ok := value.(string)
  10038. if !ok {
  10039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10040. }
  10041. m.SetPhone(v)
  10042. return nil
  10043. }
  10044. return fmt.Errorf("unknown Contact field %s", name)
  10045. }
  10046. // AddedFields returns all numeric fields that were incremented/decremented during
  10047. // this mutation.
  10048. func (m *ContactMutation) AddedFields() []string {
  10049. var fields []string
  10050. if m.addstatus != nil {
  10051. fields = append(fields, contact.FieldStatus)
  10052. }
  10053. if m.add_type != nil {
  10054. fields = append(fields, contact.FieldType)
  10055. }
  10056. if m.addsex != nil {
  10057. fields = append(fields, contact.FieldSex)
  10058. }
  10059. if m.adddontseeit != nil {
  10060. fields = append(fields, contact.FieldDontseeit)
  10061. }
  10062. if m.adddontseeme != nil {
  10063. fields = append(fields, contact.FieldDontseeme)
  10064. }
  10065. if m.addorganization_id != nil {
  10066. fields = append(fields, contact.FieldOrganizationID)
  10067. }
  10068. if m.addctype != nil {
  10069. fields = append(fields, contact.FieldCtype)
  10070. }
  10071. if m.addcage != nil {
  10072. fields = append(fields, contact.FieldCage)
  10073. }
  10074. return fields
  10075. }
  10076. // AddedField returns the numeric value that was incremented/decremented on a field
  10077. // with the given name. The second boolean return value indicates that this field
  10078. // was not set, or was not defined in the schema.
  10079. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  10080. switch name {
  10081. case contact.FieldStatus:
  10082. return m.AddedStatus()
  10083. case contact.FieldType:
  10084. return m.AddedType()
  10085. case contact.FieldSex:
  10086. return m.AddedSex()
  10087. case contact.FieldDontseeit:
  10088. return m.AddedDontseeit()
  10089. case contact.FieldDontseeme:
  10090. return m.AddedDontseeme()
  10091. case contact.FieldOrganizationID:
  10092. return m.AddedOrganizationID()
  10093. case contact.FieldCtype:
  10094. return m.AddedCtype()
  10095. case contact.FieldCage:
  10096. return m.AddedCage()
  10097. }
  10098. return nil, false
  10099. }
  10100. // AddField adds the value to the field with the given name. It returns an error if
  10101. // the field is not defined in the schema, or if the type mismatched the field
  10102. // type.
  10103. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  10104. switch name {
  10105. case contact.FieldStatus:
  10106. v, ok := value.(int8)
  10107. if !ok {
  10108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10109. }
  10110. m.AddStatus(v)
  10111. return nil
  10112. case contact.FieldType:
  10113. v, ok := value.(int)
  10114. if !ok {
  10115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10116. }
  10117. m.AddType(v)
  10118. return nil
  10119. case contact.FieldSex:
  10120. v, ok := value.(int)
  10121. if !ok {
  10122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10123. }
  10124. m.AddSex(v)
  10125. return nil
  10126. case contact.FieldDontseeit:
  10127. v, ok := value.(int)
  10128. if !ok {
  10129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10130. }
  10131. m.AddDontseeit(v)
  10132. return nil
  10133. case contact.FieldDontseeme:
  10134. v, ok := value.(int)
  10135. if !ok {
  10136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10137. }
  10138. m.AddDontseeme(v)
  10139. return nil
  10140. case contact.FieldOrganizationID:
  10141. v, ok := value.(int64)
  10142. if !ok {
  10143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10144. }
  10145. m.AddOrganizationID(v)
  10146. return nil
  10147. case contact.FieldCtype:
  10148. v, ok := value.(int64)
  10149. if !ok {
  10150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10151. }
  10152. m.AddCtype(v)
  10153. return nil
  10154. case contact.FieldCage:
  10155. v, ok := value.(int)
  10156. if !ok {
  10157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10158. }
  10159. m.AddCage(v)
  10160. return nil
  10161. }
  10162. return fmt.Errorf("unknown Contact numeric field %s", name)
  10163. }
  10164. // ClearedFields returns all nullable fields that were cleared during this
  10165. // mutation.
  10166. func (m *ContactMutation) ClearedFields() []string {
  10167. var fields []string
  10168. if m.FieldCleared(contact.FieldStatus) {
  10169. fields = append(fields, contact.FieldStatus)
  10170. }
  10171. if m.FieldCleared(contact.FieldDeletedAt) {
  10172. fields = append(fields, contact.FieldDeletedAt)
  10173. }
  10174. if m.FieldCleared(contact.FieldType) {
  10175. fields = append(fields, contact.FieldType)
  10176. }
  10177. if m.FieldCleared(contact.FieldOrganizationID) {
  10178. fields = append(fields, contact.FieldOrganizationID)
  10179. }
  10180. return fields
  10181. }
  10182. // FieldCleared returns a boolean indicating if a field with the given name was
  10183. // cleared in this mutation.
  10184. func (m *ContactMutation) FieldCleared(name string) bool {
  10185. _, ok := m.clearedFields[name]
  10186. return ok
  10187. }
  10188. // ClearField clears the value of the field with the given name. It returns an
  10189. // error if the field is not defined in the schema.
  10190. func (m *ContactMutation) ClearField(name string) error {
  10191. switch name {
  10192. case contact.FieldStatus:
  10193. m.ClearStatus()
  10194. return nil
  10195. case contact.FieldDeletedAt:
  10196. m.ClearDeletedAt()
  10197. return nil
  10198. case contact.FieldType:
  10199. m.ClearType()
  10200. return nil
  10201. case contact.FieldOrganizationID:
  10202. m.ClearOrganizationID()
  10203. return nil
  10204. }
  10205. return fmt.Errorf("unknown Contact nullable field %s", name)
  10206. }
  10207. // ResetField resets all changes in the mutation for the field with the given name.
  10208. // It returns an error if the field is not defined in the schema.
  10209. func (m *ContactMutation) ResetField(name string) error {
  10210. switch name {
  10211. case contact.FieldCreatedAt:
  10212. m.ResetCreatedAt()
  10213. return nil
  10214. case contact.FieldUpdatedAt:
  10215. m.ResetUpdatedAt()
  10216. return nil
  10217. case contact.FieldStatus:
  10218. m.ResetStatus()
  10219. return nil
  10220. case contact.FieldDeletedAt:
  10221. m.ResetDeletedAt()
  10222. return nil
  10223. case contact.FieldWxWxid:
  10224. m.ResetWxWxid()
  10225. return nil
  10226. case contact.FieldType:
  10227. m.ResetType()
  10228. return nil
  10229. case contact.FieldWxid:
  10230. m.ResetWxid()
  10231. return nil
  10232. case contact.FieldAccount:
  10233. m.ResetAccount()
  10234. return nil
  10235. case contact.FieldNickname:
  10236. m.ResetNickname()
  10237. return nil
  10238. case contact.FieldMarkname:
  10239. m.ResetMarkname()
  10240. return nil
  10241. case contact.FieldHeadimg:
  10242. m.ResetHeadimg()
  10243. return nil
  10244. case contact.FieldSex:
  10245. m.ResetSex()
  10246. return nil
  10247. case contact.FieldStarrole:
  10248. m.ResetStarrole()
  10249. return nil
  10250. case contact.FieldDontseeit:
  10251. m.ResetDontseeit()
  10252. return nil
  10253. case contact.FieldDontseeme:
  10254. m.ResetDontseeme()
  10255. return nil
  10256. case contact.FieldLag:
  10257. m.ResetLag()
  10258. return nil
  10259. case contact.FieldGid:
  10260. m.ResetGid()
  10261. return nil
  10262. case contact.FieldGname:
  10263. m.ResetGname()
  10264. return nil
  10265. case contact.FieldV3:
  10266. m.ResetV3()
  10267. return nil
  10268. case contact.FieldOrganizationID:
  10269. m.ResetOrganizationID()
  10270. return nil
  10271. case contact.FieldCtype:
  10272. m.ResetCtype()
  10273. return nil
  10274. case contact.FieldCage:
  10275. m.ResetCage()
  10276. return nil
  10277. case contact.FieldCname:
  10278. m.ResetCname()
  10279. return nil
  10280. case contact.FieldCarea:
  10281. m.ResetCarea()
  10282. return nil
  10283. case contact.FieldCbirthday:
  10284. m.ResetCbirthday()
  10285. return nil
  10286. case contact.FieldCbirtharea:
  10287. m.ResetCbirtharea()
  10288. return nil
  10289. case contact.FieldCidcardNo:
  10290. m.ResetCidcardNo()
  10291. return nil
  10292. case contact.FieldCtitle:
  10293. m.ResetCtitle()
  10294. return nil
  10295. case contact.FieldCc:
  10296. m.ResetCc()
  10297. return nil
  10298. case contact.FieldPhone:
  10299. m.ResetPhone()
  10300. return nil
  10301. }
  10302. return fmt.Errorf("unknown Contact field %s", name)
  10303. }
  10304. // AddedEdges returns all edge names that were set/added in this mutation.
  10305. func (m *ContactMutation) AddedEdges() []string {
  10306. edges := make([]string, 0, 2)
  10307. if m.contact_relationships != nil {
  10308. edges = append(edges, contact.EdgeContactRelationships)
  10309. }
  10310. if m.contact_messages != nil {
  10311. edges = append(edges, contact.EdgeContactMessages)
  10312. }
  10313. return edges
  10314. }
  10315. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10316. // name in this mutation.
  10317. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  10318. switch name {
  10319. case contact.EdgeContactRelationships:
  10320. ids := make([]ent.Value, 0, len(m.contact_relationships))
  10321. for id := range m.contact_relationships {
  10322. ids = append(ids, id)
  10323. }
  10324. return ids
  10325. case contact.EdgeContactMessages:
  10326. ids := make([]ent.Value, 0, len(m.contact_messages))
  10327. for id := range m.contact_messages {
  10328. ids = append(ids, id)
  10329. }
  10330. return ids
  10331. }
  10332. return nil
  10333. }
  10334. // RemovedEdges returns all edge names that were removed in this mutation.
  10335. func (m *ContactMutation) RemovedEdges() []string {
  10336. edges := make([]string, 0, 2)
  10337. if m.removedcontact_relationships != nil {
  10338. edges = append(edges, contact.EdgeContactRelationships)
  10339. }
  10340. if m.removedcontact_messages != nil {
  10341. edges = append(edges, contact.EdgeContactMessages)
  10342. }
  10343. return edges
  10344. }
  10345. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10346. // the given name in this mutation.
  10347. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  10348. switch name {
  10349. case contact.EdgeContactRelationships:
  10350. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  10351. for id := range m.removedcontact_relationships {
  10352. ids = append(ids, id)
  10353. }
  10354. return ids
  10355. case contact.EdgeContactMessages:
  10356. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  10357. for id := range m.removedcontact_messages {
  10358. ids = append(ids, id)
  10359. }
  10360. return ids
  10361. }
  10362. return nil
  10363. }
  10364. // ClearedEdges returns all edge names that were cleared in this mutation.
  10365. func (m *ContactMutation) ClearedEdges() []string {
  10366. edges := make([]string, 0, 2)
  10367. if m.clearedcontact_relationships {
  10368. edges = append(edges, contact.EdgeContactRelationships)
  10369. }
  10370. if m.clearedcontact_messages {
  10371. edges = append(edges, contact.EdgeContactMessages)
  10372. }
  10373. return edges
  10374. }
  10375. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10376. // was cleared in this mutation.
  10377. func (m *ContactMutation) EdgeCleared(name string) bool {
  10378. switch name {
  10379. case contact.EdgeContactRelationships:
  10380. return m.clearedcontact_relationships
  10381. case contact.EdgeContactMessages:
  10382. return m.clearedcontact_messages
  10383. }
  10384. return false
  10385. }
  10386. // ClearEdge clears the value of the edge with the given name. It returns an error
  10387. // if that edge is not defined in the schema.
  10388. func (m *ContactMutation) ClearEdge(name string) error {
  10389. switch name {
  10390. }
  10391. return fmt.Errorf("unknown Contact unique edge %s", name)
  10392. }
  10393. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10394. // It returns an error if the edge is not defined in the schema.
  10395. func (m *ContactMutation) ResetEdge(name string) error {
  10396. switch name {
  10397. case contact.EdgeContactRelationships:
  10398. m.ResetContactRelationships()
  10399. return nil
  10400. case contact.EdgeContactMessages:
  10401. m.ResetContactMessages()
  10402. return nil
  10403. }
  10404. return fmt.Errorf("unknown Contact edge %s", name)
  10405. }
  10406. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  10407. type CreditBalanceMutation struct {
  10408. config
  10409. op Op
  10410. typ string
  10411. id *uint64
  10412. created_at *time.Time
  10413. updated_at *time.Time
  10414. deleted_at *time.Time
  10415. user_id *string
  10416. balance *float32
  10417. addbalance *float32
  10418. status *int
  10419. addstatus *int
  10420. organization_id *uint64
  10421. addorganization_id *int64
  10422. clearedFields map[string]struct{}
  10423. done bool
  10424. oldValue func(context.Context) (*CreditBalance, error)
  10425. predicates []predicate.CreditBalance
  10426. }
  10427. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  10428. // creditbalanceOption allows management of the mutation configuration using functional options.
  10429. type creditbalanceOption func(*CreditBalanceMutation)
  10430. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  10431. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  10432. m := &CreditBalanceMutation{
  10433. config: c,
  10434. op: op,
  10435. typ: TypeCreditBalance,
  10436. clearedFields: make(map[string]struct{}),
  10437. }
  10438. for _, opt := range opts {
  10439. opt(m)
  10440. }
  10441. return m
  10442. }
  10443. // withCreditBalanceID sets the ID field of the mutation.
  10444. func withCreditBalanceID(id uint64) creditbalanceOption {
  10445. return func(m *CreditBalanceMutation) {
  10446. var (
  10447. err error
  10448. once sync.Once
  10449. value *CreditBalance
  10450. )
  10451. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  10452. once.Do(func() {
  10453. if m.done {
  10454. err = errors.New("querying old values post mutation is not allowed")
  10455. } else {
  10456. value, err = m.Client().CreditBalance.Get(ctx, id)
  10457. }
  10458. })
  10459. return value, err
  10460. }
  10461. m.id = &id
  10462. }
  10463. }
  10464. // withCreditBalance sets the old CreditBalance of the mutation.
  10465. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  10466. return func(m *CreditBalanceMutation) {
  10467. m.oldValue = func(context.Context) (*CreditBalance, error) {
  10468. return node, nil
  10469. }
  10470. m.id = &node.ID
  10471. }
  10472. }
  10473. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10474. // executed in a transaction (ent.Tx), a transactional client is returned.
  10475. func (m CreditBalanceMutation) Client() *Client {
  10476. client := &Client{config: m.config}
  10477. client.init()
  10478. return client
  10479. }
  10480. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10481. // it returns an error otherwise.
  10482. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  10483. if _, ok := m.driver.(*txDriver); !ok {
  10484. return nil, errors.New("ent: mutation is not running in a transaction")
  10485. }
  10486. tx := &Tx{config: m.config}
  10487. tx.init()
  10488. return tx, nil
  10489. }
  10490. // SetID sets the value of the id field. Note that this
  10491. // operation is only accepted on creation of CreditBalance entities.
  10492. func (m *CreditBalanceMutation) SetID(id uint64) {
  10493. m.id = &id
  10494. }
  10495. // ID returns the ID value in the mutation. Note that the ID is only available
  10496. // if it was provided to the builder or after it was returned from the database.
  10497. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  10498. if m.id == nil {
  10499. return
  10500. }
  10501. return *m.id, true
  10502. }
  10503. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10504. // That means, if the mutation is applied within a transaction with an isolation level such
  10505. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10506. // or updated by the mutation.
  10507. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  10508. switch {
  10509. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10510. id, exists := m.ID()
  10511. if exists {
  10512. return []uint64{id}, nil
  10513. }
  10514. fallthrough
  10515. case m.op.Is(OpUpdate | OpDelete):
  10516. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  10517. default:
  10518. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10519. }
  10520. }
  10521. // SetCreatedAt sets the "created_at" field.
  10522. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  10523. m.created_at = &t
  10524. }
  10525. // CreatedAt returns the value of the "created_at" field in the mutation.
  10526. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  10527. v := m.created_at
  10528. if v == nil {
  10529. return
  10530. }
  10531. return *v, true
  10532. }
  10533. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  10534. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10536. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10537. if !m.op.Is(OpUpdateOne) {
  10538. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10539. }
  10540. if m.id == nil || m.oldValue == nil {
  10541. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10542. }
  10543. oldValue, err := m.oldValue(ctx)
  10544. if err != nil {
  10545. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10546. }
  10547. return oldValue.CreatedAt, nil
  10548. }
  10549. // ResetCreatedAt resets all changes to the "created_at" field.
  10550. func (m *CreditBalanceMutation) ResetCreatedAt() {
  10551. m.created_at = nil
  10552. }
  10553. // SetUpdatedAt sets the "updated_at" field.
  10554. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  10555. m.updated_at = &t
  10556. }
  10557. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10558. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  10559. v := m.updated_at
  10560. if v == nil {
  10561. return
  10562. }
  10563. return *v, true
  10564. }
  10565. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  10566. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10568. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10569. if !m.op.Is(OpUpdateOne) {
  10570. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10571. }
  10572. if m.id == nil || m.oldValue == nil {
  10573. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10574. }
  10575. oldValue, err := m.oldValue(ctx)
  10576. if err != nil {
  10577. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10578. }
  10579. return oldValue.UpdatedAt, nil
  10580. }
  10581. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10582. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  10583. m.updated_at = nil
  10584. }
  10585. // SetDeletedAt sets the "deleted_at" field.
  10586. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  10587. m.deleted_at = &t
  10588. }
  10589. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10590. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  10591. v := m.deleted_at
  10592. if v == nil {
  10593. return
  10594. }
  10595. return *v, true
  10596. }
  10597. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  10598. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10600. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10601. if !m.op.Is(OpUpdateOne) {
  10602. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10603. }
  10604. if m.id == nil || m.oldValue == nil {
  10605. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10606. }
  10607. oldValue, err := m.oldValue(ctx)
  10608. if err != nil {
  10609. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10610. }
  10611. return oldValue.DeletedAt, nil
  10612. }
  10613. // ClearDeletedAt clears the value of the "deleted_at" field.
  10614. func (m *CreditBalanceMutation) ClearDeletedAt() {
  10615. m.deleted_at = nil
  10616. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  10617. }
  10618. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10619. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  10620. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  10621. return ok
  10622. }
  10623. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10624. func (m *CreditBalanceMutation) ResetDeletedAt() {
  10625. m.deleted_at = nil
  10626. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  10627. }
  10628. // SetUserID sets the "user_id" field.
  10629. func (m *CreditBalanceMutation) SetUserID(s string) {
  10630. m.user_id = &s
  10631. }
  10632. // UserID returns the value of the "user_id" field in the mutation.
  10633. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  10634. v := m.user_id
  10635. if v == nil {
  10636. return
  10637. }
  10638. return *v, true
  10639. }
  10640. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  10641. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10643. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  10644. if !m.op.Is(OpUpdateOne) {
  10645. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10646. }
  10647. if m.id == nil || m.oldValue == nil {
  10648. return v, errors.New("OldUserID requires an ID field in the mutation")
  10649. }
  10650. oldValue, err := m.oldValue(ctx)
  10651. if err != nil {
  10652. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10653. }
  10654. return oldValue.UserID, nil
  10655. }
  10656. // ClearUserID clears the value of the "user_id" field.
  10657. func (m *CreditBalanceMutation) ClearUserID() {
  10658. m.user_id = nil
  10659. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  10660. }
  10661. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  10662. func (m *CreditBalanceMutation) UserIDCleared() bool {
  10663. _, ok := m.clearedFields[creditbalance.FieldUserID]
  10664. return ok
  10665. }
  10666. // ResetUserID resets all changes to the "user_id" field.
  10667. func (m *CreditBalanceMutation) ResetUserID() {
  10668. m.user_id = nil
  10669. delete(m.clearedFields, creditbalance.FieldUserID)
  10670. }
  10671. // SetBalance sets the "balance" field.
  10672. func (m *CreditBalanceMutation) SetBalance(f float32) {
  10673. m.balance = &f
  10674. m.addbalance = nil
  10675. }
  10676. // Balance returns the value of the "balance" field in the mutation.
  10677. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  10678. v := m.balance
  10679. if v == nil {
  10680. return
  10681. }
  10682. return *v, true
  10683. }
  10684. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  10685. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10687. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  10688. if !m.op.Is(OpUpdateOne) {
  10689. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  10690. }
  10691. if m.id == nil || m.oldValue == nil {
  10692. return v, errors.New("OldBalance requires an ID field in the mutation")
  10693. }
  10694. oldValue, err := m.oldValue(ctx)
  10695. if err != nil {
  10696. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  10697. }
  10698. return oldValue.Balance, nil
  10699. }
  10700. // AddBalance adds f to the "balance" field.
  10701. func (m *CreditBalanceMutation) AddBalance(f float32) {
  10702. if m.addbalance != nil {
  10703. *m.addbalance += f
  10704. } else {
  10705. m.addbalance = &f
  10706. }
  10707. }
  10708. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  10709. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  10710. v := m.addbalance
  10711. if v == nil {
  10712. return
  10713. }
  10714. return *v, true
  10715. }
  10716. // ResetBalance resets all changes to the "balance" field.
  10717. func (m *CreditBalanceMutation) ResetBalance() {
  10718. m.balance = nil
  10719. m.addbalance = nil
  10720. }
  10721. // SetStatus sets the "status" field.
  10722. func (m *CreditBalanceMutation) SetStatus(i int) {
  10723. m.status = &i
  10724. m.addstatus = nil
  10725. }
  10726. // Status returns the value of the "status" field in the mutation.
  10727. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  10728. v := m.status
  10729. if v == nil {
  10730. return
  10731. }
  10732. return *v, true
  10733. }
  10734. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  10735. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10737. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  10738. if !m.op.Is(OpUpdateOne) {
  10739. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10740. }
  10741. if m.id == nil || m.oldValue == nil {
  10742. return v, errors.New("OldStatus requires an ID field in the mutation")
  10743. }
  10744. oldValue, err := m.oldValue(ctx)
  10745. if err != nil {
  10746. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10747. }
  10748. return oldValue.Status, nil
  10749. }
  10750. // AddStatus adds i to the "status" field.
  10751. func (m *CreditBalanceMutation) AddStatus(i int) {
  10752. if m.addstatus != nil {
  10753. *m.addstatus += i
  10754. } else {
  10755. m.addstatus = &i
  10756. }
  10757. }
  10758. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10759. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  10760. v := m.addstatus
  10761. if v == nil {
  10762. return
  10763. }
  10764. return *v, true
  10765. }
  10766. // ClearStatus clears the value of the "status" field.
  10767. func (m *CreditBalanceMutation) ClearStatus() {
  10768. m.status = nil
  10769. m.addstatus = nil
  10770. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  10771. }
  10772. // StatusCleared returns if the "status" field was cleared in this mutation.
  10773. func (m *CreditBalanceMutation) StatusCleared() bool {
  10774. _, ok := m.clearedFields[creditbalance.FieldStatus]
  10775. return ok
  10776. }
  10777. // ResetStatus resets all changes to the "status" field.
  10778. func (m *CreditBalanceMutation) ResetStatus() {
  10779. m.status = nil
  10780. m.addstatus = nil
  10781. delete(m.clearedFields, creditbalance.FieldStatus)
  10782. }
  10783. // SetOrganizationID sets the "organization_id" field.
  10784. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  10785. m.organization_id = &u
  10786. m.addorganization_id = nil
  10787. }
  10788. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10789. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  10790. v := m.organization_id
  10791. if v == nil {
  10792. return
  10793. }
  10794. return *v, true
  10795. }
  10796. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  10797. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10799. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10800. if !m.op.Is(OpUpdateOne) {
  10801. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10802. }
  10803. if m.id == nil || m.oldValue == nil {
  10804. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10805. }
  10806. oldValue, err := m.oldValue(ctx)
  10807. if err != nil {
  10808. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10809. }
  10810. return oldValue.OrganizationID, nil
  10811. }
  10812. // AddOrganizationID adds u to the "organization_id" field.
  10813. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  10814. if m.addorganization_id != nil {
  10815. *m.addorganization_id += u
  10816. } else {
  10817. m.addorganization_id = &u
  10818. }
  10819. }
  10820. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10821. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  10822. v := m.addorganization_id
  10823. if v == nil {
  10824. return
  10825. }
  10826. return *v, true
  10827. }
  10828. // ClearOrganizationID clears the value of the "organization_id" field.
  10829. func (m *CreditBalanceMutation) ClearOrganizationID() {
  10830. m.organization_id = nil
  10831. m.addorganization_id = nil
  10832. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  10833. }
  10834. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10835. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  10836. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  10837. return ok
  10838. }
  10839. // ResetOrganizationID resets all changes to the "organization_id" field.
  10840. func (m *CreditBalanceMutation) ResetOrganizationID() {
  10841. m.organization_id = nil
  10842. m.addorganization_id = nil
  10843. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  10844. }
  10845. // Where appends a list predicates to the CreditBalanceMutation builder.
  10846. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  10847. m.predicates = append(m.predicates, ps...)
  10848. }
  10849. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  10850. // users can use type-assertion to append predicates that do not depend on any generated package.
  10851. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  10852. p := make([]predicate.CreditBalance, len(ps))
  10853. for i := range ps {
  10854. p[i] = ps[i]
  10855. }
  10856. m.Where(p...)
  10857. }
  10858. // Op returns the operation name.
  10859. func (m *CreditBalanceMutation) Op() Op {
  10860. return m.op
  10861. }
  10862. // SetOp allows setting the mutation operation.
  10863. func (m *CreditBalanceMutation) SetOp(op Op) {
  10864. m.op = op
  10865. }
  10866. // Type returns the node type of this mutation (CreditBalance).
  10867. func (m *CreditBalanceMutation) Type() string {
  10868. return m.typ
  10869. }
  10870. // Fields returns all fields that were changed during this mutation. Note that in
  10871. // order to get all numeric fields that were incremented/decremented, call
  10872. // AddedFields().
  10873. func (m *CreditBalanceMutation) Fields() []string {
  10874. fields := make([]string, 0, 7)
  10875. if m.created_at != nil {
  10876. fields = append(fields, creditbalance.FieldCreatedAt)
  10877. }
  10878. if m.updated_at != nil {
  10879. fields = append(fields, creditbalance.FieldUpdatedAt)
  10880. }
  10881. if m.deleted_at != nil {
  10882. fields = append(fields, creditbalance.FieldDeletedAt)
  10883. }
  10884. if m.user_id != nil {
  10885. fields = append(fields, creditbalance.FieldUserID)
  10886. }
  10887. if m.balance != nil {
  10888. fields = append(fields, creditbalance.FieldBalance)
  10889. }
  10890. if m.status != nil {
  10891. fields = append(fields, creditbalance.FieldStatus)
  10892. }
  10893. if m.organization_id != nil {
  10894. fields = append(fields, creditbalance.FieldOrganizationID)
  10895. }
  10896. return fields
  10897. }
  10898. // Field returns the value of a field with the given name. The second boolean
  10899. // return value indicates that this field was not set, or was not defined in the
  10900. // schema.
  10901. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  10902. switch name {
  10903. case creditbalance.FieldCreatedAt:
  10904. return m.CreatedAt()
  10905. case creditbalance.FieldUpdatedAt:
  10906. return m.UpdatedAt()
  10907. case creditbalance.FieldDeletedAt:
  10908. return m.DeletedAt()
  10909. case creditbalance.FieldUserID:
  10910. return m.UserID()
  10911. case creditbalance.FieldBalance:
  10912. return m.Balance()
  10913. case creditbalance.FieldStatus:
  10914. return m.Status()
  10915. case creditbalance.FieldOrganizationID:
  10916. return m.OrganizationID()
  10917. }
  10918. return nil, false
  10919. }
  10920. // OldField returns the old value of the field from the database. An error is
  10921. // returned if the mutation operation is not UpdateOne, or the query to the
  10922. // database failed.
  10923. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10924. switch name {
  10925. case creditbalance.FieldCreatedAt:
  10926. return m.OldCreatedAt(ctx)
  10927. case creditbalance.FieldUpdatedAt:
  10928. return m.OldUpdatedAt(ctx)
  10929. case creditbalance.FieldDeletedAt:
  10930. return m.OldDeletedAt(ctx)
  10931. case creditbalance.FieldUserID:
  10932. return m.OldUserID(ctx)
  10933. case creditbalance.FieldBalance:
  10934. return m.OldBalance(ctx)
  10935. case creditbalance.FieldStatus:
  10936. return m.OldStatus(ctx)
  10937. case creditbalance.FieldOrganizationID:
  10938. return m.OldOrganizationID(ctx)
  10939. }
  10940. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  10941. }
  10942. // SetField sets the value of a field with the given name. It returns an error if
  10943. // the field is not defined in the schema, or if the type mismatched the field
  10944. // type.
  10945. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  10946. switch name {
  10947. case creditbalance.FieldCreatedAt:
  10948. v, ok := value.(time.Time)
  10949. if !ok {
  10950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10951. }
  10952. m.SetCreatedAt(v)
  10953. return nil
  10954. case creditbalance.FieldUpdatedAt:
  10955. v, ok := value.(time.Time)
  10956. if !ok {
  10957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10958. }
  10959. m.SetUpdatedAt(v)
  10960. return nil
  10961. case creditbalance.FieldDeletedAt:
  10962. v, ok := value.(time.Time)
  10963. if !ok {
  10964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10965. }
  10966. m.SetDeletedAt(v)
  10967. return nil
  10968. case creditbalance.FieldUserID:
  10969. v, ok := value.(string)
  10970. if !ok {
  10971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10972. }
  10973. m.SetUserID(v)
  10974. return nil
  10975. case creditbalance.FieldBalance:
  10976. v, ok := value.(float32)
  10977. if !ok {
  10978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10979. }
  10980. m.SetBalance(v)
  10981. return nil
  10982. case creditbalance.FieldStatus:
  10983. v, ok := value.(int)
  10984. if !ok {
  10985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10986. }
  10987. m.SetStatus(v)
  10988. return nil
  10989. case creditbalance.FieldOrganizationID:
  10990. v, ok := value.(uint64)
  10991. if !ok {
  10992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10993. }
  10994. m.SetOrganizationID(v)
  10995. return nil
  10996. }
  10997. return fmt.Errorf("unknown CreditBalance field %s", name)
  10998. }
  10999. // AddedFields returns all numeric fields that were incremented/decremented during
  11000. // this mutation.
  11001. func (m *CreditBalanceMutation) AddedFields() []string {
  11002. var fields []string
  11003. if m.addbalance != nil {
  11004. fields = append(fields, creditbalance.FieldBalance)
  11005. }
  11006. if m.addstatus != nil {
  11007. fields = append(fields, creditbalance.FieldStatus)
  11008. }
  11009. if m.addorganization_id != nil {
  11010. fields = append(fields, creditbalance.FieldOrganizationID)
  11011. }
  11012. return fields
  11013. }
  11014. // AddedField returns the numeric value that was incremented/decremented on a field
  11015. // with the given name. The second boolean return value indicates that this field
  11016. // was not set, or was not defined in the schema.
  11017. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  11018. switch name {
  11019. case creditbalance.FieldBalance:
  11020. return m.AddedBalance()
  11021. case creditbalance.FieldStatus:
  11022. return m.AddedStatus()
  11023. case creditbalance.FieldOrganizationID:
  11024. return m.AddedOrganizationID()
  11025. }
  11026. return nil, false
  11027. }
  11028. // AddField adds the value to the field with the given name. It returns an error if
  11029. // the field is not defined in the schema, or if the type mismatched the field
  11030. // type.
  11031. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  11032. switch name {
  11033. case creditbalance.FieldBalance:
  11034. v, ok := value.(float32)
  11035. if !ok {
  11036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11037. }
  11038. m.AddBalance(v)
  11039. return nil
  11040. case creditbalance.FieldStatus:
  11041. v, ok := value.(int)
  11042. if !ok {
  11043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11044. }
  11045. m.AddStatus(v)
  11046. return nil
  11047. case creditbalance.FieldOrganizationID:
  11048. v, ok := value.(int64)
  11049. if !ok {
  11050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11051. }
  11052. m.AddOrganizationID(v)
  11053. return nil
  11054. }
  11055. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  11056. }
  11057. // ClearedFields returns all nullable fields that were cleared during this
  11058. // mutation.
  11059. func (m *CreditBalanceMutation) ClearedFields() []string {
  11060. var fields []string
  11061. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  11062. fields = append(fields, creditbalance.FieldDeletedAt)
  11063. }
  11064. if m.FieldCleared(creditbalance.FieldUserID) {
  11065. fields = append(fields, creditbalance.FieldUserID)
  11066. }
  11067. if m.FieldCleared(creditbalance.FieldStatus) {
  11068. fields = append(fields, creditbalance.FieldStatus)
  11069. }
  11070. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  11071. fields = append(fields, creditbalance.FieldOrganizationID)
  11072. }
  11073. return fields
  11074. }
  11075. // FieldCleared returns a boolean indicating if a field with the given name was
  11076. // cleared in this mutation.
  11077. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  11078. _, ok := m.clearedFields[name]
  11079. return ok
  11080. }
  11081. // ClearField clears the value of the field with the given name. It returns an
  11082. // error if the field is not defined in the schema.
  11083. func (m *CreditBalanceMutation) ClearField(name string) error {
  11084. switch name {
  11085. case creditbalance.FieldDeletedAt:
  11086. m.ClearDeletedAt()
  11087. return nil
  11088. case creditbalance.FieldUserID:
  11089. m.ClearUserID()
  11090. return nil
  11091. case creditbalance.FieldStatus:
  11092. m.ClearStatus()
  11093. return nil
  11094. case creditbalance.FieldOrganizationID:
  11095. m.ClearOrganizationID()
  11096. return nil
  11097. }
  11098. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  11099. }
  11100. // ResetField resets all changes in the mutation for the field with the given name.
  11101. // It returns an error if the field is not defined in the schema.
  11102. func (m *CreditBalanceMutation) ResetField(name string) error {
  11103. switch name {
  11104. case creditbalance.FieldCreatedAt:
  11105. m.ResetCreatedAt()
  11106. return nil
  11107. case creditbalance.FieldUpdatedAt:
  11108. m.ResetUpdatedAt()
  11109. return nil
  11110. case creditbalance.FieldDeletedAt:
  11111. m.ResetDeletedAt()
  11112. return nil
  11113. case creditbalance.FieldUserID:
  11114. m.ResetUserID()
  11115. return nil
  11116. case creditbalance.FieldBalance:
  11117. m.ResetBalance()
  11118. return nil
  11119. case creditbalance.FieldStatus:
  11120. m.ResetStatus()
  11121. return nil
  11122. case creditbalance.FieldOrganizationID:
  11123. m.ResetOrganizationID()
  11124. return nil
  11125. }
  11126. return fmt.Errorf("unknown CreditBalance field %s", name)
  11127. }
  11128. // AddedEdges returns all edge names that were set/added in this mutation.
  11129. func (m *CreditBalanceMutation) AddedEdges() []string {
  11130. edges := make([]string, 0, 0)
  11131. return edges
  11132. }
  11133. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11134. // name in this mutation.
  11135. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  11136. return nil
  11137. }
  11138. // RemovedEdges returns all edge names that were removed in this mutation.
  11139. func (m *CreditBalanceMutation) RemovedEdges() []string {
  11140. edges := make([]string, 0, 0)
  11141. return edges
  11142. }
  11143. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11144. // the given name in this mutation.
  11145. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  11146. return nil
  11147. }
  11148. // ClearedEdges returns all edge names that were cleared in this mutation.
  11149. func (m *CreditBalanceMutation) ClearedEdges() []string {
  11150. edges := make([]string, 0, 0)
  11151. return edges
  11152. }
  11153. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11154. // was cleared in this mutation.
  11155. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  11156. return false
  11157. }
  11158. // ClearEdge clears the value of the edge with the given name. It returns an error
  11159. // if that edge is not defined in the schema.
  11160. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  11161. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  11162. }
  11163. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11164. // It returns an error if the edge is not defined in the schema.
  11165. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  11166. return fmt.Errorf("unknown CreditBalance edge %s", name)
  11167. }
  11168. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  11169. type CreditUsageMutation struct {
  11170. config
  11171. op Op
  11172. typ string
  11173. id *uint64
  11174. created_at *time.Time
  11175. updated_at *time.Time
  11176. deleted_at *time.Time
  11177. user_id *string
  11178. number *float32
  11179. addnumber *float32
  11180. status *int
  11181. addstatus *int
  11182. ntype *int
  11183. addntype *int
  11184. table *string
  11185. organization_id *uint64
  11186. addorganization_id *int64
  11187. nid *uint64
  11188. addnid *int64
  11189. reason *string
  11190. operator *string
  11191. clearedFields map[string]struct{}
  11192. done bool
  11193. oldValue func(context.Context) (*CreditUsage, error)
  11194. predicates []predicate.CreditUsage
  11195. }
  11196. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  11197. // creditusageOption allows management of the mutation configuration using functional options.
  11198. type creditusageOption func(*CreditUsageMutation)
  11199. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  11200. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  11201. m := &CreditUsageMutation{
  11202. config: c,
  11203. op: op,
  11204. typ: TypeCreditUsage,
  11205. clearedFields: make(map[string]struct{}),
  11206. }
  11207. for _, opt := range opts {
  11208. opt(m)
  11209. }
  11210. return m
  11211. }
  11212. // withCreditUsageID sets the ID field of the mutation.
  11213. func withCreditUsageID(id uint64) creditusageOption {
  11214. return func(m *CreditUsageMutation) {
  11215. var (
  11216. err error
  11217. once sync.Once
  11218. value *CreditUsage
  11219. )
  11220. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  11221. once.Do(func() {
  11222. if m.done {
  11223. err = errors.New("querying old values post mutation is not allowed")
  11224. } else {
  11225. value, err = m.Client().CreditUsage.Get(ctx, id)
  11226. }
  11227. })
  11228. return value, err
  11229. }
  11230. m.id = &id
  11231. }
  11232. }
  11233. // withCreditUsage sets the old CreditUsage of the mutation.
  11234. func withCreditUsage(node *CreditUsage) creditusageOption {
  11235. return func(m *CreditUsageMutation) {
  11236. m.oldValue = func(context.Context) (*CreditUsage, error) {
  11237. return node, nil
  11238. }
  11239. m.id = &node.ID
  11240. }
  11241. }
  11242. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11243. // executed in a transaction (ent.Tx), a transactional client is returned.
  11244. func (m CreditUsageMutation) Client() *Client {
  11245. client := &Client{config: m.config}
  11246. client.init()
  11247. return client
  11248. }
  11249. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11250. // it returns an error otherwise.
  11251. func (m CreditUsageMutation) Tx() (*Tx, error) {
  11252. if _, ok := m.driver.(*txDriver); !ok {
  11253. return nil, errors.New("ent: mutation is not running in a transaction")
  11254. }
  11255. tx := &Tx{config: m.config}
  11256. tx.init()
  11257. return tx, nil
  11258. }
  11259. // SetID sets the value of the id field. Note that this
  11260. // operation is only accepted on creation of CreditUsage entities.
  11261. func (m *CreditUsageMutation) SetID(id uint64) {
  11262. m.id = &id
  11263. }
  11264. // ID returns the ID value in the mutation. Note that the ID is only available
  11265. // if it was provided to the builder or after it was returned from the database.
  11266. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  11267. if m.id == nil {
  11268. return
  11269. }
  11270. return *m.id, true
  11271. }
  11272. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11273. // That means, if the mutation is applied within a transaction with an isolation level such
  11274. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11275. // or updated by the mutation.
  11276. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  11277. switch {
  11278. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11279. id, exists := m.ID()
  11280. if exists {
  11281. return []uint64{id}, nil
  11282. }
  11283. fallthrough
  11284. case m.op.Is(OpUpdate | OpDelete):
  11285. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  11286. default:
  11287. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11288. }
  11289. }
  11290. // SetCreatedAt sets the "created_at" field.
  11291. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  11292. m.created_at = &t
  11293. }
  11294. // CreatedAt returns the value of the "created_at" field in the mutation.
  11295. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  11296. v := m.created_at
  11297. if v == nil {
  11298. return
  11299. }
  11300. return *v, true
  11301. }
  11302. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  11303. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11305. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11306. if !m.op.Is(OpUpdateOne) {
  11307. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11308. }
  11309. if m.id == nil || m.oldValue == nil {
  11310. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11311. }
  11312. oldValue, err := m.oldValue(ctx)
  11313. if err != nil {
  11314. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11315. }
  11316. return oldValue.CreatedAt, nil
  11317. }
  11318. // ResetCreatedAt resets all changes to the "created_at" field.
  11319. func (m *CreditUsageMutation) ResetCreatedAt() {
  11320. m.created_at = nil
  11321. }
  11322. // SetUpdatedAt sets the "updated_at" field.
  11323. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  11324. m.updated_at = &t
  11325. }
  11326. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11327. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  11328. v := m.updated_at
  11329. if v == nil {
  11330. return
  11331. }
  11332. return *v, true
  11333. }
  11334. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  11335. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11337. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11338. if !m.op.Is(OpUpdateOne) {
  11339. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11340. }
  11341. if m.id == nil || m.oldValue == nil {
  11342. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11343. }
  11344. oldValue, err := m.oldValue(ctx)
  11345. if err != nil {
  11346. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11347. }
  11348. return oldValue.UpdatedAt, nil
  11349. }
  11350. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11351. func (m *CreditUsageMutation) ResetUpdatedAt() {
  11352. m.updated_at = nil
  11353. }
  11354. // SetDeletedAt sets the "deleted_at" field.
  11355. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  11356. m.deleted_at = &t
  11357. }
  11358. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11359. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  11360. v := m.deleted_at
  11361. if v == nil {
  11362. return
  11363. }
  11364. return *v, true
  11365. }
  11366. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  11367. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11369. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11370. if !m.op.Is(OpUpdateOne) {
  11371. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11372. }
  11373. if m.id == nil || m.oldValue == nil {
  11374. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11375. }
  11376. oldValue, err := m.oldValue(ctx)
  11377. if err != nil {
  11378. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11379. }
  11380. return oldValue.DeletedAt, nil
  11381. }
  11382. // ClearDeletedAt clears the value of the "deleted_at" field.
  11383. func (m *CreditUsageMutation) ClearDeletedAt() {
  11384. m.deleted_at = nil
  11385. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  11386. }
  11387. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11388. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  11389. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  11390. return ok
  11391. }
  11392. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11393. func (m *CreditUsageMutation) ResetDeletedAt() {
  11394. m.deleted_at = nil
  11395. delete(m.clearedFields, creditusage.FieldDeletedAt)
  11396. }
  11397. // SetUserID sets the "user_id" field.
  11398. func (m *CreditUsageMutation) SetUserID(s string) {
  11399. m.user_id = &s
  11400. }
  11401. // UserID returns the value of the "user_id" field in the mutation.
  11402. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  11403. v := m.user_id
  11404. if v == nil {
  11405. return
  11406. }
  11407. return *v, true
  11408. }
  11409. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  11410. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11412. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  11413. if !m.op.Is(OpUpdateOne) {
  11414. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11415. }
  11416. if m.id == nil || m.oldValue == nil {
  11417. return v, errors.New("OldUserID requires an ID field in the mutation")
  11418. }
  11419. oldValue, err := m.oldValue(ctx)
  11420. if err != nil {
  11421. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11422. }
  11423. return oldValue.UserID, nil
  11424. }
  11425. // ClearUserID clears the value of the "user_id" field.
  11426. func (m *CreditUsageMutation) ClearUserID() {
  11427. m.user_id = nil
  11428. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  11429. }
  11430. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11431. func (m *CreditUsageMutation) UserIDCleared() bool {
  11432. _, ok := m.clearedFields[creditusage.FieldUserID]
  11433. return ok
  11434. }
  11435. // ResetUserID resets all changes to the "user_id" field.
  11436. func (m *CreditUsageMutation) ResetUserID() {
  11437. m.user_id = nil
  11438. delete(m.clearedFields, creditusage.FieldUserID)
  11439. }
  11440. // SetNumber sets the "number" field.
  11441. func (m *CreditUsageMutation) SetNumber(f float32) {
  11442. m.number = &f
  11443. m.addnumber = nil
  11444. }
  11445. // Number returns the value of the "number" field in the mutation.
  11446. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  11447. v := m.number
  11448. if v == nil {
  11449. return
  11450. }
  11451. return *v, true
  11452. }
  11453. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  11454. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11456. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  11457. if !m.op.Is(OpUpdateOne) {
  11458. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  11459. }
  11460. if m.id == nil || m.oldValue == nil {
  11461. return v, errors.New("OldNumber requires an ID field in the mutation")
  11462. }
  11463. oldValue, err := m.oldValue(ctx)
  11464. if err != nil {
  11465. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  11466. }
  11467. return oldValue.Number, nil
  11468. }
  11469. // AddNumber adds f to the "number" field.
  11470. func (m *CreditUsageMutation) AddNumber(f float32) {
  11471. if m.addnumber != nil {
  11472. *m.addnumber += f
  11473. } else {
  11474. m.addnumber = &f
  11475. }
  11476. }
  11477. // AddedNumber returns the value that was added to the "number" field in this mutation.
  11478. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  11479. v := m.addnumber
  11480. if v == nil {
  11481. return
  11482. }
  11483. return *v, true
  11484. }
  11485. // ResetNumber resets all changes to the "number" field.
  11486. func (m *CreditUsageMutation) ResetNumber() {
  11487. m.number = nil
  11488. m.addnumber = nil
  11489. }
  11490. // SetStatus sets the "status" field.
  11491. func (m *CreditUsageMutation) SetStatus(i int) {
  11492. m.status = &i
  11493. m.addstatus = nil
  11494. }
  11495. // Status returns the value of the "status" field in the mutation.
  11496. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  11497. v := m.status
  11498. if v == nil {
  11499. return
  11500. }
  11501. return *v, true
  11502. }
  11503. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  11504. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11506. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  11507. if !m.op.Is(OpUpdateOne) {
  11508. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11509. }
  11510. if m.id == nil || m.oldValue == nil {
  11511. return v, errors.New("OldStatus requires an ID field in the mutation")
  11512. }
  11513. oldValue, err := m.oldValue(ctx)
  11514. if err != nil {
  11515. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11516. }
  11517. return oldValue.Status, nil
  11518. }
  11519. // AddStatus adds i to the "status" field.
  11520. func (m *CreditUsageMutation) AddStatus(i int) {
  11521. if m.addstatus != nil {
  11522. *m.addstatus += i
  11523. } else {
  11524. m.addstatus = &i
  11525. }
  11526. }
  11527. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11528. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  11529. v := m.addstatus
  11530. if v == nil {
  11531. return
  11532. }
  11533. return *v, true
  11534. }
  11535. // ClearStatus clears the value of the "status" field.
  11536. func (m *CreditUsageMutation) ClearStatus() {
  11537. m.status = nil
  11538. m.addstatus = nil
  11539. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  11540. }
  11541. // StatusCleared returns if the "status" field was cleared in this mutation.
  11542. func (m *CreditUsageMutation) StatusCleared() bool {
  11543. _, ok := m.clearedFields[creditusage.FieldStatus]
  11544. return ok
  11545. }
  11546. // ResetStatus resets all changes to the "status" field.
  11547. func (m *CreditUsageMutation) ResetStatus() {
  11548. m.status = nil
  11549. m.addstatus = nil
  11550. delete(m.clearedFields, creditusage.FieldStatus)
  11551. }
  11552. // SetNtype sets the "ntype" field.
  11553. func (m *CreditUsageMutation) SetNtype(i int) {
  11554. m.ntype = &i
  11555. m.addntype = nil
  11556. }
  11557. // Ntype returns the value of the "ntype" field in the mutation.
  11558. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  11559. v := m.ntype
  11560. if v == nil {
  11561. return
  11562. }
  11563. return *v, true
  11564. }
  11565. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  11566. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11568. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  11569. if !m.op.Is(OpUpdateOne) {
  11570. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  11571. }
  11572. if m.id == nil || m.oldValue == nil {
  11573. return v, errors.New("OldNtype requires an ID field in the mutation")
  11574. }
  11575. oldValue, err := m.oldValue(ctx)
  11576. if err != nil {
  11577. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  11578. }
  11579. return oldValue.Ntype, nil
  11580. }
  11581. // AddNtype adds i to the "ntype" field.
  11582. func (m *CreditUsageMutation) AddNtype(i int) {
  11583. if m.addntype != nil {
  11584. *m.addntype += i
  11585. } else {
  11586. m.addntype = &i
  11587. }
  11588. }
  11589. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  11590. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  11591. v := m.addntype
  11592. if v == nil {
  11593. return
  11594. }
  11595. return *v, true
  11596. }
  11597. // ResetNtype resets all changes to the "ntype" field.
  11598. func (m *CreditUsageMutation) ResetNtype() {
  11599. m.ntype = nil
  11600. m.addntype = nil
  11601. }
  11602. // SetTable sets the "table" field.
  11603. func (m *CreditUsageMutation) SetTable(s string) {
  11604. m.table = &s
  11605. }
  11606. // Table returns the value of the "table" field in the mutation.
  11607. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  11608. v := m.table
  11609. if v == nil {
  11610. return
  11611. }
  11612. return *v, true
  11613. }
  11614. // OldTable returns the old "table" field's value of the CreditUsage entity.
  11615. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11617. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  11618. if !m.op.Is(OpUpdateOne) {
  11619. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  11620. }
  11621. if m.id == nil || m.oldValue == nil {
  11622. return v, errors.New("OldTable requires an ID field in the mutation")
  11623. }
  11624. oldValue, err := m.oldValue(ctx)
  11625. if err != nil {
  11626. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  11627. }
  11628. return oldValue.Table, nil
  11629. }
  11630. // ResetTable resets all changes to the "table" field.
  11631. func (m *CreditUsageMutation) ResetTable() {
  11632. m.table = nil
  11633. }
  11634. // SetOrganizationID sets the "organization_id" field.
  11635. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  11636. m.organization_id = &u
  11637. m.addorganization_id = nil
  11638. }
  11639. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11640. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  11641. v := m.organization_id
  11642. if v == nil {
  11643. return
  11644. }
  11645. return *v, true
  11646. }
  11647. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  11648. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11650. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11651. if !m.op.Is(OpUpdateOne) {
  11652. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11653. }
  11654. if m.id == nil || m.oldValue == nil {
  11655. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11656. }
  11657. oldValue, err := m.oldValue(ctx)
  11658. if err != nil {
  11659. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11660. }
  11661. return oldValue.OrganizationID, nil
  11662. }
  11663. // AddOrganizationID adds u to the "organization_id" field.
  11664. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  11665. if m.addorganization_id != nil {
  11666. *m.addorganization_id += u
  11667. } else {
  11668. m.addorganization_id = &u
  11669. }
  11670. }
  11671. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11672. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  11673. v := m.addorganization_id
  11674. if v == nil {
  11675. return
  11676. }
  11677. return *v, true
  11678. }
  11679. // ClearOrganizationID clears the value of the "organization_id" field.
  11680. func (m *CreditUsageMutation) ClearOrganizationID() {
  11681. m.organization_id = nil
  11682. m.addorganization_id = nil
  11683. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  11684. }
  11685. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11686. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  11687. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  11688. return ok
  11689. }
  11690. // ResetOrganizationID resets all changes to the "organization_id" field.
  11691. func (m *CreditUsageMutation) ResetOrganizationID() {
  11692. m.organization_id = nil
  11693. m.addorganization_id = nil
  11694. delete(m.clearedFields, creditusage.FieldOrganizationID)
  11695. }
  11696. // SetNid sets the "nid" field.
  11697. func (m *CreditUsageMutation) SetNid(u uint64) {
  11698. m.nid = &u
  11699. m.addnid = nil
  11700. }
  11701. // Nid returns the value of the "nid" field in the mutation.
  11702. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  11703. v := m.nid
  11704. if v == nil {
  11705. return
  11706. }
  11707. return *v, true
  11708. }
  11709. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  11710. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11712. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  11713. if !m.op.Is(OpUpdateOne) {
  11714. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  11715. }
  11716. if m.id == nil || m.oldValue == nil {
  11717. return v, errors.New("OldNid requires an ID field in the mutation")
  11718. }
  11719. oldValue, err := m.oldValue(ctx)
  11720. if err != nil {
  11721. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  11722. }
  11723. return oldValue.Nid, nil
  11724. }
  11725. // AddNid adds u to the "nid" field.
  11726. func (m *CreditUsageMutation) AddNid(u int64) {
  11727. if m.addnid != nil {
  11728. *m.addnid += u
  11729. } else {
  11730. m.addnid = &u
  11731. }
  11732. }
  11733. // AddedNid returns the value that was added to the "nid" field in this mutation.
  11734. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  11735. v := m.addnid
  11736. if v == nil {
  11737. return
  11738. }
  11739. return *v, true
  11740. }
  11741. // ResetNid resets all changes to the "nid" field.
  11742. func (m *CreditUsageMutation) ResetNid() {
  11743. m.nid = nil
  11744. m.addnid = nil
  11745. }
  11746. // SetReason sets the "reason" field.
  11747. func (m *CreditUsageMutation) SetReason(s string) {
  11748. m.reason = &s
  11749. }
  11750. // Reason returns the value of the "reason" field in the mutation.
  11751. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  11752. v := m.reason
  11753. if v == nil {
  11754. return
  11755. }
  11756. return *v, true
  11757. }
  11758. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  11759. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11761. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  11762. if !m.op.Is(OpUpdateOne) {
  11763. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  11764. }
  11765. if m.id == nil || m.oldValue == nil {
  11766. return v, errors.New("OldReason requires an ID field in the mutation")
  11767. }
  11768. oldValue, err := m.oldValue(ctx)
  11769. if err != nil {
  11770. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  11771. }
  11772. return oldValue.Reason, nil
  11773. }
  11774. // ResetReason resets all changes to the "reason" field.
  11775. func (m *CreditUsageMutation) ResetReason() {
  11776. m.reason = nil
  11777. }
  11778. // SetOperator sets the "operator" field.
  11779. func (m *CreditUsageMutation) SetOperator(s string) {
  11780. m.operator = &s
  11781. }
  11782. // Operator returns the value of the "operator" field in the mutation.
  11783. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  11784. v := m.operator
  11785. if v == nil {
  11786. return
  11787. }
  11788. return *v, true
  11789. }
  11790. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  11791. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11793. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  11794. if !m.op.Is(OpUpdateOne) {
  11795. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  11796. }
  11797. if m.id == nil || m.oldValue == nil {
  11798. return v, errors.New("OldOperator requires an ID field in the mutation")
  11799. }
  11800. oldValue, err := m.oldValue(ctx)
  11801. if err != nil {
  11802. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  11803. }
  11804. return oldValue.Operator, nil
  11805. }
  11806. // ResetOperator resets all changes to the "operator" field.
  11807. func (m *CreditUsageMutation) ResetOperator() {
  11808. m.operator = nil
  11809. }
  11810. // Where appends a list predicates to the CreditUsageMutation builder.
  11811. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  11812. m.predicates = append(m.predicates, ps...)
  11813. }
  11814. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  11815. // users can use type-assertion to append predicates that do not depend on any generated package.
  11816. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  11817. p := make([]predicate.CreditUsage, len(ps))
  11818. for i := range ps {
  11819. p[i] = ps[i]
  11820. }
  11821. m.Where(p...)
  11822. }
  11823. // Op returns the operation name.
  11824. func (m *CreditUsageMutation) Op() Op {
  11825. return m.op
  11826. }
  11827. // SetOp allows setting the mutation operation.
  11828. func (m *CreditUsageMutation) SetOp(op Op) {
  11829. m.op = op
  11830. }
  11831. // Type returns the node type of this mutation (CreditUsage).
  11832. func (m *CreditUsageMutation) Type() string {
  11833. return m.typ
  11834. }
  11835. // Fields returns all fields that were changed during this mutation. Note that in
  11836. // order to get all numeric fields that were incremented/decremented, call
  11837. // AddedFields().
  11838. func (m *CreditUsageMutation) Fields() []string {
  11839. fields := make([]string, 0, 12)
  11840. if m.created_at != nil {
  11841. fields = append(fields, creditusage.FieldCreatedAt)
  11842. }
  11843. if m.updated_at != nil {
  11844. fields = append(fields, creditusage.FieldUpdatedAt)
  11845. }
  11846. if m.deleted_at != nil {
  11847. fields = append(fields, creditusage.FieldDeletedAt)
  11848. }
  11849. if m.user_id != nil {
  11850. fields = append(fields, creditusage.FieldUserID)
  11851. }
  11852. if m.number != nil {
  11853. fields = append(fields, creditusage.FieldNumber)
  11854. }
  11855. if m.status != nil {
  11856. fields = append(fields, creditusage.FieldStatus)
  11857. }
  11858. if m.ntype != nil {
  11859. fields = append(fields, creditusage.FieldNtype)
  11860. }
  11861. if m.table != nil {
  11862. fields = append(fields, creditusage.FieldTable)
  11863. }
  11864. if m.organization_id != nil {
  11865. fields = append(fields, creditusage.FieldOrganizationID)
  11866. }
  11867. if m.nid != nil {
  11868. fields = append(fields, creditusage.FieldNid)
  11869. }
  11870. if m.reason != nil {
  11871. fields = append(fields, creditusage.FieldReason)
  11872. }
  11873. if m.operator != nil {
  11874. fields = append(fields, creditusage.FieldOperator)
  11875. }
  11876. return fields
  11877. }
  11878. // Field returns the value of a field with the given name. The second boolean
  11879. // return value indicates that this field was not set, or was not defined in the
  11880. // schema.
  11881. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  11882. switch name {
  11883. case creditusage.FieldCreatedAt:
  11884. return m.CreatedAt()
  11885. case creditusage.FieldUpdatedAt:
  11886. return m.UpdatedAt()
  11887. case creditusage.FieldDeletedAt:
  11888. return m.DeletedAt()
  11889. case creditusage.FieldUserID:
  11890. return m.UserID()
  11891. case creditusage.FieldNumber:
  11892. return m.Number()
  11893. case creditusage.FieldStatus:
  11894. return m.Status()
  11895. case creditusage.FieldNtype:
  11896. return m.Ntype()
  11897. case creditusage.FieldTable:
  11898. return m.Table()
  11899. case creditusage.FieldOrganizationID:
  11900. return m.OrganizationID()
  11901. case creditusage.FieldNid:
  11902. return m.Nid()
  11903. case creditusage.FieldReason:
  11904. return m.Reason()
  11905. case creditusage.FieldOperator:
  11906. return m.Operator()
  11907. }
  11908. return nil, false
  11909. }
  11910. // OldField returns the old value of the field from the database. An error is
  11911. // returned if the mutation operation is not UpdateOne, or the query to the
  11912. // database failed.
  11913. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11914. switch name {
  11915. case creditusage.FieldCreatedAt:
  11916. return m.OldCreatedAt(ctx)
  11917. case creditusage.FieldUpdatedAt:
  11918. return m.OldUpdatedAt(ctx)
  11919. case creditusage.FieldDeletedAt:
  11920. return m.OldDeletedAt(ctx)
  11921. case creditusage.FieldUserID:
  11922. return m.OldUserID(ctx)
  11923. case creditusage.FieldNumber:
  11924. return m.OldNumber(ctx)
  11925. case creditusage.FieldStatus:
  11926. return m.OldStatus(ctx)
  11927. case creditusage.FieldNtype:
  11928. return m.OldNtype(ctx)
  11929. case creditusage.FieldTable:
  11930. return m.OldTable(ctx)
  11931. case creditusage.FieldOrganizationID:
  11932. return m.OldOrganizationID(ctx)
  11933. case creditusage.FieldNid:
  11934. return m.OldNid(ctx)
  11935. case creditusage.FieldReason:
  11936. return m.OldReason(ctx)
  11937. case creditusage.FieldOperator:
  11938. return m.OldOperator(ctx)
  11939. }
  11940. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  11941. }
  11942. // SetField sets the value of a field with the given name. It returns an error if
  11943. // the field is not defined in the schema, or if the type mismatched the field
  11944. // type.
  11945. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  11946. switch name {
  11947. case creditusage.FieldCreatedAt:
  11948. v, ok := value.(time.Time)
  11949. if !ok {
  11950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11951. }
  11952. m.SetCreatedAt(v)
  11953. return nil
  11954. case creditusage.FieldUpdatedAt:
  11955. v, ok := value.(time.Time)
  11956. if !ok {
  11957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11958. }
  11959. m.SetUpdatedAt(v)
  11960. return nil
  11961. case creditusage.FieldDeletedAt:
  11962. v, ok := value.(time.Time)
  11963. if !ok {
  11964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11965. }
  11966. m.SetDeletedAt(v)
  11967. return nil
  11968. case creditusage.FieldUserID:
  11969. v, ok := value.(string)
  11970. if !ok {
  11971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11972. }
  11973. m.SetUserID(v)
  11974. return nil
  11975. case creditusage.FieldNumber:
  11976. v, ok := value.(float32)
  11977. if !ok {
  11978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11979. }
  11980. m.SetNumber(v)
  11981. return nil
  11982. case creditusage.FieldStatus:
  11983. v, ok := value.(int)
  11984. if !ok {
  11985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11986. }
  11987. m.SetStatus(v)
  11988. return nil
  11989. case creditusage.FieldNtype:
  11990. v, ok := value.(int)
  11991. if !ok {
  11992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11993. }
  11994. m.SetNtype(v)
  11995. return nil
  11996. case creditusage.FieldTable:
  11997. v, ok := value.(string)
  11998. if !ok {
  11999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12000. }
  12001. m.SetTable(v)
  12002. return nil
  12003. case creditusage.FieldOrganizationID:
  12004. v, ok := value.(uint64)
  12005. if !ok {
  12006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12007. }
  12008. m.SetOrganizationID(v)
  12009. return nil
  12010. case creditusage.FieldNid:
  12011. v, ok := value.(uint64)
  12012. if !ok {
  12013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12014. }
  12015. m.SetNid(v)
  12016. return nil
  12017. case creditusage.FieldReason:
  12018. v, ok := value.(string)
  12019. if !ok {
  12020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12021. }
  12022. m.SetReason(v)
  12023. return nil
  12024. case creditusage.FieldOperator:
  12025. v, ok := value.(string)
  12026. if !ok {
  12027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12028. }
  12029. m.SetOperator(v)
  12030. return nil
  12031. }
  12032. return fmt.Errorf("unknown CreditUsage field %s", name)
  12033. }
  12034. // AddedFields returns all numeric fields that were incremented/decremented during
  12035. // this mutation.
  12036. func (m *CreditUsageMutation) AddedFields() []string {
  12037. var fields []string
  12038. if m.addnumber != nil {
  12039. fields = append(fields, creditusage.FieldNumber)
  12040. }
  12041. if m.addstatus != nil {
  12042. fields = append(fields, creditusage.FieldStatus)
  12043. }
  12044. if m.addntype != nil {
  12045. fields = append(fields, creditusage.FieldNtype)
  12046. }
  12047. if m.addorganization_id != nil {
  12048. fields = append(fields, creditusage.FieldOrganizationID)
  12049. }
  12050. if m.addnid != nil {
  12051. fields = append(fields, creditusage.FieldNid)
  12052. }
  12053. return fields
  12054. }
  12055. // AddedField returns the numeric value that was incremented/decremented on a field
  12056. // with the given name. The second boolean return value indicates that this field
  12057. // was not set, or was not defined in the schema.
  12058. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  12059. switch name {
  12060. case creditusage.FieldNumber:
  12061. return m.AddedNumber()
  12062. case creditusage.FieldStatus:
  12063. return m.AddedStatus()
  12064. case creditusage.FieldNtype:
  12065. return m.AddedNtype()
  12066. case creditusage.FieldOrganizationID:
  12067. return m.AddedOrganizationID()
  12068. case creditusage.FieldNid:
  12069. return m.AddedNid()
  12070. }
  12071. return nil, false
  12072. }
  12073. // AddField adds the value to the field with the given name. It returns an error if
  12074. // the field is not defined in the schema, or if the type mismatched the field
  12075. // type.
  12076. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  12077. switch name {
  12078. case creditusage.FieldNumber:
  12079. v, ok := value.(float32)
  12080. if !ok {
  12081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12082. }
  12083. m.AddNumber(v)
  12084. return nil
  12085. case creditusage.FieldStatus:
  12086. v, ok := value.(int)
  12087. if !ok {
  12088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12089. }
  12090. m.AddStatus(v)
  12091. return nil
  12092. case creditusage.FieldNtype:
  12093. v, ok := value.(int)
  12094. if !ok {
  12095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12096. }
  12097. m.AddNtype(v)
  12098. return nil
  12099. case creditusage.FieldOrganizationID:
  12100. v, ok := value.(int64)
  12101. if !ok {
  12102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12103. }
  12104. m.AddOrganizationID(v)
  12105. return nil
  12106. case creditusage.FieldNid:
  12107. v, ok := value.(int64)
  12108. if !ok {
  12109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12110. }
  12111. m.AddNid(v)
  12112. return nil
  12113. }
  12114. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  12115. }
  12116. // ClearedFields returns all nullable fields that were cleared during this
  12117. // mutation.
  12118. func (m *CreditUsageMutation) ClearedFields() []string {
  12119. var fields []string
  12120. if m.FieldCleared(creditusage.FieldDeletedAt) {
  12121. fields = append(fields, creditusage.FieldDeletedAt)
  12122. }
  12123. if m.FieldCleared(creditusage.FieldUserID) {
  12124. fields = append(fields, creditusage.FieldUserID)
  12125. }
  12126. if m.FieldCleared(creditusage.FieldStatus) {
  12127. fields = append(fields, creditusage.FieldStatus)
  12128. }
  12129. if m.FieldCleared(creditusage.FieldOrganizationID) {
  12130. fields = append(fields, creditusage.FieldOrganizationID)
  12131. }
  12132. return fields
  12133. }
  12134. // FieldCleared returns a boolean indicating if a field with the given name was
  12135. // cleared in this mutation.
  12136. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  12137. _, ok := m.clearedFields[name]
  12138. return ok
  12139. }
  12140. // ClearField clears the value of the field with the given name. It returns an
  12141. // error if the field is not defined in the schema.
  12142. func (m *CreditUsageMutation) ClearField(name string) error {
  12143. switch name {
  12144. case creditusage.FieldDeletedAt:
  12145. m.ClearDeletedAt()
  12146. return nil
  12147. case creditusage.FieldUserID:
  12148. m.ClearUserID()
  12149. return nil
  12150. case creditusage.FieldStatus:
  12151. m.ClearStatus()
  12152. return nil
  12153. case creditusage.FieldOrganizationID:
  12154. m.ClearOrganizationID()
  12155. return nil
  12156. }
  12157. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  12158. }
  12159. // ResetField resets all changes in the mutation for the field with the given name.
  12160. // It returns an error if the field is not defined in the schema.
  12161. func (m *CreditUsageMutation) ResetField(name string) error {
  12162. switch name {
  12163. case creditusage.FieldCreatedAt:
  12164. m.ResetCreatedAt()
  12165. return nil
  12166. case creditusage.FieldUpdatedAt:
  12167. m.ResetUpdatedAt()
  12168. return nil
  12169. case creditusage.FieldDeletedAt:
  12170. m.ResetDeletedAt()
  12171. return nil
  12172. case creditusage.FieldUserID:
  12173. m.ResetUserID()
  12174. return nil
  12175. case creditusage.FieldNumber:
  12176. m.ResetNumber()
  12177. return nil
  12178. case creditusage.FieldStatus:
  12179. m.ResetStatus()
  12180. return nil
  12181. case creditusage.FieldNtype:
  12182. m.ResetNtype()
  12183. return nil
  12184. case creditusage.FieldTable:
  12185. m.ResetTable()
  12186. return nil
  12187. case creditusage.FieldOrganizationID:
  12188. m.ResetOrganizationID()
  12189. return nil
  12190. case creditusage.FieldNid:
  12191. m.ResetNid()
  12192. return nil
  12193. case creditusage.FieldReason:
  12194. m.ResetReason()
  12195. return nil
  12196. case creditusage.FieldOperator:
  12197. m.ResetOperator()
  12198. return nil
  12199. }
  12200. return fmt.Errorf("unknown CreditUsage field %s", name)
  12201. }
  12202. // AddedEdges returns all edge names that were set/added in this mutation.
  12203. func (m *CreditUsageMutation) AddedEdges() []string {
  12204. edges := make([]string, 0, 0)
  12205. return edges
  12206. }
  12207. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12208. // name in this mutation.
  12209. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  12210. return nil
  12211. }
  12212. // RemovedEdges returns all edge names that were removed in this mutation.
  12213. func (m *CreditUsageMutation) RemovedEdges() []string {
  12214. edges := make([]string, 0, 0)
  12215. return edges
  12216. }
  12217. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12218. // the given name in this mutation.
  12219. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  12220. return nil
  12221. }
  12222. // ClearedEdges returns all edge names that were cleared in this mutation.
  12223. func (m *CreditUsageMutation) ClearedEdges() []string {
  12224. edges := make([]string, 0, 0)
  12225. return edges
  12226. }
  12227. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12228. // was cleared in this mutation.
  12229. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  12230. return false
  12231. }
  12232. // ClearEdge clears the value of the edge with the given name. It returns an error
  12233. // if that edge is not defined in the schema.
  12234. func (m *CreditUsageMutation) ClearEdge(name string) error {
  12235. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  12236. }
  12237. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12238. // It returns an error if the edge is not defined in the schema.
  12239. func (m *CreditUsageMutation) ResetEdge(name string) error {
  12240. return fmt.Errorf("unknown CreditUsage edge %s", name)
  12241. }
  12242. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  12243. type EmployeeMutation struct {
  12244. config
  12245. op Op
  12246. typ string
  12247. id *uint64
  12248. created_at *time.Time
  12249. updated_at *time.Time
  12250. deleted_at *time.Time
  12251. title *string
  12252. avatar *string
  12253. tags *string
  12254. hire_count *int
  12255. addhire_count *int
  12256. service_count *int
  12257. addservice_count *int
  12258. achievement_count *int
  12259. addachievement_count *int
  12260. intro *string
  12261. estimate *string
  12262. skill *string
  12263. ability_type *string
  12264. scene *string
  12265. switch_in *string
  12266. video_url *string
  12267. organization_id *uint64
  12268. addorganization_id *int64
  12269. category_id *uint64
  12270. addcategory_id *int64
  12271. api_base *string
  12272. api_key *string
  12273. ai_info *string
  12274. is_vip *int
  12275. addis_vip *int
  12276. chat_url *string
  12277. clearedFields map[string]struct{}
  12278. em_work_experiences map[uint64]struct{}
  12279. removedem_work_experiences map[uint64]struct{}
  12280. clearedem_work_experiences bool
  12281. em_tutorial map[uint64]struct{}
  12282. removedem_tutorial map[uint64]struct{}
  12283. clearedem_tutorial bool
  12284. done bool
  12285. oldValue func(context.Context) (*Employee, error)
  12286. predicates []predicate.Employee
  12287. }
  12288. var _ ent.Mutation = (*EmployeeMutation)(nil)
  12289. // employeeOption allows management of the mutation configuration using functional options.
  12290. type employeeOption func(*EmployeeMutation)
  12291. // newEmployeeMutation creates new mutation for the Employee entity.
  12292. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  12293. m := &EmployeeMutation{
  12294. config: c,
  12295. op: op,
  12296. typ: TypeEmployee,
  12297. clearedFields: make(map[string]struct{}),
  12298. }
  12299. for _, opt := range opts {
  12300. opt(m)
  12301. }
  12302. return m
  12303. }
  12304. // withEmployeeID sets the ID field of the mutation.
  12305. func withEmployeeID(id uint64) employeeOption {
  12306. return func(m *EmployeeMutation) {
  12307. var (
  12308. err error
  12309. once sync.Once
  12310. value *Employee
  12311. )
  12312. m.oldValue = func(ctx context.Context) (*Employee, error) {
  12313. once.Do(func() {
  12314. if m.done {
  12315. err = errors.New("querying old values post mutation is not allowed")
  12316. } else {
  12317. value, err = m.Client().Employee.Get(ctx, id)
  12318. }
  12319. })
  12320. return value, err
  12321. }
  12322. m.id = &id
  12323. }
  12324. }
  12325. // withEmployee sets the old Employee of the mutation.
  12326. func withEmployee(node *Employee) employeeOption {
  12327. return func(m *EmployeeMutation) {
  12328. m.oldValue = func(context.Context) (*Employee, error) {
  12329. return node, nil
  12330. }
  12331. m.id = &node.ID
  12332. }
  12333. }
  12334. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12335. // executed in a transaction (ent.Tx), a transactional client is returned.
  12336. func (m EmployeeMutation) Client() *Client {
  12337. client := &Client{config: m.config}
  12338. client.init()
  12339. return client
  12340. }
  12341. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12342. // it returns an error otherwise.
  12343. func (m EmployeeMutation) Tx() (*Tx, error) {
  12344. if _, ok := m.driver.(*txDriver); !ok {
  12345. return nil, errors.New("ent: mutation is not running in a transaction")
  12346. }
  12347. tx := &Tx{config: m.config}
  12348. tx.init()
  12349. return tx, nil
  12350. }
  12351. // SetID sets the value of the id field. Note that this
  12352. // operation is only accepted on creation of Employee entities.
  12353. func (m *EmployeeMutation) SetID(id uint64) {
  12354. m.id = &id
  12355. }
  12356. // ID returns the ID value in the mutation. Note that the ID is only available
  12357. // if it was provided to the builder or after it was returned from the database.
  12358. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  12359. if m.id == nil {
  12360. return
  12361. }
  12362. return *m.id, true
  12363. }
  12364. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12365. // That means, if the mutation is applied within a transaction with an isolation level such
  12366. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12367. // or updated by the mutation.
  12368. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12369. switch {
  12370. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12371. id, exists := m.ID()
  12372. if exists {
  12373. return []uint64{id}, nil
  12374. }
  12375. fallthrough
  12376. case m.op.Is(OpUpdate | OpDelete):
  12377. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  12378. default:
  12379. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12380. }
  12381. }
  12382. // SetCreatedAt sets the "created_at" field.
  12383. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  12384. m.created_at = &t
  12385. }
  12386. // CreatedAt returns the value of the "created_at" field in the mutation.
  12387. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  12388. v := m.created_at
  12389. if v == nil {
  12390. return
  12391. }
  12392. return *v, true
  12393. }
  12394. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  12395. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12397. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12398. if !m.op.Is(OpUpdateOne) {
  12399. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12400. }
  12401. if m.id == nil || m.oldValue == nil {
  12402. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12403. }
  12404. oldValue, err := m.oldValue(ctx)
  12405. if err != nil {
  12406. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12407. }
  12408. return oldValue.CreatedAt, nil
  12409. }
  12410. // ResetCreatedAt resets all changes to the "created_at" field.
  12411. func (m *EmployeeMutation) ResetCreatedAt() {
  12412. m.created_at = nil
  12413. }
  12414. // SetUpdatedAt sets the "updated_at" field.
  12415. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  12416. m.updated_at = &t
  12417. }
  12418. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12419. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  12420. v := m.updated_at
  12421. if v == nil {
  12422. return
  12423. }
  12424. return *v, true
  12425. }
  12426. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  12427. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12429. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12430. if !m.op.Is(OpUpdateOne) {
  12431. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12432. }
  12433. if m.id == nil || m.oldValue == nil {
  12434. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12435. }
  12436. oldValue, err := m.oldValue(ctx)
  12437. if err != nil {
  12438. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12439. }
  12440. return oldValue.UpdatedAt, nil
  12441. }
  12442. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12443. func (m *EmployeeMutation) ResetUpdatedAt() {
  12444. m.updated_at = nil
  12445. }
  12446. // SetDeletedAt sets the "deleted_at" field.
  12447. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  12448. m.deleted_at = &t
  12449. }
  12450. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12451. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  12452. v := m.deleted_at
  12453. if v == nil {
  12454. return
  12455. }
  12456. return *v, true
  12457. }
  12458. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  12459. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12461. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12462. if !m.op.Is(OpUpdateOne) {
  12463. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12464. }
  12465. if m.id == nil || m.oldValue == nil {
  12466. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12467. }
  12468. oldValue, err := m.oldValue(ctx)
  12469. if err != nil {
  12470. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12471. }
  12472. return oldValue.DeletedAt, nil
  12473. }
  12474. // ClearDeletedAt clears the value of the "deleted_at" field.
  12475. func (m *EmployeeMutation) ClearDeletedAt() {
  12476. m.deleted_at = nil
  12477. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  12478. }
  12479. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12480. func (m *EmployeeMutation) DeletedAtCleared() bool {
  12481. _, ok := m.clearedFields[employee.FieldDeletedAt]
  12482. return ok
  12483. }
  12484. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12485. func (m *EmployeeMutation) ResetDeletedAt() {
  12486. m.deleted_at = nil
  12487. delete(m.clearedFields, employee.FieldDeletedAt)
  12488. }
  12489. // SetTitle sets the "title" field.
  12490. func (m *EmployeeMutation) SetTitle(s string) {
  12491. m.title = &s
  12492. }
  12493. // Title returns the value of the "title" field in the mutation.
  12494. func (m *EmployeeMutation) Title() (r string, exists bool) {
  12495. v := m.title
  12496. if v == nil {
  12497. return
  12498. }
  12499. return *v, true
  12500. }
  12501. // OldTitle returns the old "title" field's value of the Employee entity.
  12502. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12504. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  12505. if !m.op.Is(OpUpdateOne) {
  12506. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  12507. }
  12508. if m.id == nil || m.oldValue == nil {
  12509. return v, errors.New("OldTitle requires an ID field in the mutation")
  12510. }
  12511. oldValue, err := m.oldValue(ctx)
  12512. if err != nil {
  12513. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  12514. }
  12515. return oldValue.Title, nil
  12516. }
  12517. // ResetTitle resets all changes to the "title" field.
  12518. func (m *EmployeeMutation) ResetTitle() {
  12519. m.title = nil
  12520. }
  12521. // SetAvatar sets the "avatar" field.
  12522. func (m *EmployeeMutation) SetAvatar(s string) {
  12523. m.avatar = &s
  12524. }
  12525. // Avatar returns the value of the "avatar" field in the mutation.
  12526. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  12527. v := m.avatar
  12528. if v == nil {
  12529. return
  12530. }
  12531. return *v, true
  12532. }
  12533. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  12534. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12536. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  12537. if !m.op.Is(OpUpdateOne) {
  12538. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  12539. }
  12540. if m.id == nil || m.oldValue == nil {
  12541. return v, errors.New("OldAvatar requires an ID field in the mutation")
  12542. }
  12543. oldValue, err := m.oldValue(ctx)
  12544. if err != nil {
  12545. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  12546. }
  12547. return oldValue.Avatar, nil
  12548. }
  12549. // ResetAvatar resets all changes to the "avatar" field.
  12550. func (m *EmployeeMutation) ResetAvatar() {
  12551. m.avatar = nil
  12552. }
  12553. // SetTags sets the "tags" field.
  12554. func (m *EmployeeMutation) SetTags(s string) {
  12555. m.tags = &s
  12556. }
  12557. // Tags returns the value of the "tags" field in the mutation.
  12558. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  12559. v := m.tags
  12560. if v == nil {
  12561. return
  12562. }
  12563. return *v, true
  12564. }
  12565. // OldTags returns the old "tags" field's value of the Employee entity.
  12566. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12568. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  12569. if !m.op.Is(OpUpdateOne) {
  12570. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  12571. }
  12572. if m.id == nil || m.oldValue == nil {
  12573. return v, errors.New("OldTags requires an ID field in the mutation")
  12574. }
  12575. oldValue, err := m.oldValue(ctx)
  12576. if err != nil {
  12577. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  12578. }
  12579. return oldValue.Tags, nil
  12580. }
  12581. // ResetTags resets all changes to the "tags" field.
  12582. func (m *EmployeeMutation) ResetTags() {
  12583. m.tags = nil
  12584. }
  12585. // SetHireCount sets the "hire_count" field.
  12586. func (m *EmployeeMutation) SetHireCount(i int) {
  12587. m.hire_count = &i
  12588. m.addhire_count = nil
  12589. }
  12590. // HireCount returns the value of the "hire_count" field in the mutation.
  12591. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  12592. v := m.hire_count
  12593. if v == nil {
  12594. return
  12595. }
  12596. return *v, true
  12597. }
  12598. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  12599. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12601. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  12602. if !m.op.Is(OpUpdateOne) {
  12603. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  12604. }
  12605. if m.id == nil || m.oldValue == nil {
  12606. return v, errors.New("OldHireCount requires an ID field in the mutation")
  12607. }
  12608. oldValue, err := m.oldValue(ctx)
  12609. if err != nil {
  12610. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  12611. }
  12612. return oldValue.HireCount, nil
  12613. }
  12614. // AddHireCount adds i to the "hire_count" field.
  12615. func (m *EmployeeMutation) AddHireCount(i int) {
  12616. if m.addhire_count != nil {
  12617. *m.addhire_count += i
  12618. } else {
  12619. m.addhire_count = &i
  12620. }
  12621. }
  12622. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  12623. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  12624. v := m.addhire_count
  12625. if v == nil {
  12626. return
  12627. }
  12628. return *v, true
  12629. }
  12630. // ResetHireCount resets all changes to the "hire_count" field.
  12631. func (m *EmployeeMutation) ResetHireCount() {
  12632. m.hire_count = nil
  12633. m.addhire_count = nil
  12634. }
  12635. // SetServiceCount sets the "service_count" field.
  12636. func (m *EmployeeMutation) SetServiceCount(i int) {
  12637. m.service_count = &i
  12638. m.addservice_count = nil
  12639. }
  12640. // ServiceCount returns the value of the "service_count" field in the mutation.
  12641. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  12642. v := m.service_count
  12643. if v == nil {
  12644. return
  12645. }
  12646. return *v, true
  12647. }
  12648. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  12649. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12651. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  12652. if !m.op.Is(OpUpdateOne) {
  12653. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  12654. }
  12655. if m.id == nil || m.oldValue == nil {
  12656. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  12657. }
  12658. oldValue, err := m.oldValue(ctx)
  12659. if err != nil {
  12660. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  12661. }
  12662. return oldValue.ServiceCount, nil
  12663. }
  12664. // AddServiceCount adds i to the "service_count" field.
  12665. func (m *EmployeeMutation) AddServiceCount(i int) {
  12666. if m.addservice_count != nil {
  12667. *m.addservice_count += i
  12668. } else {
  12669. m.addservice_count = &i
  12670. }
  12671. }
  12672. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  12673. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  12674. v := m.addservice_count
  12675. if v == nil {
  12676. return
  12677. }
  12678. return *v, true
  12679. }
  12680. // ResetServiceCount resets all changes to the "service_count" field.
  12681. func (m *EmployeeMutation) ResetServiceCount() {
  12682. m.service_count = nil
  12683. m.addservice_count = nil
  12684. }
  12685. // SetAchievementCount sets the "achievement_count" field.
  12686. func (m *EmployeeMutation) SetAchievementCount(i int) {
  12687. m.achievement_count = &i
  12688. m.addachievement_count = nil
  12689. }
  12690. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  12691. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  12692. v := m.achievement_count
  12693. if v == nil {
  12694. return
  12695. }
  12696. return *v, true
  12697. }
  12698. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  12699. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12701. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  12702. if !m.op.Is(OpUpdateOne) {
  12703. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  12704. }
  12705. if m.id == nil || m.oldValue == nil {
  12706. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  12707. }
  12708. oldValue, err := m.oldValue(ctx)
  12709. if err != nil {
  12710. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  12711. }
  12712. return oldValue.AchievementCount, nil
  12713. }
  12714. // AddAchievementCount adds i to the "achievement_count" field.
  12715. func (m *EmployeeMutation) AddAchievementCount(i int) {
  12716. if m.addachievement_count != nil {
  12717. *m.addachievement_count += i
  12718. } else {
  12719. m.addachievement_count = &i
  12720. }
  12721. }
  12722. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  12723. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  12724. v := m.addachievement_count
  12725. if v == nil {
  12726. return
  12727. }
  12728. return *v, true
  12729. }
  12730. // ResetAchievementCount resets all changes to the "achievement_count" field.
  12731. func (m *EmployeeMutation) ResetAchievementCount() {
  12732. m.achievement_count = nil
  12733. m.addachievement_count = nil
  12734. }
  12735. // SetIntro sets the "intro" field.
  12736. func (m *EmployeeMutation) SetIntro(s string) {
  12737. m.intro = &s
  12738. }
  12739. // Intro returns the value of the "intro" field in the mutation.
  12740. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  12741. v := m.intro
  12742. if v == nil {
  12743. return
  12744. }
  12745. return *v, true
  12746. }
  12747. // OldIntro returns the old "intro" field's value of the Employee entity.
  12748. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12750. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  12751. if !m.op.Is(OpUpdateOne) {
  12752. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  12753. }
  12754. if m.id == nil || m.oldValue == nil {
  12755. return v, errors.New("OldIntro requires an ID field in the mutation")
  12756. }
  12757. oldValue, err := m.oldValue(ctx)
  12758. if err != nil {
  12759. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  12760. }
  12761. return oldValue.Intro, nil
  12762. }
  12763. // ResetIntro resets all changes to the "intro" field.
  12764. func (m *EmployeeMutation) ResetIntro() {
  12765. m.intro = nil
  12766. }
  12767. // SetEstimate sets the "estimate" field.
  12768. func (m *EmployeeMutation) SetEstimate(s string) {
  12769. m.estimate = &s
  12770. }
  12771. // Estimate returns the value of the "estimate" field in the mutation.
  12772. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  12773. v := m.estimate
  12774. if v == nil {
  12775. return
  12776. }
  12777. return *v, true
  12778. }
  12779. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  12780. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12782. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  12783. if !m.op.Is(OpUpdateOne) {
  12784. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  12785. }
  12786. if m.id == nil || m.oldValue == nil {
  12787. return v, errors.New("OldEstimate requires an ID field in the mutation")
  12788. }
  12789. oldValue, err := m.oldValue(ctx)
  12790. if err != nil {
  12791. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  12792. }
  12793. return oldValue.Estimate, nil
  12794. }
  12795. // ResetEstimate resets all changes to the "estimate" field.
  12796. func (m *EmployeeMutation) ResetEstimate() {
  12797. m.estimate = nil
  12798. }
  12799. // SetSkill sets the "skill" field.
  12800. func (m *EmployeeMutation) SetSkill(s string) {
  12801. m.skill = &s
  12802. }
  12803. // Skill returns the value of the "skill" field in the mutation.
  12804. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  12805. v := m.skill
  12806. if v == nil {
  12807. return
  12808. }
  12809. return *v, true
  12810. }
  12811. // OldSkill returns the old "skill" field's value of the Employee entity.
  12812. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12814. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  12815. if !m.op.Is(OpUpdateOne) {
  12816. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  12817. }
  12818. if m.id == nil || m.oldValue == nil {
  12819. return v, errors.New("OldSkill requires an ID field in the mutation")
  12820. }
  12821. oldValue, err := m.oldValue(ctx)
  12822. if err != nil {
  12823. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  12824. }
  12825. return oldValue.Skill, nil
  12826. }
  12827. // ResetSkill resets all changes to the "skill" field.
  12828. func (m *EmployeeMutation) ResetSkill() {
  12829. m.skill = nil
  12830. }
  12831. // SetAbilityType sets the "ability_type" field.
  12832. func (m *EmployeeMutation) SetAbilityType(s string) {
  12833. m.ability_type = &s
  12834. }
  12835. // AbilityType returns the value of the "ability_type" field in the mutation.
  12836. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  12837. v := m.ability_type
  12838. if v == nil {
  12839. return
  12840. }
  12841. return *v, true
  12842. }
  12843. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  12844. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12846. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  12847. if !m.op.Is(OpUpdateOne) {
  12848. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  12849. }
  12850. if m.id == nil || m.oldValue == nil {
  12851. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  12852. }
  12853. oldValue, err := m.oldValue(ctx)
  12854. if err != nil {
  12855. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  12856. }
  12857. return oldValue.AbilityType, nil
  12858. }
  12859. // ResetAbilityType resets all changes to the "ability_type" field.
  12860. func (m *EmployeeMutation) ResetAbilityType() {
  12861. m.ability_type = nil
  12862. }
  12863. // SetScene sets the "scene" field.
  12864. func (m *EmployeeMutation) SetScene(s string) {
  12865. m.scene = &s
  12866. }
  12867. // Scene returns the value of the "scene" field in the mutation.
  12868. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  12869. v := m.scene
  12870. if v == nil {
  12871. return
  12872. }
  12873. return *v, true
  12874. }
  12875. // OldScene returns the old "scene" field's value of the Employee entity.
  12876. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12878. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  12879. if !m.op.Is(OpUpdateOne) {
  12880. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  12881. }
  12882. if m.id == nil || m.oldValue == nil {
  12883. return v, errors.New("OldScene requires an ID field in the mutation")
  12884. }
  12885. oldValue, err := m.oldValue(ctx)
  12886. if err != nil {
  12887. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  12888. }
  12889. return oldValue.Scene, nil
  12890. }
  12891. // ResetScene resets all changes to the "scene" field.
  12892. func (m *EmployeeMutation) ResetScene() {
  12893. m.scene = nil
  12894. }
  12895. // SetSwitchIn sets the "switch_in" field.
  12896. func (m *EmployeeMutation) SetSwitchIn(s string) {
  12897. m.switch_in = &s
  12898. }
  12899. // SwitchIn returns the value of the "switch_in" field in the mutation.
  12900. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  12901. v := m.switch_in
  12902. if v == nil {
  12903. return
  12904. }
  12905. return *v, true
  12906. }
  12907. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  12908. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12910. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  12911. if !m.op.Is(OpUpdateOne) {
  12912. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  12913. }
  12914. if m.id == nil || m.oldValue == nil {
  12915. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  12916. }
  12917. oldValue, err := m.oldValue(ctx)
  12918. if err != nil {
  12919. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  12920. }
  12921. return oldValue.SwitchIn, nil
  12922. }
  12923. // ResetSwitchIn resets all changes to the "switch_in" field.
  12924. func (m *EmployeeMutation) ResetSwitchIn() {
  12925. m.switch_in = nil
  12926. }
  12927. // SetVideoURL sets the "video_url" field.
  12928. func (m *EmployeeMutation) SetVideoURL(s string) {
  12929. m.video_url = &s
  12930. }
  12931. // VideoURL returns the value of the "video_url" field in the mutation.
  12932. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  12933. v := m.video_url
  12934. if v == nil {
  12935. return
  12936. }
  12937. return *v, true
  12938. }
  12939. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  12940. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12942. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  12943. if !m.op.Is(OpUpdateOne) {
  12944. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  12945. }
  12946. if m.id == nil || m.oldValue == nil {
  12947. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  12948. }
  12949. oldValue, err := m.oldValue(ctx)
  12950. if err != nil {
  12951. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  12952. }
  12953. return oldValue.VideoURL, nil
  12954. }
  12955. // ResetVideoURL resets all changes to the "video_url" field.
  12956. func (m *EmployeeMutation) ResetVideoURL() {
  12957. m.video_url = nil
  12958. }
  12959. // SetOrganizationID sets the "organization_id" field.
  12960. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  12961. m.organization_id = &u
  12962. m.addorganization_id = nil
  12963. }
  12964. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12965. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  12966. v := m.organization_id
  12967. if v == nil {
  12968. return
  12969. }
  12970. return *v, true
  12971. }
  12972. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  12973. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12975. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12976. if !m.op.Is(OpUpdateOne) {
  12977. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12978. }
  12979. if m.id == nil || m.oldValue == nil {
  12980. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12981. }
  12982. oldValue, err := m.oldValue(ctx)
  12983. if err != nil {
  12984. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12985. }
  12986. return oldValue.OrganizationID, nil
  12987. }
  12988. // AddOrganizationID adds u to the "organization_id" field.
  12989. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  12990. if m.addorganization_id != nil {
  12991. *m.addorganization_id += u
  12992. } else {
  12993. m.addorganization_id = &u
  12994. }
  12995. }
  12996. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12997. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  12998. v := m.addorganization_id
  12999. if v == nil {
  13000. return
  13001. }
  13002. return *v, true
  13003. }
  13004. // ResetOrganizationID resets all changes to the "organization_id" field.
  13005. func (m *EmployeeMutation) ResetOrganizationID() {
  13006. m.organization_id = nil
  13007. m.addorganization_id = nil
  13008. }
  13009. // SetCategoryID sets the "category_id" field.
  13010. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  13011. m.category_id = &u
  13012. m.addcategory_id = nil
  13013. }
  13014. // CategoryID returns the value of the "category_id" field in the mutation.
  13015. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  13016. v := m.category_id
  13017. if v == nil {
  13018. return
  13019. }
  13020. return *v, true
  13021. }
  13022. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  13023. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13025. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  13026. if !m.op.Is(OpUpdateOne) {
  13027. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  13028. }
  13029. if m.id == nil || m.oldValue == nil {
  13030. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  13031. }
  13032. oldValue, err := m.oldValue(ctx)
  13033. if err != nil {
  13034. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  13035. }
  13036. return oldValue.CategoryID, nil
  13037. }
  13038. // AddCategoryID adds u to the "category_id" field.
  13039. func (m *EmployeeMutation) AddCategoryID(u int64) {
  13040. if m.addcategory_id != nil {
  13041. *m.addcategory_id += u
  13042. } else {
  13043. m.addcategory_id = &u
  13044. }
  13045. }
  13046. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  13047. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  13048. v := m.addcategory_id
  13049. if v == nil {
  13050. return
  13051. }
  13052. return *v, true
  13053. }
  13054. // ResetCategoryID resets all changes to the "category_id" field.
  13055. func (m *EmployeeMutation) ResetCategoryID() {
  13056. m.category_id = nil
  13057. m.addcategory_id = nil
  13058. }
  13059. // SetAPIBase sets the "api_base" field.
  13060. func (m *EmployeeMutation) SetAPIBase(s string) {
  13061. m.api_base = &s
  13062. }
  13063. // APIBase returns the value of the "api_base" field in the mutation.
  13064. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  13065. v := m.api_base
  13066. if v == nil {
  13067. return
  13068. }
  13069. return *v, true
  13070. }
  13071. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  13072. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13074. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  13075. if !m.op.Is(OpUpdateOne) {
  13076. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  13077. }
  13078. if m.id == nil || m.oldValue == nil {
  13079. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  13080. }
  13081. oldValue, err := m.oldValue(ctx)
  13082. if err != nil {
  13083. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  13084. }
  13085. return oldValue.APIBase, nil
  13086. }
  13087. // ResetAPIBase resets all changes to the "api_base" field.
  13088. func (m *EmployeeMutation) ResetAPIBase() {
  13089. m.api_base = nil
  13090. }
  13091. // SetAPIKey sets the "api_key" field.
  13092. func (m *EmployeeMutation) SetAPIKey(s string) {
  13093. m.api_key = &s
  13094. }
  13095. // APIKey returns the value of the "api_key" field in the mutation.
  13096. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  13097. v := m.api_key
  13098. if v == nil {
  13099. return
  13100. }
  13101. return *v, true
  13102. }
  13103. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  13104. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13106. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  13107. if !m.op.Is(OpUpdateOne) {
  13108. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  13109. }
  13110. if m.id == nil || m.oldValue == nil {
  13111. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  13112. }
  13113. oldValue, err := m.oldValue(ctx)
  13114. if err != nil {
  13115. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  13116. }
  13117. return oldValue.APIKey, nil
  13118. }
  13119. // ResetAPIKey resets all changes to the "api_key" field.
  13120. func (m *EmployeeMutation) ResetAPIKey() {
  13121. m.api_key = nil
  13122. }
  13123. // SetAiInfo sets the "ai_info" field.
  13124. func (m *EmployeeMutation) SetAiInfo(s string) {
  13125. m.ai_info = &s
  13126. }
  13127. // AiInfo returns the value of the "ai_info" field in the mutation.
  13128. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  13129. v := m.ai_info
  13130. if v == nil {
  13131. return
  13132. }
  13133. return *v, true
  13134. }
  13135. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  13136. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13138. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  13139. if !m.op.Is(OpUpdateOne) {
  13140. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  13141. }
  13142. if m.id == nil || m.oldValue == nil {
  13143. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  13144. }
  13145. oldValue, err := m.oldValue(ctx)
  13146. if err != nil {
  13147. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  13148. }
  13149. return oldValue.AiInfo, nil
  13150. }
  13151. // ClearAiInfo clears the value of the "ai_info" field.
  13152. func (m *EmployeeMutation) ClearAiInfo() {
  13153. m.ai_info = nil
  13154. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  13155. }
  13156. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  13157. func (m *EmployeeMutation) AiInfoCleared() bool {
  13158. _, ok := m.clearedFields[employee.FieldAiInfo]
  13159. return ok
  13160. }
  13161. // ResetAiInfo resets all changes to the "ai_info" field.
  13162. func (m *EmployeeMutation) ResetAiInfo() {
  13163. m.ai_info = nil
  13164. delete(m.clearedFields, employee.FieldAiInfo)
  13165. }
  13166. // SetIsVip sets the "is_vip" field.
  13167. func (m *EmployeeMutation) SetIsVip(i int) {
  13168. m.is_vip = &i
  13169. m.addis_vip = nil
  13170. }
  13171. // IsVip returns the value of the "is_vip" field in the mutation.
  13172. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  13173. v := m.is_vip
  13174. if v == nil {
  13175. return
  13176. }
  13177. return *v, true
  13178. }
  13179. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  13180. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13182. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  13183. if !m.op.Is(OpUpdateOne) {
  13184. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  13185. }
  13186. if m.id == nil || m.oldValue == nil {
  13187. return v, errors.New("OldIsVip requires an ID field in the mutation")
  13188. }
  13189. oldValue, err := m.oldValue(ctx)
  13190. if err != nil {
  13191. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  13192. }
  13193. return oldValue.IsVip, nil
  13194. }
  13195. // AddIsVip adds i to the "is_vip" field.
  13196. func (m *EmployeeMutation) AddIsVip(i int) {
  13197. if m.addis_vip != nil {
  13198. *m.addis_vip += i
  13199. } else {
  13200. m.addis_vip = &i
  13201. }
  13202. }
  13203. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  13204. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  13205. v := m.addis_vip
  13206. if v == nil {
  13207. return
  13208. }
  13209. return *v, true
  13210. }
  13211. // ResetIsVip resets all changes to the "is_vip" field.
  13212. func (m *EmployeeMutation) ResetIsVip() {
  13213. m.is_vip = nil
  13214. m.addis_vip = nil
  13215. }
  13216. // SetChatURL sets the "chat_url" field.
  13217. func (m *EmployeeMutation) SetChatURL(s string) {
  13218. m.chat_url = &s
  13219. }
  13220. // ChatURL returns the value of the "chat_url" field in the mutation.
  13221. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  13222. v := m.chat_url
  13223. if v == nil {
  13224. return
  13225. }
  13226. return *v, true
  13227. }
  13228. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  13229. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13231. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  13232. if !m.op.Is(OpUpdateOne) {
  13233. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  13234. }
  13235. if m.id == nil || m.oldValue == nil {
  13236. return v, errors.New("OldChatURL requires an ID field in the mutation")
  13237. }
  13238. oldValue, err := m.oldValue(ctx)
  13239. if err != nil {
  13240. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  13241. }
  13242. return oldValue.ChatURL, nil
  13243. }
  13244. // ResetChatURL resets all changes to the "chat_url" field.
  13245. func (m *EmployeeMutation) ResetChatURL() {
  13246. m.chat_url = nil
  13247. }
  13248. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  13249. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  13250. if m.em_work_experiences == nil {
  13251. m.em_work_experiences = make(map[uint64]struct{})
  13252. }
  13253. for i := range ids {
  13254. m.em_work_experiences[ids[i]] = struct{}{}
  13255. }
  13256. }
  13257. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  13258. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  13259. m.clearedem_work_experiences = true
  13260. }
  13261. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  13262. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  13263. return m.clearedem_work_experiences
  13264. }
  13265. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  13266. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  13267. if m.removedem_work_experiences == nil {
  13268. m.removedem_work_experiences = make(map[uint64]struct{})
  13269. }
  13270. for i := range ids {
  13271. delete(m.em_work_experiences, ids[i])
  13272. m.removedem_work_experiences[ids[i]] = struct{}{}
  13273. }
  13274. }
  13275. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  13276. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  13277. for id := range m.removedem_work_experiences {
  13278. ids = append(ids, id)
  13279. }
  13280. return
  13281. }
  13282. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  13283. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  13284. for id := range m.em_work_experiences {
  13285. ids = append(ids, id)
  13286. }
  13287. return
  13288. }
  13289. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  13290. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  13291. m.em_work_experiences = nil
  13292. m.clearedem_work_experiences = false
  13293. m.removedem_work_experiences = nil
  13294. }
  13295. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  13296. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  13297. if m.em_tutorial == nil {
  13298. m.em_tutorial = make(map[uint64]struct{})
  13299. }
  13300. for i := range ids {
  13301. m.em_tutorial[ids[i]] = struct{}{}
  13302. }
  13303. }
  13304. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  13305. func (m *EmployeeMutation) ClearEmTutorial() {
  13306. m.clearedem_tutorial = true
  13307. }
  13308. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  13309. func (m *EmployeeMutation) EmTutorialCleared() bool {
  13310. return m.clearedem_tutorial
  13311. }
  13312. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  13313. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  13314. if m.removedem_tutorial == nil {
  13315. m.removedem_tutorial = make(map[uint64]struct{})
  13316. }
  13317. for i := range ids {
  13318. delete(m.em_tutorial, ids[i])
  13319. m.removedem_tutorial[ids[i]] = struct{}{}
  13320. }
  13321. }
  13322. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  13323. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  13324. for id := range m.removedem_tutorial {
  13325. ids = append(ids, id)
  13326. }
  13327. return
  13328. }
  13329. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  13330. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  13331. for id := range m.em_tutorial {
  13332. ids = append(ids, id)
  13333. }
  13334. return
  13335. }
  13336. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  13337. func (m *EmployeeMutation) ResetEmTutorial() {
  13338. m.em_tutorial = nil
  13339. m.clearedem_tutorial = false
  13340. m.removedem_tutorial = nil
  13341. }
  13342. // Where appends a list predicates to the EmployeeMutation builder.
  13343. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  13344. m.predicates = append(m.predicates, ps...)
  13345. }
  13346. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  13347. // users can use type-assertion to append predicates that do not depend on any generated package.
  13348. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  13349. p := make([]predicate.Employee, len(ps))
  13350. for i := range ps {
  13351. p[i] = ps[i]
  13352. }
  13353. m.Where(p...)
  13354. }
  13355. // Op returns the operation name.
  13356. func (m *EmployeeMutation) Op() Op {
  13357. return m.op
  13358. }
  13359. // SetOp allows setting the mutation operation.
  13360. func (m *EmployeeMutation) SetOp(op Op) {
  13361. m.op = op
  13362. }
  13363. // Type returns the node type of this mutation (Employee).
  13364. func (m *EmployeeMutation) Type() string {
  13365. return m.typ
  13366. }
  13367. // Fields returns all fields that were changed during this mutation. Note that in
  13368. // order to get all numeric fields that were incremented/decremented, call
  13369. // AddedFields().
  13370. func (m *EmployeeMutation) Fields() []string {
  13371. fields := make([]string, 0, 23)
  13372. if m.created_at != nil {
  13373. fields = append(fields, employee.FieldCreatedAt)
  13374. }
  13375. if m.updated_at != nil {
  13376. fields = append(fields, employee.FieldUpdatedAt)
  13377. }
  13378. if m.deleted_at != nil {
  13379. fields = append(fields, employee.FieldDeletedAt)
  13380. }
  13381. if m.title != nil {
  13382. fields = append(fields, employee.FieldTitle)
  13383. }
  13384. if m.avatar != nil {
  13385. fields = append(fields, employee.FieldAvatar)
  13386. }
  13387. if m.tags != nil {
  13388. fields = append(fields, employee.FieldTags)
  13389. }
  13390. if m.hire_count != nil {
  13391. fields = append(fields, employee.FieldHireCount)
  13392. }
  13393. if m.service_count != nil {
  13394. fields = append(fields, employee.FieldServiceCount)
  13395. }
  13396. if m.achievement_count != nil {
  13397. fields = append(fields, employee.FieldAchievementCount)
  13398. }
  13399. if m.intro != nil {
  13400. fields = append(fields, employee.FieldIntro)
  13401. }
  13402. if m.estimate != nil {
  13403. fields = append(fields, employee.FieldEstimate)
  13404. }
  13405. if m.skill != nil {
  13406. fields = append(fields, employee.FieldSkill)
  13407. }
  13408. if m.ability_type != nil {
  13409. fields = append(fields, employee.FieldAbilityType)
  13410. }
  13411. if m.scene != nil {
  13412. fields = append(fields, employee.FieldScene)
  13413. }
  13414. if m.switch_in != nil {
  13415. fields = append(fields, employee.FieldSwitchIn)
  13416. }
  13417. if m.video_url != nil {
  13418. fields = append(fields, employee.FieldVideoURL)
  13419. }
  13420. if m.organization_id != nil {
  13421. fields = append(fields, employee.FieldOrganizationID)
  13422. }
  13423. if m.category_id != nil {
  13424. fields = append(fields, employee.FieldCategoryID)
  13425. }
  13426. if m.api_base != nil {
  13427. fields = append(fields, employee.FieldAPIBase)
  13428. }
  13429. if m.api_key != nil {
  13430. fields = append(fields, employee.FieldAPIKey)
  13431. }
  13432. if m.ai_info != nil {
  13433. fields = append(fields, employee.FieldAiInfo)
  13434. }
  13435. if m.is_vip != nil {
  13436. fields = append(fields, employee.FieldIsVip)
  13437. }
  13438. if m.chat_url != nil {
  13439. fields = append(fields, employee.FieldChatURL)
  13440. }
  13441. return fields
  13442. }
  13443. // Field returns the value of a field with the given name. The second boolean
  13444. // return value indicates that this field was not set, or was not defined in the
  13445. // schema.
  13446. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  13447. switch name {
  13448. case employee.FieldCreatedAt:
  13449. return m.CreatedAt()
  13450. case employee.FieldUpdatedAt:
  13451. return m.UpdatedAt()
  13452. case employee.FieldDeletedAt:
  13453. return m.DeletedAt()
  13454. case employee.FieldTitle:
  13455. return m.Title()
  13456. case employee.FieldAvatar:
  13457. return m.Avatar()
  13458. case employee.FieldTags:
  13459. return m.Tags()
  13460. case employee.FieldHireCount:
  13461. return m.HireCount()
  13462. case employee.FieldServiceCount:
  13463. return m.ServiceCount()
  13464. case employee.FieldAchievementCount:
  13465. return m.AchievementCount()
  13466. case employee.FieldIntro:
  13467. return m.Intro()
  13468. case employee.FieldEstimate:
  13469. return m.Estimate()
  13470. case employee.FieldSkill:
  13471. return m.Skill()
  13472. case employee.FieldAbilityType:
  13473. return m.AbilityType()
  13474. case employee.FieldScene:
  13475. return m.Scene()
  13476. case employee.FieldSwitchIn:
  13477. return m.SwitchIn()
  13478. case employee.FieldVideoURL:
  13479. return m.VideoURL()
  13480. case employee.FieldOrganizationID:
  13481. return m.OrganizationID()
  13482. case employee.FieldCategoryID:
  13483. return m.CategoryID()
  13484. case employee.FieldAPIBase:
  13485. return m.APIBase()
  13486. case employee.FieldAPIKey:
  13487. return m.APIKey()
  13488. case employee.FieldAiInfo:
  13489. return m.AiInfo()
  13490. case employee.FieldIsVip:
  13491. return m.IsVip()
  13492. case employee.FieldChatURL:
  13493. return m.ChatURL()
  13494. }
  13495. return nil, false
  13496. }
  13497. // OldField returns the old value of the field from the database. An error is
  13498. // returned if the mutation operation is not UpdateOne, or the query to the
  13499. // database failed.
  13500. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13501. switch name {
  13502. case employee.FieldCreatedAt:
  13503. return m.OldCreatedAt(ctx)
  13504. case employee.FieldUpdatedAt:
  13505. return m.OldUpdatedAt(ctx)
  13506. case employee.FieldDeletedAt:
  13507. return m.OldDeletedAt(ctx)
  13508. case employee.FieldTitle:
  13509. return m.OldTitle(ctx)
  13510. case employee.FieldAvatar:
  13511. return m.OldAvatar(ctx)
  13512. case employee.FieldTags:
  13513. return m.OldTags(ctx)
  13514. case employee.FieldHireCount:
  13515. return m.OldHireCount(ctx)
  13516. case employee.FieldServiceCount:
  13517. return m.OldServiceCount(ctx)
  13518. case employee.FieldAchievementCount:
  13519. return m.OldAchievementCount(ctx)
  13520. case employee.FieldIntro:
  13521. return m.OldIntro(ctx)
  13522. case employee.FieldEstimate:
  13523. return m.OldEstimate(ctx)
  13524. case employee.FieldSkill:
  13525. return m.OldSkill(ctx)
  13526. case employee.FieldAbilityType:
  13527. return m.OldAbilityType(ctx)
  13528. case employee.FieldScene:
  13529. return m.OldScene(ctx)
  13530. case employee.FieldSwitchIn:
  13531. return m.OldSwitchIn(ctx)
  13532. case employee.FieldVideoURL:
  13533. return m.OldVideoURL(ctx)
  13534. case employee.FieldOrganizationID:
  13535. return m.OldOrganizationID(ctx)
  13536. case employee.FieldCategoryID:
  13537. return m.OldCategoryID(ctx)
  13538. case employee.FieldAPIBase:
  13539. return m.OldAPIBase(ctx)
  13540. case employee.FieldAPIKey:
  13541. return m.OldAPIKey(ctx)
  13542. case employee.FieldAiInfo:
  13543. return m.OldAiInfo(ctx)
  13544. case employee.FieldIsVip:
  13545. return m.OldIsVip(ctx)
  13546. case employee.FieldChatURL:
  13547. return m.OldChatURL(ctx)
  13548. }
  13549. return nil, fmt.Errorf("unknown Employee field %s", name)
  13550. }
  13551. // SetField sets the value of a field with the given name. It returns an error if
  13552. // the field is not defined in the schema, or if the type mismatched the field
  13553. // type.
  13554. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  13555. switch name {
  13556. case employee.FieldCreatedAt:
  13557. v, ok := value.(time.Time)
  13558. if !ok {
  13559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13560. }
  13561. m.SetCreatedAt(v)
  13562. return nil
  13563. case employee.FieldUpdatedAt:
  13564. v, ok := value.(time.Time)
  13565. if !ok {
  13566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13567. }
  13568. m.SetUpdatedAt(v)
  13569. return nil
  13570. case employee.FieldDeletedAt:
  13571. v, ok := value.(time.Time)
  13572. if !ok {
  13573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13574. }
  13575. m.SetDeletedAt(v)
  13576. return nil
  13577. case employee.FieldTitle:
  13578. v, ok := value.(string)
  13579. if !ok {
  13580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13581. }
  13582. m.SetTitle(v)
  13583. return nil
  13584. case employee.FieldAvatar:
  13585. v, ok := value.(string)
  13586. if !ok {
  13587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13588. }
  13589. m.SetAvatar(v)
  13590. return nil
  13591. case employee.FieldTags:
  13592. v, ok := value.(string)
  13593. if !ok {
  13594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13595. }
  13596. m.SetTags(v)
  13597. return nil
  13598. case employee.FieldHireCount:
  13599. v, ok := value.(int)
  13600. if !ok {
  13601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13602. }
  13603. m.SetHireCount(v)
  13604. return nil
  13605. case employee.FieldServiceCount:
  13606. v, ok := value.(int)
  13607. if !ok {
  13608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13609. }
  13610. m.SetServiceCount(v)
  13611. return nil
  13612. case employee.FieldAchievementCount:
  13613. v, ok := value.(int)
  13614. if !ok {
  13615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13616. }
  13617. m.SetAchievementCount(v)
  13618. return nil
  13619. case employee.FieldIntro:
  13620. v, ok := value.(string)
  13621. if !ok {
  13622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13623. }
  13624. m.SetIntro(v)
  13625. return nil
  13626. case employee.FieldEstimate:
  13627. v, ok := value.(string)
  13628. if !ok {
  13629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13630. }
  13631. m.SetEstimate(v)
  13632. return nil
  13633. case employee.FieldSkill:
  13634. v, ok := value.(string)
  13635. if !ok {
  13636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13637. }
  13638. m.SetSkill(v)
  13639. return nil
  13640. case employee.FieldAbilityType:
  13641. v, ok := value.(string)
  13642. if !ok {
  13643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13644. }
  13645. m.SetAbilityType(v)
  13646. return nil
  13647. case employee.FieldScene:
  13648. v, ok := value.(string)
  13649. if !ok {
  13650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13651. }
  13652. m.SetScene(v)
  13653. return nil
  13654. case employee.FieldSwitchIn:
  13655. v, ok := value.(string)
  13656. if !ok {
  13657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13658. }
  13659. m.SetSwitchIn(v)
  13660. return nil
  13661. case employee.FieldVideoURL:
  13662. v, ok := value.(string)
  13663. if !ok {
  13664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13665. }
  13666. m.SetVideoURL(v)
  13667. return nil
  13668. case employee.FieldOrganizationID:
  13669. v, ok := value.(uint64)
  13670. if !ok {
  13671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13672. }
  13673. m.SetOrganizationID(v)
  13674. return nil
  13675. case employee.FieldCategoryID:
  13676. v, ok := value.(uint64)
  13677. if !ok {
  13678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13679. }
  13680. m.SetCategoryID(v)
  13681. return nil
  13682. case employee.FieldAPIBase:
  13683. v, ok := value.(string)
  13684. if !ok {
  13685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13686. }
  13687. m.SetAPIBase(v)
  13688. return nil
  13689. case employee.FieldAPIKey:
  13690. v, ok := value.(string)
  13691. if !ok {
  13692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13693. }
  13694. m.SetAPIKey(v)
  13695. return nil
  13696. case employee.FieldAiInfo:
  13697. v, ok := value.(string)
  13698. if !ok {
  13699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13700. }
  13701. m.SetAiInfo(v)
  13702. return nil
  13703. case employee.FieldIsVip:
  13704. v, ok := value.(int)
  13705. if !ok {
  13706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13707. }
  13708. m.SetIsVip(v)
  13709. return nil
  13710. case employee.FieldChatURL:
  13711. v, ok := value.(string)
  13712. if !ok {
  13713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13714. }
  13715. m.SetChatURL(v)
  13716. return nil
  13717. }
  13718. return fmt.Errorf("unknown Employee field %s", name)
  13719. }
  13720. // AddedFields returns all numeric fields that were incremented/decremented during
  13721. // this mutation.
  13722. func (m *EmployeeMutation) AddedFields() []string {
  13723. var fields []string
  13724. if m.addhire_count != nil {
  13725. fields = append(fields, employee.FieldHireCount)
  13726. }
  13727. if m.addservice_count != nil {
  13728. fields = append(fields, employee.FieldServiceCount)
  13729. }
  13730. if m.addachievement_count != nil {
  13731. fields = append(fields, employee.FieldAchievementCount)
  13732. }
  13733. if m.addorganization_id != nil {
  13734. fields = append(fields, employee.FieldOrganizationID)
  13735. }
  13736. if m.addcategory_id != nil {
  13737. fields = append(fields, employee.FieldCategoryID)
  13738. }
  13739. if m.addis_vip != nil {
  13740. fields = append(fields, employee.FieldIsVip)
  13741. }
  13742. return fields
  13743. }
  13744. // AddedField returns the numeric value that was incremented/decremented on a field
  13745. // with the given name. The second boolean return value indicates that this field
  13746. // was not set, or was not defined in the schema.
  13747. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  13748. switch name {
  13749. case employee.FieldHireCount:
  13750. return m.AddedHireCount()
  13751. case employee.FieldServiceCount:
  13752. return m.AddedServiceCount()
  13753. case employee.FieldAchievementCount:
  13754. return m.AddedAchievementCount()
  13755. case employee.FieldOrganizationID:
  13756. return m.AddedOrganizationID()
  13757. case employee.FieldCategoryID:
  13758. return m.AddedCategoryID()
  13759. case employee.FieldIsVip:
  13760. return m.AddedIsVip()
  13761. }
  13762. return nil, false
  13763. }
  13764. // AddField adds the value to the field with the given name. It returns an error if
  13765. // the field is not defined in the schema, or if the type mismatched the field
  13766. // type.
  13767. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  13768. switch name {
  13769. case employee.FieldHireCount:
  13770. v, ok := value.(int)
  13771. if !ok {
  13772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13773. }
  13774. m.AddHireCount(v)
  13775. return nil
  13776. case employee.FieldServiceCount:
  13777. v, ok := value.(int)
  13778. if !ok {
  13779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13780. }
  13781. m.AddServiceCount(v)
  13782. return nil
  13783. case employee.FieldAchievementCount:
  13784. v, ok := value.(int)
  13785. if !ok {
  13786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13787. }
  13788. m.AddAchievementCount(v)
  13789. return nil
  13790. case employee.FieldOrganizationID:
  13791. v, ok := value.(int64)
  13792. if !ok {
  13793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13794. }
  13795. m.AddOrganizationID(v)
  13796. return nil
  13797. case employee.FieldCategoryID:
  13798. v, ok := value.(int64)
  13799. if !ok {
  13800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13801. }
  13802. m.AddCategoryID(v)
  13803. return nil
  13804. case employee.FieldIsVip:
  13805. v, ok := value.(int)
  13806. if !ok {
  13807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13808. }
  13809. m.AddIsVip(v)
  13810. return nil
  13811. }
  13812. return fmt.Errorf("unknown Employee numeric field %s", name)
  13813. }
  13814. // ClearedFields returns all nullable fields that were cleared during this
  13815. // mutation.
  13816. func (m *EmployeeMutation) ClearedFields() []string {
  13817. var fields []string
  13818. if m.FieldCleared(employee.FieldDeletedAt) {
  13819. fields = append(fields, employee.FieldDeletedAt)
  13820. }
  13821. if m.FieldCleared(employee.FieldAiInfo) {
  13822. fields = append(fields, employee.FieldAiInfo)
  13823. }
  13824. return fields
  13825. }
  13826. // FieldCleared returns a boolean indicating if a field with the given name was
  13827. // cleared in this mutation.
  13828. func (m *EmployeeMutation) FieldCleared(name string) bool {
  13829. _, ok := m.clearedFields[name]
  13830. return ok
  13831. }
  13832. // ClearField clears the value of the field with the given name. It returns an
  13833. // error if the field is not defined in the schema.
  13834. func (m *EmployeeMutation) ClearField(name string) error {
  13835. switch name {
  13836. case employee.FieldDeletedAt:
  13837. m.ClearDeletedAt()
  13838. return nil
  13839. case employee.FieldAiInfo:
  13840. m.ClearAiInfo()
  13841. return nil
  13842. }
  13843. return fmt.Errorf("unknown Employee nullable field %s", name)
  13844. }
  13845. // ResetField resets all changes in the mutation for the field with the given name.
  13846. // It returns an error if the field is not defined in the schema.
  13847. func (m *EmployeeMutation) ResetField(name string) error {
  13848. switch name {
  13849. case employee.FieldCreatedAt:
  13850. m.ResetCreatedAt()
  13851. return nil
  13852. case employee.FieldUpdatedAt:
  13853. m.ResetUpdatedAt()
  13854. return nil
  13855. case employee.FieldDeletedAt:
  13856. m.ResetDeletedAt()
  13857. return nil
  13858. case employee.FieldTitle:
  13859. m.ResetTitle()
  13860. return nil
  13861. case employee.FieldAvatar:
  13862. m.ResetAvatar()
  13863. return nil
  13864. case employee.FieldTags:
  13865. m.ResetTags()
  13866. return nil
  13867. case employee.FieldHireCount:
  13868. m.ResetHireCount()
  13869. return nil
  13870. case employee.FieldServiceCount:
  13871. m.ResetServiceCount()
  13872. return nil
  13873. case employee.FieldAchievementCount:
  13874. m.ResetAchievementCount()
  13875. return nil
  13876. case employee.FieldIntro:
  13877. m.ResetIntro()
  13878. return nil
  13879. case employee.FieldEstimate:
  13880. m.ResetEstimate()
  13881. return nil
  13882. case employee.FieldSkill:
  13883. m.ResetSkill()
  13884. return nil
  13885. case employee.FieldAbilityType:
  13886. m.ResetAbilityType()
  13887. return nil
  13888. case employee.FieldScene:
  13889. m.ResetScene()
  13890. return nil
  13891. case employee.FieldSwitchIn:
  13892. m.ResetSwitchIn()
  13893. return nil
  13894. case employee.FieldVideoURL:
  13895. m.ResetVideoURL()
  13896. return nil
  13897. case employee.FieldOrganizationID:
  13898. m.ResetOrganizationID()
  13899. return nil
  13900. case employee.FieldCategoryID:
  13901. m.ResetCategoryID()
  13902. return nil
  13903. case employee.FieldAPIBase:
  13904. m.ResetAPIBase()
  13905. return nil
  13906. case employee.FieldAPIKey:
  13907. m.ResetAPIKey()
  13908. return nil
  13909. case employee.FieldAiInfo:
  13910. m.ResetAiInfo()
  13911. return nil
  13912. case employee.FieldIsVip:
  13913. m.ResetIsVip()
  13914. return nil
  13915. case employee.FieldChatURL:
  13916. m.ResetChatURL()
  13917. return nil
  13918. }
  13919. return fmt.Errorf("unknown Employee field %s", name)
  13920. }
  13921. // AddedEdges returns all edge names that were set/added in this mutation.
  13922. func (m *EmployeeMutation) AddedEdges() []string {
  13923. edges := make([]string, 0, 2)
  13924. if m.em_work_experiences != nil {
  13925. edges = append(edges, employee.EdgeEmWorkExperiences)
  13926. }
  13927. if m.em_tutorial != nil {
  13928. edges = append(edges, employee.EdgeEmTutorial)
  13929. }
  13930. return edges
  13931. }
  13932. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13933. // name in this mutation.
  13934. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  13935. switch name {
  13936. case employee.EdgeEmWorkExperiences:
  13937. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  13938. for id := range m.em_work_experiences {
  13939. ids = append(ids, id)
  13940. }
  13941. return ids
  13942. case employee.EdgeEmTutorial:
  13943. ids := make([]ent.Value, 0, len(m.em_tutorial))
  13944. for id := range m.em_tutorial {
  13945. ids = append(ids, id)
  13946. }
  13947. return ids
  13948. }
  13949. return nil
  13950. }
  13951. // RemovedEdges returns all edge names that were removed in this mutation.
  13952. func (m *EmployeeMutation) RemovedEdges() []string {
  13953. edges := make([]string, 0, 2)
  13954. if m.removedem_work_experiences != nil {
  13955. edges = append(edges, employee.EdgeEmWorkExperiences)
  13956. }
  13957. if m.removedem_tutorial != nil {
  13958. edges = append(edges, employee.EdgeEmTutorial)
  13959. }
  13960. return edges
  13961. }
  13962. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13963. // the given name in this mutation.
  13964. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  13965. switch name {
  13966. case employee.EdgeEmWorkExperiences:
  13967. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  13968. for id := range m.removedem_work_experiences {
  13969. ids = append(ids, id)
  13970. }
  13971. return ids
  13972. case employee.EdgeEmTutorial:
  13973. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  13974. for id := range m.removedem_tutorial {
  13975. ids = append(ids, id)
  13976. }
  13977. return ids
  13978. }
  13979. return nil
  13980. }
  13981. // ClearedEdges returns all edge names that were cleared in this mutation.
  13982. func (m *EmployeeMutation) ClearedEdges() []string {
  13983. edges := make([]string, 0, 2)
  13984. if m.clearedem_work_experiences {
  13985. edges = append(edges, employee.EdgeEmWorkExperiences)
  13986. }
  13987. if m.clearedem_tutorial {
  13988. edges = append(edges, employee.EdgeEmTutorial)
  13989. }
  13990. return edges
  13991. }
  13992. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13993. // was cleared in this mutation.
  13994. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  13995. switch name {
  13996. case employee.EdgeEmWorkExperiences:
  13997. return m.clearedem_work_experiences
  13998. case employee.EdgeEmTutorial:
  13999. return m.clearedem_tutorial
  14000. }
  14001. return false
  14002. }
  14003. // ClearEdge clears the value of the edge with the given name. It returns an error
  14004. // if that edge is not defined in the schema.
  14005. func (m *EmployeeMutation) ClearEdge(name string) error {
  14006. switch name {
  14007. }
  14008. return fmt.Errorf("unknown Employee unique edge %s", name)
  14009. }
  14010. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14011. // It returns an error if the edge is not defined in the schema.
  14012. func (m *EmployeeMutation) ResetEdge(name string) error {
  14013. switch name {
  14014. case employee.EdgeEmWorkExperiences:
  14015. m.ResetEmWorkExperiences()
  14016. return nil
  14017. case employee.EdgeEmTutorial:
  14018. m.ResetEmTutorial()
  14019. return nil
  14020. }
  14021. return fmt.Errorf("unknown Employee edge %s", name)
  14022. }
  14023. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  14024. type EmployeeConfigMutation struct {
  14025. config
  14026. op Op
  14027. typ string
  14028. id *uint64
  14029. created_at *time.Time
  14030. updated_at *time.Time
  14031. deleted_at *time.Time
  14032. stype *string
  14033. title *string
  14034. photo *string
  14035. organization_id *uint64
  14036. addorganization_id *int64
  14037. clearedFields map[string]struct{}
  14038. done bool
  14039. oldValue func(context.Context) (*EmployeeConfig, error)
  14040. predicates []predicate.EmployeeConfig
  14041. }
  14042. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  14043. // employeeconfigOption allows management of the mutation configuration using functional options.
  14044. type employeeconfigOption func(*EmployeeConfigMutation)
  14045. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  14046. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  14047. m := &EmployeeConfigMutation{
  14048. config: c,
  14049. op: op,
  14050. typ: TypeEmployeeConfig,
  14051. clearedFields: make(map[string]struct{}),
  14052. }
  14053. for _, opt := range opts {
  14054. opt(m)
  14055. }
  14056. return m
  14057. }
  14058. // withEmployeeConfigID sets the ID field of the mutation.
  14059. func withEmployeeConfigID(id uint64) employeeconfigOption {
  14060. return func(m *EmployeeConfigMutation) {
  14061. var (
  14062. err error
  14063. once sync.Once
  14064. value *EmployeeConfig
  14065. )
  14066. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  14067. once.Do(func() {
  14068. if m.done {
  14069. err = errors.New("querying old values post mutation is not allowed")
  14070. } else {
  14071. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  14072. }
  14073. })
  14074. return value, err
  14075. }
  14076. m.id = &id
  14077. }
  14078. }
  14079. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  14080. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  14081. return func(m *EmployeeConfigMutation) {
  14082. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  14083. return node, nil
  14084. }
  14085. m.id = &node.ID
  14086. }
  14087. }
  14088. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14089. // executed in a transaction (ent.Tx), a transactional client is returned.
  14090. func (m EmployeeConfigMutation) Client() *Client {
  14091. client := &Client{config: m.config}
  14092. client.init()
  14093. return client
  14094. }
  14095. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14096. // it returns an error otherwise.
  14097. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  14098. if _, ok := m.driver.(*txDriver); !ok {
  14099. return nil, errors.New("ent: mutation is not running in a transaction")
  14100. }
  14101. tx := &Tx{config: m.config}
  14102. tx.init()
  14103. return tx, nil
  14104. }
  14105. // SetID sets the value of the id field. Note that this
  14106. // operation is only accepted on creation of EmployeeConfig entities.
  14107. func (m *EmployeeConfigMutation) SetID(id uint64) {
  14108. m.id = &id
  14109. }
  14110. // ID returns the ID value in the mutation. Note that the ID is only available
  14111. // if it was provided to the builder or after it was returned from the database.
  14112. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  14113. if m.id == nil {
  14114. return
  14115. }
  14116. return *m.id, true
  14117. }
  14118. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14119. // That means, if the mutation is applied within a transaction with an isolation level such
  14120. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14121. // or updated by the mutation.
  14122. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  14123. switch {
  14124. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14125. id, exists := m.ID()
  14126. if exists {
  14127. return []uint64{id}, nil
  14128. }
  14129. fallthrough
  14130. case m.op.Is(OpUpdate | OpDelete):
  14131. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  14132. default:
  14133. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14134. }
  14135. }
  14136. // SetCreatedAt sets the "created_at" field.
  14137. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  14138. m.created_at = &t
  14139. }
  14140. // CreatedAt returns the value of the "created_at" field in the mutation.
  14141. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  14142. v := m.created_at
  14143. if v == nil {
  14144. return
  14145. }
  14146. return *v, true
  14147. }
  14148. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  14149. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14151. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14152. if !m.op.Is(OpUpdateOne) {
  14153. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14154. }
  14155. if m.id == nil || m.oldValue == nil {
  14156. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14157. }
  14158. oldValue, err := m.oldValue(ctx)
  14159. if err != nil {
  14160. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14161. }
  14162. return oldValue.CreatedAt, nil
  14163. }
  14164. // ResetCreatedAt resets all changes to the "created_at" field.
  14165. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  14166. m.created_at = nil
  14167. }
  14168. // SetUpdatedAt sets the "updated_at" field.
  14169. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  14170. m.updated_at = &t
  14171. }
  14172. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14173. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  14174. v := m.updated_at
  14175. if v == nil {
  14176. return
  14177. }
  14178. return *v, true
  14179. }
  14180. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  14181. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14183. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14184. if !m.op.Is(OpUpdateOne) {
  14185. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14186. }
  14187. if m.id == nil || m.oldValue == nil {
  14188. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14189. }
  14190. oldValue, err := m.oldValue(ctx)
  14191. if err != nil {
  14192. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14193. }
  14194. return oldValue.UpdatedAt, nil
  14195. }
  14196. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14197. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  14198. m.updated_at = nil
  14199. }
  14200. // SetDeletedAt sets the "deleted_at" field.
  14201. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  14202. m.deleted_at = &t
  14203. }
  14204. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14205. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  14206. v := m.deleted_at
  14207. if v == nil {
  14208. return
  14209. }
  14210. return *v, true
  14211. }
  14212. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  14213. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14215. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14216. if !m.op.Is(OpUpdateOne) {
  14217. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14218. }
  14219. if m.id == nil || m.oldValue == nil {
  14220. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14221. }
  14222. oldValue, err := m.oldValue(ctx)
  14223. if err != nil {
  14224. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14225. }
  14226. return oldValue.DeletedAt, nil
  14227. }
  14228. // ClearDeletedAt clears the value of the "deleted_at" field.
  14229. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  14230. m.deleted_at = nil
  14231. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  14232. }
  14233. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14234. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  14235. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  14236. return ok
  14237. }
  14238. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14239. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  14240. m.deleted_at = nil
  14241. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  14242. }
  14243. // SetStype sets the "stype" field.
  14244. func (m *EmployeeConfigMutation) SetStype(s string) {
  14245. m.stype = &s
  14246. }
  14247. // Stype returns the value of the "stype" field in the mutation.
  14248. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  14249. v := m.stype
  14250. if v == nil {
  14251. return
  14252. }
  14253. return *v, true
  14254. }
  14255. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  14256. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14258. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  14259. if !m.op.Is(OpUpdateOne) {
  14260. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  14261. }
  14262. if m.id == nil || m.oldValue == nil {
  14263. return v, errors.New("OldStype requires an ID field in the mutation")
  14264. }
  14265. oldValue, err := m.oldValue(ctx)
  14266. if err != nil {
  14267. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  14268. }
  14269. return oldValue.Stype, nil
  14270. }
  14271. // ResetStype resets all changes to the "stype" field.
  14272. func (m *EmployeeConfigMutation) ResetStype() {
  14273. m.stype = nil
  14274. }
  14275. // SetTitle sets the "title" field.
  14276. func (m *EmployeeConfigMutation) SetTitle(s string) {
  14277. m.title = &s
  14278. }
  14279. // Title returns the value of the "title" field in the mutation.
  14280. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  14281. v := m.title
  14282. if v == nil {
  14283. return
  14284. }
  14285. return *v, true
  14286. }
  14287. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  14288. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14290. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  14291. if !m.op.Is(OpUpdateOne) {
  14292. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14293. }
  14294. if m.id == nil || m.oldValue == nil {
  14295. return v, errors.New("OldTitle requires an ID field in the mutation")
  14296. }
  14297. oldValue, err := m.oldValue(ctx)
  14298. if err != nil {
  14299. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14300. }
  14301. return oldValue.Title, nil
  14302. }
  14303. // ResetTitle resets all changes to the "title" field.
  14304. func (m *EmployeeConfigMutation) ResetTitle() {
  14305. m.title = nil
  14306. }
  14307. // SetPhoto sets the "photo" field.
  14308. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  14309. m.photo = &s
  14310. }
  14311. // Photo returns the value of the "photo" field in the mutation.
  14312. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  14313. v := m.photo
  14314. if v == nil {
  14315. return
  14316. }
  14317. return *v, true
  14318. }
  14319. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  14320. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14322. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  14323. if !m.op.Is(OpUpdateOne) {
  14324. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  14325. }
  14326. if m.id == nil || m.oldValue == nil {
  14327. return v, errors.New("OldPhoto requires an ID field in the mutation")
  14328. }
  14329. oldValue, err := m.oldValue(ctx)
  14330. if err != nil {
  14331. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  14332. }
  14333. return oldValue.Photo, nil
  14334. }
  14335. // ResetPhoto resets all changes to the "photo" field.
  14336. func (m *EmployeeConfigMutation) ResetPhoto() {
  14337. m.photo = nil
  14338. }
  14339. // SetOrganizationID sets the "organization_id" field.
  14340. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  14341. m.organization_id = &u
  14342. m.addorganization_id = nil
  14343. }
  14344. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14345. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  14346. v := m.organization_id
  14347. if v == nil {
  14348. return
  14349. }
  14350. return *v, true
  14351. }
  14352. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  14353. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14355. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14356. if !m.op.Is(OpUpdateOne) {
  14357. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14358. }
  14359. if m.id == nil || m.oldValue == nil {
  14360. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14361. }
  14362. oldValue, err := m.oldValue(ctx)
  14363. if err != nil {
  14364. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14365. }
  14366. return oldValue.OrganizationID, nil
  14367. }
  14368. // AddOrganizationID adds u to the "organization_id" field.
  14369. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  14370. if m.addorganization_id != nil {
  14371. *m.addorganization_id += u
  14372. } else {
  14373. m.addorganization_id = &u
  14374. }
  14375. }
  14376. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14377. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  14378. v := m.addorganization_id
  14379. if v == nil {
  14380. return
  14381. }
  14382. return *v, true
  14383. }
  14384. // ClearOrganizationID clears the value of the "organization_id" field.
  14385. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  14386. m.organization_id = nil
  14387. m.addorganization_id = nil
  14388. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  14389. }
  14390. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14391. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  14392. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  14393. return ok
  14394. }
  14395. // ResetOrganizationID resets all changes to the "organization_id" field.
  14396. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  14397. m.organization_id = nil
  14398. m.addorganization_id = nil
  14399. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  14400. }
  14401. // Where appends a list predicates to the EmployeeConfigMutation builder.
  14402. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  14403. m.predicates = append(m.predicates, ps...)
  14404. }
  14405. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  14406. // users can use type-assertion to append predicates that do not depend on any generated package.
  14407. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  14408. p := make([]predicate.EmployeeConfig, len(ps))
  14409. for i := range ps {
  14410. p[i] = ps[i]
  14411. }
  14412. m.Where(p...)
  14413. }
  14414. // Op returns the operation name.
  14415. func (m *EmployeeConfigMutation) Op() Op {
  14416. return m.op
  14417. }
  14418. // SetOp allows setting the mutation operation.
  14419. func (m *EmployeeConfigMutation) SetOp(op Op) {
  14420. m.op = op
  14421. }
  14422. // Type returns the node type of this mutation (EmployeeConfig).
  14423. func (m *EmployeeConfigMutation) Type() string {
  14424. return m.typ
  14425. }
  14426. // Fields returns all fields that were changed during this mutation. Note that in
  14427. // order to get all numeric fields that were incremented/decremented, call
  14428. // AddedFields().
  14429. func (m *EmployeeConfigMutation) Fields() []string {
  14430. fields := make([]string, 0, 7)
  14431. if m.created_at != nil {
  14432. fields = append(fields, employeeconfig.FieldCreatedAt)
  14433. }
  14434. if m.updated_at != nil {
  14435. fields = append(fields, employeeconfig.FieldUpdatedAt)
  14436. }
  14437. if m.deleted_at != nil {
  14438. fields = append(fields, employeeconfig.FieldDeletedAt)
  14439. }
  14440. if m.stype != nil {
  14441. fields = append(fields, employeeconfig.FieldStype)
  14442. }
  14443. if m.title != nil {
  14444. fields = append(fields, employeeconfig.FieldTitle)
  14445. }
  14446. if m.photo != nil {
  14447. fields = append(fields, employeeconfig.FieldPhoto)
  14448. }
  14449. if m.organization_id != nil {
  14450. fields = append(fields, employeeconfig.FieldOrganizationID)
  14451. }
  14452. return fields
  14453. }
  14454. // Field returns the value of a field with the given name. The second boolean
  14455. // return value indicates that this field was not set, or was not defined in the
  14456. // schema.
  14457. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  14458. switch name {
  14459. case employeeconfig.FieldCreatedAt:
  14460. return m.CreatedAt()
  14461. case employeeconfig.FieldUpdatedAt:
  14462. return m.UpdatedAt()
  14463. case employeeconfig.FieldDeletedAt:
  14464. return m.DeletedAt()
  14465. case employeeconfig.FieldStype:
  14466. return m.Stype()
  14467. case employeeconfig.FieldTitle:
  14468. return m.Title()
  14469. case employeeconfig.FieldPhoto:
  14470. return m.Photo()
  14471. case employeeconfig.FieldOrganizationID:
  14472. return m.OrganizationID()
  14473. }
  14474. return nil, false
  14475. }
  14476. // OldField returns the old value of the field from the database. An error is
  14477. // returned if the mutation operation is not UpdateOne, or the query to the
  14478. // database failed.
  14479. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14480. switch name {
  14481. case employeeconfig.FieldCreatedAt:
  14482. return m.OldCreatedAt(ctx)
  14483. case employeeconfig.FieldUpdatedAt:
  14484. return m.OldUpdatedAt(ctx)
  14485. case employeeconfig.FieldDeletedAt:
  14486. return m.OldDeletedAt(ctx)
  14487. case employeeconfig.FieldStype:
  14488. return m.OldStype(ctx)
  14489. case employeeconfig.FieldTitle:
  14490. return m.OldTitle(ctx)
  14491. case employeeconfig.FieldPhoto:
  14492. return m.OldPhoto(ctx)
  14493. case employeeconfig.FieldOrganizationID:
  14494. return m.OldOrganizationID(ctx)
  14495. }
  14496. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  14497. }
  14498. // SetField sets the value of a field with the given name. It returns an error if
  14499. // the field is not defined in the schema, or if the type mismatched the field
  14500. // type.
  14501. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  14502. switch name {
  14503. case employeeconfig.FieldCreatedAt:
  14504. v, ok := value.(time.Time)
  14505. if !ok {
  14506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14507. }
  14508. m.SetCreatedAt(v)
  14509. return nil
  14510. case employeeconfig.FieldUpdatedAt:
  14511. v, ok := value.(time.Time)
  14512. if !ok {
  14513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14514. }
  14515. m.SetUpdatedAt(v)
  14516. return nil
  14517. case employeeconfig.FieldDeletedAt:
  14518. v, ok := value.(time.Time)
  14519. if !ok {
  14520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14521. }
  14522. m.SetDeletedAt(v)
  14523. return nil
  14524. case employeeconfig.FieldStype:
  14525. v, ok := value.(string)
  14526. if !ok {
  14527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14528. }
  14529. m.SetStype(v)
  14530. return nil
  14531. case employeeconfig.FieldTitle:
  14532. v, ok := value.(string)
  14533. if !ok {
  14534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14535. }
  14536. m.SetTitle(v)
  14537. return nil
  14538. case employeeconfig.FieldPhoto:
  14539. v, ok := value.(string)
  14540. if !ok {
  14541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14542. }
  14543. m.SetPhoto(v)
  14544. return nil
  14545. case employeeconfig.FieldOrganizationID:
  14546. v, ok := value.(uint64)
  14547. if !ok {
  14548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14549. }
  14550. m.SetOrganizationID(v)
  14551. return nil
  14552. }
  14553. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14554. }
  14555. // AddedFields returns all numeric fields that were incremented/decremented during
  14556. // this mutation.
  14557. func (m *EmployeeConfigMutation) AddedFields() []string {
  14558. var fields []string
  14559. if m.addorganization_id != nil {
  14560. fields = append(fields, employeeconfig.FieldOrganizationID)
  14561. }
  14562. return fields
  14563. }
  14564. // AddedField returns the numeric value that was incremented/decremented on a field
  14565. // with the given name. The second boolean return value indicates that this field
  14566. // was not set, or was not defined in the schema.
  14567. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  14568. switch name {
  14569. case employeeconfig.FieldOrganizationID:
  14570. return m.AddedOrganizationID()
  14571. }
  14572. return nil, false
  14573. }
  14574. // AddField adds the value to the field with the given name. It returns an error if
  14575. // the field is not defined in the schema, or if the type mismatched the field
  14576. // type.
  14577. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  14578. switch name {
  14579. case employeeconfig.FieldOrganizationID:
  14580. v, ok := value.(int64)
  14581. if !ok {
  14582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14583. }
  14584. m.AddOrganizationID(v)
  14585. return nil
  14586. }
  14587. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  14588. }
  14589. // ClearedFields returns all nullable fields that were cleared during this
  14590. // mutation.
  14591. func (m *EmployeeConfigMutation) ClearedFields() []string {
  14592. var fields []string
  14593. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  14594. fields = append(fields, employeeconfig.FieldDeletedAt)
  14595. }
  14596. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  14597. fields = append(fields, employeeconfig.FieldOrganizationID)
  14598. }
  14599. return fields
  14600. }
  14601. // FieldCleared returns a boolean indicating if a field with the given name was
  14602. // cleared in this mutation.
  14603. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  14604. _, ok := m.clearedFields[name]
  14605. return ok
  14606. }
  14607. // ClearField clears the value of the field with the given name. It returns an
  14608. // error if the field is not defined in the schema.
  14609. func (m *EmployeeConfigMutation) ClearField(name string) error {
  14610. switch name {
  14611. case employeeconfig.FieldDeletedAt:
  14612. m.ClearDeletedAt()
  14613. return nil
  14614. case employeeconfig.FieldOrganizationID:
  14615. m.ClearOrganizationID()
  14616. return nil
  14617. }
  14618. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  14619. }
  14620. // ResetField resets all changes in the mutation for the field with the given name.
  14621. // It returns an error if the field is not defined in the schema.
  14622. func (m *EmployeeConfigMutation) ResetField(name string) error {
  14623. switch name {
  14624. case employeeconfig.FieldCreatedAt:
  14625. m.ResetCreatedAt()
  14626. return nil
  14627. case employeeconfig.FieldUpdatedAt:
  14628. m.ResetUpdatedAt()
  14629. return nil
  14630. case employeeconfig.FieldDeletedAt:
  14631. m.ResetDeletedAt()
  14632. return nil
  14633. case employeeconfig.FieldStype:
  14634. m.ResetStype()
  14635. return nil
  14636. case employeeconfig.FieldTitle:
  14637. m.ResetTitle()
  14638. return nil
  14639. case employeeconfig.FieldPhoto:
  14640. m.ResetPhoto()
  14641. return nil
  14642. case employeeconfig.FieldOrganizationID:
  14643. m.ResetOrganizationID()
  14644. return nil
  14645. }
  14646. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14647. }
  14648. // AddedEdges returns all edge names that were set/added in this mutation.
  14649. func (m *EmployeeConfigMutation) AddedEdges() []string {
  14650. edges := make([]string, 0, 0)
  14651. return edges
  14652. }
  14653. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14654. // name in this mutation.
  14655. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  14656. return nil
  14657. }
  14658. // RemovedEdges returns all edge names that were removed in this mutation.
  14659. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  14660. edges := make([]string, 0, 0)
  14661. return edges
  14662. }
  14663. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14664. // the given name in this mutation.
  14665. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  14666. return nil
  14667. }
  14668. // ClearedEdges returns all edge names that were cleared in this mutation.
  14669. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  14670. edges := make([]string, 0, 0)
  14671. return edges
  14672. }
  14673. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14674. // was cleared in this mutation.
  14675. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  14676. return false
  14677. }
  14678. // ClearEdge clears the value of the edge with the given name. It returns an error
  14679. // if that edge is not defined in the schema.
  14680. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  14681. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  14682. }
  14683. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14684. // It returns an error if the edge is not defined in the schema.
  14685. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  14686. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  14687. }
  14688. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  14689. type LabelMutation struct {
  14690. config
  14691. op Op
  14692. typ string
  14693. id *uint64
  14694. created_at *time.Time
  14695. updated_at *time.Time
  14696. status *uint8
  14697. addstatus *int8
  14698. _type *int
  14699. add_type *int
  14700. name *string
  14701. from *int
  14702. addfrom *int
  14703. mode *int
  14704. addmode *int
  14705. conditions *string
  14706. organization_id *uint64
  14707. addorganization_id *int64
  14708. clearedFields map[string]struct{}
  14709. label_relationships map[uint64]struct{}
  14710. removedlabel_relationships map[uint64]struct{}
  14711. clearedlabel_relationships bool
  14712. done bool
  14713. oldValue func(context.Context) (*Label, error)
  14714. predicates []predicate.Label
  14715. }
  14716. var _ ent.Mutation = (*LabelMutation)(nil)
  14717. // labelOption allows management of the mutation configuration using functional options.
  14718. type labelOption func(*LabelMutation)
  14719. // newLabelMutation creates new mutation for the Label entity.
  14720. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  14721. m := &LabelMutation{
  14722. config: c,
  14723. op: op,
  14724. typ: TypeLabel,
  14725. clearedFields: make(map[string]struct{}),
  14726. }
  14727. for _, opt := range opts {
  14728. opt(m)
  14729. }
  14730. return m
  14731. }
  14732. // withLabelID sets the ID field of the mutation.
  14733. func withLabelID(id uint64) labelOption {
  14734. return func(m *LabelMutation) {
  14735. var (
  14736. err error
  14737. once sync.Once
  14738. value *Label
  14739. )
  14740. m.oldValue = func(ctx context.Context) (*Label, error) {
  14741. once.Do(func() {
  14742. if m.done {
  14743. err = errors.New("querying old values post mutation is not allowed")
  14744. } else {
  14745. value, err = m.Client().Label.Get(ctx, id)
  14746. }
  14747. })
  14748. return value, err
  14749. }
  14750. m.id = &id
  14751. }
  14752. }
  14753. // withLabel sets the old Label of the mutation.
  14754. func withLabel(node *Label) labelOption {
  14755. return func(m *LabelMutation) {
  14756. m.oldValue = func(context.Context) (*Label, error) {
  14757. return node, nil
  14758. }
  14759. m.id = &node.ID
  14760. }
  14761. }
  14762. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14763. // executed in a transaction (ent.Tx), a transactional client is returned.
  14764. func (m LabelMutation) Client() *Client {
  14765. client := &Client{config: m.config}
  14766. client.init()
  14767. return client
  14768. }
  14769. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14770. // it returns an error otherwise.
  14771. func (m LabelMutation) Tx() (*Tx, error) {
  14772. if _, ok := m.driver.(*txDriver); !ok {
  14773. return nil, errors.New("ent: mutation is not running in a transaction")
  14774. }
  14775. tx := &Tx{config: m.config}
  14776. tx.init()
  14777. return tx, nil
  14778. }
  14779. // SetID sets the value of the id field. Note that this
  14780. // operation is only accepted on creation of Label entities.
  14781. func (m *LabelMutation) SetID(id uint64) {
  14782. m.id = &id
  14783. }
  14784. // ID returns the ID value in the mutation. Note that the ID is only available
  14785. // if it was provided to the builder or after it was returned from the database.
  14786. func (m *LabelMutation) ID() (id uint64, exists bool) {
  14787. if m.id == nil {
  14788. return
  14789. }
  14790. return *m.id, true
  14791. }
  14792. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14793. // That means, if the mutation is applied within a transaction with an isolation level such
  14794. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14795. // or updated by the mutation.
  14796. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  14797. switch {
  14798. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14799. id, exists := m.ID()
  14800. if exists {
  14801. return []uint64{id}, nil
  14802. }
  14803. fallthrough
  14804. case m.op.Is(OpUpdate | OpDelete):
  14805. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  14806. default:
  14807. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14808. }
  14809. }
  14810. // SetCreatedAt sets the "created_at" field.
  14811. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  14812. m.created_at = &t
  14813. }
  14814. // CreatedAt returns the value of the "created_at" field in the mutation.
  14815. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  14816. v := m.created_at
  14817. if v == nil {
  14818. return
  14819. }
  14820. return *v, true
  14821. }
  14822. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  14823. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14825. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14826. if !m.op.Is(OpUpdateOne) {
  14827. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14828. }
  14829. if m.id == nil || m.oldValue == nil {
  14830. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14831. }
  14832. oldValue, err := m.oldValue(ctx)
  14833. if err != nil {
  14834. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14835. }
  14836. return oldValue.CreatedAt, nil
  14837. }
  14838. // ResetCreatedAt resets all changes to the "created_at" field.
  14839. func (m *LabelMutation) ResetCreatedAt() {
  14840. m.created_at = nil
  14841. }
  14842. // SetUpdatedAt sets the "updated_at" field.
  14843. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  14844. m.updated_at = &t
  14845. }
  14846. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14847. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  14848. v := m.updated_at
  14849. if v == nil {
  14850. return
  14851. }
  14852. return *v, true
  14853. }
  14854. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  14855. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14857. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14858. if !m.op.Is(OpUpdateOne) {
  14859. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14860. }
  14861. if m.id == nil || m.oldValue == nil {
  14862. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14863. }
  14864. oldValue, err := m.oldValue(ctx)
  14865. if err != nil {
  14866. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14867. }
  14868. return oldValue.UpdatedAt, nil
  14869. }
  14870. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14871. func (m *LabelMutation) ResetUpdatedAt() {
  14872. m.updated_at = nil
  14873. }
  14874. // SetStatus sets the "status" field.
  14875. func (m *LabelMutation) SetStatus(u uint8) {
  14876. m.status = &u
  14877. m.addstatus = nil
  14878. }
  14879. // Status returns the value of the "status" field in the mutation.
  14880. func (m *LabelMutation) Status() (r uint8, exists bool) {
  14881. v := m.status
  14882. if v == nil {
  14883. return
  14884. }
  14885. return *v, true
  14886. }
  14887. // OldStatus returns the old "status" field's value of the Label entity.
  14888. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14890. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14891. if !m.op.Is(OpUpdateOne) {
  14892. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14893. }
  14894. if m.id == nil || m.oldValue == nil {
  14895. return v, errors.New("OldStatus requires an ID field in the mutation")
  14896. }
  14897. oldValue, err := m.oldValue(ctx)
  14898. if err != nil {
  14899. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14900. }
  14901. return oldValue.Status, nil
  14902. }
  14903. // AddStatus adds u to the "status" field.
  14904. func (m *LabelMutation) AddStatus(u int8) {
  14905. if m.addstatus != nil {
  14906. *m.addstatus += u
  14907. } else {
  14908. m.addstatus = &u
  14909. }
  14910. }
  14911. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14912. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  14913. v := m.addstatus
  14914. if v == nil {
  14915. return
  14916. }
  14917. return *v, true
  14918. }
  14919. // ClearStatus clears the value of the "status" field.
  14920. func (m *LabelMutation) ClearStatus() {
  14921. m.status = nil
  14922. m.addstatus = nil
  14923. m.clearedFields[label.FieldStatus] = struct{}{}
  14924. }
  14925. // StatusCleared returns if the "status" field was cleared in this mutation.
  14926. func (m *LabelMutation) StatusCleared() bool {
  14927. _, ok := m.clearedFields[label.FieldStatus]
  14928. return ok
  14929. }
  14930. // ResetStatus resets all changes to the "status" field.
  14931. func (m *LabelMutation) ResetStatus() {
  14932. m.status = nil
  14933. m.addstatus = nil
  14934. delete(m.clearedFields, label.FieldStatus)
  14935. }
  14936. // SetType sets the "type" field.
  14937. func (m *LabelMutation) SetType(i int) {
  14938. m._type = &i
  14939. m.add_type = nil
  14940. }
  14941. // GetType returns the value of the "type" field in the mutation.
  14942. func (m *LabelMutation) GetType() (r int, exists bool) {
  14943. v := m._type
  14944. if v == nil {
  14945. return
  14946. }
  14947. return *v, true
  14948. }
  14949. // OldType returns the old "type" field's value of the Label entity.
  14950. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14952. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  14953. if !m.op.Is(OpUpdateOne) {
  14954. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14955. }
  14956. if m.id == nil || m.oldValue == nil {
  14957. return v, errors.New("OldType requires an ID field in the mutation")
  14958. }
  14959. oldValue, err := m.oldValue(ctx)
  14960. if err != nil {
  14961. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14962. }
  14963. return oldValue.Type, nil
  14964. }
  14965. // AddType adds i to the "type" field.
  14966. func (m *LabelMutation) AddType(i int) {
  14967. if m.add_type != nil {
  14968. *m.add_type += i
  14969. } else {
  14970. m.add_type = &i
  14971. }
  14972. }
  14973. // AddedType returns the value that was added to the "type" field in this mutation.
  14974. func (m *LabelMutation) AddedType() (r int, exists bool) {
  14975. v := m.add_type
  14976. if v == nil {
  14977. return
  14978. }
  14979. return *v, true
  14980. }
  14981. // ResetType resets all changes to the "type" field.
  14982. func (m *LabelMutation) ResetType() {
  14983. m._type = nil
  14984. m.add_type = nil
  14985. }
  14986. // SetName sets the "name" field.
  14987. func (m *LabelMutation) SetName(s string) {
  14988. m.name = &s
  14989. }
  14990. // Name returns the value of the "name" field in the mutation.
  14991. func (m *LabelMutation) Name() (r string, exists bool) {
  14992. v := m.name
  14993. if v == nil {
  14994. return
  14995. }
  14996. return *v, true
  14997. }
  14998. // OldName returns the old "name" field's value of the Label entity.
  14999. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15001. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  15002. if !m.op.Is(OpUpdateOne) {
  15003. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15004. }
  15005. if m.id == nil || m.oldValue == nil {
  15006. return v, errors.New("OldName requires an ID field in the mutation")
  15007. }
  15008. oldValue, err := m.oldValue(ctx)
  15009. if err != nil {
  15010. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15011. }
  15012. return oldValue.Name, nil
  15013. }
  15014. // ResetName resets all changes to the "name" field.
  15015. func (m *LabelMutation) ResetName() {
  15016. m.name = nil
  15017. }
  15018. // SetFrom sets the "from" field.
  15019. func (m *LabelMutation) SetFrom(i int) {
  15020. m.from = &i
  15021. m.addfrom = nil
  15022. }
  15023. // From returns the value of the "from" field in the mutation.
  15024. func (m *LabelMutation) From() (r int, exists bool) {
  15025. v := m.from
  15026. if v == nil {
  15027. return
  15028. }
  15029. return *v, true
  15030. }
  15031. // OldFrom returns the old "from" field's value of the Label entity.
  15032. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15034. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  15035. if !m.op.Is(OpUpdateOne) {
  15036. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  15037. }
  15038. if m.id == nil || m.oldValue == nil {
  15039. return v, errors.New("OldFrom requires an ID field in the mutation")
  15040. }
  15041. oldValue, err := m.oldValue(ctx)
  15042. if err != nil {
  15043. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  15044. }
  15045. return oldValue.From, nil
  15046. }
  15047. // AddFrom adds i to the "from" field.
  15048. func (m *LabelMutation) AddFrom(i int) {
  15049. if m.addfrom != nil {
  15050. *m.addfrom += i
  15051. } else {
  15052. m.addfrom = &i
  15053. }
  15054. }
  15055. // AddedFrom returns the value that was added to the "from" field in this mutation.
  15056. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  15057. v := m.addfrom
  15058. if v == nil {
  15059. return
  15060. }
  15061. return *v, true
  15062. }
  15063. // ResetFrom resets all changes to the "from" field.
  15064. func (m *LabelMutation) ResetFrom() {
  15065. m.from = nil
  15066. m.addfrom = nil
  15067. }
  15068. // SetMode sets the "mode" field.
  15069. func (m *LabelMutation) SetMode(i int) {
  15070. m.mode = &i
  15071. m.addmode = nil
  15072. }
  15073. // Mode returns the value of the "mode" field in the mutation.
  15074. func (m *LabelMutation) Mode() (r int, exists bool) {
  15075. v := m.mode
  15076. if v == nil {
  15077. return
  15078. }
  15079. return *v, true
  15080. }
  15081. // OldMode returns the old "mode" field's value of the Label entity.
  15082. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15084. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  15085. if !m.op.Is(OpUpdateOne) {
  15086. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  15087. }
  15088. if m.id == nil || m.oldValue == nil {
  15089. return v, errors.New("OldMode requires an ID field in the mutation")
  15090. }
  15091. oldValue, err := m.oldValue(ctx)
  15092. if err != nil {
  15093. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  15094. }
  15095. return oldValue.Mode, nil
  15096. }
  15097. // AddMode adds i to the "mode" field.
  15098. func (m *LabelMutation) AddMode(i int) {
  15099. if m.addmode != nil {
  15100. *m.addmode += i
  15101. } else {
  15102. m.addmode = &i
  15103. }
  15104. }
  15105. // AddedMode returns the value that was added to the "mode" field in this mutation.
  15106. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  15107. v := m.addmode
  15108. if v == nil {
  15109. return
  15110. }
  15111. return *v, true
  15112. }
  15113. // ResetMode resets all changes to the "mode" field.
  15114. func (m *LabelMutation) ResetMode() {
  15115. m.mode = nil
  15116. m.addmode = nil
  15117. }
  15118. // SetConditions sets the "conditions" field.
  15119. func (m *LabelMutation) SetConditions(s string) {
  15120. m.conditions = &s
  15121. }
  15122. // Conditions returns the value of the "conditions" field in the mutation.
  15123. func (m *LabelMutation) Conditions() (r string, exists bool) {
  15124. v := m.conditions
  15125. if v == nil {
  15126. return
  15127. }
  15128. return *v, true
  15129. }
  15130. // OldConditions returns the old "conditions" field's value of the Label entity.
  15131. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15133. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  15134. if !m.op.Is(OpUpdateOne) {
  15135. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15136. }
  15137. if m.id == nil || m.oldValue == nil {
  15138. return v, errors.New("OldConditions requires an ID field in the mutation")
  15139. }
  15140. oldValue, err := m.oldValue(ctx)
  15141. if err != nil {
  15142. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15143. }
  15144. return oldValue.Conditions, nil
  15145. }
  15146. // ClearConditions clears the value of the "conditions" field.
  15147. func (m *LabelMutation) ClearConditions() {
  15148. m.conditions = nil
  15149. m.clearedFields[label.FieldConditions] = struct{}{}
  15150. }
  15151. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  15152. func (m *LabelMutation) ConditionsCleared() bool {
  15153. _, ok := m.clearedFields[label.FieldConditions]
  15154. return ok
  15155. }
  15156. // ResetConditions resets all changes to the "conditions" field.
  15157. func (m *LabelMutation) ResetConditions() {
  15158. m.conditions = nil
  15159. delete(m.clearedFields, label.FieldConditions)
  15160. }
  15161. // SetOrganizationID sets the "organization_id" field.
  15162. func (m *LabelMutation) SetOrganizationID(u uint64) {
  15163. m.organization_id = &u
  15164. m.addorganization_id = nil
  15165. }
  15166. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15167. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  15168. v := m.organization_id
  15169. if v == nil {
  15170. return
  15171. }
  15172. return *v, true
  15173. }
  15174. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  15175. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15177. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15178. if !m.op.Is(OpUpdateOne) {
  15179. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15180. }
  15181. if m.id == nil || m.oldValue == nil {
  15182. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15183. }
  15184. oldValue, err := m.oldValue(ctx)
  15185. if err != nil {
  15186. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15187. }
  15188. return oldValue.OrganizationID, nil
  15189. }
  15190. // AddOrganizationID adds u to the "organization_id" field.
  15191. func (m *LabelMutation) AddOrganizationID(u int64) {
  15192. if m.addorganization_id != nil {
  15193. *m.addorganization_id += u
  15194. } else {
  15195. m.addorganization_id = &u
  15196. }
  15197. }
  15198. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15199. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  15200. v := m.addorganization_id
  15201. if v == nil {
  15202. return
  15203. }
  15204. return *v, true
  15205. }
  15206. // ClearOrganizationID clears the value of the "organization_id" field.
  15207. func (m *LabelMutation) ClearOrganizationID() {
  15208. m.organization_id = nil
  15209. m.addorganization_id = nil
  15210. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  15211. }
  15212. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15213. func (m *LabelMutation) OrganizationIDCleared() bool {
  15214. _, ok := m.clearedFields[label.FieldOrganizationID]
  15215. return ok
  15216. }
  15217. // ResetOrganizationID resets all changes to the "organization_id" field.
  15218. func (m *LabelMutation) ResetOrganizationID() {
  15219. m.organization_id = nil
  15220. m.addorganization_id = nil
  15221. delete(m.clearedFields, label.FieldOrganizationID)
  15222. }
  15223. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  15224. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  15225. if m.label_relationships == nil {
  15226. m.label_relationships = make(map[uint64]struct{})
  15227. }
  15228. for i := range ids {
  15229. m.label_relationships[ids[i]] = struct{}{}
  15230. }
  15231. }
  15232. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  15233. func (m *LabelMutation) ClearLabelRelationships() {
  15234. m.clearedlabel_relationships = true
  15235. }
  15236. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  15237. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  15238. return m.clearedlabel_relationships
  15239. }
  15240. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  15241. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  15242. if m.removedlabel_relationships == nil {
  15243. m.removedlabel_relationships = make(map[uint64]struct{})
  15244. }
  15245. for i := range ids {
  15246. delete(m.label_relationships, ids[i])
  15247. m.removedlabel_relationships[ids[i]] = struct{}{}
  15248. }
  15249. }
  15250. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  15251. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  15252. for id := range m.removedlabel_relationships {
  15253. ids = append(ids, id)
  15254. }
  15255. return
  15256. }
  15257. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  15258. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  15259. for id := range m.label_relationships {
  15260. ids = append(ids, id)
  15261. }
  15262. return
  15263. }
  15264. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  15265. func (m *LabelMutation) ResetLabelRelationships() {
  15266. m.label_relationships = nil
  15267. m.clearedlabel_relationships = false
  15268. m.removedlabel_relationships = nil
  15269. }
  15270. // Where appends a list predicates to the LabelMutation builder.
  15271. func (m *LabelMutation) Where(ps ...predicate.Label) {
  15272. m.predicates = append(m.predicates, ps...)
  15273. }
  15274. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  15275. // users can use type-assertion to append predicates that do not depend on any generated package.
  15276. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  15277. p := make([]predicate.Label, len(ps))
  15278. for i := range ps {
  15279. p[i] = ps[i]
  15280. }
  15281. m.Where(p...)
  15282. }
  15283. // Op returns the operation name.
  15284. func (m *LabelMutation) Op() Op {
  15285. return m.op
  15286. }
  15287. // SetOp allows setting the mutation operation.
  15288. func (m *LabelMutation) SetOp(op Op) {
  15289. m.op = op
  15290. }
  15291. // Type returns the node type of this mutation (Label).
  15292. func (m *LabelMutation) Type() string {
  15293. return m.typ
  15294. }
  15295. // Fields returns all fields that were changed during this mutation. Note that in
  15296. // order to get all numeric fields that were incremented/decremented, call
  15297. // AddedFields().
  15298. func (m *LabelMutation) Fields() []string {
  15299. fields := make([]string, 0, 9)
  15300. if m.created_at != nil {
  15301. fields = append(fields, label.FieldCreatedAt)
  15302. }
  15303. if m.updated_at != nil {
  15304. fields = append(fields, label.FieldUpdatedAt)
  15305. }
  15306. if m.status != nil {
  15307. fields = append(fields, label.FieldStatus)
  15308. }
  15309. if m._type != nil {
  15310. fields = append(fields, label.FieldType)
  15311. }
  15312. if m.name != nil {
  15313. fields = append(fields, label.FieldName)
  15314. }
  15315. if m.from != nil {
  15316. fields = append(fields, label.FieldFrom)
  15317. }
  15318. if m.mode != nil {
  15319. fields = append(fields, label.FieldMode)
  15320. }
  15321. if m.conditions != nil {
  15322. fields = append(fields, label.FieldConditions)
  15323. }
  15324. if m.organization_id != nil {
  15325. fields = append(fields, label.FieldOrganizationID)
  15326. }
  15327. return fields
  15328. }
  15329. // Field returns the value of a field with the given name. The second boolean
  15330. // return value indicates that this field was not set, or was not defined in the
  15331. // schema.
  15332. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  15333. switch name {
  15334. case label.FieldCreatedAt:
  15335. return m.CreatedAt()
  15336. case label.FieldUpdatedAt:
  15337. return m.UpdatedAt()
  15338. case label.FieldStatus:
  15339. return m.Status()
  15340. case label.FieldType:
  15341. return m.GetType()
  15342. case label.FieldName:
  15343. return m.Name()
  15344. case label.FieldFrom:
  15345. return m.From()
  15346. case label.FieldMode:
  15347. return m.Mode()
  15348. case label.FieldConditions:
  15349. return m.Conditions()
  15350. case label.FieldOrganizationID:
  15351. return m.OrganizationID()
  15352. }
  15353. return nil, false
  15354. }
  15355. // OldField returns the old value of the field from the database. An error is
  15356. // returned if the mutation operation is not UpdateOne, or the query to the
  15357. // database failed.
  15358. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15359. switch name {
  15360. case label.FieldCreatedAt:
  15361. return m.OldCreatedAt(ctx)
  15362. case label.FieldUpdatedAt:
  15363. return m.OldUpdatedAt(ctx)
  15364. case label.FieldStatus:
  15365. return m.OldStatus(ctx)
  15366. case label.FieldType:
  15367. return m.OldType(ctx)
  15368. case label.FieldName:
  15369. return m.OldName(ctx)
  15370. case label.FieldFrom:
  15371. return m.OldFrom(ctx)
  15372. case label.FieldMode:
  15373. return m.OldMode(ctx)
  15374. case label.FieldConditions:
  15375. return m.OldConditions(ctx)
  15376. case label.FieldOrganizationID:
  15377. return m.OldOrganizationID(ctx)
  15378. }
  15379. return nil, fmt.Errorf("unknown Label field %s", name)
  15380. }
  15381. // SetField sets the value of a field with the given name. It returns an error if
  15382. // the field is not defined in the schema, or if the type mismatched the field
  15383. // type.
  15384. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  15385. switch name {
  15386. case label.FieldCreatedAt:
  15387. v, ok := value.(time.Time)
  15388. if !ok {
  15389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15390. }
  15391. m.SetCreatedAt(v)
  15392. return nil
  15393. case label.FieldUpdatedAt:
  15394. v, ok := value.(time.Time)
  15395. if !ok {
  15396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15397. }
  15398. m.SetUpdatedAt(v)
  15399. return nil
  15400. case label.FieldStatus:
  15401. v, ok := value.(uint8)
  15402. if !ok {
  15403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15404. }
  15405. m.SetStatus(v)
  15406. return nil
  15407. case label.FieldType:
  15408. v, ok := value.(int)
  15409. if !ok {
  15410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15411. }
  15412. m.SetType(v)
  15413. return nil
  15414. case label.FieldName:
  15415. v, ok := value.(string)
  15416. if !ok {
  15417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15418. }
  15419. m.SetName(v)
  15420. return nil
  15421. case label.FieldFrom:
  15422. v, ok := value.(int)
  15423. if !ok {
  15424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15425. }
  15426. m.SetFrom(v)
  15427. return nil
  15428. case label.FieldMode:
  15429. v, ok := value.(int)
  15430. if !ok {
  15431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15432. }
  15433. m.SetMode(v)
  15434. return nil
  15435. case label.FieldConditions:
  15436. v, ok := value.(string)
  15437. if !ok {
  15438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15439. }
  15440. m.SetConditions(v)
  15441. return nil
  15442. case label.FieldOrganizationID:
  15443. v, ok := value.(uint64)
  15444. if !ok {
  15445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15446. }
  15447. m.SetOrganizationID(v)
  15448. return nil
  15449. }
  15450. return fmt.Errorf("unknown Label field %s", name)
  15451. }
  15452. // AddedFields returns all numeric fields that were incremented/decremented during
  15453. // this mutation.
  15454. func (m *LabelMutation) AddedFields() []string {
  15455. var fields []string
  15456. if m.addstatus != nil {
  15457. fields = append(fields, label.FieldStatus)
  15458. }
  15459. if m.add_type != nil {
  15460. fields = append(fields, label.FieldType)
  15461. }
  15462. if m.addfrom != nil {
  15463. fields = append(fields, label.FieldFrom)
  15464. }
  15465. if m.addmode != nil {
  15466. fields = append(fields, label.FieldMode)
  15467. }
  15468. if m.addorganization_id != nil {
  15469. fields = append(fields, label.FieldOrganizationID)
  15470. }
  15471. return fields
  15472. }
  15473. // AddedField returns the numeric value that was incremented/decremented on a field
  15474. // with the given name. The second boolean return value indicates that this field
  15475. // was not set, or was not defined in the schema.
  15476. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  15477. switch name {
  15478. case label.FieldStatus:
  15479. return m.AddedStatus()
  15480. case label.FieldType:
  15481. return m.AddedType()
  15482. case label.FieldFrom:
  15483. return m.AddedFrom()
  15484. case label.FieldMode:
  15485. return m.AddedMode()
  15486. case label.FieldOrganizationID:
  15487. return m.AddedOrganizationID()
  15488. }
  15489. return nil, false
  15490. }
  15491. // AddField adds the value to the field with the given name. It returns an error if
  15492. // the field is not defined in the schema, or if the type mismatched the field
  15493. // type.
  15494. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  15495. switch name {
  15496. case label.FieldStatus:
  15497. v, ok := value.(int8)
  15498. if !ok {
  15499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15500. }
  15501. m.AddStatus(v)
  15502. return nil
  15503. case label.FieldType:
  15504. v, ok := value.(int)
  15505. if !ok {
  15506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15507. }
  15508. m.AddType(v)
  15509. return nil
  15510. case label.FieldFrom:
  15511. v, ok := value.(int)
  15512. if !ok {
  15513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15514. }
  15515. m.AddFrom(v)
  15516. return nil
  15517. case label.FieldMode:
  15518. v, ok := value.(int)
  15519. if !ok {
  15520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15521. }
  15522. m.AddMode(v)
  15523. return nil
  15524. case label.FieldOrganizationID:
  15525. v, ok := value.(int64)
  15526. if !ok {
  15527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15528. }
  15529. m.AddOrganizationID(v)
  15530. return nil
  15531. }
  15532. return fmt.Errorf("unknown Label numeric field %s", name)
  15533. }
  15534. // ClearedFields returns all nullable fields that were cleared during this
  15535. // mutation.
  15536. func (m *LabelMutation) ClearedFields() []string {
  15537. var fields []string
  15538. if m.FieldCleared(label.FieldStatus) {
  15539. fields = append(fields, label.FieldStatus)
  15540. }
  15541. if m.FieldCleared(label.FieldConditions) {
  15542. fields = append(fields, label.FieldConditions)
  15543. }
  15544. if m.FieldCleared(label.FieldOrganizationID) {
  15545. fields = append(fields, label.FieldOrganizationID)
  15546. }
  15547. return fields
  15548. }
  15549. // FieldCleared returns a boolean indicating if a field with the given name was
  15550. // cleared in this mutation.
  15551. func (m *LabelMutation) FieldCleared(name string) bool {
  15552. _, ok := m.clearedFields[name]
  15553. return ok
  15554. }
  15555. // ClearField clears the value of the field with the given name. It returns an
  15556. // error if the field is not defined in the schema.
  15557. func (m *LabelMutation) ClearField(name string) error {
  15558. switch name {
  15559. case label.FieldStatus:
  15560. m.ClearStatus()
  15561. return nil
  15562. case label.FieldConditions:
  15563. m.ClearConditions()
  15564. return nil
  15565. case label.FieldOrganizationID:
  15566. m.ClearOrganizationID()
  15567. return nil
  15568. }
  15569. return fmt.Errorf("unknown Label nullable field %s", name)
  15570. }
  15571. // ResetField resets all changes in the mutation for the field with the given name.
  15572. // It returns an error if the field is not defined in the schema.
  15573. func (m *LabelMutation) ResetField(name string) error {
  15574. switch name {
  15575. case label.FieldCreatedAt:
  15576. m.ResetCreatedAt()
  15577. return nil
  15578. case label.FieldUpdatedAt:
  15579. m.ResetUpdatedAt()
  15580. return nil
  15581. case label.FieldStatus:
  15582. m.ResetStatus()
  15583. return nil
  15584. case label.FieldType:
  15585. m.ResetType()
  15586. return nil
  15587. case label.FieldName:
  15588. m.ResetName()
  15589. return nil
  15590. case label.FieldFrom:
  15591. m.ResetFrom()
  15592. return nil
  15593. case label.FieldMode:
  15594. m.ResetMode()
  15595. return nil
  15596. case label.FieldConditions:
  15597. m.ResetConditions()
  15598. return nil
  15599. case label.FieldOrganizationID:
  15600. m.ResetOrganizationID()
  15601. return nil
  15602. }
  15603. return fmt.Errorf("unknown Label field %s", name)
  15604. }
  15605. // AddedEdges returns all edge names that were set/added in this mutation.
  15606. func (m *LabelMutation) AddedEdges() []string {
  15607. edges := make([]string, 0, 1)
  15608. if m.label_relationships != nil {
  15609. edges = append(edges, label.EdgeLabelRelationships)
  15610. }
  15611. return edges
  15612. }
  15613. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15614. // name in this mutation.
  15615. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  15616. switch name {
  15617. case label.EdgeLabelRelationships:
  15618. ids := make([]ent.Value, 0, len(m.label_relationships))
  15619. for id := range m.label_relationships {
  15620. ids = append(ids, id)
  15621. }
  15622. return ids
  15623. }
  15624. return nil
  15625. }
  15626. // RemovedEdges returns all edge names that were removed in this mutation.
  15627. func (m *LabelMutation) RemovedEdges() []string {
  15628. edges := make([]string, 0, 1)
  15629. if m.removedlabel_relationships != nil {
  15630. edges = append(edges, label.EdgeLabelRelationships)
  15631. }
  15632. return edges
  15633. }
  15634. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15635. // the given name in this mutation.
  15636. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  15637. switch name {
  15638. case label.EdgeLabelRelationships:
  15639. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  15640. for id := range m.removedlabel_relationships {
  15641. ids = append(ids, id)
  15642. }
  15643. return ids
  15644. }
  15645. return nil
  15646. }
  15647. // ClearedEdges returns all edge names that were cleared in this mutation.
  15648. func (m *LabelMutation) ClearedEdges() []string {
  15649. edges := make([]string, 0, 1)
  15650. if m.clearedlabel_relationships {
  15651. edges = append(edges, label.EdgeLabelRelationships)
  15652. }
  15653. return edges
  15654. }
  15655. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15656. // was cleared in this mutation.
  15657. func (m *LabelMutation) EdgeCleared(name string) bool {
  15658. switch name {
  15659. case label.EdgeLabelRelationships:
  15660. return m.clearedlabel_relationships
  15661. }
  15662. return false
  15663. }
  15664. // ClearEdge clears the value of the edge with the given name. It returns an error
  15665. // if that edge is not defined in the schema.
  15666. func (m *LabelMutation) ClearEdge(name string) error {
  15667. switch name {
  15668. }
  15669. return fmt.Errorf("unknown Label unique edge %s", name)
  15670. }
  15671. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15672. // It returns an error if the edge is not defined in the schema.
  15673. func (m *LabelMutation) ResetEdge(name string) error {
  15674. switch name {
  15675. case label.EdgeLabelRelationships:
  15676. m.ResetLabelRelationships()
  15677. return nil
  15678. }
  15679. return fmt.Errorf("unknown Label edge %s", name)
  15680. }
  15681. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  15682. type LabelRelationshipMutation struct {
  15683. config
  15684. op Op
  15685. typ string
  15686. id *uint64
  15687. created_at *time.Time
  15688. updated_at *time.Time
  15689. status *uint8
  15690. addstatus *int8
  15691. organization_id *uint64
  15692. addorganization_id *int64
  15693. clearedFields map[string]struct{}
  15694. contacts *uint64
  15695. clearedcontacts bool
  15696. labels *uint64
  15697. clearedlabels bool
  15698. done bool
  15699. oldValue func(context.Context) (*LabelRelationship, error)
  15700. predicates []predicate.LabelRelationship
  15701. }
  15702. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  15703. // labelrelationshipOption allows management of the mutation configuration using functional options.
  15704. type labelrelationshipOption func(*LabelRelationshipMutation)
  15705. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  15706. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  15707. m := &LabelRelationshipMutation{
  15708. config: c,
  15709. op: op,
  15710. typ: TypeLabelRelationship,
  15711. clearedFields: make(map[string]struct{}),
  15712. }
  15713. for _, opt := range opts {
  15714. opt(m)
  15715. }
  15716. return m
  15717. }
  15718. // withLabelRelationshipID sets the ID field of the mutation.
  15719. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  15720. return func(m *LabelRelationshipMutation) {
  15721. var (
  15722. err error
  15723. once sync.Once
  15724. value *LabelRelationship
  15725. )
  15726. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  15727. once.Do(func() {
  15728. if m.done {
  15729. err = errors.New("querying old values post mutation is not allowed")
  15730. } else {
  15731. value, err = m.Client().LabelRelationship.Get(ctx, id)
  15732. }
  15733. })
  15734. return value, err
  15735. }
  15736. m.id = &id
  15737. }
  15738. }
  15739. // withLabelRelationship sets the old LabelRelationship of the mutation.
  15740. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  15741. return func(m *LabelRelationshipMutation) {
  15742. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  15743. return node, nil
  15744. }
  15745. m.id = &node.ID
  15746. }
  15747. }
  15748. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15749. // executed in a transaction (ent.Tx), a transactional client is returned.
  15750. func (m LabelRelationshipMutation) Client() *Client {
  15751. client := &Client{config: m.config}
  15752. client.init()
  15753. return client
  15754. }
  15755. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15756. // it returns an error otherwise.
  15757. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  15758. if _, ok := m.driver.(*txDriver); !ok {
  15759. return nil, errors.New("ent: mutation is not running in a transaction")
  15760. }
  15761. tx := &Tx{config: m.config}
  15762. tx.init()
  15763. return tx, nil
  15764. }
  15765. // SetID sets the value of the id field. Note that this
  15766. // operation is only accepted on creation of LabelRelationship entities.
  15767. func (m *LabelRelationshipMutation) SetID(id uint64) {
  15768. m.id = &id
  15769. }
  15770. // ID returns the ID value in the mutation. Note that the ID is only available
  15771. // if it was provided to the builder or after it was returned from the database.
  15772. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  15773. if m.id == nil {
  15774. return
  15775. }
  15776. return *m.id, true
  15777. }
  15778. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15779. // That means, if the mutation is applied within a transaction with an isolation level such
  15780. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15781. // or updated by the mutation.
  15782. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  15783. switch {
  15784. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15785. id, exists := m.ID()
  15786. if exists {
  15787. return []uint64{id}, nil
  15788. }
  15789. fallthrough
  15790. case m.op.Is(OpUpdate | OpDelete):
  15791. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  15792. default:
  15793. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15794. }
  15795. }
  15796. // SetCreatedAt sets the "created_at" field.
  15797. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  15798. m.created_at = &t
  15799. }
  15800. // CreatedAt returns the value of the "created_at" field in the mutation.
  15801. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  15802. v := m.created_at
  15803. if v == nil {
  15804. return
  15805. }
  15806. return *v, true
  15807. }
  15808. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  15809. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15811. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15812. if !m.op.Is(OpUpdateOne) {
  15813. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15814. }
  15815. if m.id == nil || m.oldValue == nil {
  15816. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15817. }
  15818. oldValue, err := m.oldValue(ctx)
  15819. if err != nil {
  15820. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15821. }
  15822. return oldValue.CreatedAt, nil
  15823. }
  15824. // ResetCreatedAt resets all changes to the "created_at" field.
  15825. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  15826. m.created_at = nil
  15827. }
  15828. // SetUpdatedAt sets the "updated_at" field.
  15829. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  15830. m.updated_at = &t
  15831. }
  15832. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15833. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  15834. v := m.updated_at
  15835. if v == nil {
  15836. return
  15837. }
  15838. return *v, true
  15839. }
  15840. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  15841. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15843. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15844. if !m.op.Is(OpUpdateOne) {
  15845. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15846. }
  15847. if m.id == nil || m.oldValue == nil {
  15848. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15849. }
  15850. oldValue, err := m.oldValue(ctx)
  15851. if err != nil {
  15852. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15853. }
  15854. return oldValue.UpdatedAt, nil
  15855. }
  15856. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15857. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  15858. m.updated_at = nil
  15859. }
  15860. // SetStatus sets the "status" field.
  15861. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  15862. m.status = &u
  15863. m.addstatus = nil
  15864. }
  15865. // Status returns the value of the "status" field in the mutation.
  15866. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  15867. v := m.status
  15868. if v == nil {
  15869. return
  15870. }
  15871. return *v, true
  15872. }
  15873. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  15874. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15876. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15877. if !m.op.Is(OpUpdateOne) {
  15878. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15879. }
  15880. if m.id == nil || m.oldValue == nil {
  15881. return v, errors.New("OldStatus requires an ID field in the mutation")
  15882. }
  15883. oldValue, err := m.oldValue(ctx)
  15884. if err != nil {
  15885. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15886. }
  15887. return oldValue.Status, nil
  15888. }
  15889. // AddStatus adds u to the "status" field.
  15890. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  15891. if m.addstatus != nil {
  15892. *m.addstatus += u
  15893. } else {
  15894. m.addstatus = &u
  15895. }
  15896. }
  15897. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15898. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  15899. v := m.addstatus
  15900. if v == nil {
  15901. return
  15902. }
  15903. return *v, true
  15904. }
  15905. // ClearStatus clears the value of the "status" field.
  15906. func (m *LabelRelationshipMutation) ClearStatus() {
  15907. m.status = nil
  15908. m.addstatus = nil
  15909. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  15910. }
  15911. // StatusCleared returns if the "status" field was cleared in this mutation.
  15912. func (m *LabelRelationshipMutation) StatusCleared() bool {
  15913. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  15914. return ok
  15915. }
  15916. // ResetStatus resets all changes to the "status" field.
  15917. func (m *LabelRelationshipMutation) ResetStatus() {
  15918. m.status = nil
  15919. m.addstatus = nil
  15920. delete(m.clearedFields, labelrelationship.FieldStatus)
  15921. }
  15922. // SetLabelID sets the "label_id" field.
  15923. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  15924. m.labels = &u
  15925. }
  15926. // LabelID returns the value of the "label_id" field in the mutation.
  15927. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  15928. v := m.labels
  15929. if v == nil {
  15930. return
  15931. }
  15932. return *v, true
  15933. }
  15934. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  15935. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15937. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  15938. if !m.op.Is(OpUpdateOne) {
  15939. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  15940. }
  15941. if m.id == nil || m.oldValue == nil {
  15942. return v, errors.New("OldLabelID requires an ID field in the mutation")
  15943. }
  15944. oldValue, err := m.oldValue(ctx)
  15945. if err != nil {
  15946. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  15947. }
  15948. return oldValue.LabelID, nil
  15949. }
  15950. // ResetLabelID resets all changes to the "label_id" field.
  15951. func (m *LabelRelationshipMutation) ResetLabelID() {
  15952. m.labels = nil
  15953. }
  15954. // SetContactID sets the "contact_id" field.
  15955. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  15956. m.contacts = &u
  15957. }
  15958. // ContactID returns the value of the "contact_id" field in the mutation.
  15959. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  15960. v := m.contacts
  15961. if v == nil {
  15962. return
  15963. }
  15964. return *v, true
  15965. }
  15966. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  15967. // If the LabelRelationship 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 *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15970. if !m.op.Is(OpUpdateOne) {
  15971. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15972. }
  15973. if m.id == nil || m.oldValue == nil {
  15974. return v, errors.New("OldContactID 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 OldContactID: %w", err)
  15979. }
  15980. return oldValue.ContactID, nil
  15981. }
  15982. // ResetContactID resets all changes to the "contact_id" field.
  15983. func (m *LabelRelationshipMutation) ResetContactID() {
  15984. m.contacts = nil
  15985. }
  15986. // SetOrganizationID sets the "organization_id" field.
  15987. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  15988. m.organization_id = &u
  15989. m.addorganization_id = nil
  15990. }
  15991. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15992. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  15993. v := m.organization_id
  15994. if v == nil {
  15995. return
  15996. }
  15997. return *v, true
  15998. }
  15999. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  16000. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16002. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16003. if !m.op.Is(OpUpdateOne) {
  16004. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16005. }
  16006. if m.id == nil || m.oldValue == nil {
  16007. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16008. }
  16009. oldValue, err := m.oldValue(ctx)
  16010. if err != nil {
  16011. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16012. }
  16013. return oldValue.OrganizationID, nil
  16014. }
  16015. // AddOrganizationID adds u to the "organization_id" field.
  16016. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  16017. if m.addorganization_id != nil {
  16018. *m.addorganization_id += u
  16019. } else {
  16020. m.addorganization_id = &u
  16021. }
  16022. }
  16023. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16024. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  16025. v := m.addorganization_id
  16026. if v == nil {
  16027. return
  16028. }
  16029. return *v, true
  16030. }
  16031. // ClearOrganizationID clears the value of the "organization_id" field.
  16032. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  16033. m.organization_id = nil
  16034. m.addorganization_id = nil
  16035. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  16036. }
  16037. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16038. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  16039. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  16040. return ok
  16041. }
  16042. // ResetOrganizationID resets all changes to the "organization_id" field.
  16043. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  16044. m.organization_id = nil
  16045. m.addorganization_id = nil
  16046. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  16047. }
  16048. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  16049. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  16050. m.contacts = &id
  16051. }
  16052. // ClearContacts clears the "contacts" edge to the Contact entity.
  16053. func (m *LabelRelationshipMutation) ClearContacts() {
  16054. m.clearedcontacts = true
  16055. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  16056. }
  16057. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  16058. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  16059. return m.clearedcontacts
  16060. }
  16061. // ContactsID returns the "contacts" edge ID in the mutation.
  16062. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  16063. if m.contacts != nil {
  16064. return *m.contacts, true
  16065. }
  16066. return
  16067. }
  16068. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  16069. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16070. // ContactsID instead. It exists only for internal usage by the builders.
  16071. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  16072. if id := m.contacts; id != nil {
  16073. ids = append(ids, *id)
  16074. }
  16075. return
  16076. }
  16077. // ResetContacts resets all changes to the "contacts" edge.
  16078. func (m *LabelRelationshipMutation) ResetContacts() {
  16079. m.contacts = nil
  16080. m.clearedcontacts = false
  16081. }
  16082. // SetLabelsID sets the "labels" edge to the Label entity by id.
  16083. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  16084. m.labels = &id
  16085. }
  16086. // ClearLabels clears the "labels" edge to the Label entity.
  16087. func (m *LabelRelationshipMutation) ClearLabels() {
  16088. m.clearedlabels = true
  16089. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  16090. }
  16091. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  16092. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  16093. return m.clearedlabels
  16094. }
  16095. // LabelsID returns the "labels" edge ID in the mutation.
  16096. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  16097. if m.labels != nil {
  16098. return *m.labels, true
  16099. }
  16100. return
  16101. }
  16102. // LabelsIDs returns the "labels" edge IDs in the mutation.
  16103. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16104. // LabelsID instead. It exists only for internal usage by the builders.
  16105. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  16106. if id := m.labels; id != nil {
  16107. ids = append(ids, *id)
  16108. }
  16109. return
  16110. }
  16111. // ResetLabels resets all changes to the "labels" edge.
  16112. func (m *LabelRelationshipMutation) ResetLabels() {
  16113. m.labels = nil
  16114. m.clearedlabels = false
  16115. }
  16116. // Where appends a list predicates to the LabelRelationshipMutation builder.
  16117. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  16118. m.predicates = append(m.predicates, ps...)
  16119. }
  16120. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  16121. // users can use type-assertion to append predicates that do not depend on any generated package.
  16122. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  16123. p := make([]predicate.LabelRelationship, len(ps))
  16124. for i := range ps {
  16125. p[i] = ps[i]
  16126. }
  16127. m.Where(p...)
  16128. }
  16129. // Op returns the operation name.
  16130. func (m *LabelRelationshipMutation) Op() Op {
  16131. return m.op
  16132. }
  16133. // SetOp allows setting the mutation operation.
  16134. func (m *LabelRelationshipMutation) SetOp(op Op) {
  16135. m.op = op
  16136. }
  16137. // Type returns the node type of this mutation (LabelRelationship).
  16138. func (m *LabelRelationshipMutation) Type() string {
  16139. return m.typ
  16140. }
  16141. // Fields returns all fields that were changed during this mutation. Note that in
  16142. // order to get all numeric fields that were incremented/decremented, call
  16143. // AddedFields().
  16144. func (m *LabelRelationshipMutation) Fields() []string {
  16145. fields := make([]string, 0, 6)
  16146. if m.created_at != nil {
  16147. fields = append(fields, labelrelationship.FieldCreatedAt)
  16148. }
  16149. if m.updated_at != nil {
  16150. fields = append(fields, labelrelationship.FieldUpdatedAt)
  16151. }
  16152. if m.status != nil {
  16153. fields = append(fields, labelrelationship.FieldStatus)
  16154. }
  16155. if m.labels != nil {
  16156. fields = append(fields, labelrelationship.FieldLabelID)
  16157. }
  16158. if m.contacts != nil {
  16159. fields = append(fields, labelrelationship.FieldContactID)
  16160. }
  16161. if m.organization_id != nil {
  16162. fields = append(fields, labelrelationship.FieldOrganizationID)
  16163. }
  16164. return fields
  16165. }
  16166. // Field returns the value of a field with the given name. The second boolean
  16167. // return value indicates that this field was not set, or was not defined in the
  16168. // schema.
  16169. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  16170. switch name {
  16171. case labelrelationship.FieldCreatedAt:
  16172. return m.CreatedAt()
  16173. case labelrelationship.FieldUpdatedAt:
  16174. return m.UpdatedAt()
  16175. case labelrelationship.FieldStatus:
  16176. return m.Status()
  16177. case labelrelationship.FieldLabelID:
  16178. return m.LabelID()
  16179. case labelrelationship.FieldContactID:
  16180. return m.ContactID()
  16181. case labelrelationship.FieldOrganizationID:
  16182. return m.OrganizationID()
  16183. }
  16184. return nil, false
  16185. }
  16186. // OldField returns the old value of the field from the database. An error is
  16187. // returned if the mutation operation is not UpdateOne, or the query to the
  16188. // database failed.
  16189. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16190. switch name {
  16191. case labelrelationship.FieldCreatedAt:
  16192. return m.OldCreatedAt(ctx)
  16193. case labelrelationship.FieldUpdatedAt:
  16194. return m.OldUpdatedAt(ctx)
  16195. case labelrelationship.FieldStatus:
  16196. return m.OldStatus(ctx)
  16197. case labelrelationship.FieldLabelID:
  16198. return m.OldLabelID(ctx)
  16199. case labelrelationship.FieldContactID:
  16200. return m.OldContactID(ctx)
  16201. case labelrelationship.FieldOrganizationID:
  16202. return m.OldOrganizationID(ctx)
  16203. }
  16204. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  16205. }
  16206. // SetField sets the value of a field with the given name. It returns an error if
  16207. // the field is not defined in the schema, or if the type mismatched the field
  16208. // type.
  16209. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  16210. switch name {
  16211. case labelrelationship.FieldCreatedAt:
  16212. v, ok := value.(time.Time)
  16213. if !ok {
  16214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16215. }
  16216. m.SetCreatedAt(v)
  16217. return nil
  16218. case labelrelationship.FieldUpdatedAt:
  16219. v, ok := value.(time.Time)
  16220. if !ok {
  16221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16222. }
  16223. m.SetUpdatedAt(v)
  16224. return nil
  16225. case labelrelationship.FieldStatus:
  16226. v, ok := value.(uint8)
  16227. if !ok {
  16228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16229. }
  16230. m.SetStatus(v)
  16231. return nil
  16232. case labelrelationship.FieldLabelID:
  16233. v, ok := value.(uint64)
  16234. if !ok {
  16235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16236. }
  16237. m.SetLabelID(v)
  16238. return nil
  16239. case labelrelationship.FieldContactID:
  16240. v, ok := value.(uint64)
  16241. if !ok {
  16242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16243. }
  16244. m.SetContactID(v)
  16245. return nil
  16246. case labelrelationship.FieldOrganizationID:
  16247. v, ok := value.(uint64)
  16248. if !ok {
  16249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16250. }
  16251. m.SetOrganizationID(v)
  16252. return nil
  16253. }
  16254. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16255. }
  16256. // AddedFields returns all numeric fields that were incremented/decremented during
  16257. // this mutation.
  16258. func (m *LabelRelationshipMutation) AddedFields() []string {
  16259. var fields []string
  16260. if m.addstatus != nil {
  16261. fields = append(fields, labelrelationship.FieldStatus)
  16262. }
  16263. if m.addorganization_id != nil {
  16264. fields = append(fields, labelrelationship.FieldOrganizationID)
  16265. }
  16266. return fields
  16267. }
  16268. // AddedField returns the numeric value that was incremented/decremented on a field
  16269. // with the given name. The second boolean return value indicates that this field
  16270. // was not set, or was not defined in the schema.
  16271. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  16272. switch name {
  16273. case labelrelationship.FieldStatus:
  16274. return m.AddedStatus()
  16275. case labelrelationship.FieldOrganizationID:
  16276. return m.AddedOrganizationID()
  16277. }
  16278. return nil, false
  16279. }
  16280. // AddField adds the value to the field with the given name. It returns an error if
  16281. // the field is not defined in the schema, or if the type mismatched the field
  16282. // type.
  16283. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  16284. switch name {
  16285. case labelrelationship.FieldStatus:
  16286. v, ok := value.(int8)
  16287. if !ok {
  16288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16289. }
  16290. m.AddStatus(v)
  16291. return nil
  16292. case labelrelationship.FieldOrganizationID:
  16293. v, ok := value.(int64)
  16294. if !ok {
  16295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16296. }
  16297. m.AddOrganizationID(v)
  16298. return nil
  16299. }
  16300. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  16301. }
  16302. // ClearedFields returns all nullable fields that were cleared during this
  16303. // mutation.
  16304. func (m *LabelRelationshipMutation) ClearedFields() []string {
  16305. var fields []string
  16306. if m.FieldCleared(labelrelationship.FieldStatus) {
  16307. fields = append(fields, labelrelationship.FieldStatus)
  16308. }
  16309. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  16310. fields = append(fields, labelrelationship.FieldOrganizationID)
  16311. }
  16312. return fields
  16313. }
  16314. // FieldCleared returns a boolean indicating if a field with the given name was
  16315. // cleared in this mutation.
  16316. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  16317. _, ok := m.clearedFields[name]
  16318. return ok
  16319. }
  16320. // ClearField clears the value of the field with the given name. It returns an
  16321. // error if the field is not defined in the schema.
  16322. func (m *LabelRelationshipMutation) ClearField(name string) error {
  16323. switch name {
  16324. case labelrelationship.FieldStatus:
  16325. m.ClearStatus()
  16326. return nil
  16327. case labelrelationship.FieldOrganizationID:
  16328. m.ClearOrganizationID()
  16329. return nil
  16330. }
  16331. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  16332. }
  16333. // ResetField resets all changes in the mutation for the field with the given name.
  16334. // It returns an error if the field is not defined in the schema.
  16335. func (m *LabelRelationshipMutation) ResetField(name string) error {
  16336. switch name {
  16337. case labelrelationship.FieldCreatedAt:
  16338. m.ResetCreatedAt()
  16339. return nil
  16340. case labelrelationship.FieldUpdatedAt:
  16341. m.ResetUpdatedAt()
  16342. return nil
  16343. case labelrelationship.FieldStatus:
  16344. m.ResetStatus()
  16345. return nil
  16346. case labelrelationship.FieldLabelID:
  16347. m.ResetLabelID()
  16348. return nil
  16349. case labelrelationship.FieldContactID:
  16350. m.ResetContactID()
  16351. return nil
  16352. case labelrelationship.FieldOrganizationID:
  16353. m.ResetOrganizationID()
  16354. return nil
  16355. }
  16356. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16357. }
  16358. // AddedEdges returns all edge names that were set/added in this mutation.
  16359. func (m *LabelRelationshipMutation) AddedEdges() []string {
  16360. edges := make([]string, 0, 2)
  16361. if m.contacts != nil {
  16362. edges = append(edges, labelrelationship.EdgeContacts)
  16363. }
  16364. if m.labels != nil {
  16365. edges = append(edges, labelrelationship.EdgeLabels)
  16366. }
  16367. return edges
  16368. }
  16369. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16370. // name in this mutation.
  16371. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  16372. switch name {
  16373. case labelrelationship.EdgeContacts:
  16374. if id := m.contacts; id != nil {
  16375. return []ent.Value{*id}
  16376. }
  16377. case labelrelationship.EdgeLabels:
  16378. if id := m.labels; id != nil {
  16379. return []ent.Value{*id}
  16380. }
  16381. }
  16382. return nil
  16383. }
  16384. // RemovedEdges returns all edge names that were removed in this mutation.
  16385. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  16386. edges := make([]string, 0, 2)
  16387. return edges
  16388. }
  16389. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16390. // the given name in this mutation.
  16391. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  16392. return nil
  16393. }
  16394. // ClearedEdges returns all edge names that were cleared in this mutation.
  16395. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  16396. edges := make([]string, 0, 2)
  16397. if m.clearedcontacts {
  16398. edges = append(edges, labelrelationship.EdgeContacts)
  16399. }
  16400. if m.clearedlabels {
  16401. edges = append(edges, labelrelationship.EdgeLabels)
  16402. }
  16403. return edges
  16404. }
  16405. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16406. // was cleared in this mutation.
  16407. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  16408. switch name {
  16409. case labelrelationship.EdgeContacts:
  16410. return m.clearedcontacts
  16411. case labelrelationship.EdgeLabels:
  16412. return m.clearedlabels
  16413. }
  16414. return false
  16415. }
  16416. // ClearEdge clears the value of the edge with the given name. It returns an error
  16417. // if that edge is not defined in the schema.
  16418. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  16419. switch name {
  16420. case labelrelationship.EdgeContacts:
  16421. m.ClearContacts()
  16422. return nil
  16423. case labelrelationship.EdgeLabels:
  16424. m.ClearLabels()
  16425. return nil
  16426. }
  16427. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  16428. }
  16429. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16430. // It returns an error if the edge is not defined in the schema.
  16431. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  16432. switch name {
  16433. case labelrelationship.EdgeContacts:
  16434. m.ResetContacts()
  16435. return nil
  16436. case labelrelationship.EdgeLabels:
  16437. m.ResetLabels()
  16438. return nil
  16439. }
  16440. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  16441. }
  16442. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  16443. type LabelTaggingMutation struct {
  16444. config
  16445. op Op
  16446. typ string
  16447. id *uint64
  16448. created_at *time.Time
  16449. updated_at *time.Time
  16450. status *uint8
  16451. addstatus *int8
  16452. deleted_at *time.Time
  16453. organization_id *uint64
  16454. addorganization_id *int64
  16455. _type *int
  16456. add_type *int
  16457. conditions *string
  16458. action_label_add *[]uint64
  16459. appendaction_label_add []uint64
  16460. action_label_del *[]uint64
  16461. appendaction_label_del []uint64
  16462. clearedFields map[string]struct{}
  16463. done bool
  16464. oldValue func(context.Context) (*LabelTagging, error)
  16465. predicates []predicate.LabelTagging
  16466. }
  16467. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  16468. // labeltaggingOption allows management of the mutation configuration using functional options.
  16469. type labeltaggingOption func(*LabelTaggingMutation)
  16470. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  16471. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  16472. m := &LabelTaggingMutation{
  16473. config: c,
  16474. op: op,
  16475. typ: TypeLabelTagging,
  16476. clearedFields: make(map[string]struct{}),
  16477. }
  16478. for _, opt := range opts {
  16479. opt(m)
  16480. }
  16481. return m
  16482. }
  16483. // withLabelTaggingID sets the ID field of the mutation.
  16484. func withLabelTaggingID(id uint64) labeltaggingOption {
  16485. return func(m *LabelTaggingMutation) {
  16486. var (
  16487. err error
  16488. once sync.Once
  16489. value *LabelTagging
  16490. )
  16491. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  16492. once.Do(func() {
  16493. if m.done {
  16494. err = errors.New("querying old values post mutation is not allowed")
  16495. } else {
  16496. value, err = m.Client().LabelTagging.Get(ctx, id)
  16497. }
  16498. })
  16499. return value, err
  16500. }
  16501. m.id = &id
  16502. }
  16503. }
  16504. // withLabelTagging sets the old LabelTagging of the mutation.
  16505. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  16506. return func(m *LabelTaggingMutation) {
  16507. m.oldValue = func(context.Context) (*LabelTagging, error) {
  16508. return node, nil
  16509. }
  16510. m.id = &node.ID
  16511. }
  16512. }
  16513. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16514. // executed in a transaction (ent.Tx), a transactional client is returned.
  16515. func (m LabelTaggingMutation) Client() *Client {
  16516. client := &Client{config: m.config}
  16517. client.init()
  16518. return client
  16519. }
  16520. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16521. // it returns an error otherwise.
  16522. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  16523. if _, ok := m.driver.(*txDriver); !ok {
  16524. return nil, errors.New("ent: mutation is not running in a transaction")
  16525. }
  16526. tx := &Tx{config: m.config}
  16527. tx.init()
  16528. return tx, nil
  16529. }
  16530. // SetID sets the value of the id field. Note that this
  16531. // operation is only accepted on creation of LabelTagging entities.
  16532. func (m *LabelTaggingMutation) SetID(id uint64) {
  16533. m.id = &id
  16534. }
  16535. // ID returns the ID value in the mutation. Note that the ID is only available
  16536. // if it was provided to the builder or after it was returned from the database.
  16537. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  16538. if m.id == nil {
  16539. return
  16540. }
  16541. return *m.id, true
  16542. }
  16543. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16544. // That means, if the mutation is applied within a transaction with an isolation level such
  16545. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16546. // or updated by the mutation.
  16547. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  16548. switch {
  16549. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16550. id, exists := m.ID()
  16551. if exists {
  16552. return []uint64{id}, nil
  16553. }
  16554. fallthrough
  16555. case m.op.Is(OpUpdate | OpDelete):
  16556. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  16557. default:
  16558. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16559. }
  16560. }
  16561. // SetCreatedAt sets the "created_at" field.
  16562. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  16563. m.created_at = &t
  16564. }
  16565. // CreatedAt returns the value of the "created_at" field in the mutation.
  16566. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  16567. v := m.created_at
  16568. if v == nil {
  16569. return
  16570. }
  16571. return *v, true
  16572. }
  16573. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  16574. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16576. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16577. if !m.op.Is(OpUpdateOne) {
  16578. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16579. }
  16580. if m.id == nil || m.oldValue == nil {
  16581. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16582. }
  16583. oldValue, err := m.oldValue(ctx)
  16584. if err != nil {
  16585. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16586. }
  16587. return oldValue.CreatedAt, nil
  16588. }
  16589. // ResetCreatedAt resets all changes to the "created_at" field.
  16590. func (m *LabelTaggingMutation) ResetCreatedAt() {
  16591. m.created_at = nil
  16592. }
  16593. // SetUpdatedAt sets the "updated_at" field.
  16594. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  16595. m.updated_at = &t
  16596. }
  16597. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16598. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  16599. v := m.updated_at
  16600. if v == nil {
  16601. return
  16602. }
  16603. return *v, true
  16604. }
  16605. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  16606. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16608. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16609. if !m.op.Is(OpUpdateOne) {
  16610. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16611. }
  16612. if m.id == nil || m.oldValue == nil {
  16613. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16614. }
  16615. oldValue, err := m.oldValue(ctx)
  16616. if err != nil {
  16617. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16618. }
  16619. return oldValue.UpdatedAt, nil
  16620. }
  16621. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16622. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  16623. m.updated_at = nil
  16624. }
  16625. // SetStatus sets the "status" field.
  16626. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  16627. m.status = &u
  16628. m.addstatus = nil
  16629. }
  16630. // Status returns the value of the "status" field in the mutation.
  16631. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  16632. v := m.status
  16633. if v == nil {
  16634. return
  16635. }
  16636. return *v, true
  16637. }
  16638. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  16639. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16641. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16642. if !m.op.Is(OpUpdateOne) {
  16643. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16644. }
  16645. if m.id == nil || m.oldValue == nil {
  16646. return v, errors.New("OldStatus requires an ID field in the mutation")
  16647. }
  16648. oldValue, err := m.oldValue(ctx)
  16649. if err != nil {
  16650. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16651. }
  16652. return oldValue.Status, nil
  16653. }
  16654. // AddStatus adds u to the "status" field.
  16655. func (m *LabelTaggingMutation) AddStatus(u int8) {
  16656. if m.addstatus != nil {
  16657. *m.addstatus += u
  16658. } else {
  16659. m.addstatus = &u
  16660. }
  16661. }
  16662. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16663. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  16664. v := m.addstatus
  16665. if v == nil {
  16666. return
  16667. }
  16668. return *v, true
  16669. }
  16670. // ClearStatus clears the value of the "status" field.
  16671. func (m *LabelTaggingMutation) ClearStatus() {
  16672. m.status = nil
  16673. m.addstatus = nil
  16674. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  16675. }
  16676. // StatusCleared returns if the "status" field was cleared in this mutation.
  16677. func (m *LabelTaggingMutation) StatusCleared() bool {
  16678. _, ok := m.clearedFields[labeltagging.FieldStatus]
  16679. return ok
  16680. }
  16681. // ResetStatus resets all changes to the "status" field.
  16682. func (m *LabelTaggingMutation) ResetStatus() {
  16683. m.status = nil
  16684. m.addstatus = nil
  16685. delete(m.clearedFields, labeltagging.FieldStatus)
  16686. }
  16687. // SetDeletedAt sets the "deleted_at" field.
  16688. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  16689. m.deleted_at = &t
  16690. }
  16691. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16692. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  16693. v := m.deleted_at
  16694. if v == nil {
  16695. return
  16696. }
  16697. return *v, true
  16698. }
  16699. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  16700. // If the LabelTagging 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 *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16703. if !m.op.Is(OpUpdateOne) {
  16704. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16705. }
  16706. if m.id == nil || m.oldValue == nil {
  16707. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  16712. }
  16713. return oldValue.DeletedAt, nil
  16714. }
  16715. // ClearDeletedAt clears the value of the "deleted_at" field.
  16716. func (m *LabelTaggingMutation) ClearDeletedAt() {
  16717. m.deleted_at = nil
  16718. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  16719. }
  16720. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16721. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  16722. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  16723. return ok
  16724. }
  16725. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16726. func (m *LabelTaggingMutation) ResetDeletedAt() {
  16727. m.deleted_at = nil
  16728. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  16729. }
  16730. // SetOrganizationID sets the "organization_id" field.
  16731. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  16732. m.organization_id = &u
  16733. m.addorganization_id = nil
  16734. }
  16735. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16736. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  16737. v := m.organization_id
  16738. if v == nil {
  16739. return
  16740. }
  16741. return *v, true
  16742. }
  16743. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  16744. // If the LabelTagging 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 *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16747. if !m.op.Is(OpUpdateOne) {
  16748. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16749. }
  16750. if m.id == nil || m.oldValue == nil {
  16751. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  16756. }
  16757. return oldValue.OrganizationID, nil
  16758. }
  16759. // AddOrganizationID adds u to the "organization_id" field.
  16760. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  16761. if m.addorganization_id != nil {
  16762. *m.addorganization_id += u
  16763. } else {
  16764. m.addorganization_id = &u
  16765. }
  16766. }
  16767. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16768. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  16769. v := m.addorganization_id
  16770. if v == nil {
  16771. return
  16772. }
  16773. return *v, true
  16774. }
  16775. // ResetOrganizationID resets all changes to the "organization_id" field.
  16776. func (m *LabelTaggingMutation) ResetOrganizationID() {
  16777. m.organization_id = nil
  16778. m.addorganization_id = nil
  16779. }
  16780. // SetType sets the "type" field.
  16781. func (m *LabelTaggingMutation) SetType(i int) {
  16782. m._type = &i
  16783. m.add_type = nil
  16784. }
  16785. // GetType returns the value of the "type" field in the mutation.
  16786. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  16787. v := m._type
  16788. if v == nil {
  16789. return
  16790. }
  16791. return *v, true
  16792. }
  16793. // OldType returns the old "type" field's value of the LabelTagging entity.
  16794. // If the LabelTagging 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 *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  16797. if !m.op.Is(OpUpdateOne) {
  16798. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16799. }
  16800. if m.id == nil || m.oldValue == nil {
  16801. return v, errors.New("OldType 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 OldType: %w", err)
  16806. }
  16807. return oldValue.Type, nil
  16808. }
  16809. // AddType adds i to the "type" field.
  16810. func (m *LabelTaggingMutation) AddType(i int) {
  16811. if m.add_type != nil {
  16812. *m.add_type += i
  16813. } else {
  16814. m.add_type = &i
  16815. }
  16816. }
  16817. // AddedType returns the value that was added to the "type" field in this mutation.
  16818. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  16819. v := m.add_type
  16820. if v == nil {
  16821. return
  16822. }
  16823. return *v, true
  16824. }
  16825. // ResetType resets all changes to the "type" field.
  16826. func (m *LabelTaggingMutation) ResetType() {
  16827. m._type = nil
  16828. m.add_type = nil
  16829. }
  16830. // SetConditions sets the "conditions" field.
  16831. func (m *LabelTaggingMutation) SetConditions(s string) {
  16832. m.conditions = &s
  16833. }
  16834. // Conditions returns the value of the "conditions" field in the mutation.
  16835. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  16836. v := m.conditions
  16837. if v == nil {
  16838. return
  16839. }
  16840. return *v, true
  16841. }
  16842. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  16843. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16845. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  16846. if !m.op.Is(OpUpdateOne) {
  16847. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16848. }
  16849. if m.id == nil || m.oldValue == nil {
  16850. return v, errors.New("OldConditions requires an ID field in the mutation")
  16851. }
  16852. oldValue, err := m.oldValue(ctx)
  16853. if err != nil {
  16854. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16855. }
  16856. return oldValue.Conditions, nil
  16857. }
  16858. // ResetConditions resets all changes to the "conditions" field.
  16859. func (m *LabelTaggingMutation) ResetConditions() {
  16860. m.conditions = nil
  16861. }
  16862. // SetActionLabelAdd sets the "action_label_add" field.
  16863. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  16864. m.action_label_add = &u
  16865. m.appendaction_label_add = nil
  16866. }
  16867. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16868. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16869. v := m.action_label_add
  16870. if v == nil {
  16871. return
  16872. }
  16873. return *v, true
  16874. }
  16875. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  16876. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16878. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16879. if !m.op.Is(OpUpdateOne) {
  16880. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16881. }
  16882. if m.id == nil || m.oldValue == nil {
  16883. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16884. }
  16885. oldValue, err := m.oldValue(ctx)
  16886. if err != nil {
  16887. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16888. }
  16889. return oldValue.ActionLabelAdd, nil
  16890. }
  16891. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16892. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  16893. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16894. }
  16895. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16896. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16897. if len(m.appendaction_label_add) == 0 {
  16898. return nil, false
  16899. }
  16900. return m.appendaction_label_add, true
  16901. }
  16902. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16903. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  16904. m.action_label_add = nil
  16905. m.appendaction_label_add = nil
  16906. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  16907. }
  16908. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16909. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  16910. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  16911. return ok
  16912. }
  16913. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16914. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  16915. m.action_label_add = nil
  16916. m.appendaction_label_add = nil
  16917. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  16918. }
  16919. // SetActionLabelDel sets the "action_label_del" field.
  16920. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  16921. m.action_label_del = &u
  16922. m.appendaction_label_del = nil
  16923. }
  16924. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16925. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  16926. v := m.action_label_del
  16927. if v == nil {
  16928. return
  16929. }
  16930. return *v, true
  16931. }
  16932. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  16933. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16935. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16936. if !m.op.Is(OpUpdateOne) {
  16937. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16938. }
  16939. if m.id == nil || m.oldValue == nil {
  16940. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16941. }
  16942. oldValue, err := m.oldValue(ctx)
  16943. if err != nil {
  16944. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16945. }
  16946. return oldValue.ActionLabelDel, nil
  16947. }
  16948. // AppendActionLabelDel adds u to the "action_label_del" field.
  16949. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  16950. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16951. }
  16952. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16953. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16954. if len(m.appendaction_label_del) == 0 {
  16955. return nil, false
  16956. }
  16957. return m.appendaction_label_del, true
  16958. }
  16959. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16960. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  16961. m.action_label_del = nil
  16962. m.appendaction_label_del = nil
  16963. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  16964. }
  16965. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16966. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  16967. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  16968. return ok
  16969. }
  16970. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16971. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  16972. m.action_label_del = nil
  16973. m.appendaction_label_del = nil
  16974. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  16975. }
  16976. // Where appends a list predicates to the LabelTaggingMutation builder.
  16977. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  16978. m.predicates = append(m.predicates, ps...)
  16979. }
  16980. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  16981. // users can use type-assertion to append predicates that do not depend on any generated package.
  16982. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  16983. p := make([]predicate.LabelTagging, len(ps))
  16984. for i := range ps {
  16985. p[i] = ps[i]
  16986. }
  16987. m.Where(p...)
  16988. }
  16989. // Op returns the operation name.
  16990. func (m *LabelTaggingMutation) Op() Op {
  16991. return m.op
  16992. }
  16993. // SetOp allows setting the mutation operation.
  16994. func (m *LabelTaggingMutation) SetOp(op Op) {
  16995. m.op = op
  16996. }
  16997. // Type returns the node type of this mutation (LabelTagging).
  16998. func (m *LabelTaggingMutation) Type() string {
  16999. return m.typ
  17000. }
  17001. // Fields returns all fields that were changed during this mutation. Note that in
  17002. // order to get all numeric fields that were incremented/decremented, call
  17003. // AddedFields().
  17004. func (m *LabelTaggingMutation) Fields() []string {
  17005. fields := make([]string, 0, 9)
  17006. if m.created_at != nil {
  17007. fields = append(fields, labeltagging.FieldCreatedAt)
  17008. }
  17009. if m.updated_at != nil {
  17010. fields = append(fields, labeltagging.FieldUpdatedAt)
  17011. }
  17012. if m.status != nil {
  17013. fields = append(fields, labeltagging.FieldStatus)
  17014. }
  17015. if m.deleted_at != nil {
  17016. fields = append(fields, labeltagging.FieldDeletedAt)
  17017. }
  17018. if m.organization_id != nil {
  17019. fields = append(fields, labeltagging.FieldOrganizationID)
  17020. }
  17021. if m._type != nil {
  17022. fields = append(fields, labeltagging.FieldType)
  17023. }
  17024. if m.conditions != nil {
  17025. fields = append(fields, labeltagging.FieldConditions)
  17026. }
  17027. if m.action_label_add != nil {
  17028. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17029. }
  17030. if m.action_label_del != nil {
  17031. fields = append(fields, labeltagging.FieldActionLabelDel)
  17032. }
  17033. return fields
  17034. }
  17035. // Field returns the value of a field with the given name. The second boolean
  17036. // return value indicates that this field was not set, or was not defined in the
  17037. // schema.
  17038. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  17039. switch name {
  17040. case labeltagging.FieldCreatedAt:
  17041. return m.CreatedAt()
  17042. case labeltagging.FieldUpdatedAt:
  17043. return m.UpdatedAt()
  17044. case labeltagging.FieldStatus:
  17045. return m.Status()
  17046. case labeltagging.FieldDeletedAt:
  17047. return m.DeletedAt()
  17048. case labeltagging.FieldOrganizationID:
  17049. return m.OrganizationID()
  17050. case labeltagging.FieldType:
  17051. return m.GetType()
  17052. case labeltagging.FieldConditions:
  17053. return m.Conditions()
  17054. case labeltagging.FieldActionLabelAdd:
  17055. return m.ActionLabelAdd()
  17056. case labeltagging.FieldActionLabelDel:
  17057. return m.ActionLabelDel()
  17058. }
  17059. return nil, false
  17060. }
  17061. // OldField returns the old value of the field from the database. An error is
  17062. // returned if the mutation operation is not UpdateOne, or the query to the
  17063. // database failed.
  17064. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17065. switch name {
  17066. case labeltagging.FieldCreatedAt:
  17067. return m.OldCreatedAt(ctx)
  17068. case labeltagging.FieldUpdatedAt:
  17069. return m.OldUpdatedAt(ctx)
  17070. case labeltagging.FieldStatus:
  17071. return m.OldStatus(ctx)
  17072. case labeltagging.FieldDeletedAt:
  17073. return m.OldDeletedAt(ctx)
  17074. case labeltagging.FieldOrganizationID:
  17075. return m.OldOrganizationID(ctx)
  17076. case labeltagging.FieldType:
  17077. return m.OldType(ctx)
  17078. case labeltagging.FieldConditions:
  17079. return m.OldConditions(ctx)
  17080. case labeltagging.FieldActionLabelAdd:
  17081. return m.OldActionLabelAdd(ctx)
  17082. case labeltagging.FieldActionLabelDel:
  17083. return m.OldActionLabelDel(ctx)
  17084. }
  17085. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  17086. }
  17087. // SetField sets the value of a field with the given name. It returns an error if
  17088. // the field is not defined in the schema, or if the type mismatched the field
  17089. // type.
  17090. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  17091. switch name {
  17092. case labeltagging.FieldCreatedAt:
  17093. v, ok := value.(time.Time)
  17094. if !ok {
  17095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17096. }
  17097. m.SetCreatedAt(v)
  17098. return nil
  17099. case labeltagging.FieldUpdatedAt:
  17100. v, ok := value.(time.Time)
  17101. if !ok {
  17102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17103. }
  17104. m.SetUpdatedAt(v)
  17105. return nil
  17106. case labeltagging.FieldStatus:
  17107. v, ok := value.(uint8)
  17108. if !ok {
  17109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17110. }
  17111. m.SetStatus(v)
  17112. return nil
  17113. case labeltagging.FieldDeletedAt:
  17114. v, ok := value.(time.Time)
  17115. if !ok {
  17116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17117. }
  17118. m.SetDeletedAt(v)
  17119. return nil
  17120. case labeltagging.FieldOrganizationID:
  17121. v, ok := value.(uint64)
  17122. if !ok {
  17123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17124. }
  17125. m.SetOrganizationID(v)
  17126. return nil
  17127. case labeltagging.FieldType:
  17128. v, ok := value.(int)
  17129. if !ok {
  17130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17131. }
  17132. m.SetType(v)
  17133. return nil
  17134. case labeltagging.FieldConditions:
  17135. v, ok := value.(string)
  17136. if !ok {
  17137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17138. }
  17139. m.SetConditions(v)
  17140. return nil
  17141. case labeltagging.FieldActionLabelAdd:
  17142. v, ok := value.([]uint64)
  17143. if !ok {
  17144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17145. }
  17146. m.SetActionLabelAdd(v)
  17147. return nil
  17148. case labeltagging.FieldActionLabelDel:
  17149. v, ok := value.([]uint64)
  17150. if !ok {
  17151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17152. }
  17153. m.SetActionLabelDel(v)
  17154. return nil
  17155. }
  17156. return fmt.Errorf("unknown LabelTagging field %s", name)
  17157. }
  17158. // AddedFields returns all numeric fields that were incremented/decremented during
  17159. // this mutation.
  17160. func (m *LabelTaggingMutation) AddedFields() []string {
  17161. var fields []string
  17162. if m.addstatus != nil {
  17163. fields = append(fields, labeltagging.FieldStatus)
  17164. }
  17165. if m.addorganization_id != nil {
  17166. fields = append(fields, labeltagging.FieldOrganizationID)
  17167. }
  17168. if m.add_type != nil {
  17169. fields = append(fields, labeltagging.FieldType)
  17170. }
  17171. return fields
  17172. }
  17173. // AddedField returns the numeric value that was incremented/decremented on a field
  17174. // with the given name. The second boolean return value indicates that this field
  17175. // was not set, or was not defined in the schema.
  17176. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  17177. switch name {
  17178. case labeltagging.FieldStatus:
  17179. return m.AddedStatus()
  17180. case labeltagging.FieldOrganizationID:
  17181. return m.AddedOrganizationID()
  17182. case labeltagging.FieldType:
  17183. return m.AddedType()
  17184. }
  17185. return nil, false
  17186. }
  17187. // AddField adds the value to the field with the given name. It returns an error if
  17188. // the field is not defined in the schema, or if the type mismatched the field
  17189. // type.
  17190. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  17191. switch name {
  17192. case labeltagging.FieldStatus:
  17193. v, ok := value.(int8)
  17194. if !ok {
  17195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17196. }
  17197. m.AddStatus(v)
  17198. return nil
  17199. case labeltagging.FieldOrganizationID:
  17200. v, ok := value.(int64)
  17201. if !ok {
  17202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17203. }
  17204. m.AddOrganizationID(v)
  17205. return nil
  17206. case labeltagging.FieldType:
  17207. v, ok := value.(int)
  17208. if !ok {
  17209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17210. }
  17211. m.AddType(v)
  17212. return nil
  17213. }
  17214. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  17215. }
  17216. // ClearedFields returns all nullable fields that were cleared during this
  17217. // mutation.
  17218. func (m *LabelTaggingMutation) ClearedFields() []string {
  17219. var fields []string
  17220. if m.FieldCleared(labeltagging.FieldStatus) {
  17221. fields = append(fields, labeltagging.FieldStatus)
  17222. }
  17223. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  17224. fields = append(fields, labeltagging.FieldDeletedAt)
  17225. }
  17226. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  17227. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17228. }
  17229. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  17230. fields = append(fields, labeltagging.FieldActionLabelDel)
  17231. }
  17232. return fields
  17233. }
  17234. // FieldCleared returns a boolean indicating if a field with the given name was
  17235. // cleared in this mutation.
  17236. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  17237. _, ok := m.clearedFields[name]
  17238. return ok
  17239. }
  17240. // ClearField clears the value of the field with the given name. It returns an
  17241. // error if the field is not defined in the schema.
  17242. func (m *LabelTaggingMutation) ClearField(name string) error {
  17243. switch name {
  17244. case labeltagging.FieldStatus:
  17245. m.ClearStatus()
  17246. return nil
  17247. case labeltagging.FieldDeletedAt:
  17248. m.ClearDeletedAt()
  17249. return nil
  17250. case labeltagging.FieldActionLabelAdd:
  17251. m.ClearActionLabelAdd()
  17252. return nil
  17253. case labeltagging.FieldActionLabelDel:
  17254. m.ClearActionLabelDel()
  17255. return nil
  17256. }
  17257. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  17258. }
  17259. // ResetField resets all changes in the mutation for the field with the given name.
  17260. // It returns an error if the field is not defined in the schema.
  17261. func (m *LabelTaggingMutation) ResetField(name string) error {
  17262. switch name {
  17263. case labeltagging.FieldCreatedAt:
  17264. m.ResetCreatedAt()
  17265. return nil
  17266. case labeltagging.FieldUpdatedAt:
  17267. m.ResetUpdatedAt()
  17268. return nil
  17269. case labeltagging.FieldStatus:
  17270. m.ResetStatus()
  17271. return nil
  17272. case labeltagging.FieldDeletedAt:
  17273. m.ResetDeletedAt()
  17274. return nil
  17275. case labeltagging.FieldOrganizationID:
  17276. m.ResetOrganizationID()
  17277. return nil
  17278. case labeltagging.FieldType:
  17279. m.ResetType()
  17280. return nil
  17281. case labeltagging.FieldConditions:
  17282. m.ResetConditions()
  17283. return nil
  17284. case labeltagging.FieldActionLabelAdd:
  17285. m.ResetActionLabelAdd()
  17286. return nil
  17287. case labeltagging.FieldActionLabelDel:
  17288. m.ResetActionLabelDel()
  17289. return nil
  17290. }
  17291. return fmt.Errorf("unknown LabelTagging field %s", name)
  17292. }
  17293. // AddedEdges returns all edge names that were set/added in this mutation.
  17294. func (m *LabelTaggingMutation) AddedEdges() []string {
  17295. edges := make([]string, 0, 0)
  17296. return edges
  17297. }
  17298. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17299. // name in this mutation.
  17300. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  17301. return nil
  17302. }
  17303. // RemovedEdges returns all edge names that were removed in this mutation.
  17304. func (m *LabelTaggingMutation) RemovedEdges() []string {
  17305. edges := make([]string, 0, 0)
  17306. return edges
  17307. }
  17308. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17309. // the given name in this mutation.
  17310. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  17311. return nil
  17312. }
  17313. // ClearedEdges returns all edge names that were cleared in this mutation.
  17314. func (m *LabelTaggingMutation) ClearedEdges() []string {
  17315. edges := make([]string, 0, 0)
  17316. return edges
  17317. }
  17318. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17319. // was cleared in this mutation.
  17320. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  17321. return false
  17322. }
  17323. // ClearEdge clears the value of the edge with the given name. It returns an error
  17324. // if that edge is not defined in the schema.
  17325. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  17326. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  17327. }
  17328. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17329. // It returns an error if the edge is not defined in the schema.
  17330. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  17331. return fmt.Errorf("unknown LabelTagging edge %s", name)
  17332. }
  17333. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  17334. type MessageMutation struct {
  17335. config
  17336. op Op
  17337. typ string
  17338. id *int
  17339. wx_wxid *string
  17340. wxid *string
  17341. content *string
  17342. clearedFields map[string]struct{}
  17343. done bool
  17344. oldValue func(context.Context) (*Message, error)
  17345. predicates []predicate.Message
  17346. }
  17347. var _ ent.Mutation = (*MessageMutation)(nil)
  17348. // messageOption allows management of the mutation configuration using functional options.
  17349. type messageOption func(*MessageMutation)
  17350. // newMessageMutation creates new mutation for the Message entity.
  17351. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  17352. m := &MessageMutation{
  17353. config: c,
  17354. op: op,
  17355. typ: TypeMessage,
  17356. clearedFields: make(map[string]struct{}),
  17357. }
  17358. for _, opt := range opts {
  17359. opt(m)
  17360. }
  17361. return m
  17362. }
  17363. // withMessageID sets the ID field of the mutation.
  17364. func withMessageID(id int) messageOption {
  17365. return func(m *MessageMutation) {
  17366. var (
  17367. err error
  17368. once sync.Once
  17369. value *Message
  17370. )
  17371. m.oldValue = func(ctx context.Context) (*Message, error) {
  17372. once.Do(func() {
  17373. if m.done {
  17374. err = errors.New("querying old values post mutation is not allowed")
  17375. } else {
  17376. value, err = m.Client().Message.Get(ctx, id)
  17377. }
  17378. })
  17379. return value, err
  17380. }
  17381. m.id = &id
  17382. }
  17383. }
  17384. // withMessage sets the old Message of the mutation.
  17385. func withMessage(node *Message) messageOption {
  17386. return func(m *MessageMutation) {
  17387. m.oldValue = func(context.Context) (*Message, error) {
  17388. return node, nil
  17389. }
  17390. m.id = &node.ID
  17391. }
  17392. }
  17393. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17394. // executed in a transaction (ent.Tx), a transactional client is returned.
  17395. func (m MessageMutation) Client() *Client {
  17396. client := &Client{config: m.config}
  17397. client.init()
  17398. return client
  17399. }
  17400. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17401. // it returns an error otherwise.
  17402. func (m MessageMutation) Tx() (*Tx, error) {
  17403. if _, ok := m.driver.(*txDriver); !ok {
  17404. return nil, errors.New("ent: mutation is not running in a transaction")
  17405. }
  17406. tx := &Tx{config: m.config}
  17407. tx.init()
  17408. return tx, nil
  17409. }
  17410. // ID returns the ID value in the mutation. Note that the ID is only available
  17411. // if it was provided to the builder or after it was returned from the database.
  17412. func (m *MessageMutation) ID() (id int, exists bool) {
  17413. if m.id == nil {
  17414. return
  17415. }
  17416. return *m.id, true
  17417. }
  17418. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17419. // That means, if the mutation is applied within a transaction with an isolation level such
  17420. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17421. // or updated by the mutation.
  17422. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  17423. switch {
  17424. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17425. id, exists := m.ID()
  17426. if exists {
  17427. return []int{id}, nil
  17428. }
  17429. fallthrough
  17430. case m.op.Is(OpUpdate | OpDelete):
  17431. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  17432. default:
  17433. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17434. }
  17435. }
  17436. // SetWxWxid sets the "wx_wxid" field.
  17437. func (m *MessageMutation) SetWxWxid(s string) {
  17438. m.wx_wxid = &s
  17439. }
  17440. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  17441. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  17442. v := m.wx_wxid
  17443. if v == nil {
  17444. return
  17445. }
  17446. return *v, true
  17447. }
  17448. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  17449. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17451. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  17452. if !m.op.Is(OpUpdateOne) {
  17453. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  17454. }
  17455. if m.id == nil || m.oldValue == nil {
  17456. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  17457. }
  17458. oldValue, err := m.oldValue(ctx)
  17459. if err != nil {
  17460. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  17461. }
  17462. return oldValue.WxWxid, nil
  17463. }
  17464. // ClearWxWxid clears the value of the "wx_wxid" field.
  17465. func (m *MessageMutation) ClearWxWxid() {
  17466. m.wx_wxid = nil
  17467. m.clearedFields[message.FieldWxWxid] = struct{}{}
  17468. }
  17469. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  17470. func (m *MessageMutation) WxWxidCleared() bool {
  17471. _, ok := m.clearedFields[message.FieldWxWxid]
  17472. return ok
  17473. }
  17474. // ResetWxWxid resets all changes to the "wx_wxid" field.
  17475. func (m *MessageMutation) ResetWxWxid() {
  17476. m.wx_wxid = nil
  17477. delete(m.clearedFields, message.FieldWxWxid)
  17478. }
  17479. // SetWxid sets the "wxid" field.
  17480. func (m *MessageMutation) SetWxid(s string) {
  17481. m.wxid = &s
  17482. }
  17483. // Wxid returns the value of the "wxid" field in the mutation.
  17484. func (m *MessageMutation) Wxid() (r string, exists bool) {
  17485. v := m.wxid
  17486. if v == nil {
  17487. return
  17488. }
  17489. return *v, true
  17490. }
  17491. // OldWxid returns the old "wxid" field's value of the Message entity.
  17492. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17494. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  17495. if !m.op.Is(OpUpdateOne) {
  17496. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17497. }
  17498. if m.id == nil || m.oldValue == nil {
  17499. return v, errors.New("OldWxid requires an ID field in the mutation")
  17500. }
  17501. oldValue, err := m.oldValue(ctx)
  17502. if err != nil {
  17503. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17504. }
  17505. return oldValue.Wxid, nil
  17506. }
  17507. // ResetWxid resets all changes to the "wxid" field.
  17508. func (m *MessageMutation) ResetWxid() {
  17509. m.wxid = nil
  17510. }
  17511. // SetContent sets the "content" field.
  17512. func (m *MessageMutation) SetContent(s string) {
  17513. m.content = &s
  17514. }
  17515. // Content returns the value of the "content" field in the mutation.
  17516. func (m *MessageMutation) Content() (r string, exists bool) {
  17517. v := m.content
  17518. if v == nil {
  17519. return
  17520. }
  17521. return *v, true
  17522. }
  17523. // OldContent returns the old "content" field's value of the Message entity.
  17524. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17526. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  17527. if !m.op.Is(OpUpdateOne) {
  17528. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17529. }
  17530. if m.id == nil || m.oldValue == nil {
  17531. return v, errors.New("OldContent requires an ID field in the mutation")
  17532. }
  17533. oldValue, err := m.oldValue(ctx)
  17534. if err != nil {
  17535. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17536. }
  17537. return oldValue.Content, nil
  17538. }
  17539. // ResetContent resets all changes to the "content" field.
  17540. func (m *MessageMutation) ResetContent() {
  17541. m.content = nil
  17542. }
  17543. // Where appends a list predicates to the MessageMutation builder.
  17544. func (m *MessageMutation) Where(ps ...predicate.Message) {
  17545. m.predicates = append(m.predicates, ps...)
  17546. }
  17547. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  17548. // users can use type-assertion to append predicates that do not depend on any generated package.
  17549. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  17550. p := make([]predicate.Message, len(ps))
  17551. for i := range ps {
  17552. p[i] = ps[i]
  17553. }
  17554. m.Where(p...)
  17555. }
  17556. // Op returns the operation name.
  17557. func (m *MessageMutation) Op() Op {
  17558. return m.op
  17559. }
  17560. // SetOp allows setting the mutation operation.
  17561. func (m *MessageMutation) SetOp(op Op) {
  17562. m.op = op
  17563. }
  17564. // Type returns the node type of this mutation (Message).
  17565. func (m *MessageMutation) Type() string {
  17566. return m.typ
  17567. }
  17568. // Fields returns all fields that were changed during this mutation. Note that in
  17569. // order to get all numeric fields that were incremented/decremented, call
  17570. // AddedFields().
  17571. func (m *MessageMutation) Fields() []string {
  17572. fields := make([]string, 0, 3)
  17573. if m.wx_wxid != nil {
  17574. fields = append(fields, message.FieldWxWxid)
  17575. }
  17576. if m.wxid != nil {
  17577. fields = append(fields, message.FieldWxid)
  17578. }
  17579. if m.content != nil {
  17580. fields = append(fields, message.FieldContent)
  17581. }
  17582. return fields
  17583. }
  17584. // Field returns the value of a field with the given name. The second boolean
  17585. // return value indicates that this field was not set, or was not defined in the
  17586. // schema.
  17587. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  17588. switch name {
  17589. case message.FieldWxWxid:
  17590. return m.WxWxid()
  17591. case message.FieldWxid:
  17592. return m.Wxid()
  17593. case message.FieldContent:
  17594. return m.Content()
  17595. }
  17596. return nil, false
  17597. }
  17598. // OldField returns the old value of the field from the database. An error is
  17599. // returned if the mutation operation is not UpdateOne, or the query to the
  17600. // database failed.
  17601. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17602. switch name {
  17603. case message.FieldWxWxid:
  17604. return m.OldWxWxid(ctx)
  17605. case message.FieldWxid:
  17606. return m.OldWxid(ctx)
  17607. case message.FieldContent:
  17608. return m.OldContent(ctx)
  17609. }
  17610. return nil, fmt.Errorf("unknown Message field %s", name)
  17611. }
  17612. // SetField sets the value of a field with the given name. It returns an error if
  17613. // the field is not defined in the schema, or if the type mismatched the field
  17614. // type.
  17615. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  17616. switch name {
  17617. case message.FieldWxWxid:
  17618. v, ok := value.(string)
  17619. if !ok {
  17620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17621. }
  17622. m.SetWxWxid(v)
  17623. return nil
  17624. case message.FieldWxid:
  17625. v, ok := value.(string)
  17626. if !ok {
  17627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17628. }
  17629. m.SetWxid(v)
  17630. return nil
  17631. case message.FieldContent:
  17632. v, ok := value.(string)
  17633. if !ok {
  17634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17635. }
  17636. m.SetContent(v)
  17637. return nil
  17638. }
  17639. return fmt.Errorf("unknown Message field %s", name)
  17640. }
  17641. // AddedFields returns all numeric fields that were incremented/decremented during
  17642. // this mutation.
  17643. func (m *MessageMutation) AddedFields() []string {
  17644. return nil
  17645. }
  17646. // AddedField returns the numeric value that was incremented/decremented on a field
  17647. // with the given name. The second boolean return value indicates that this field
  17648. // was not set, or was not defined in the schema.
  17649. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  17650. return nil, false
  17651. }
  17652. // AddField adds the value to the field with the given name. It returns an error if
  17653. // the field is not defined in the schema, or if the type mismatched the field
  17654. // type.
  17655. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  17656. switch name {
  17657. }
  17658. return fmt.Errorf("unknown Message numeric field %s", name)
  17659. }
  17660. // ClearedFields returns all nullable fields that were cleared during this
  17661. // mutation.
  17662. func (m *MessageMutation) ClearedFields() []string {
  17663. var fields []string
  17664. if m.FieldCleared(message.FieldWxWxid) {
  17665. fields = append(fields, message.FieldWxWxid)
  17666. }
  17667. return fields
  17668. }
  17669. // FieldCleared returns a boolean indicating if a field with the given name was
  17670. // cleared in this mutation.
  17671. func (m *MessageMutation) FieldCleared(name string) bool {
  17672. _, ok := m.clearedFields[name]
  17673. return ok
  17674. }
  17675. // ClearField clears the value of the field with the given name. It returns an
  17676. // error if the field is not defined in the schema.
  17677. func (m *MessageMutation) ClearField(name string) error {
  17678. switch name {
  17679. case message.FieldWxWxid:
  17680. m.ClearWxWxid()
  17681. return nil
  17682. }
  17683. return fmt.Errorf("unknown Message nullable field %s", name)
  17684. }
  17685. // ResetField resets all changes in the mutation for the field with the given name.
  17686. // It returns an error if the field is not defined in the schema.
  17687. func (m *MessageMutation) ResetField(name string) error {
  17688. switch name {
  17689. case message.FieldWxWxid:
  17690. m.ResetWxWxid()
  17691. return nil
  17692. case message.FieldWxid:
  17693. m.ResetWxid()
  17694. return nil
  17695. case message.FieldContent:
  17696. m.ResetContent()
  17697. return nil
  17698. }
  17699. return fmt.Errorf("unknown Message field %s", name)
  17700. }
  17701. // AddedEdges returns all edge names that were set/added in this mutation.
  17702. func (m *MessageMutation) AddedEdges() []string {
  17703. edges := make([]string, 0, 0)
  17704. return edges
  17705. }
  17706. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17707. // name in this mutation.
  17708. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  17709. return nil
  17710. }
  17711. // RemovedEdges returns all edge names that were removed in this mutation.
  17712. func (m *MessageMutation) RemovedEdges() []string {
  17713. edges := make([]string, 0, 0)
  17714. return edges
  17715. }
  17716. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17717. // the given name in this mutation.
  17718. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  17719. return nil
  17720. }
  17721. // ClearedEdges returns all edge names that were cleared in this mutation.
  17722. func (m *MessageMutation) ClearedEdges() []string {
  17723. edges := make([]string, 0, 0)
  17724. return edges
  17725. }
  17726. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17727. // was cleared in this mutation.
  17728. func (m *MessageMutation) EdgeCleared(name string) bool {
  17729. return false
  17730. }
  17731. // ClearEdge clears the value of the edge with the given name. It returns an error
  17732. // if that edge is not defined in the schema.
  17733. func (m *MessageMutation) ClearEdge(name string) error {
  17734. return fmt.Errorf("unknown Message unique edge %s", name)
  17735. }
  17736. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17737. // It returns an error if the edge is not defined in the schema.
  17738. func (m *MessageMutation) ResetEdge(name string) error {
  17739. return fmt.Errorf("unknown Message edge %s", name)
  17740. }
  17741. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  17742. type MessageRecordsMutation struct {
  17743. config
  17744. op Op
  17745. typ string
  17746. id *uint64
  17747. created_at *time.Time
  17748. updated_at *time.Time
  17749. status *uint8
  17750. addstatus *int8
  17751. bot_wxid *string
  17752. contact_type *int
  17753. addcontact_type *int
  17754. contact_wxid *string
  17755. content_type *int
  17756. addcontent_type *int
  17757. content *string
  17758. meta *custom_types.Meta
  17759. error_detail *string
  17760. send_time *time.Time
  17761. source_type *int
  17762. addsource_type *int
  17763. organization_id *uint64
  17764. addorganization_id *int64
  17765. clearedFields map[string]struct{}
  17766. sop_stage *uint64
  17767. clearedsop_stage bool
  17768. sop_node *uint64
  17769. clearedsop_node bool
  17770. message_contact *uint64
  17771. clearedmessage_contact bool
  17772. done bool
  17773. oldValue func(context.Context) (*MessageRecords, error)
  17774. predicates []predicate.MessageRecords
  17775. }
  17776. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  17777. // messagerecordsOption allows management of the mutation configuration using functional options.
  17778. type messagerecordsOption func(*MessageRecordsMutation)
  17779. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  17780. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  17781. m := &MessageRecordsMutation{
  17782. config: c,
  17783. op: op,
  17784. typ: TypeMessageRecords,
  17785. clearedFields: make(map[string]struct{}),
  17786. }
  17787. for _, opt := range opts {
  17788. opt(m)
  17789. }
  17790. return m
  17791. }
  17792. // withMessageRecordsID sets the ID field of the mutation.
  17793. func withMessageRecordsID(id uint64) messagerecordsOption {
  17794. return func(m *MessageRecordsMutation) {
  17795. var (
  17796. err error
  17797. once sync.Once
  17798. value *MessageRecords
  17799. )
  17800. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  17801. once.Do(func() {
  17802. if m.done {
  17803. err = errors.New("querying old values post mutation is not allowed")
  17804. } else {
  17805. value, err = m.Client().MessageRecords.Get(ctx, id)
  17806. }
  17807. })
  17808. return value, err
  17809. }
  17810. m.id = &id
  17811. }
  17812. }
  17813. // withMessageRecords sets the old MessageRecords of the mutation.
  17814. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  17815. return func(m *MessageRecordsMutation) {
  17816. m.oldValue = func(context.Context) (*MessageRecords, error) {
  17817. return node, nil
  17818. }
  17819. m.id = &node.ID
  17820. }
  17821. }
  17822. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17823. // executed in a transaction (ent.Tx), a transactional client is returned.
  17824. func (m MessageRecordsMutation) Client() *Client {
  17825. client := &Client{config: m.config}
  17826. client.init()
  17827. return client
  17828. }
  17829. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17830. // it returns an error otherwise.
  17831. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  17832. if _, ok := m.driver.(*txDriver); !ok {
  17833. return nil, errors.New("ent: mutation is not running in a transaction")
  17834. }
  17835. tx := &Tx{config: m.config}
  17836. tx.init()
  17837. return tx, nil
  17838. }
  17839. // SetID sets the value of the id field. Note that this
  17840. // operation is only accepted on creation of MessageRecords entities.
  17841. func (m *MessageRecordsMutation) SetID(id uint64) {
  17842. m.id = &id
  17843. }
  17844. // ID returns the ID value in the mutation. Note that the ID is only available
  17845. // if it was provided to the builder or after it was returned from the database.
  17846. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  17847. if m.id == nil {
  17848. return
  17849. }
  17850. return *m.id, true
  17851. }
  17852. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17853. // That means, if the mutation is applied within a transaction with an isolation level such
  17854. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17855. // or updated by the mutation.
  17856. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  17857. switch {
  17858. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17859. id, exists := m.ID()
  17860. if exists {
  17861. return []uint64{id}, nil
  17862. }
  17863. fallthrough
  17864. case m.op.Is(OpUpdate | OpDelete):
  17865. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  17866. default:
  17867. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17868. }
  17869. }
  17870. // SetCreatedAt sets the "created_at" field.
  17871. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  17872. m.created_at = &t
  17873. }
  17874. // CreatedAt returns the value of the "created_at" field in the mutation.
  17875. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  17876. v := m.created_at
  17877. if v == nil {
  17878. return
  17879. }
  17880. return *v, true
  17881. }
  17882. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  17883. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17885. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17886. if !m.op.Is(OpUpdateOne) {
  17887. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17888. }
  17889. if m.id == nil || m.oldValue == nil {
  17890. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17891. }
  17892. oldValue, err := m.oldValue(ctx)
  17893. if err != nil {
  17894. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17895. }
  17896. return oldValue.CreatedAt, nil
  17897. }
  17898. // ResetCreatedAt resets all changes to the "created_at" field.
  17899. func (m *MessageRecordsMutation) ResetCreatedAt() {
  17900. m.created_at = nil
  17901. }
  17902. // SetUpdatedAt sets the "updated_at" field.
  17903. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  17904. m.updated_at = &t
  17905. }
  17906. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17907. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  17908. v := m.updated_at
  17909. if v == nil {
  17910. return
  17911. }
  17912. return *v, true
  17913. }
  17914. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  17915. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17917. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17918. if !m.op.Is(OpUpdateOne) {
  17919. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17920. }
  17921. if m.id == nil || m.oldValue == nil {
  17922. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17923. }
  17924. oldValue, err := m.oldValue(ctx)
  17925. if err != nil {
  17926. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17927. }
  17928. return oldValue.UpdatedAt, nil
  17929. }
  17930. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17931. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  17932. m.updated_at = nil
  17933. }
  17934. // SetStatus sets the "status" field.
  17935. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  17936. m.status = &u
  17937. m.addstatus = nil
  17938. }
  17939. // Status returns the value of the "status" field in the mutation.
  17940. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  17941. v := m.status
  17942. if v == nil {
  17943. return
  17944. }
  17945. return *v, true
  17946. }
  17947. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  17948. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17950. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17951. if !m.op.Is(OpUpdateOne) {
  17952. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17953. }
  17954. if m.id == nil || m.oldValue == nil {
  17955. return v, errors.New("OldStatus requires an ID field in the mutation")
  17956. }
  17957. oldValue, err := m.oldValue(ctx)
  17958. if err != nil {
  17959. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17960. }
  17961. return oldValue.Status, nil
  17962. }
  17963. // AddStatus adds u to the "status" field.
  17964. func (m *MessageRecordsMutation) AddStatus(u int8) {
  17965. if m.addstatus != nil {
  17966. *m.addstatus += u
  17967. } else {
  17968. m.addstatus = &u
  17969. }
  17970. }
  17971. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17972. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  17973. v := m.addstatus
  17974. if v == nil {
  17975. return
  17976. }
  17977. return *v, true
  17978. }
  17979. // ClearStatus clears the value of the "status" field.
  17980. func (m *MessageRecordsMutation) ClearStatus() {
  17981. m.status = nil
  17982. m.addstatus = nil
  17983. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  17984. }
  17985. // StatusCleared returns if the "status" field was cleared in this mutation.
  17986. func (m *MessageRecordsMutation) StatusCleared() bool {
  17987. _, ok := m.clearedFields[messagerecords.FieldStatus]
  17988. return ok
  17989. }
  17990. // ResetStatus resets all changes to the "status" field.
  17991. func (m *MessageRecordsMutation) ResetStatus() {
  17992. m.status = nil
  17993. m.addstatus = nil
  17994. delete(m.clearedFields, messagerecords.FieldStatus)
  17995. }
  17996. // SetBotWxid sets the "bot_wxid" field.
  17997. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  17998. m.bot_wxid = &s
  17999. }
  18000. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  18001. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  18002. v := m.bot_wxid
  18003. if v == nil {
  18004. return
  18005. }
  18006. return *v, true
  18007. }
  18008. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  18009. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18011. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  18012. if !m.op.Is(OpUpdateOne) {
  18013. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  18014. }
  18015. if m.id == nil || m.oldValue == nil {
  18016. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  18017. }
  18018. oldValue, err := m.oldValue(ctx)
  18019. if err != nil {
  18020. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  18021. }
  18022. return oldValue.BotWxid, nil
  18023. }
  18024. // ResetBotWxid resets all changes to the "bot_wxid" field.
  18025. func (m *MessageRecordsMutation) ResetBotWxid() {
  18026. m.bot_wxid = nil
  18027. }
  18028. // SetContactID sets the "contact_id" field.
  18029. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  18030. m.message_contact = &u
  18031. }
  18032. // ContactID returns the value of the "contact_id" field in the mutation.
  18033. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  18034. v := m.message_contact
  18035. if v == nil {
  18036. return
  18037. }
  18038. return *v, true
  18039. }
  18040. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  18041. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18043. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  18044. if !m.op.Is(OpUpdateOne) {
  18045. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18046. }
  18047. if m.id == nil || m.oldValue == nil {
  18048. return v, errors.New("OldContactID requires an ID field in the mutation")
  18049. }
  18050. oldValue, err := m.oldValue(ctx)
  18051. if err != nil {
  18052. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  18053. }
  18054. return oldValue.ContactID, nil
  18055. }
  18056. // ClearContactID clears the value of the "contact_id" field.
  18057. func (m *MessageRecordsMutation) ClearContactID() {
  18058. m.message_contact = nil
  18059. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18060. }
  18061. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  18062. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  18063. _, ok := m.clearedFields[messagerecords.FieldContactID]
  18064. return ok
  18065. }
  18066. // ResetContactID resets all changes to the "contact_id" field.
  18067. func (m *MessageRecordsMutation) ResetContactID() {
  18068. m.message_contact = nil
  18069. delete(m.clearedFields, messagerecords.FieldContactID)
  18070. }
  18071. // SetContactType sets the "contact_type" field.
  18072. func (m *MessageRecordsMutation) SetContactType(i int) {
  18073. m.contact_type = &i
  18074. m.addcontact_type = nil
  18075. }
  18076. // ContactType returns the value of the "contact_type" field in the mutation.
  18077. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  18078. v := m.contact_type
  18079. if v == nil {
  18080. return
  18081. }
  18082. return *v, true
  18083. }
  18084. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  18085. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18087. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  18088. if !m.op.Is(OpUpdateOne) {
  18089. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  18090. }
  18091. if m.id == nil || m.oldValue == nil {
  18092. return v, errors.New("OldContactType requires an ID field in the mutation")
  18093. }
  18094. oldValue, err := m.oldValue(ctx)
  18095. if err != nil {
  18096. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  18097. }
  18098. return oldValue.ContactType, nil
  18099. }
  18100. // AddContactType adds i to the "contact_type" field.
  18101. func (m *MessageRecordsMutation) AddContactType(i int) {
  18102. if m.addcontact_type != nil {
  18103. *m.addcontact_type += i
  18104. } else {
  18105. m.addcontact_type = &i
  18106. }
  18107. }
  18108. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  18109. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  18110. v := m.addcontact_type
  18111. if v == nil {
  18112. return
  18113. }
  18114. return *v, true
  18115. }
  18116. // ResetContactType resets all changes to the "contact_type" field.
  18117. func (m *MessageRecordsMutation) ResetContactType() {
  18118. m.contact_type = nil
  18119. m.addcontact_type = nil
  18120. }
  18121. // SetContactWxid sets the "contact_wxid" field.
  18122. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  18123. m.contact_wxid = &s
  18124. }
  18125. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  18126. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  18127. v := m.contact_wxid
  18128. if v == nil {
  18129. return
  18130. }
  18131. return *v, true
  18132. }
  18133. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  18134. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18136. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  18137. if !m.op.Is(OpUpdateOne) {
  18138. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  18139. }
  18140. if m.id == nil || m.oldValue == nil {
  18141. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  18142. }
  18143. oldValue, err := m.oldValue(ctx)
  18144. if err != nil {
  18145. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  18146. }
  18147. return oldValue.ContactWxid, nil
  18148. }
  18149. // ResetContactWxid resets all changes to the "contact_wxid" field.
  18150. func (m *MessageRecordsMutation) ResetContactWxid() {
  18151. m.contact_wxid = nil
  18152. }
  18153. // SetContentType sets the "content_type" field.
  18154. func (m *MessageRecordsMutation) SetContentType(i int) {
  18155. m.content_type = &i
  18156. m.addcontent_type = nil
  18157. }
  18158. // ContentType returns the value of the "content_type" field in the mutation.
  18159. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  18160. v := m.content_type
  18161. if v == nil {
  18162. return
  18163. }
  18164. return *v, true
  18165. }
  18166. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  18167. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18169. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  18170. if !m.op.Is(OpUpdateOne) {
  18171. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  18172. }
  18173. if m.id == nil || m.oldValue == nil {
  18174. return v, errors.New("OldContentType requires an ID field in the mutation")
  18175. }
  18176. oldValue, err := m.oldValue(ctx)
  18177. if err != nil {
  18178. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  18179. }
  18180. return oldValue.ContentType, nil
  18181. }
  18182. // AddContentType adds i to the "content_type" field.
  18183. func (m *MessageRecordsMutation) AddContentType(i int) {
  18184. if m.addcontent_type != nil {
  18185. *m.addcontent_type += i
  18186. } else {
  18187. m.addcontent_type = &i
  18188. }
  18189. }
  18190. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  18191. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  18192. v := m.addcontent_type
  18193. if v == nil {
  18194. return
  18195. }
  18196. return *v, true
  18197. }
  18198. // ResetContentType resets all changes to the "content_type" field.
  18199. func (m *MessageRecordsMutation) ResetContentType() {
  18200. m.content_type = nil
  18201. m.addcontent_type = nil
  18202. }
  18203. // SetContent sets the "content" field.
  18204. func (m *MessageRecordsMutation) SetContent(s string) {
  18205. m.content = &s
  18206. }
  18207. // Content returns the value of the "content" field in the mutation.
  18208. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  18209. v := m.content
  18210. if v == nil {
  18211. return
  18212. }
  18213. return *v, true
  18214. }
  18215. // OldContent returns the old "content" field's value of the MessageRecords entity.
  18216. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18218. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  18219. if !m.op.Is(OpUpdateOne) {
  18220. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18221. }
  18222. if m.id == nil || m.oldValue == nil {
  18223. return v, errors.New("OldContent requires an ID field in the mutation")
  18224. }
  18225. oldValue, err := m.oldValue(ctx)
  18226. if err != nil {
  18227. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18228. }
  18229. return oldValue.Content, nil
  18230. }
  18231. // ResetContent resets all changes to the "content" field.
  18232. func (m *MessageRecordsMutation) ResetContent() {
  18233. m.content = nil
  18234. }
  18235. // SetMeta sets the "meta" field.
  18236. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  18237. m.meta = &ct
  18238. }
  18239. // Meta returns the value of the "meta" field in the mutation.
  18240. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  18241. v := m.meta
  18242. if v == nil {
  18243. return
  18244. }
  18245. return *v, true
  18246. }
  18247. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  18248. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18250. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  18251. if !m.op.Is(OpUpdateOne) {
  18252. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  18253. }
  18254. if m.id == nil || m.oldValue == nil {
  18255. return v, errors.New("OldMeta requires an ID field in the mutation")
  18256. }
  18257. oldValue, err := m.oldValue(ctx)
  18258. if err != nil {
  18259. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  18260. }
  18261. return oldValue.Meta, nil
  18262. }
  18263. // ClearMeta clears the value of the "meta" field.
  18264. func (m *MessageRecordsMutation) ClearMeta() {
  18265. m.meta = nil
  18266. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  18267. }
  18268. // MetaCleared returns if the "meta" field was cleared in this mutation.
  18269. func (m *MessageRecordsMutation) MetaCleared() bool {
  18270. _, ok := m.clearedFields[messagerecords.FieldMeta]
  18271. return ok
  18272. }
  18273. // ResetMeta resets all changes to the "meta" field.
  18274. func (m *MessageRecordsMutation) ResetMeta() {
  18275. m.meta = nil
  18276. delete(m.clearedFields, messagerecords.FieldMeta)
  18277. }
  18278. // SetErrorDetail sets the "error_detail" field.
  18279. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  18280. m.error_detail = &s
  18281. }
  18282. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  18283. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  18284. v := m.error_detail
  18285. if v == nil {
  18286. return
  18287. }
  18288. return *v, true
  18289. }
  18290. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  18291. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18293. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  18294. if !m.op.Is(OpUpdateOne) {
  18295. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  18296. }
  18297. if m.id == nil || m.oldValue == nil {
  18298. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  18299. }
  18300. oldValue, err := m.oldValue(ctx)
  18301. if err != nil {
  18302. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  18303. }
  18304. return oldValue.ErrorDetail, nil
  18305. }
  18306. // ResetErrorDetail resets all changes to the "error_detail" field.
  18307. func (m *MessageRecordsMutation) ResetErrorDetail() {
  18308. m.error_detail = nil
  18309. }
  18310. // SetSendTime sets the "send_time" field.
  18311. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  18312. m.send_time = &t
  18313. }
  18314. // SendTime returns the value of the "send_time" field in the mutation.
  18315. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  18316. v := m.send_time
  18317. if v == nil {
  18318. return
  18319. }
  18320. return *v, true
  18321. }
  18322. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  18323. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18325. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  18326. if !m.op.Is(OpUpdateOne) {
  18327. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  18328. }
  18329. if m.id == nil || m.oldValue == nil {
  18330. return v, errors.New("OldSendTime requires an ID field in the mutation")
  18331. }
  18332. oldValue, err := m.oldValue(ctx)
  18333. if err != nil {
  18334. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  18335. }
  18336. return oldValue.SendTime, nil
  18337. }
  18338. // ClearSendTime clears the value of the "send_time" field.
  18339. func (m *MessageRecordsMutation) ClearSendTime() {
  18340. m.send_time = nil
  18341. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  18342. }
  18343. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  18344. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  18345. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  18346. return ok
  18347. }
  18348. // ResetSendTime resets all changes to the "send_time" field.
  18349. func (m *MessageRecordsMutation) ResetSendTime() {
  18350. m.send_time = nil
  18351. delete(m.clearedFields, messagerecords.FieldSendTime)
  18352. }
  18353. // SetSourceType sets the "source_type" field.
  18354. func (m *MessageRecordsMutation) SetSourceType(i int) {
  18355. m.source_type = &i
  18356. m.addsource_type = nil
  18357. }
  18358. // SourceType returns the value of the "source_type" field in the mutation.
  18359. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  18360. v := m.source_type
  18361. if v == nil {
  18362. return
  18363. }
  18364. return *v, true
  18365. }
  18366. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  18367. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18369. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  18370. if !m.op.Is(OpUpdateOne) {
  18371. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  18372. }
  18373. if m.id == nil || m.oldValue == nil {
  18374. return v, errors.New("OldSourceType requires an ID field in the mutation")
  18375. }
  18376. oldValue, err := m.oldValue(ctx)
  18377. if err != nil {
  18378. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  18379. }
  18380. return oldValue.SourceType, nil
  18381. }
  18382. // AddSourceType adds i to the "source_type" field.
  18383. func (m *MessageRecordsMutation) AddSourceType(i int) {
  18384. if m.addsource_type != nil {
  18385. *m.addsource_type += i
  18386. } else {
  18387. m.addsource_type = &i
  18388. }
  18389. }
  18390. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  18391. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  18392. v := m.addsource_type
  18393. if v == nil {
  18394. return
  18395. }
  18396. return *v, true
  18397. }
  18398. // ResetSourceType resets all changes to the "source_type" field.
  18399. func (m *MessageRecordsMutation) ResetSourceType() {
  18400. m.source_type = nil
  18401. m.addsource_type = nil
  18402. }
  18403. // SetSourceID sets the "source_id" field.
  18404. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  18405. m.sop_stage = &u
  18406. }
  18407. // SourceID returns the value of the "source_id" field in the mutation.
  18408. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  18409. v := m.sop_stage
  18410. if v == nil {
  18411. return
  18412. }
  18413. return *v, true
  18414. }
  18415. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  18416. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18418. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  18419. if !m.op.Is(OpUpdateOne) {
  18420. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  18421. }
  18422. if m.id == nil || m.oldValue == nil {
  18423. return v, errors.New("OldSourceID requires an ID field in the mutation")
  18424. }
  18425. oldValue, err := m.oldValue(ctx)
  18426. if err != nil {
  18427. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  18428. }
  18429. return oldValue.SourceID, nil
  18430. }
  18431. // ClearSourceID clears the value of the "source_id" field.
  18432. func (m *MessageRecordsMutation) ClearSourceID() {
  18433. m.sop_stage = nil
  18434. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18435. }
  18436. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  18437. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  18438. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  18439. return ok
  18440. }
  18441. // ResetSourceID resets all changes to the "source_id" field.
  18442. func (m *MessageRecordsMutation) ResetSourceID() {
  18443. m.sop_stage = nil
  18444. delete(m.clearedFields, messagerecords.FieldSourceID)
  18445. }
  18446. // SetSubSourceID sets the "sub_source_id" field.
  18447. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  18448. m.sop_node = &u
  18449. }
  18450. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  18451. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  18452. v := m.sop_node
  18453. if v == nil {
  18454. return
  18455. }
  18456. return *v, true
  18457. }
  18458. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  18459. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18461. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  18462. if !m.op.Is(OpUpdateOne) {
  18463. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  18464. }
  18465. if m.id == nil || m.oldValue == nil {
  18466. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  18467. }
  18468. oldValue, err := m.oldValue(ctx)
  18469. if err != nil {
  18470. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  18471. }
  18472. return oldValue.SubSourceID, nil
  18473. }
  18474. // ClearSubSourceID clears the value of the "sub_source_id" field.
  18475. func (m *MessageRecordsMutation) ClearSubSourceID() {
  18476. m.sop_node = nil
  18477. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18478. }
  18479. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  18480. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  18481. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  18482. return ok
  18483. }
  18484. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  18485. func (m *MessageRecordsMutation) ResetSubSourceID() {
  18486. m.sop_node = nil
  18487. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  18488. }
  18489. // SetOrganizationID sets the "organization_id" field.
  18490. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  18491. m.organization_id = &u
  18492. m.addorganization_id = nil
  18493. }
  18494. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18495. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  18496. v := m.organization_id
  18497. if v == nil {
  18498. return
  18499. }
  18500. return *v, true
  18501. }
  18502. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  18503. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18505. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18506. if !m.op.Is(OpUpdateOne) {
  18507. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18508. }
  18509. if m.id == nil || m.oldValue == nil {
  18510. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18511. }
  18512. oldValue, err := m.oldValue(ctx)
  18513. if err != nil {
  18514. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18515. }
  18516. return oldValue.OrganizationID, nil
  18517. }
  18518. // AddOrganizationID adds u to the "organization_id" field.
  18519. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  18520. if m.addorganization_id != nil {
  18521. *m.addorganization_id += u
  18522. } else {
  18523. m.addorganization_id = &u
  18524. }
  18525. }
  18526. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18527. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  18528. v := m.addorganization_id
  18529. if v == nil {
  18530. return
  18531. }
  18532. return *v, true
  18533. }
  18534. // ClearOrganizationID clears the value of the "organization_id" field.
  18535. func (m *MessageRecordsMutation) ClearOrganizationID() {
  18536. m.organization_id = nil
  18537. m.addorganization_id = nil
  18538. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  18539. }
  18540. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18541. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  18542. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  18543. return ok
  18544. }
  18545. // ResetOrganizationID resets all changes to the "organization_id" field.
  18546. func (m *MessageRecordsMutation) ResetOrganizationID() {
  18547. m.organization_id = nil
  18548. m.addorganization_id = nil
  18549. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  18550. }
  18551. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18552. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  18553. m.sop_stage = &id
  18554. }
  18555. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18556. func (m *MessageRecordsMutation) ClearSopStage() {
  18557. m.clearedsop_stage = true
  18558. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18559. }
  18560. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18561. func (m *MessageRecordsMutation) SopStageCleared() bool {
  18562. return m.SourceIDCleared() || m.clearedsop_stage
  18563. }
  18564. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18565. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  18566. if m.sop_stage != nil {
  18567. return *m.sop_stage, true
  18568. }
  18569. return
  18570. }
  18571. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18572. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18573. // SopStageID instead. It exists only for internal usage by the builders.
  18574. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  18575. if id := m.sop_stage; id != nil {
  18576. ids = append(ids, *id)
  18577. }
  18578. return
  18579. }
  18580. // ResetSopStage resets all changes to the "sop_stage" edge.
  18581. func (m *MessageRecordsMutation) ResetSopStage() {
  18582. m.sop_stage = nil
  18583. m.clearedsop_stage = false
  18584. }
  18585. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  18586. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  18587. m.sop_node = &id
  18588. }
  18589. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  18590. func (m *MessageRecordsMutation) ClearSopNode() {
  18591. m.clearedsop_node = true
  18592. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18593. }
  18594. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  18595. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  18596. return m.SubSourceIDCleared() || m.clearedsop_node
  18597. }
  18598. // SopNodeID returns the "sop_node" edge ID in the mutation.
  18599. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  18600. if m.sop_node != nil {
  18601. return *m.sop_node, true
  18602. }
  18603. return
  18604. }
  18605. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  18606. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18607. // SopNodeID instead. It exists only for internal usage by the builders.
  18608. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  18609. if id := m.sop_node; id != nil {
  18610. ids = append(ids, *id)
  18611. }
  18612. return
  18613. }
  18614. // ResetSopNode resets all changes to the "sop_node" edge.
  18615. func (m *MessageRecordsMutation) ResetSopNode() {
  18616. m.sop_node = nil
  18617. m.clearedsop_node = false
  18618. }
  18619. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  18620. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  18621. m.message_contact = &id
  18622. }
  18623. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  18624. func (m *MessageRecordsMutation) ClearMessageContact() {
  18625. m.clearedmessage_contact = true
  18626. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18627. }
  18628. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  18629. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  18630. return m.ContactIDCleared() || m.clearedmessage_contact
  18631. }
  18632. // MessageContactID returns the "message_contact" edge ID in the mutation.
  18633. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  18634. if m.message_contact != nil {
  18635. return *m.message_contact, true
  18636. }
  18637. return
  18638. }
  18639. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  18640. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18641. // MessageContactID instead. It exists only for internal usage by the builders.
  18642. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  18643. if id := m.message_contact; id != nil {
  18644. ids = append(ids, *id)
  18645. }
  18646. return
  18647. }
  18648. // ResetMessageContact resets all changes to the "message_contact" edge.
  18649. func (m *MessageRecordsMutation) ResetMessageContact() {
  18650. m.message_contact = nil
  18651. m.clearedmessage_contact = false
  18652. }
  18653. // Where appends a list predicates to the MessageRecordsMutation builder.
  18654. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  18655. m.predicates = append(m.predicates, ps...)
  18656. }
  18657. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  18658. // users can use type-assertion to append predicates that do not depend on any generated package.
  18659. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  18660. p := make([]predicate.MessageRecords, len(ps))
  18661. for i := range ps {
  18662. p[i] = ps[i]
  18663. }
  18664. m.Where(p...)
  18665. }
  18666. // Op returns the operation name.
  18667. func (m *MessageRecordsMutation) Op() Op {
  18668. return m.op
  18669. }
  18670. // SetOp allows setting the mutation operation.
  18671. func (m *MessageRecordsMutation) SetOp(op Op) {
  18672. m.op = op
  18673. }
  18674. // Type returns the node type of this mutation (MessageRecords).
  18675. func (m *MessageRecordsMutation) Type() string {
  18676. return m.typ
  18677. }
  18678. // Fields returns all fields that were changed during this mutation. Note that in
  18679. // order to get all numeric fields that were incremented/decremented, call
  18680. // AddedFields().
  18681. func (m *MessageRecordsMutation) Fields() []string {
  18682. fields := make([]string, 0, 16)
  18683. if m.created_at != nil {
  18684. fields = append(fields, messagerecords.FieldCreatedAt)
  18685. }
  18686. if m.updated_at != nil {
  18687. fields = append(fields, messagerecords.FieldUpdatedAt)
  18688. }
  18689. if m.status != nil {
  18690. fields = append(fields, messagerecords.FieldStatus)
  18691. }
  18692. if m.bot_wxid != nil {
  18693. fields = append(fields, messagerecords.FieldBotWxid)
  18694. }
  18695. if m.message_contact != nil {
  18696. fields = append(fields, messagerecords.FieldContactID)
  18697. }
  18698. if m.contact_type != nil {
  18699. fields = append(fields, messagerecords.FieldContactType)
  18700. }
  18701. if m.contact_wxid != nil {
  18702. fields = append(fields, messagerecords.FieldContactWxid)
  18703. }
  18704. if m.content_type != nil {
  18705. fields = append(fields, messagerecords.FieldContentType)
  18706. }
  18707. if m.content != nil {
  18708. fields = append(fields, messagerecords.FieldContent)
  18709. }
  18710. if m.meta != nil {
  18711. fields = append(fields, messagerecords.FieldMeta)
  18712. }
  18713. if m.error_detail != nil {
  18714. fields = append(fields, messagerecords.FieldErrorDetail)
  18715. }
  18716. if m.send_time != nil {
  18717. fields = append(fields, messagerecords.FieldSendTime)
  18718. }
  18719. if m.source_type != nil {
  18720. fields = append(fields, messagerecords.FieldSourceType)
  18721. }
  18722. if m.sop_stage != nil {
  18723. fields = append(fields, messagerecords.FieldSourceID)
  18724. }
  18725. if m.sop_node != nil {
  18726. fields = append(fields, messagerecords.FieldSubSourceID)
  18727. }
  18728. if m.organization_id != nil {
  18729. fields = append(fields, messagerecords.FieldOrganizationID)
  18730. }
  18731. return fields
  18732. }
  18733. // Field returns the value of a field with the given name. The second boolean
  18734. // return value indicates that this field was not set, or was not defined in the
  18735. // schema.
  18736. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  18737. switch name {
  18738. case messagerecords.FieldCreatedAt:
  18739. return m.CreatedAt()
  18740. case messagerecords.FieldUpdatedAt:
  18741. return m.UpdatedAt()
  18742. case messagerecords.FieldStatus:
  18743. return m.Status()
  18744. case messagerecords.FieldBotWxid:
  18745. return m.BotWxid()
  18746. case messagerecords.FieldContactID:
  18747. return m.ContactID()
  18748. case messagerecords.FieldContactType:
  18749. return m.ContactType()
  18750. case messagerecords.FieldContactWxid:
  18751. return m.ContactWxid()
  18752. case messagerecords.FieldContentType:
  18753. return m.ContentType()
  18754. case messagerecords.FieldContent:
  18755. return m.Content()
  18756. case messagerecords.FieldMeta:
  18757. return m.Meta()
  18758. case messagerecords.FieldErrorDetail:
  18759. return m.ErrorDetail()
  18760. case messagerecords.FieldSendTime:
  18761. return m.SendTime()
  18762. case messagerecords.FieldSourceType:
  18763. return m.SourceType()
  18764. case messagerecords.FieldSourceID:
  18765. return m.SourceID()
  18766. case messagerecords.FieldSubSourceID:
  18767. return m.SubSourceID()
  18768. case messagerecords.FieldOrganizationID:
  18769. return m.OrganizationID()
  18770. }
  18771. return nil, false
  18772. }
  18773. // OldField returns the old value of the field from the database. An error is
  18774. // returned if the mutation operation is not UpdateOne, or the query to the
  18775. // database failed.
  18776. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18777. switch name {
  18778. case messagerecords.FieldCreatedAt:
  18779. return m.OldCreatedAt(ctx)
  18780. case messagerecords.FieldUpdatedAt:
  18781. return m.OldUpdatedAt(ctx)
  18782. case messagerecords.FieldStatus:
  18783. return m.OldStatus(ctx)
  18784. case messagerecords.FieldBotWxid:
  18785. return m.OldBotWxid(ctx)
  18786. case messagerecords.FieldContactID:
  18787. return m.OldContactID(ctx)
  18788. case messagerecords.FieldContactType:
  18789. return m.OldContactType(ctx)
  18790. case messagerecords.FieldContactWxid:
  18791. return m.OldContactWxid(ctx)
  18792. case messagerecords.FieldContentType:
  18793. return m.OldContentType(ctx)
  18794. case messagerecords.FieldContent:
  18795. return m.OldContent(ctx)
  18796. case messagerecords.FieldMeta:
  18797. return m.OldMeta(ctx)
  18798. case messagerecords.FieldErrorDetail:
  18799. return m.OldErrorDetail(ctx)
  18800. case messagerecords.FieldSendTime:
  18801. return m.OldSendTime(ctx)
  18802. case messagerecords.FieldSourceType:
  18803. return m.OldSourceType(ctx)
  18804. case messagerecords.FieldSourceID:
  18805. return m.OldSourceID(ctx)
  18806. case messagerecords.FieldSubSourceID:
  18807. return m.OldSubSourceID(ctx)
  18808. case messagerecords.FieldOrganizationID:
  18809. return m.OldOrganizationID(ctx)
  18810. }
  18811. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  18812. }
  18813. // SetField sets the value of a field with the given name. It returns an error if
  18814. // the field is not defined in the schema, or if the type mismatched the field
  18815. // type.
  18816. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  18817. switch name {
  18818. case messagerecords.FieldCreatedAt:
  18819. v, ok := value.(time.Time)
  18820. if !ok {
  18821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18822. }
  18823. m.SetCreatedAt(v)
  18824. return nil
  18825. case messagerecords.FieldUpdatedAt:
  18826. v, ok := value.(time.Time)
  18827. if !ok {
  18828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18829. }
  18830. m.SetUpdatedAt(v)
  18831. return nil
  18832. case messagerecords.FieldStatus:
  18833. v, ok := value.(uint8)
  18834. if !ok {
  18835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18836. }
  18837. m.SetStatus(v)
  18838. return nil
  18839. case messagerecords.FieldBotWxid:
  18840. v, ok := value.(string)
  18841. if !ok {
  18842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18843. }
  18844. m.SetBotWxid(v)
  18845. return nil
  18846. case messagerecords.FieldContactID:
  18847. v, ok := value.(uint64)
  18848. if !ok {
  18849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18850. }
  18851. m.SetContactID(v)
  18852. return nil
  18853. case messagerecords.FieldContactType:
  18854. v, ok := value.(int)
  18855. if !ok {
  18856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18857. }
  18858. m.SetContactType(v)
  18859. return nil
  18860. case messagerecords.FieldContactWxid:
  18861. v, ok := value.(string)
  18862. if !ok {
  18863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18864. }
  18865. m.SetContactWxid(v)
  18866. return nil
  18867. case messagerecords.FieldContentType:
  18868. v, ok := value.(int)
  18869. if !ok {
  18870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18871. }
  18872. m.SetContentType(v)
  18873. return nil
  18874. case messagerecords.FieldContent:
  18875. v, ok := value.(string)
  18876. if !ok {
  18877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18878. }
  18879. m.SetContent(v)
  18880. return nil
  18881. case messagerecords.FieldMeta:
  18882. v, ok := value.(custom_types.Meta)
  18883. if !ok {
  18884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18885. }
  18886. m.SetMeta(v)
  18887. return nil
  18888. case messagerecords.FieldErrorDetail:
  18889. v, ok := value.(string)
  18890. if !ok {
  18891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18892. }
  18893. m.SetErrorDetail(v)
  18894. return nil
  18895. case messagerecords.FieldSendTime:
  18896. v, ok := value.(time.Time)
  18897. if !ok {
  18898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18899. }
  18900. m.SetSendTime(v)
  18901. return nil
  18902. case messagerecords.FieldSourceType:
  18903. v, ok := value.(int)
  18904. if !ok {
  18905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18906. }
  18907. m.SetSourceType(v)
  18908. return nil
  18909. case messagerecords.FieldSourceID:
  18910. v, ok := value.(uint64)
  18911. if !ok {
  18912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18913. }
  18914. m.SetSourceID(v)
  18915. return nil
  18916. case messagerecords.FieldSubSourceID:
  18917. v, ok := value.(uint64)
  18918. if !ok {
  18919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18920. }
  18921. m.SetSubSourceID(v)
  18922. return nil
  18923. case messagerecords.FieldOrganizationID:
  18924. v, ok := value.(uint64)
  18925. if !ok {
  18926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18927. }
  18928. m.SetOrganizationID(v)
  18929. return nil
  18930. }
  18931. return fmt.Errorf("unknown MessageRecords field %s", name)
  18932. }
  18933. // AddedFields returns all numeric fields that were incremented/decremented during
  18934. // this mutation.
  18935. func (m *MessageRecordsMutation) AddedFields() []string {
  18936. var fields []string
  18937. if m.addstatus != nil {
  18938. fields = append(fields, messagerecords.FieldStatus)
  18939. }
  18940. if m.addcontact_type != nil {
  18941. fields = append(fields, messagerecords.FieldContactType)
  18942. }
  18943. if m.addcontent_type != nil {
  18944. fields = append(fields, messagerecords.FieldContentType)
  18945. }
  18946. if m.addsource_type != nil {
  18947. fields = append(fields, messagerecords.FieldSourceType)
  18948. }
  18949. if m.addorganization_id != nil {
  18950. fields = append(fields, messagerecords.FieldOrganizationID)
  18951. }
  18952. return fields
  18953. }
  18954. // AddedField returns the numeric value that was incremented/decremented on a field
  18955. // with the given name. The second boolean return value indicates that this field
  18956. // was not set, or was not defined in the schema.
  18957. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  18958. switch name {
  18959. case messagerecords.FieldStatus:
  18960. return m.AddedStatus()
  18961. case messagerecords.FieldContactType:
  18962. return m.AddedContactType()
  18963. case messagerecords.FieldContentType:
  18964. return m.AddedContentType()
  18965. case messagerecords.FieldSourceType:
  18966. return m.AddedSourceType()
  18967. case messagerecords.FieldOrganizationID:
  18968. return m.AddedOrganizationID()
  18969. }
  18970. return nil, false
  18971. }
  18972. // AddField adds the value to the field with the given name. It returns an error if
  18973. // the field is not defined in the schema, or if the type mismatched the field
  18974. // type.
  18975. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  18976. switch name {
  18977. case messagerecords.FieldStatus:
  18978. v, ok := value.(int8)
  18979. if !ok {
  18980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18981. }
  18982. m.AddStatus(v)
  18983. return nil
  18984. case messagerecords.FieldContactType:
  18985. v, ok := value.(int)
  18986. if !ok {
  18987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18988. }
  18989. m.AddContactType(v)
  18990. return nil
  18991. case messagerecords.FieldContentType:
  18992. v, ok := value.(int)
  18993. if !ok {
  18994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18995. }
  18996. m.AddContentType(v)
  18997. return nil
  18998. case messagerecords.FieldSourceType:
  18999. v, ok := value.(int)
  19000. if !ok {
  19001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19002. }
  19003. m.AddSourceType(v)
  19004. return nil
  19005. case messagerecords.FieldOrganizationID:
  19006. v, ok := value.(int64)
  19007. if !ok {
  19008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19009. }
  19010. m.AddOrganizationID(v)
  19011. return nil
  19012. }
  19013. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  19014. }
  19015. // ClearedFields returns all nullable fields that were cleared during this
  19016. // mutation.
  19017. func (m *MessageRecordsMutation) ClearedFields() []string {
  19018. var fields []string
  19019. if m.FieldCleared(messagerecords.FieldStatus) {
  19020. fields = append(fields, messagerecords.FieldStatus)
  19021. }
  19022. if m.FieldCleared(messagerecords.FieldContactID) {
  19023. fields = append(fields, messagerecords.FieldContactID)
  19024. }
  19025. if m.FieldCleared(messagerecords.FieldMeta) {
  19026. fields = append(fields, messagerecords.FieldMeta)
  19027. }
  19028. if m.FieldCleared(messagerecords.FieldSendTime) {
  19029. fields = append(fields, messagerecords.FieldSendTime)
  19030. }
  19031. if m.FieldCleared(messagerecords.FieldSourceID) {
  19032. fields = append(fields, messagerecords.FieldSourceID)
  19033. }
  19034. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  19035. fields = append(fields, messagerecords.FieldSubSourceID)
  19036. }
  19037. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  19038. fields = append(fields, messagerecords.FieldOrganizationID)
  19039. }
  19040. return fields
  19041. }
  19042. // FieldCleared returns a boolean indicating if a field with the given name was
  19043. // cleared in this mutation.
  19044. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  19045. _, ok := m.clearedFields[name]
  19046. return ok
  19047. }
  19048. // ClearField clears the value of the field with the given name. It returns an
  19049. // error if the field is not defined in the schema.
  19050. func (m *MessageRecordsMutation) ClearField(name string) error {
  19051. switch name {
  19052. case messagerecords.FieldStatus:
  19053. m.ClearStatus()
  19054. return nil
  19055. case messagerecords.FieldContactID:
  19056. m.ClearContactID()
  19057. return nil
  19058. case messagerecords.FieldMeta:
  19059. m.ClearMeta()
  19060. return nil
  19061. case messagerecords.FieldSendTime:
  19062. m.ClearSendTime()
  19063. return nil
  19064. case messagerecords.FieldSourceID:
  19065. m.ClearSourceID()
  19066. return nil
  19067. case messagerecords.FieldSubSourceID:
  19068. m.ClearSubSourceID()
  19069. return nil
  19070. case messagerecords.FieldOrganizationID:
  19071. m.ClearOrganizationID()
  19072. return nil
  19073. }
  19074. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  19075. }
  19076. // ResetField resets all changes in the mutation for the field with the given name.
  19077. // It returns an error if the field is not defined in the schema.
  19078. func (m *MessageRecordsMutation) ResetField(name string) error {
  19079. switch name {
  19080. case messagerecords.FieldCreatedAt:
  19081. m.ResetCreatedAt()
  19082. return nil
  19083. case messagerecords.FieldUpdatedAt:
  19084. m.ResetUpdatedAt()
  19085. return nil
  19086. case messagerecords.FieldStatus:
  19087. m.ResetStatus()
  19088. return nil
  19089. case messagerecords.FieldBotWxid:
  19090. m.ResetBotWxid()
  19091. return nil
  19092. case messagerecords.FieldContactID:
  19093. m.ResetContactID()
  19094. return nil
  19095. case messagerecords.FieldContactType:
  19096. m.ResetContactType()
  19097. return nil
  19098. case messagerecords.FieldContactWxid:
  19099. m.ResetContactWxid()
  19100. return nil
  19101. case messagerecords.FieldContentType:
  19102. m.ResetContentType()
  19103. return nil
  19104. case messagerecords.FieldContent:
  19105. m.ResetContent()
  19106. return nil
  19107. case messagerecords.FieldMeta:
  19108. m.ResetMeta()
  19109. return nil
  19110. case messagerecords.FieldErrorDetail:
  19111. m.ResetErrorDetail()
  19112. return nil
  19113. case messagerecords.FieldSendTime:
  19114. m.ResetSendTime()
  19115. return nil
  19116. case messagerecords.FieldSourceType:
  19117. m.ResetSourceType()
  19118. return nil
  19119. case messagerecords.FieldSourceID:
  19120. m.ResetSourceID()
  19121. return nil
  19122. case messagerecords.FieldSubSourceID:
  19123. m.ResetSubSourceID()
  19124. return nil
  19125. case messagerecords.FieldOrganizationID:
  19126. m.ResetOrganizationID()
  19127. return nil
  19128. }
  19129. return fmt.Errorf("unknown MessageRecords field %s", name)
  19130. }
  19131. // AddedEdges returns all edge names that were set/added in this mutation.
  19132. func (m *MessageRecordsMutation) AddedEdges() []string {
  19133. edges := make([]string, 0, 3)
  19134. if m.sop_stage != nil {
  19135. edges = append(edges, messagerecords.EdgeSopStage)
  19136. }
  19137. if m.sop_node != nil {
  19138. edges = append(edges, messagerecords.EdgeSopNode)
  19139. }
  19140. if m.message_contact != nil {
  19141. edges = append(edges, messagerecords.EdgeMessageContact)
  19142. }
  19143. return edges
  19144. }
  19145. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19146. // name in this mutation.
  19147. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  19148. switch name {
  19149. case messagerecords.EdgeSopStage:
  19150. if id := m.sop_stage; id != nil {
  19151. return []ent.Value{*id}
  19152. }
  19153. case messagerecords.EdgeSopNode:
  19154. if id := m.sop_node; id != nil {
  19155. return []ent.Value{*id}
  19156. }
  19157. case messagerecords.EdgeMessageContact:
  19158. if id := m.message_contact; id != nil {
  19159. return []ent.Value{*id}
  19160. }
  19161. }
  19162. return nil
  19163. }
  19164. // RemovedEdges returns all edge names that were removed in this mutation.
  19165. func (m *MessageRecordsMutation) RemovedEdges() []string {
  19166. edges := make([]string, 0, 3)
  19167. return edges
  19168. }
  19169. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19170. // the given name in this mutation.
  19171. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  19172. return nil
  19173. }
  19174. // ClearedEdges returns all edge names that were cleared in this mutation.
  19175. func (m *MessageRecordsMutation) ClearedEdges() []string {
  19176. edges := make([]string, 0, 3)
  19177. if m.clearedsop_stage {
  19178. edges = append(edges, messagerecords.EdgeSopStage)
  19179. }
  19180. if m.clearedsop_node {
  19181. edges = append(edges, messagerecords.EdgeSopNode)
  19182. }
  19183. if m.clearedmessage_contact {
  19184. edges = append(edges, messagerecords.EdgeMessageContact)
  19185. }
  19186. return edges
  19187. }
  19188. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19189. // was cleared in this mutation.
  19190. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  19191. switch name {
  19192. case messagerecords.EdgeSopStage:
  19193. return m.clearedsop_stage
  19194. case messagerecords.EdgeSopNode:
  19195. return m.clearedsop_node
  19196. case messagerecords.EdgeMessageContact:
  19197. return m.clearedmessage_contact
  19198. }
  19199. return false
  19200. }
  19201. // ClearEdge clears the value of the edge with the given name. It returns an error
  19202. // if that edge is not defined in the schema.
  19203. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  19204. switch name {
  19205. case messagerecords.EdgeSopStage:
  19206. m.ClearSopStage()
  19207. return nil
  19208. case messagerecords.EdgeSopNode:
  19209. m.ClearSopNode()
  19210. return nil
  19211. case messagerecords.EdgeMessageContact:
  19212. m.ClearMessageContact()
  19213. return nil
  19214. }
  19215. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  19216. }
  19217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19218. // It returns an error if the edge is not defined in the schema.
  19219. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  19220. switch name {
  19221. case messagerecords.EdgeSopStage:
  19222. m.ResetSopStage()
  19223. return nil
  19224. case messagerecords.EdgeSopNode:
  19225. m.ResetSopNode()
  19226. return nil
  19227. case messagerecords.EdgeMessageContact:
  19228. m.ResetMessageContact()
  19229. return nil
  19230. }
  19231. return fmt.Errorf("unknown MessageRecords edge %s", name)
  19232. }
  19233. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  19234. type MsgMutation struct {
  19235. config
  19236. op Op
  19237. typ string
  19238. id *uint64
  19239. created_at *time.Time
  19240. updated_at *time.Time
  19241. deleted_at *time.Time
  19242. status *uint8
  19243. addstatus *int8
  19244. fromwxid *string
  19245. toid *string
  19246. msgtype *int32
  19247. addmsgtype *int32
  19248. msg *string
  19249. batch_no *string
  19250. cc *string
  19251. phone *string
  19252. clearedFields map[string]struct{}
  19253. done bool
  19254. oldValue func(context.Context) (*Msg, error)
  19255. predicates []predicate.Msg
  19256. }
  19257. var _ ent.Mutation = (*MsgMutation)(nil)
  19258. // msgOption allows management of the mutation configuration using functional options.
  19259. type msgOption func(*MsgMutation)
  19260. // newMsgMutation creates new mutation for the Msg entity.
  19261. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  19262. m := &MsgMutation{
  19263. config: c,
  19264. op: op,
  19265. typ: TypeMsg,
  19266. clearedFields: make(map[string]struct{}),
  19267. }
  19268. for _, opt := range opts {
  19269. opt(m)
  19270. }
  19271. return m
  19272. }
  19273. // withMsgID sets the ID field of the mutation.
  19274. func withMsgID(id uint64) msgOption {
  19275. return func(m *MsgMutation) {
  19276. var (
  19277. err error
  19278. once sync.Once
  19279. value *Msg
  19280. )
  19281. m.oldValue = func(ctx context.Context) (*Msg, error) {
  19282. once.Do(func() {
  19283. if m.done {
  19284. err = errors.New("querying old values post mutation is not allowed")
  19285. } else {
  19286. value, err = m.Client().Msg.Get(ctx, id)
  19287. }
  19288. })
  19289. return value, err
  19290. }
  19291. m.id = &id
  19292. }
  19293. }
  19294. // withMsg sets the old Msg of the mutation.
  19295. func withMsg(node *Msg) msgOption {
  19296. return func(m *MsgMutation) {
  19297. m.oldValue = func(context.Context) (*Msg, error) {
  19298. return node, nil
  19299. }
  19300. m.id = &node.ID
  19301. }
  19302. }
  19303. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19304. // executed in a transaction (ent.Tx), a transactional client is returned.
  19305. func (m MsgMutation) Client() *Client {
  19306. client := &Client{config: m.config}
  19307. client.init()
  19308. return client
  19309. }
  19310. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19311. // it returns an error otherwise.
  19312. func (m MsgMutation) Tx() (*Tx, error) {
  19313. if _, ok := m.driver.(*txDriver); !ok {
  19314. return nil, errors.New("ent: mutation is not running in a transaction")
  19315. }
  19316. tx := &Tx{config: m.config}
  19317. tx.init()
  19318. return tx, nil
  19319. }
  19320. // SetID sets the value of the id field. Note that this
  19321. // operation is only accepted on creation of Msg entities.
  19322. func (m *MsgMutation) SetID(id uint64) {
  19323. m.id = &id
  19324. }
  19325. // ID returns the ID value in the mutation. Note that the ID is only available
  19326. // if it was provided to the builder or after it was returned from the database.
  19327. func (m *MsgMutation) ID() (id uint64, exists bool) {
  19328. if m.id == nil {
  19329. return
  19330. }
  19331. return *m.id, true
  19332. }
  19333. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19334. // That means, if the mutation is applied within a transaction with an isolation level such
  19335. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19336. // or updated by the mutation.
  19337. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  19338. switch {
  19339. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19340. id, exists := m.ID()
  19341. if exists {
  19342. return []uint64{id}, nil
  19343. }
  19344. fallthrough
  19345. case m.op.Is(OpUpdate | OpDelete):
  19346. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  19347. default:
  19348. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19349. }
  19350. }
  19351. // SetCreatedAt sets the "created_at" field.
  19352. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  19353. m.created_at = &t
  19354. }
  19355. // CreatedAt returns the value of the "created_at" field in the mutation.
  19356. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  19357. v := m.created_at
  19358. if v == nil {
  19359. return
  19360. }
  19361. return *v, true
  19362. }
  19363. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  19364. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19366. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19367. if !m.op.Is(OpUpdateOne) {
  19368. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19369. }
  19370. if m.id == nil || m.oldValue == nil {
  19371. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19372. }
  19373. oldValue, err := m.oldValue(ctx)
  19374. if err != nil {
  19375. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19376. }
  19377. return oldValue.CreatedAt, nil
  19378. }
  19379. // ResetCreatedAt resets all changes to the "created_at" field.
  19380. func (m *MsgMutation) ResetCreatedAt() {
  19381. m.created_at = nil
  19382. }
  19383. // SetUpdatedAt sets the "updated_at" field.
  19384. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  19385. m.updated_at = &t
  19386. }
  19387. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19388. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  19389. v := m.updated_at
  19390. if v == nil {
  19391. return
  19392. }
  19393. return *v, true
  19394. }
  19395. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  19396. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19398. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19399. if !m.op.Is(OpUpdateOne) {
  19400. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19401. }
  19402. if m.id == nil || m.oldValue == nil {
  19403. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19404. }
  19405. oldValue, err := m.oldValue(ctx)
  19406. if err != nil {
  19407. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19408. }
  19409. return oldValue.UpdatedAt, nil
  19410. }
  19411. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19412. func (m *MsgMutation) ResetUpdatedAt() {
  19413. m.updated_at = nil
  19414. }
  19415. // SetDeletedAt sets the "deleted_at" field.
  19416. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  19417. m.deleted_at = &t
  19418. }
  19419. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19420. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  19421. v := m.deleted_at
  19422. if v == nil {
  19423. return
  19424. }
  19425. return *v, true
  19426. }
  19427. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  19428. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19430. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19431. if !m.op.Is(OpUpdateOne) {
  19432. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19433. }
  19434. if m.id == nil || m.oldValue == nil {
  19435. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19436. }
  19437. oldValue, err := m.oldValue(ctx)
  19438. if err != nil {
  19439. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19440. }
  19441. return oldValue.DeletedAt, nil
  19442. }
  19443. // ClearDeletedAt clears the value of the "deleted_at" field.
  19444. func (m *MsgMutation) ClearDeletedAt() {
  19445. m.deleted_at = nil
  19446. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  19447. }
  19448. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19449. func (m *MsgMutation) DeletedAtCleared() bool {
  19450. _, ok := m.clearedFields[msg.FieldDeletedAt]
  19451. return ok
  19452. }
  19453. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19454. func (m *MsgMutation) ResetDeletedAt() {
  19455. m.deleted_at = nil
  19456. delete(m.clearedFields, msg.FieldDeletedAt)
  19457. }
  19458. // SetStatus sets the "status" field.
  19459. func (m *MsgMutation) SetStatus(u uint8) {
  19460. m.status = &u
  19461. m.addstatus = nil
  19462. }
  19463. // Status returns the value of the "status" field in the mutation.
  19464. func (m *MsgMutation) Status() (r uint8, exists bool) {
  19465. v := m.status
  19466. if v == nil {
  19467. return
  19468. }
  19469. return *v, true
  19470. }
  19471. // OldStatus returns the old "status" field's value of the Msg entity.
  19472. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19474. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19475. if !m.op.Is(OpUpdateOne) {
  19476. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19477. }
  19478. if m.id == nil || m.oldValue == nil {
  19479. return v, errors.New("OldStatus requires an ID field in the mutation")
  19480. }
  19481. oldValue, err := m.oldValue(ctx)
  19482. if err != nil {
  19483. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19484. }
  19485. return oldValue.Status, nil
  19486. }
  19487. // AddStatus adds u to the "status" field.
  19488. func (m *MsgMutation) AddStatus(u int8) {
  19489. if m.addstatus != nil {
  19490. *m.addstatus += u
  19491. } else {
  19492. m.addstatus = &u
  19493. }
  19494. }
  19495. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19496. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  19497. v := m.addstatus
  19498. if v == nil {
  19499. return
  19500. }
  19501. return *v, true
  19502. }
  19503. // ClearStatus clears the value of the "status" field.
  19504. func (m *MsgMutation) ClearStatus() {
  19505. m.status = nil
  19506. m.addstatus = nil
  19507. m.clearedFields[msg.FieldStatus] = struct{}{}
  19508. }
  19509. // StatusCleared returns if the "status" field was cleared in this mutation.
  19510. func (m *MsgMutation) StatusCleared() bool {
  19511. _, ok := m.clearedFields[msg.FieldStatus]
  19512. return ok
  19513. }
  19514. // ResetStatus resets all changes to the "status" field.
  19515. func (m *MsgMutation) ResetStatus() {
  19516. m.status = nil
  19517. m.addstatus = nil
  19518. delete(m.clearedFields, msg.FieldStatus)
  19519. }
  19520. // SetFromwxid sets the "fromwxid" field.
  19521. func (m *MsgMutation) SetFromwxid(s string) {
  19522. m.fromwxid = &s
  19523. }
  19524. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  19525. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  19526. v := m.fromwxid
  19527. if v == nil {
  19528. return
  19529. }
  19530. return *v, true
  19531. }
  19532. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  19533. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19535. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  19536. if !m.op.Is(OpUpdateOne) {
  19537. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  19538. }
  19539. if m.id == nil || m.oldValue == nil {
  19540. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  19541. }
  19542. oldValue, err := m.oldValue(ctx)
  19543. if err != nil {
  19544. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  19545. }
  19546. return oldValue.Fromwxid, nil
  19547. }
  19548. // ClearFromwxid clears the value of the "fromwxid" field.
  19549. func (m *MsgMutation) ClearFromwxid() {
  19550. m.fromwxid = nil
  19551. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  19552. }
  19553. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  19554. func (m *MsgMutation) FromwxidCleared() bool {
  19555. _, ok := m.clearedFields[msg.FieldFromwxid]
  19556. return ok
  19557. }
  19558. // ResetFromwxid resets all changes to the "fromwxid" field.
  19559. func (m *MsgMutation) ResetFromwxid() {
  19560. m.fromwxid = nil
  19561. delete(m.clearedFields, msg.FieldFromwxid)
  19562. }
  19563. // SetToid sets the "toid" field.
  19564. func (m *MsgMutation) SetToid(s string) {
  19565. m.toid = &s
  19566. }
  19567. // Toid returns the value of the "toid" field in the mutation.
  19568. func (m *MsgMutation) Toid() (r string, exists bool) {
  19569. v := m.toid
  19570. if v == nil {
  19571. return
  19572. }
  19573. return *v, true
  19574. }
  19575. // OldToid returns the old "toid" field's value of the Msg entity.
  19576. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19578. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  19579. if !m.op.Is(OpUpdateOne) {
  19580. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  19581. }
  19582. if m.id == nil || m.oldValue == nil {
  19583. return v, errors.New("OldToid requires an ID field in the mutation")
  19584. }
  19585. oldValue, err := m.oldValue(ctx)
  19586. if err != nil {
  19587. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  19588. }
  19589. return oldValue.Toid, nil
  19590. }
  19591. // ClearToid clears the value of the "toid" field.
  19592. func (m *MsgMutation) ClearToid() {
  19593. m.toid = nil
  19594. m.clearedFields[msg.FieldToid] = struct{}{}
  19595. }
  19596. // ToidCleared returns if the "toid" field was cleared in this mutation.
  19597. func (m *MsgMutation) ToidCleared() bool {
  19598. _, ok := m.clearedFields[msg.FieldToid]
  19599. return ok
  19600. }
  19601. // ResetToid resets all changes to the "toid" field.
  19602. func (m *MsgMutation) ResetToid() {
  19603. m.toid = nil
  19604. delete(m.clearedFields, msg.FieldToid)
  19605. }
  19606. // SetMsgtype sets the "msgtype" field.
  19607. func (m *MsgMutation) SetMsgtype(i int32) {
  19608. m.msgtype = &i
  19609. m.addmsgtype = nil
  19610. }
  19611. // Msgtype returns the value of the "msgtype" field in the mutation.
  19612. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  19613. v := m.msgtype
  19614. if v == nil {
  19615. return
  19616. }
  19617. return *v, true
  19618. }
  19619. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  19620. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19622. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  19623. if !m.op.Is(OpUpdateOne) {
  19624. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  19625. }
  19626. if m.id == nil || m.oldValue == nil {
  19627. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  19628. }
  19629. oldValue, err := m.oldValue(ctx)
  19630. if err != nil {
  19631. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  19632. }
  19633. return oldValue.Msgtype, nil
  19634. }
  19635. // AddMsgtype adds i to the "msgtype" field.
  19636. func (m *MsgMutation) AddMsgtype(i int32) {
  19637. if m.addmsgtype != nil {
  19638. *m.addmsgtype += i
  19639. } else {
  19640. m.addmsgtype = &i
  19641. }
  19642. }
  19643. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  19644. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  19645. v := m.addmsgtype
  19646. if v == nil {
  19647. return
  19648. }
  19649. return *v, true
  19650. }
  19651. // ClearMsgtype clears the value of the "msgtype" field.
  19652. func (m *MsgMutation) ClearMsgtype() {
  19653. m.msgtype = nil
  19654. m.addmsgtype = nil
  19655. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  19656. }
  19657. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  19658. func (m *MsgMutation) MsgtypeCleared() bool {
  19659. _, ok := m.clearedFields[msg.FieldMsgtype]
  19660. return ok
  19661. }
  19662. // ResetMsgtype resets all changes to the "msgtype" field.
  19663. func (m *MsgMutation) ResetMsgtype() {
  19664. m.msgtype = nil
  19665. m.addmsgtype = nil
  19666. delete(m.clearedFields, msg.FieldMsgtype)
  19667. }
  19668. // SetMsg sets the "msg" field.
  19669. func (m *MsgMutation) SetMsg(s string) {
  19670. m.msg = &s
  19671. }
  19672. // Msg returns the value of the "msg" field in the mutation.
  19673. func (m *MsgMutation) Msg() (r string, exists bool) {
  19674. v := m.msg
  19675. if v == nil {
  19676. return
  19677. }
  19678. return *v, true
  19679. }
  19680. // OldMsg returns the old "msg" field's value of the Msg entity.
  19681. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19683. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  19684. if !m.op.Is(OpUpdateOne) {
  19685. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  19686. }
  19687. if m.id == nil || m.oldValue == nil {
  19688. return v, errors.New("OldMsg requires an ID field in the mutation")
  19689. }
  19690. oldValue, err := m.oldValue(ctx)
  19691. if err != nil {
  19692. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  19693. }
  19694. return oldValue.Msg, nil
  19695. }
  19696. // ClearMsg clears the value of the "msg" field.
  19697. func (m *MsgMutation) ClearMsg() {
  19698. m.msg = nil
  19699. m.clearedFields[msg.FieldMsg] = struct{}{}
  19700. }
  19701. // MsgCleared returns if the "msg" field was cleared in this mutation.
  19702. func (m *MsgMutation) MsgCleared() bool {
  19703. _, ok := m.clearedFields[msg.FieldMsg]
  19704. return ok
  19705. }
  19706. // ResetMsg resets all changes to the "msg" field.
  19707. func (m *MsgMutation) ResetMsg() {
  19708. m.msg = nil
  19709. delete(m.clearedFields, msg.FieldMsg)
  19710. }
  19711. // SetBatchNo sets the "batch_no" field.
  19712. func (m *MsgMutation) SetBatchNo(s string) {
  19713. m.batch_no = &s
  19714. }
  19715. // BatchNo returns the value of the "batch_no" field in the mutation.
  19716. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  19717. v := m.batch_no
  19718. if v == nil {
  19719. return
  19720. }
  19721. return *v, true
  19722. }
  19723. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  19724. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19726. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  19727. if !m.op.Is(OpUpdateOne) {
  19728. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  19729. }
  19730. if m.id == nil || m.oldValue == nil {
  19731. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  19732. }
  19733. oldValue, err := m.oldValue(ctx)
  19734. if err != nil {
  19735. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  19736. }
  19737. return oldValue.BatchNo, nil
  19738. }
  19739. // ClearBatchNo clears the value of the "batch_no" field.
  19740. func (m *MsgMutation) ClearBatchNo() {
  19741. m.batch_no = nil
  19742. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  19743. }
  19744. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  19745. func (m *MsgMutation) BatchNoCleared() bool {
  19746. _, ok := m.clearedFields[msg.FieldBatchNo]
  19747. return ok
  19748. }
  19749. // ResetBatchNo resets all changes to the "batch_no" field.
  19750. func (m *MsgMutation) ResetBatchNo() {
  19751. m.batch_no = nil
  19752. delete(m.clearedFields, msg.FieldBatchNo)
  19753. }
  19754. // SetCc sets the "cc" field.
  19755. func (m *MsgMutation) SetCc(s string) {
  19756. m.cc = &s
  19757. }
  19758. // Cc returns the value of the "cc" field in the mutation.
  19759. func (m *MsgMutation) Cc() (r string, exists bool) {
  19760. v := m.cc
  19761. if v == nil {
  19762. return
  19763. }
  19764. return *v, true
  19765. }
  19766. // OldCc returns the old "cc" field's value of the Msg entity.
  19767. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19769. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  19770. if !m.op.Is(OpUpdateOne) {
  19771. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  19772. }
  19773. if m.id == nil || m.oldValue == nil {
  19774. return v, errors.New("OldCc requires an ID field in the mutation")
  19775. }
  19776. oldValue, err := m.oldValue(ctx)
  19777. if err != nil {
  19778. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  19779. }
  19780. return oldValue.Cc, nil
  19781. }
  19782. // ResetCc resets all changes to the "cc" field.
  19783. func (m *MsgMutation) ResetCc() {
  19784. m.cc = nil
  19785. }
  19786. // SetPhone sets the "phone" field.
  19787. func (m *MsgMutation) SetPhone(s string) {
  19788. m.phone = &s
  19789. }
  19790. // Phone returns the value of the "phone" field in the mutation.
  19791. func (m *MsgMutation) Phone() (r string, exists bool) {
  19792. v := m.phone
  19793. if v == nil {
  19794. return
  19795. }
  19796. return *v, true
  19797. }
  19798. // OldPhone returns the old "phone" field's value of the Msg entity.
  19799. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19801. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  19802. if !m.op.Is(OpUpdateOne) {
  19803. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  19804. }
  19805. if m.id == nil || m.oldValue == nil {
  19806. return v, errors.New("OldPhone requires an ID field in the mutation")
  19807. }
  19808. oldValue, err := m.oldValue(ctx)
  19809. if err != nil {
  19810. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  19811. }
  19812. return oldValue.Phone, nil
  19813. }
  19814. // ResetPhone resets all changes to the "phone" field.
  19815. func (m *MsgMutation) ResetPhone() {
  19816. m.phone = nil
  19817. }
  19818. // Where appends a list predicates to the MsgMutation builder.
  19819. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  19820. m.predicates = append(m.predicates, ps...)
  19821. }
  19822. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  19823. // users can use type-assertion to append predicates that do not depend on any generated package.
  19824. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  19825. p := make([]predicate.Msg, len(ps))
  19826. for i := range ps {
  19827. p[i] = ps[i]
  19828. }
  19829. m.Where(p...)
  19830. }
  19831. // Op returns the operation name.
  19832. func (m *MsgMutation) Op() Op {
  19833. return m.op
  19834. }
  19835. // SetOp allows setting the mutation operation.
  19836. func (m *MsgMutation) SetOp(op Op) {
  19837. m.op = op
  19838. }
  19839. // Type returns the node type of this mutation (Msg).
  19840. func (m *MsgMutation) Type() string {
  19841. return m.typ
  19842. }
  19843. // Fields returns all fields that were changed during this mutation. Note that in
  19844. // order to get all numeric fields that were incremented/decremented, call
  19845. // AddedFields().
  19846. func (m *MsgMutation) Fields() []string {
  19847. fields := make([]string, 0, 11)
  19848. if m.created_at != nil {
  19849. fields = append(fields, msg.FieldCreatedAt)
  19850. }
  19851. if m.updated_at != nil {
  19852. fields = append(fields, msg.FieldUpdatedAt)
  19853. }
  19854. if m.deleted_at != nil {
  19855. fields = append(fields, msg.FieldDeletedAt)
  19856. }
  19857. if m.status != nil {
  19858. fields = append(fields, msg.FieldStatus)
  19859. }
  19860. if m.fromwxid != nil {
  19861. fields = append(fields, msg.FieldFromwxid)
  19862. }
  19863. if m.toid != nil {
  19864. fields = append(fields, msg.FieldToid)
  19865. }
  19866. if m.msgtype != nil {
  19867. fields = append(fields, msg.FieldMsgtype)
  19868. }
  19869. if m.msg != nil {
  19870. fields = append(fields, msg.FieldMsg)
  19871. }
  19872. if m.batch_no != nil {
  19873. fields = append(fields, msg.FieldBatchNo)
  19874. }
  19875. if m.cc != nil {
  19876. fields = append(fields, msg.FieldCc)
  19877. }
  19878. if m.phone != nil {
  19879. fields = append(fields, msg.FieldPhone)
  19880. }
  19881. return fields
  19882. }
  19883. // Field returns the value of a field with the given name. The second boolean
  19884. // return value indicates that this field was not set, or was not defined in the
  19885. // schema.
  19886. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  19887. switch name {
  19888. case msg.FieldCreatedAt:
  19889. return m.CreatedAt()
  19890. case msg.FieldUpdatedAt:
  19891. return m.UpdatedAt()
  19892. case msg.FieldDeletedAt:
  19893. return m.DeletedAt()
  19894. case msg.FieldStatus:
  19895. return m.Status()
  19896. case msg.FieldFromwxid:
  19897. return m.Fromwxid()
  19898. case msg.FieldToid:
  19899. return m.Toid()
  19900. case msg.FieldMsgtype:
  19901. return m.Msgtype()
  19902. case msg.FieldMsg:
  19903. return m.Msg()
  19904. case msg.FieldBatchNo:
  19905. return m.BatchNo()
  19906. case msg.FieldCc:
  19907. return m.Cc()
  19908. case msg.FieldPhone:
  19909. return m.Phone()
  19910. }
  19911. return nil, false
  19912. }
  19913. // OldField returns the old value of the field from the database. An error is
  19914. // returned if the mutation operation is not UpdateOne, or the query to the
  19915. // database failed.
  19916. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19917. switch name {
  19918. case msg.FieldCreatedAt:
  19919. return m.OldCreatedAt(ctx)
  19920. case msg.FieldUpdatedAt:
  19921. return m.OldUpdatedAt(ctx)
  19922. case msg.FieldDeletedAt:
  19923. return m.OldDeletedAt(ctx)
  19924. case msg.FieldStatus:
  19925. return m.OldStatus(ctx)
  19926. case msg.FieldFromwxid:
  19927. return m.OldFromwxid(ctx)
  19928. case msg.FieldToid:
  19929. return m.OldToid(ctx)
  19930. case msg.FieldMsgtype:
  19931. return m.OldMsgtype(ctx)
  19932. case msg.FieldMsg:
  19933. return m.OldMsg(ctx)
  19934. case msg.FieldBatchNo:
  19935. return m.OldBatchNo(ctx)
  19936. case msg.FieldCc:
  19937. return m.OldCc(ctx)
  19938. case msg.FieldPhone:
  19939. return m.OldPhone(ctx)
  19940. }
  19941. return nil, fmt.Errorf("unknown Msg field %s", name)
  19942. }
  19943. // SetField sets the value of a field with the given name. It returns an error if
  19944. // the field is not defined in the schema, or if the type mismatched the field
  19945. // type.
  19946. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  19947. switch name {
  19948. case msg.FieldCreatedAt:
  19949. v, ok := value.(time.Time)
  19950. if !ok {
  19951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19952. }
  19953. m.SetCreatedAt(v)
  19954. return nil
  19955. case msg.FieldUpdatedAt:
  19956. v, ok := value.(time.Time)
  19957. if !ok {
  19958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19959. }
  19960. m.SetUpdatedAt(v)
  19961. return nil
  19962. case msg.FieldDeletedAt:
  19963. v, ok := value.(time.Time)
  19964. if !ok {
  19965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19966. }
  19967. m.SetDeletedAt(v)
  19968. return nil
  19969. case msg.FieldStatus:
  19970. v, ok := value.(uint8)
  19971. if !ok {
  19972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19973. }
  19974. m.SetStatus(v)
  19975. return nil
  19976. case msg.FieldFromwxid:
  19977. v, ok := value.(string)
  19978. if !ok {
  19979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19980. }
  19981. m.SetFromwxid(v)
  19982. return nil
  19983. case msg.FieldToid:
  19984. v, ok := value.(string)
  19985. if !ok {
  19986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19987. }
  19988. m.SetToid(v)
  19989. return nil
  19990. case msg.FieldMsgtype:
  19991. v, ok := value.(int32)
  19992. if !ok {
  19993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19994. }
  19995. m.SetMsgtype(v)
  19996. return nil
  19997. case msg.FieldMsg:
  19998. v, ok := value.(string)
  19999. if !ok {
  20000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20001. }
  20002. m.SetMsg(v)
  20003. return nil
  20004. case msg.FieldBatchNo:
  20005. v, ok := value.(string)
  20006. if !ok {
  20007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20008. }
  20009. m.SetBatchNo(v)
  20010. return nil
  20011. case msg.FieldCc:
  20012. v, ok := value.(string)
  20013. if !ok {
  20014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20015. }
  20016. m.SetCc(v)
  20017. return nil
  20018. case msg.FieldPhone:
  20019. v, ok := value.(string)
  20020. if !ok {
  20021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20022. }
  20023. m.SetPhone(v)
  20024. return nil
  20025. }
  20026. return fmt.Errorf("unknown Msg field %s", name)
  20027. }
  20028. // AddedFields returns all numeric fields that were incremented/decremented during
  20029. // this mutation.
  20030. func (m *MsgMutation) AddedFields() []string {
  20031. var fields []string
  20032. if m.addstatus != nil {
  20033. fields = append(fields, msg.FieldStatus)
  20034. }
  20035. if m.addmsgtype != nil {
  20036. fields = append(fields, msg.FieldMsgtype)
  20037. }
  20038. return fields
  20039. }
  20040. // AddedField returns the numeric value that was incremented/decremented on a field
  20041. // with the given name. The second boolean return value indicates that this field
  20042. // was not set, or was not defined in the schema.
  20043. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  20044. switch name {
  20045. case msg.FieldStatus:
  20046. return m.AddedStatus()
  20047. case msg.FieldMsgtype:
  20048. return m.AddedMsgtype()
  20049. }
  20050. return nil, false
  20051. }
  20052. // AddField adds the value to the field with the given name. It returns an error if
  20053. // the field is not defined in the schema, or if the type mismatched the field
  20054. // type.
  20055. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  20056. switch name {
  20057. case msg.FieldStatus:
  20058. v, ok := value.(int8)
  20059. if !ok {
  20060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20061. }
  20062. m.AddStatus(v)
  20063. return nil
  20064. case msg.FieldMsgtype:
  20065. v, ok := value.(int32)
  20066. if !ok {
  20067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20068. }
  20069. m.AddMsgtype(v)
  20070. return nil
  20071. }
  20072. return fmt.Errorf("unknown Msg numeric field %s", name)
  20073. }
  20074. // ClearedFields returns all nullable fields that were cleared during this
  20075. // mutation.
  20076. func (m *MsgMutation) ClearedFields() []string {
  20077. var fields []string
  20078. if m.FieldCleared(msg.FieldDeletedAt) {
  20079. fields = append(fields, msg.FieldDeletedAt)
  20080. }
  20081. if m.FieldCleared(msg.FieldStatus) {
  20082. fields = append(fields, msg.FieldStatus)
  20083. }
  20084. if m.FieldCleared(msg.FieldFromwxid) {
  20085. fields = append(fields, msg.FieldFromwxid)
  20086. }
  20087. if m.FieldCleared(msg.FieldToid) {
  20088. fields = append(fields, msg.FieldToid)
  20089. }
  20090. if m.FieldCleared(msg.FieldMsgtype) {
  20091. fields = append(fields, msg.FieldMsgtype)
  20092. }
  20093. if m.FieldCleared(msg.FieldMsg) {
  20094. fields = append(fields, msg.FieldMsg)
  20095. }
  20096. if m.FieldCleared(msg.FieldBatchNo) {
  20097. fields = append(fields, msg.FieldBatchNo)
  20098. }
  20099. return fields
  20100. }
  20101. // FieldCleared returns a boolean indicating if a field with the given name was
  20102. // cleared in this mutation.
  20103. func (m *MsgMutation) FieldCleared(name string) bool {
  20104. _, ok := m.clearedFields[name]
  20105. return ok
  20106. }
  20107. // ClearField clears the value of the field with the given name. It returns an
  20108. // error if the field is not defined in the schema.
  20109. func (m *MsgMutation) ClearField(name string) error {
  20110. switch name {
  20111. case msg.FieldDeletedAt:
  20112. m.ClearDeletedAt()
  20113. return nil
  20114. case msg.FieldStatus:
  20115. m.ClearStatus()
  20116. return nil
  20117. case msg.FieldFromwxid:
  20118. m.ClearFromwxid()
  20119. return nil
  20120. case msg.FieldToid:
  20121. m.ClearToid()
  20122. return nil
  20123. case msg.FieldMsgtype:
  20124. m.ClearMsgtype()
  20125. return nil
  20126. case msg.FieldMsg:
  20127. m.ClearMsg()
  20128. return nil
  20129. case msg.FieldBatchNo:
  20130. m.ClearBatchNo()
  20131. return nil
  20132. }
  20133. return fmt.Errorf("unknown Msg nullable field %s", name)
  20134. }
  20135. // ResetField resets all changes in the mutation for the field with the given name.
  20136. // It returns an error if the field is not defined in the schema.
  20137. func (m *MsgMutation) ResetField(name string) error {
  20138. switch name {
  20139. case msg.FieldCreatedAt:
  20140. m.ResetCreatedAt()
  20141. return nil
  20142. case msg.FieldUpdatedAt:
  20143. m.ResetUpdatedAt()
  20144. return nil
  20145. case msg.FieldDeletedAt:
  20146. m.ResetDeletedAt()
  20147. return nil
  20148. case msg.FieldStatus:
  20149. m.ResetStatus()
  20150. return nil
  20151. case msg.FieldFromwxid:
  20152. m.ResetFromwxid()
  20153. return nil
  20154. case msg.FieldToid:
  20155. m.ResetToid()
  20156. return nil
  20157. case msg.FieldMsgtype:
  20158. m.ResetMsgtype()
  20159. return nil
  20160. case msg.FieldMsg:
  20161. m.ResetMsg()
  20162. return nil
  20163. case msg.FieldBatchNo:
  20164. m.ResetBatchNo()
  20165. return nil
  20166. case msg.FieldCc:
  20167. m.ResetCc()
  20168. return nil
  20169. case msg.FieldPhone:
  20170. m.ResetPhone()
  20171. return nil
  20172. }
  20173. return fmt.Errorf("unknown Msg field %s", name)
  20174. }
  20175. // AddedEdges returns all edge names that were set/added in this mutation.
  20176. func (m *MsgMutation) AddedEdges() []string {
  20177. edges := make([]string, 0, 0)
  20178. return edges
  20179. }
  20180. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20181. // name in this mutation.
  20182. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  20183. return nil
  20184. }
  20185. // RemovedEdges returns all edge names that were removed in this mutation.
  20186. func (m *MsgMutation) RemovedEdges() []string {
  20187. edges := make([]string, 0, 0)
  20188. return edges
  20189. }
  20190. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20191. // the given name in this mutation.
  20192. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  20193. return nil
  20194. }
  20195. // ClearedEdges returns all edge names that were cleared in this mutation.
  20196. func (m *MsgMutation) ClearedEdges() []string {
  20197. edges := make([]string, 0, 0)
  20198. return edges
  20199. }
  20200. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20201. // was cleared in this mutation.
  20202. func (m *MsgMutation) EdgeCleared(name string) bool {
  20203. return false
  20204. }
  20205. // ClearEdge clears the value of the edge with the given name. It returns an error
  20206. // if that edge is not defined in the schema.
  20207. func (m *MsgMutation) ClearEdge(name string) error {
  20208. return fmt.Errorf("unknown Msg unique edge %s", name)
  20209. }
  20210. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20211. // It returns an error if the edge is not defined in the schema.
  20212. func (m *MsgMutation) ResetEdge(name string) error {
  20213. return fmt.Errorf("unknown Msg edge %s", name)
  20214. }
  20215. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  20216. type PayRechargeMutation struct {
  20217. config
  20218. op Op
  20219. typ string
  20220. id *uint64
  20221. created_at *time.Time
  20222. updated_at *time.Time
  20223. deleted_at *time.Time
  20224. user_id *string
  20225. number *float32
  20226. addnumber *float32
  20227. status *int
  20228. addstatus *int
  20229. money *float32
  20230. addmoney *float32
  20231. out_trade_no *string
  20232. organization_id *uint64
  20233. addorganization_id *int64
  20234. clearedFields map[string]struct{}
  20235. done bool
  20236. oldValue func(context.Context) (*PayRecharge, error)
  20237. predicates []predicate.PayRecharge
  20238. }
  20239. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  20240. // payrechargeOption allows management of the mutation configuration using functional options.
  20241. type payrechargeOption func(*PayRechargeMutation)
  20242. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  20243. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  20244. m := &PayRechargeMutation{
  20245. config: c,
  20246. op: op,
  20247. typ: TypePayRecharge,
  20248. clearedFields: make(map[string]struct{}),
  20249. }
  20250. for _, opt := range opts {
  20251. opt(m)
  20252. }
  20253. return m
  20254. }
  20255. // withPayRechargeID sets the ID field of the mutation.
  20256. func withPayRechargeID(id uint64) payrechargeOption {
  20257. return func(m *PayRechargeMutation) {
  20258. var (
  20259. err error
  20260. once sync.Once
  20261. value *PayRecharge
  20262. )
  20263. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  20264. once.Do(func() {
  20265. if m.done {
  20266. err = errors.New("querying old values post mutation is not allowed")
  20267. } else {
  20268. value, err = m.Client().PayRecharge.Get(ctx, id)
  20269. }
  20270. })
  20271. return value, err
  20272. }
  20273. m.id = &id
  20274. }
  20275. }
  20276. // withPayRecharge sets the old PayRecharge of the mutation.
  20277. func withPayRecharge(node *PayRecharge) payrechargeOption {
  20278. return func(m *PayRechargeMutation) {
  20279. m.oldValue = func(context.Context) (*PayRecharge, error) {
  20280. return node, nil
  20281. }
  20282. m.id = &node.ID
  20283. }
  20284. }
  20285. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20286. // executed in a transaction (ent.Tx), a transactional client is returned.
  20287. func (m PayRechargeMutation) Client() *Client {
  20288. client := &Client{config: m.config}
  20289. client.init()
  20290. return client
  20291. }
  20292. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20293. // it returns an error otherwise.
  20294. func (m PayRechargeMutation) Tx() (*Tx, error) {
  20295. if _, ok := m.driver.(*txDriver); !ok {
  20296. return nil, errors.New("ent: mutation is not running in a transaction")
  20297. }
  20298. tx := &Tx{config: m.config}
  20299. tx.init()
  20300. return tx, nil
  20301. }
  20302. // SetID sets the value of the id field. Note that this
  20303. // operation is only accepted on creation of PayRecharge entities.
  20304. func (m *PayRechargeMutation) SetID(id uint64) {
  20305. m.id = &id
  20306. }
  20307. // ID returns the ID value in the mutation. Note that the ID is only available
  20308. // if it was provided to the builder or after it was returned from the database.
  20309. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  20310. if m.id == nil {
  20311. return
  20312. }
  20313. return *m.id, true
  20314. }
  20315. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20316. // That means, if the mutation is applied within a transaction with an isolation level such
  20317. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20318. // or updated by the mutation.
  20319. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20320. switch {
  20321. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20322. id, exists := m.ID()
  20323. if exists {
  20324. return []uint64{id}, nil
  20325. }
  20326. fallthrough
  20327. case m.op.Is(OpUpdate | OpDelete):
  20328. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  20329. default:
  20330. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20331. }
  20332. }
  20333. // SetCreatedAt sets the "created_at" field.
  20334. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  20335. m.created_at = &t
  20336. }
  20337. // CreatedAt returns the value of the "created_at" field in the mutation.
  20338. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  20339. v := m.created_at
  20340. if v == nil {
  20341. return
  20342. }
  20343. return *v, true
  20344. }
  20345. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  20346. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20348. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20349. if !m.op.Is(OpUpdateOne) {
  20350. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20351. }
  20352. if m.id == nil || m.oldValue == nil {
  20353. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20354. }
  20355. oldValue, err := m.oldValue(ctx)
  20356. if err != nil {
  20357. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20358. }
  20359. return oldValue.CreatedAt, nil
  20360. }
  20361. // ResetCreatedAt resets all changes to the "created_at" field.
  20362. func (m *PayRechargeMutation) ResetCreatedAt() {
  20363. m.created_at = nil
  20364. }
  20365. // SetUpdatedAt sets the "updated_at" field.
  20366. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  20367. m.updated_at = &t
  20368. }
  20369. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20370. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  20371. v := m.updated_at
  20372. if v == nil {
  20373. return
  20374. }
  20375. return *v, true
  20376. }
  20377. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  20378. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20380. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20381. if !m.op.Is(OpUpdateOne) {
  20382. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20383. }
  20384. if m.id == nil || m.oldValue == nil {
  20385. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20386. }
  20387. oldValue, err := m.oldValue(ctx)
  20388. if err != nil {
  20389. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20390. }
  20391. return oldValue.UpdatedAt, nil
  20392. }
  20393. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20394. func (m *PayRechargeMutation) ResetUpdatedAt() {
  20395. m.updated_at = nil
  20396. }
  20397. // SetDeletedAt sets the "deleted_at" field.
  20398. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  20399. m.deleted_at = &t
  20400. }
  20401. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20402. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  20403. v := m.deleted_at
  20404. if v == nil {
  20405. return
  20406. }
  20407. return *v, true
  20408. }
  20409. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  20410. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20412. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20413. if !m.op.Is(OpUpdateOne) {
  20414. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20415. }
  20416. if m.id == nil || m.oldValue == nil {
  20417. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20418. }
  20419. oldValue, err := m.oldValue(ctx)
  20420. if err != nil {
  20421. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20422. }
  20423. return oldValue.DeletedAt, nil
  20424. }
  20425. // ClearDeletedAt clears the value of the "deleted_at" field.
  20426. func (m *PayRechargeMutation) ClearDeletedAt() {
  20427. m.deleted_at = nil
  20428. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  20429. }
  20430. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20431. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  20432. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  20433. return ok
  20434. }
  20435. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20436. func (m *PayRechargeMutation) ResetDeletedAt() {
  20437. m.deleted_at = nil
  20438. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  20439. }
  20440. // SetUserID sets the "user_id" field.
  20441. func (m *PayRechargeMutation) SetUserID(s string) {
  20442. m.user_id = &s
  20443. }
  20444. // UserID returns the value of the "user_id" field in the mutation.
  20445. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  20446. v := m.user_id
  20447. if v == nil {
  20448. return
  20449. }
  20450. return *v, true
  20451. }
  20452. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  20453. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20455. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  20456. if !m.op.Is(OpUpdateOne) {
  20457. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  20458. }
  20459. if m.id == nil || m.oldValue == nil {
  20460. return v, errors.New("OldUserID requires an ID field in the mutation")
  20461. }
  20462. oldValue, err := m.oldValue(ctx)
  20463. if err != nil {
  20464. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  20465. }
  20466. return oldValue.UserID, nil
  20467. }
  20468. // ResetUserID resets all changes to the "user_id" field.
  20469. func (m *PayRechargeMutation) ResetUserID() {
  20470. m.user_id = nil
  20471. }
  20472. // SetNumber sets the "number" field.
  20473. func (m *PayRechargeMutation) SetNumber(f float32) {
  20474. m.number = &f
  20475. m.addnumber = nil
  20476. }
  20477. // Number returns the value of the "number" field in the mutation.
  20478. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  20479. v := m.number
  20480. if v == nil {
  20481. return
  20482. }
  20483. return *v, true
  20484. }
  20485. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  20486. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20488. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  20489. if !m.op.Is(OpUpdateOne) {
  20490. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  20491. }
  20492. if m.id == nil || m.oldValue == nil {
  20493. return v, errors.New("OldNumber requires an ID field in the mutation")
  20494. }
  20495. oldValue, err := m.oldValue(ctx)
  20496. if err != nil {
  20497. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  20498. }
  20499. return oldValue.Number, nil
  20500. }
  20501. // AddNumber adds f to the "number" field.
  20502. func (m *PayRechargeMutation) AddNumber(f float32) {
  20503. if m.addnumber != nil {
  20504. *m.addnumber += f
  20505. } else {
  20506. m.addnumber = &f
  20507. }
  20508. }
  20509. // AddedNumber returns the value that was added to the "number" field in this mutation.
  20510. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  20511. v := m.addnumber
  20512. if v == nil {
  20513. return
  20514. }
  20515. return *v, true
  20516. }
  20517. // ResetNumber resets all changes to the "number" field.
  20518. func (m *PayRechargeMutation) ResetNumber() {
  20519. m.number = nil
  20520. m.addnumber = nil
  20521. }
  20522. // SetStatus sets the "status" field.
  20523. func (m *PayRechargeMutation) SetStatus(i int) {
  20524. m.status = &i
  20525. m.addstatus = nil
  20526. }
  20527. // Status returns the value of the "status" field in the mutation.
  20528. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  20529. v := m.status
  20530. if v == nil {
  20531. return
  20532. }
  20533. return *v, true
  20534. }
  20535. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  20536. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20538. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  20539. if !m.op.Is(OpUpdateOne) {
  20540. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20541. }
  20542. if m.id == nil || m.oldValue == nil {
  20543. return v, errors.New("OldStatus requires an ID field in the mutation")
  20544. }
  20545. oldValue, err := m.oldValue(ctx)
  20546. if err != nil {
  20547. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20548. }
  20549. return oldValue.Status, nil
  20550. }
  20551. // AddStatus adds i to the "status" field.
  20552. func (m *PayRechargeMutation) AddStatus(i int) {
  20553. if m.addstatus != nil {
  20554. *m.addstatus += i
  20555. } else {
  20556. m.addstatus = &i
  20557. }
  20558. }
  20559. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20560. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  20561. v := m.addstatus
  20562. if v == nil {
  20563. return
  20564. }
  20565. return *v, true
  20566. }
  20567. // ClearStatus clears the value of the "status" field.
  20568. func (m *PayRechargeMutation) ClearStatus() {
  20569. m.status = nil
  20570. m.addstatus = nil
  20571. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  20572. }
  20573. // StatusCleared returns if the "status" field was cleared in this mutation.
  20574. func (m *PayRechargeMutation) StatusCleared() bool {
  20575. _, ok := m.clearedFields[payrecharge.FieldStatus]
  20576. return ok
  20577. }
  20578. // ResetStatus resets all changes to the "status" field.
  20579. func (m *PayRechargeMutation) ResetStatus() {
  20580. m.status = nil
  20581. m.addstatus = nil
  20582. delete(m.clearedFields, payrecharge.FieldStatus)
  20583. }
  20584. // SetMoney sets the "money" field.
  20585. func (m *PayRechargeMutation) SetMoney(f float32) {
  20586. m.money = &f
  20587. m.addmoney = nil
  20588. }
  20589. // Money returns the value of the "money" field in the mutation.
  20590. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  20591. v := m.money
  20592. if v == nil {
  20593. return
  20594. }
  20595. return *v, true
  20596. }
  20597. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  20598. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20600. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  20601. if !m.op.Is(OpUpdateOne) {
  20602. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  20603. }
  20604. if m.id == nil || m.oldValue == nil {
  20605. return v, errors.New("OldMoney requires an ID field in the mutation")
  20606. }
  20607. oldValue, err := m.oldValue(ctx)
  20608. if err != nil {
  20609. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  20610. }
  20611. return oldValue.Money, nil
  20612. }
  20613. // AddMoney adds f to the "money" field.
  20614. func (m *PayRechargeMutation) AddMoney(f float32) {
  20615. if m.addmoney != nil {
  20616. *m.addmoney += f
  20617. } else {
  20618. m.addmoney = &f
  20619. }
  20620. }
  20621. // AddedMoney returns the value that was added to the "money" field in this mutation.
  20622. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  20623. v := m.addmoney
  20624. if v == nil {
  20625. return
  20626. }
  20627. return *v, true
  20628. }
  20629. // ClearMoney clears the value of the "money" field.
  20630. func (m *PayRechargeMutation) ClearMoney() {
  20631. m.money = nil
  20632. m.addmoney = nil
  20633. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  20634. }
  20635. // MoneyCleared returns if the "money" field was cleared in this mutation.
  20636. func (m *PayRechargeMutation) MoneyCleared() bool {
  20637. _, ok := m.clearedFields[payrecharge.FieldMoney]
  20638. return ok
  20639. }
  20640. // ResetMoney resets all changes to the "money" field.
  20641. func (m *PayRechargeMutation) ResetMoney() {
  20642. m.money = nil
  20643. m.addmoney = nil
  20644. delete(m.clearedFields, payrecharge.FieldMoney)
  20645. }
  20646. // SetOutTradeNo sets the "out_trade_no" field.
  20647. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  20648. m.out_trade_no = &s
  20649. }
  20650. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  20651. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  20652. v := m.out_trade_no
  20653. if v == nil {
  20654. return
  20655. }
  20656. return *v, true
  20657. }
  20658. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  20659. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20661. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  20662. if !m.op.Is(OpUpdateOne) {
  20663. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  20664. }
  20665. if m.id == nil || m.oldValue == nil {
  20666. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  20667. }
  20668. oldValue, err := m.oldValue(ctx)
  20669. if err != nil {
  20670. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  20671. }
  20672. return oldValue.OutTradeNo, nil
  20673. }
  20674. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  20675. func (m *PayRechargeMutation) ClearOutTradeNo() {
  20676. m.out_trade_no = nil
  20677. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  20678. }
  20679. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  20680. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  20681. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  20682. return ok
  20683. }
  20684. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  20685. func (m *PayRechargeMutation) ResetOutTradeNo() {
  20686. m.out_trade_no = nil
  20687. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  20688. }
  20689. // SetOrganizationID sets the "organization_id" field.
  20690. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  20691. m.organization_id = &u
  20692. m.addorganization_id = nil
  20693. }
  20694. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20695. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  20696. v := m.organization_id
  20697. if v == nil {
  20698. return
  20699. }
  20700. return *v, true
  20701. }
  20702. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  20703. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20705. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20706. if !m.op.Is(OpUpdateOne) {
  20707. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20708. }
  20709. if m.id == nil || m.oldValue == nil {
  20710. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20711. }
  20712. oldValue, err := m.oldValue(ctx)
  20713. if err != nil {
  20714. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20715. }
  20716. return oldValue.OrganizationID, nil
  20717. }
  20718. // AddOrganizationID adds u to the "organization_id" field.
  20719. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  20720. if m.addorganization_id != nil {
  20721. *m.addorganization_id += u
  20722. } else {
  20723. m.addorganization_id = &u
  20724. }
  20725. }
  20726. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20727. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  20728. v := m.addorganization_id
  20729. if v == nil {
  20730. return
  20731. }
  20732. return *v, true
  20733. }
  20734. // ResetOrganizationID resets all changes to the "organization_id" field.
  20735. func (m *PayRechargeMutation) ResetOrganizationID() {
  20736. m.organization_id = nil
  20737. m.addorganization_id = nil
  20738. }
  20739. // Where appends a list predicates to the PayRechargeMutation builder.
  20740. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  20741. m.predicates = append(m.predicates, ps...)
  20742. }
  20743. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  20744. // users can use type-assertion to append predicates that do not depend on any generated package.
  20745. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  20746. p := make([]predicate.PayRecharge, len(ps))
  20747. for i := range ps {
  20748. p[i] = ps[i]
  20749. }
  20750. m.Where(p...)
  20751. }
  20752. // Op returns the operation name.
  20753. func (m *PayRechargeMutation) Op() Op {
  20754. return m.op
  20755. }
  20756. // SetOp allows setting the mutation operation.
  20757. func (m *PayRechargeMutation) SetOp(op Op) {
  20758. m.op = op
  20759. }
  20760. // Type returns the node type of this mutation (PayRecharge).
  20761. func (m *PayRechargeMutation) Type() string {
  20762. return m.typ
  20763. }
  20764. // Fields returns all fields that were changed during this mutation. Note that in
  20765. // order to get all numeric fields that were incremented/decremented, call
  20766. // AddedFields().
  20767. func (m *PayRechargeMutation) Fields() []string {
  20768. fields := make([]string, 0, 9)
  20769. if m.created_at != nil {
  20770. fields = append(fields, payrecharge.FieldCreatedAt)
  20771. }
  20772. if m.updated_at != nil {
  20773. fields = append(fields, payrecharge.FieldUpdatedAt)
  20774. }
  20775. if m.deleted_at != nil {
  20776. fields = append(fields, payrecharge.FieldDeletedAt)
  20777. }
  20778. if m.user_id != nil {
  20779. fields = append(fields, payrecharge.FieldUserID)
  20780. }
  20781. if m.number != nil {
  20782. fields = append(fields, payrecharge.FieldNumber)
  20783. }
  20784. if m.status != nil {
  20785. fields = append(fields, payrecharge.FieldStatus)
  20786. }
  20787. if m.money != nil {
  20788. fields = append(fields, payrecharge.FieldMoney)
  20789. }
  20790. if m.out_trade_no != nil {
  20791. fields = append(fields, payrecharge.FieldOutTradeNo)
  20792. }
  20793. if m.organization_id != nil {
  20794. fields = append(fields, payrecharge.FieldOrganizationID)
  20795. }
  20796. return fields
  20797. }
  20798. // Field returns the value of a field with the given name. The second boolean
  20799. // return value indicates that this field was not set, or was not defined in the
  20800. // schema.
  20801. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  20802. switch name {
  20803. case payrecharge.FieldCreatedAt:
  20804. return m.CreatedAt()
  20805. case payrecharge.FieldUpdatedAt:
  20806. return m.UpdatedAt()
  20807. case payrecharge.FieldDeletedAt:
  20808. return m.DeletedAt()
  20809. case payrecharge.FieldUserID:
  20810. return m.UserID()
  20811. case payrecharge.FieldNumber:
  20812. return m.Number()
  20813. case payrecharge.FieldStatus:
  20814. return m.Status()
  20815. case payrecharge.FieldMoney:
  20816. return m.Money()
  20817. case payrecharge.FieldOutTradeNo:
  20818. return m.OutTradeNo()
  20819. case payrecharge.FieldOrganizationID:
  20820. return m.OrganizationID()
  20821. }
  20822. return nil, false
  20823. }
  20824. // OldField returns the old value of the field from the database. An error is
  20825. // returned if the mutation operation is not UpdateOne, or the query to the
  20826. // database failed.
  20827. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20828. switch name {
  20829. case payrecharge.FieldCreatedAt:
  20830. return m.OldCreatedAt(ctx)
  20831. case payrecharge.FieldUpdatedAt:
  20832. return m.OldUpdatedAt(ctx)
  20833. case payrecharge.FieldDeletedAt:
  20834. return m.OldDeletedAt(ctx)
  20835. case payrecharge.FieldUserID:
  20836. return m.OldUserID(ctx)
  20837. case payrecharge.FieldNumber:
  20838. return m.OldNumber(ctx)
  20839. case payrecharge.FieldStatus:
  20840. return m.OldStatus(ctx)
  20841. case payrecharge.FieldMoney:
  20842. return m.OldMoney(ctx)
  20843. case payrecharge.FieldOutTradeNo:
  20844. return m.OldOutTradeNo(ctx)
  20845. case payrecharge.FieldOrganizationID:
  20846. return m.OldOrganizationID(ctx)
  20847. }
  20848. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  20849. }
  20850. // SetField sets the value of a field with the given name. It returns an error if
  20851. // the field is not defined in the schema, or if the type mismatched the field
  20852. // type.
  20853. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  20854. switch name {
  20855. case payrecharge.FieldCreatedAt:
  20856. v, ok := value.(time.Time)
  20857. if !ok {
  20858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20859. }
  20860. m.SetCreatedAt(v)
  20861. return nil
  20862. case payrecharge.FieldUpdatedAt:
  20863. v, ok := value.(time.Time)
  20864. if !ok {
  20865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20866. }
  20867. m.SetUpdatedAt(v)
  20868. return nil
  20869. case payrecharge.FieldDeletedAt:
  20870. v, ok := value.(time.Time)
  20871. if !ok {
  20872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20873. }
  20874. m.SetDeletedAt(v)
  20875. return nil
  20876. case payrecharge.FieldUserID:
  20877. v, ok := value.(string)
  20878. if !ok {
  20879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20880. }
  20881. m.SetUserID(v)
  20882. return nil
  20883. case payrecharge.FieldNumber:
  20884. v, ok := value.(float32)
  20885. if !ok {
  20886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20887. }
  20888. m.SetNumber(v)
  20889. return nil
  20890. case payrecharge.FieldStatus:
  20891. v, ok := value.(int)
  20892. if !ok {
  20893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20894. }
  20895. m.SetStatus(v)
  20896. return nil
  20897. case payrecharge.FieldMoney:
  20898. v, ok := value.(float32)
  20899. if !ok {
  20900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20901. }
  20902. m.SetMoney(v)
  20903. return nil
  20904. case payrecharge.FieldOutTradeNo:
  20905. v, ok := value.(string)
  20906. if !ok {
  20907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20908. }
  20909. m.SetOutTradeNo(v)
  20910. return nil
  20911. case payrecharge.FieldOrganizationID:
  20912. v, ok := value.(uint64)
  20913. if !ok {
  20914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20915. }
  20916. m.SetOrganizationID(v)
  20917. return nil
  20918. }
  20919. return fmt.Errorf("unknown PayRecharge field %s", name)
  20920. }
  20921. // AddedFields returns all numeric fields that were incremented/decremented during
  20922. // this mutation.
  20923. func (m *PayRechargeMutation) AddedFields() []string {
  20924. var fields []string
  20925. if m.addnumber != nil {
  20926. fields = append(fields, payrecharge.FieldNumber)
  20927. }
  20928. if m.addstatus != nil {
  20929. fields = append(fields, payrecharge.FieldStatus)
  20930. }
  20931. if m.addmoney != nil {
  20932. fields = append(fields, payrecharge.FieldMoney)
  20933. }
  20934. if m.addorganization_id != nil {
  20935. fields = append(fields, payrecharge.FieldOrganizationID)
  20936. }
  20937. return fields
  20938. }
  20939. // AddedField returns the numeric value that was incremented/decremented on a field
  20940. // with the given name. The second boolean return value indicates that this field
  20941. // was not set, or was not defined in the schema.
  20942. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  20943. switch name {
  20944. case payrecharge.FieldNumber:
  20945. return m.AddedNumber()
  20946. case payrecharge.FieldStatus:
  20947. return m.AddedStatus()
  20948. case payrecharge.FieldMoney:
  20949. return m.AddedMoney()
  20950. case payrecharge.FieldOrganizationID:
  20951. return m.AddedOrganizationID()
  20952. }
  20953. return nil, false
  20954. }
  20955. // AddField adds the value to the field with the given name. It returns an error if
  20956. // the field is not defined in the schema, or if the type mismatched the field
  20957. // type.
  20958. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  20959. switch name {
  20960. case payrecharge.FieldNumber:
  20961. v, ok := value.(float32)
  20962. if !ok {
  20963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20964. }
  20965. m.AddNumber(v)
  20966. return nil
  20967. case payrecharge.FieldStatus:
  20968. v, ok := value.(int)
  20969. if !ok {
  20970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20971. }
  20972. m.AddStatus(v)
  20973. return nil
  20974. case payrecharge.FieldMoney:
  20975. v, ok := value.(float32)
  20976. if !ok {
  20977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20978. }
  20979. m.AddMoney(v)
  20980. return nil
  20981. case payrecharge.FieldOrganizationID:
  20982. v, ok := value.(int64)
  20983. if !ok {
  20984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20985. }
  20986. m.AddOrganizationID(v)
  20987. return nil
  20988. }
  20989. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  20990. }
  20991. // ClearedFields returns all nullable fields that were cleared during this
  20992. // mutation.
  20993. func (m *PayRechargeMutation) ClearedFields() []string {
  20994. var fields []string
  20995. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  20996. fields = append(fields, payrecharge.FieldDeletedAt)
  20997. }
  20998. if m.FieldCleared(payrecharge.FieldStatus) {
  20999. fields = append(fields, payrecharge.FieldStatus)
  21000. }
  21001. if m.FieldCleared(payrecharge.FieldMoney) {
  21002. fields = append(fields, payrecharge.FieldMoney)
  21003. }
  21004. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  21005. fields = append(fields, payrecharge.FieldOutTradeNo)
  21006. }
  21007. return fields
  21008. }
  21009. // FieldCleared returns a boolean indicating if a field with the given name was
  21010. // cleared in this mutation.
  21011. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  21012. _, ok := m.clearedFields[name]
  21013. return ok
  21014. }
  21015. // ClearField clears the value of the field with the given name. It returns an
  21016. // error if the field is not defined in the schema.
  21017. func (m *PayRechargeMutation) ClearField(name string) error {
  21018. switch name {
  21019. case payrecharge.FieldDeletedAt:
  21020. m.ClearDeletedAt()
  21021. return nil
  21022. case payrecharge.FieldStatus:
  21023. m.ClearStatus()
  21024. return nil
  21025. case payrecharge.FieldMoney:
  21026. m.ClearMoney()
  21027. return nil
  21028. case payrecharge.FieldOutTradeNo:
  21029. m.ClearOutTradeNo()
  21030. return nil
  21031. }
  21032. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  21033. }
  21034. // ResetField resets all changes in the mutation for the field with the given name.
  21035. // It returns an error if the field is not defined in the schema.
  21036. func (m *PayRechargeMutation) ResetField(name string) error {
  21037. switch name {
  21038. case payrecharge.FieldCreatedAt:
  21039. m.ResetCreatedAt()
  21040. return nil
  21041. case payrecharge.FieldUpdatedAt:
  21042. m.ResetUpdatedAt()
  21043. return nil
  21044. case payrecharge.FieldDeletedAt:
  21045. m.ResetDeletedAt()
  21046. return nil
  21047. case payrecharge.FieldUserID:
  21048. m.ResetUserID()
  21049. return nil
  21050. case payrecharge.FieldNumber:
  21051. m.ResetNumber()
  21052. return nil
  21053. case payrecharge.FieldStatus:
  21054. m.ResetStatus()
  21055. return nil
  21056. case payrecharge.FieldMoney:
  21057. m.ResetMoney()
  21058. return nil
  21059. case payrecharge.FieldOutTradeNo:
  21060. m.ResetOutTradeNo()
  21061. return nil
  21062. case payrecharge.FieldOrganizationID:
  21063. m.ResetOrganizationID()
  21064. return nil
  21065. }
  21066. return fmt.Errorf("unknown PayRecharge field %s", name)
  21067. }
  21068. // AddedEdges returns all edge names that were set/added in this mutation.
  21069. func (m *PayRechargeMutation) AddedEdges() []string {
  21070. edges := make([]string, 0, 0)
  21071. return edges
  21072. }
  21073. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21074. // name in this mutation.
  21075. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  21076. return nil
  21077. }
  21078. // RemovedEdges returns all edge names that were removed in this mutation.
  21079. func (m *PayRechargeMutation) RemovedEdges() []string {
  21080. edges := make([]string, 0, 0)
  21081. return edges
  21082. }
  21083. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21084. // the given name in this mutation.
  21085. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  21086. return nil
  21087. }
  21088. // ClearedEdges returns all edge names that were cleared in this mutation.
  21089. func (m *PayRechargeMutation) ClearedEdges() []string {
  21090. edges := make([]string, 0, 0)
  21091. return edges
  21092. }
  21093. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21094. // was cleared in this mutation.
  21095. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  21096. return false
  21097. }
  21098. // ClearEdge clears the value of the edge with the given name. It returns an error
  21099. // if that edge is not defined in the schema.
  21100. func (m *PayRechargeMutation) ClearEdge(name string) error {
  21101. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  21102. }
  21103. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21104. // It returns an error if the edge is not defined in the schema.
  21105. func (m *PayRechargeMutation) ResetEdge(name string) error {
  21106. return fmt.Errorf("unknown PayRecharge edge %s", name)
  21107. }
  21108. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  21109. type ServerMutation struct {
  21110. config
  21111. op Op
  21112. typ string
  21113. id *uint64
  21114. created_at *time.Time
  21115. updated_at *time.Time
  21116. status *uint8
  21117. addstatus *int8
  21118. deleted_at *time.Time
  21119. name *string
  21120. public_ip *string
  21121. private_ip *string
  21122. admin_port *string
  21123. clearedFields map[string]struct{}
  21124. wxs map[uint64]struct{}
  21125. removedwxs map[uint64]struct{}
  21126. clearedwxs bool
  21127. done bool
  21128. oldValue func(context.Context) (*Server, error)
  21129. predicates []predicate.Server
  21130. }
  21131. var _ ent.Mutation = (*ServerMutation)(nil)
  21132. // serverOption allows management of the mutation configuration using functional options.
  21133. type serverOption func(*ServerMutation)
  21134. // newServerMutation creates new mutation for the Server entity.
  21135. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  21136. m := &ServerMutation{
  21137. config: c,
  21138. op: op,
  21139. typ: TypeServer,
  21140. clearedFields: make(map[string]struct{}),
  21141. }
  21142. for _, opt := range opts {
  21143. opt(m)
  21144. }
  21145. return m
  21146. }
  21147. // withServerID sets the ID field of the mutation.
  21148. func withServerID(id uint64) serverOption {
  21149. return func(m *ServerMutation) {
  21150. var (
  21151. err error
  21152. once sync.Once
  21153. value *Server
  21154. )
  21155. m.oldValue = func(ctx context.Context) (*Server, error) {
  21156. once.Do(func() {
  21157. if m.done {
  21158. err = errors.New("querying old values post mutation is not allowed")
  21159. } else {
  21160. value, err = m.Client().Server.Get(ctx, id)
  21161. }
  21162. })
  21163. return value, err
  21164. }
  21165. m.id = &id
  21166. }
  21167. }
  21168. // withServer sets the old Server of the mutation.
  21169. func withServer(node *Server) serverOption {
  21170. return func(m *ServerMutation) {
  21171. m.oldValue = func(context.Context) (*Server, error) {
  21172. return node, nil
  21173. }
  21174. m.id = &node.ID
  21175. }
  21176. }
  21177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21178. // executed in a transaction (ent.Tx), a transactional client is returned.
  21179. func (m ServerMutation) Client() *Client {
  21180. client := &Client{config: m.config}
  21181. client.init()
  21182. return client
  21183. }
  21184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21185. // it returns an error otherwise.
  21186. func (m ServerMutation) Tx() (*Tx, error) {
  21187. if _, ok := m.driver.(*txDriver); !ok {
  21188. return nil, errors.New("ent: mutation is not running in a transaction")
  21189. }
  21190. tx := &Tx{config: m.config}
  21191. tx.init()
  21192. return tx, nil
  21193. }
  21194. // SetID sets the value of the id field. Note that this
  21195. // operation is only accepted on creation of Server entities.
  21196. func (m *ServerMutation) SetID(id uint64) {
  21197. m.id = &id
  21198. }
  21199. // ID returns the ID value in the mutation. Note that the ID is only available
  21200. // if it was provided to the builder or after it was returned from the database.
  21201. func (m *ServerMutation) ID() (id uint64, exists bool) {
  21202. if m.id == nil {
  21203. return
  21204. }
  21205. return *m.id, true
  21206. }
  21207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21208. // That means, if the mutation is applied within a transaction with an isolation level such
  21209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21210. // or updated by the mutation.
  21211. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  21212. switch {
  21213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21214. id, exists := m.ID()
  21215. if exists {
  21216. return []uint64{id}, nil
  21217. }
  21218. fallthrough
  21219. case m.op.Is(OpUpdate | OpDelete):
  21220. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  21221. default:
  21222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21223. }
  21224. }
  21225. // SetCreatedAt sets the "created_at" field.
  21226. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  21227. m.created_at = &t
  21228. }
  21229. // CreatedAt returns the value of the "created_at" field in the mutation.
  21230. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  21231. v := m.created_at
  21232. if v == nil {
  21233. return
  21234. }
  21235. return *v, true
  21236. }
  21237. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  21238. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21240. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21241. if !m.op.Is(OpUpdateOne) {
  21242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21243. }
  21244. if m.id == nil || m.oldValue == nil {
  21245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21246. }
  21247. oldValue, err := m.oldValue(ctx)
  21248. if err != nil {
  21249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21250. }
  21251. return oldValue.CreatedAt, nil
  21252. }
  21253. // ResetCreatedAt resets all changes to the "created_at" field.
  21254. func (m *ServerMutation) ResetCreatedAt() {
  21255. m.created_at = nil
  21256. }
  21257. // SetUpdatedAt sets the "updated_at" field.
  21258. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  21259. m.updated_at = &t
  21260. }
  21261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21262. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  21263. v := m.updated_at
  21264. if v == nil {
  21265. return
  21266. }
  21267. return *v, true
  21268. }
  21269. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  21270. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21272. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21273. if !m.op.Is(OpUpdateOne) {
  21274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21275. }
  21276. if m.id == nil || m.oldValue == nil {
  21277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21278. }
  21279. oldValue, err := m.oldValue(ctx)
  21280. if err != nil {
  21281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21282. }
  21283. return oldValue.UpdatedAt, nil
  21284. }
  21285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21286. func (m *ServerMutation) ResetUpdatedAt() {
  21287. m.updated_at = nil
  21288. }
  21289. // SetStatus sets the "status" field.
  21290. func (m *ServerMutation) SetStatus(u uint8) {
  21291. m.status = &u
  21292. m.addstatus = nil
  21293. }
  21294. // Status returns the value of the "status" field in the mutation.
  21295. func (m *ServerMutation) Status() (r uint8, exists bool) {
  21296. v := m.status
  21297. if v == nil {
  21298. return
  21299. }
  21300. return *v, true
  21301. }
  21302. // OldStatus returns the old "status" field's value of the Server entity.
  21303. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21305. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21306. if !m.op.Is(OpUpdateOne) {
  21307. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21308. }
  21309. if m.id == nil || m.oldValue == nil {
  21310. return v, errors.New("OldStatus requires an ID field in the mutation")
  21311. }
  21312. oldValue, err := m.oldValue(ctx)
  21313. if err != nil {
  21314. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21315. }
  21316. return oldValue.Status, nil
  21317. }
  21318. // AddStatus adds u to the "status" field.
  21319. func (m *ServerMutation) AddStatus(u int8) {
  21320. if m.addstatus != nil {
  21321. *m.addstatus += u
  21322. } else {
  21323. m.addstatus = &u
  21324. }
  21325. }
  21326. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21327. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  21328. v := m.addstatus
  21329. if v == nil {
  21330. return
  21331. }
  21332. return *v, true
  21333. }
  21334. // ClearStatus clears the value of the "status" field.
  21335. func (m *ServerMutation) ClearStatus() {
  21336. m.status = nil
  21337. m.addstatus = nil
  21338. m.clearedFields[server.FieldStatus] = struct{}{}
  21339. }
  21340. // StatusCleared returns if the "status" field was cleared in this mutation.
  21341. func (m *ServerMutation) StatusCleared() bool {
  21342. _, ok := m.clearedFields[server.FieldStatus]
  21343. return ok
  21344. }
  21345. // ResetStatus resets all changes to the "status" field.
  21346. func (m *ServerMutation) ResetStatus() {
  21347. m.status = nil
  21348. m.addstatus = nil
  21349. delete(m.clearedFields, server.FieldStatus)
  21350. }
  21351. // SetDeletedAt sets the "deleted_at" field.
  21352. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  21353. m.deleted_at = &t
  21354. }
  21355. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21356. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  21357. v := m.deleted_at
  21358. if v == nil {
  21359. return
  21360. }
  21361. return *v, true
  21362. }
  21363. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  21364. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21366. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21367. if !m.op.Is(OpUpdateOne) {
  21368. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21369. }
  21370. if m.id == nil || m.oldValue == nil {
  21371. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21372. }
  21373. oldValue, err := m.oldValue(ctx)
  21374. if err != nil {
  21375. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21376. }
  21377. return oldValue.DeletedAt, nil
  21378. }
  21379. // ClearDeletedAt clears the value of the "deleted_at" field.
  21380. func (m *ServerMutation) ClearDeletedAt() {
  21381. m.deleted_at = nil
  21382. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  21383. }
  21384. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21385. func (m *ServerMutation) DeletedAtCleared() bool {
  21386. _, ok := m.clearedFields[server.FieldDeletedAt]
  21387. return ok
  21388. }
  21389. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21390. func (m *ServerMutation) ResetDeletedAt() {
  21391. m.deleted_at = nil
  21392. delete(m.clearedFields, server.FieldDeletedAt)
  21393. }
  21394. // SetName sets the "name" field.
  21395. func (m *ServerMutation) SetName(s string) {
  21396. m.name = &s
  21397. }
  21398. // Name returns the value of the "name" field in the mutation.
  21399. func (m *ServerMutation) Name() (r string, exists bool) {
  21400. v := m.name
  21401. if v == nil {
  21402. return
  21403. }
  21404. return *v, true
  21405. }
  21406. // OldName returns the old "name" field's value of the Server entity.
  21407. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21409. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  21410. if !m.op.Is(OpUpdateOne) {
  21411. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21412. }
  21413. if m.id == nil || m.oldValue == nil {
  21414. return v, errors.New("OldName requires an ID field in the mutation")
  21415. }
  21416. oldValue, err := m.oldValue(ctx)
  21417. if err != nil {
  21418. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21419. }
  21420. return oldValue.Name, nil
  21421. }
  21422. // ResetName resets all changes to the "name" field.
  21423. func (m *ServerMutation) ResetName() {
  21424. m.name = nil
  21425. }
  21426. // SetPublicIP sets the "public_ip" field.
  21427. func (m *ServerMutation) SetPublicIP(s string) {
  21428. m.public_ip = &s
  21429. }
  21430. // PublicIP returns the value of the "public_ip" field in the mutation.
  21431. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  21432. v := m.public_ip
  21433. if v == nil {
  21434. return
  21435. }
  21436. return *v, true
  21437. }
  21438. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  21439. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21441. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  21442. if !m.op.Is(OpUpdateOne) {
  21443. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  21444. }
  21445. if m.id == nil || m.oldValue == nil {
  21446. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  21447. }
  21448. oldValue, err := m.oldValue(ctx)
  21449. if err != nil {
  21450. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  21451. }
  21452. return oldValue.PublicIP, nil
  21453. }
  21454. // ResetPublicIP resets all changes to the "public_ip" field.
  21455. func (m *ServerMutation) ResetPublicIP() {
  21456. m.public_ip = nil
  21457. }
  21458. // SetPrivateIP sets the "private_ip" field.
  21459. func (m *ServerMutation) SetPrivateIP(s string) {
  21460. m.private_ip = &s
  21461. }
  21462. // PrivateIP returns the value of the "private_ip" field in the mutation.
  21463. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  21464. v := m.private_ip
  21465. if v == nil {
  21466. return
  21467. }
  21468. return *v, true
  21469. }
  21470. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  21471. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21473. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  21474. if !m.op.Is(OpUpdateOne) {
  21475. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  21476. }
  21477. if m.id == nil || m.oldValue == nil {
  21478. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  21479. }
  21480. oldValue, err := m.oldValue(ctx)
  21481. if err != nil {
  21482. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  21483. }
  21484. return oldValue.PrivateIP, nil
  21485. }
  21486. // ResetPrivateIP resets all changes to the "private_ip" field.
  21487. func (m *ServerMutation) ResetPrivateIP() {
  21488. m.private_ip = nil
  21489. }
  21490. // SetAdminPort sets the "admin_port" field.
  21491. func (m *ServerMutation) SetAdminPort(s string) {
  21492. m.admin_port = &s
  21493. }
  21494. // AdminPort returns the value of the "admin_port" field in the mutation.
  21495. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  21496. v := m.admin_port
  21497. if v == nil {
  21498. return
  21499. }
  21500. return *v, true
  21501. }
  21502. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  21503. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21505. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  21506. if !m.op.Is(OpUpdateOne) {
  21507. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  21508. }
  21509. if m.id == nil || m.oldValue == nil {
  21510. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  21511. }
  21512. oldValue, err := m.oldValue(ctx)
  21513. if err != nil {
  21514. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  21515. }
  21516. return oldValue.AdminPort, nil
  21517. }
  21518. // ResetAdminPort resets all changes to the "admin_port" field.
  21519. func (m *ServerMutation) ResetAdminPort() {
  21520. m.admin_port = nil
  21521. }
  21522. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  21523. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  21524. if m.wxs == nil {
  21525. m.wxs = make(map[uint64]struct{})
  21526. }
  21527. for i := range ids {
  21528. m.wxs[ids[i]] = struct{}{}
  21529. }
  21530. }
  21531. // ClearWxs clears the "wxs" edge to the Wx entity.
  21532. func (m *ServerMutation) ClearWxs() {
  21533. m.clearedwxs = true
  21534. }
  21535. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  21536. func (m *ServerMutation) WxsCleared() bool {
  21537. return m.clearedwxs
  21538. }
  21539. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  21540. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  21541. if m.removedwxs == nil {
  21542. m.removedwxs = make(map[uint64]struct{})
  21543. }
  21544. for i := range ids {
  21545. delete(m.wxs, ids[i])
  21546. m.removedwxs[ids[i]] = struct{}{}
  21547. }
  21548. }
  21549. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  21550. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  21551. for id := range m.removedwxs {
  21552. ids = append(ids, id)
  21553. }
  21554. return
  21555. }
  21556. // WxsIDs returns the "wxs" edge IDs in the mutation.
  21557. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  21558. for id := range m.wxs {
  21559. ids = append(ids, id)
  21560. }
  21561. return
  21562. }
  21563. // ResetWxs resets all changes to the "wxs" edge.
  21564. func (m *ServerMutation) ResetWxs() {
  21565. m.wxs = nil
  21566. m.clearedwxs = false
  21567. m.removedwxs = nil
  21568. }
  21569. // Where appends a list predicates to the ServerMutation builder.
  21570. func (m *ServerMutation) Where(ps ...predicate.Server) {
  21571. m.predicates = append(m.predicates, ps...)
  21572. }
  21573. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  21574. // users can use type-assertion to append predicates that do not depend on any generated package.
  21575. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  21576. p := make([]predicate.Server, len(ps))
  21577. for i := range ps {
  21578. p[i] = ps[i]
  21579. }
  21580. m.Where(p...)
  21581. }
  21582. // Op returns the operation name.
  21583. func (m *ServerMutation) Op() Op {
  21584. return m.op
  21585. }
  21586. // SetOp allows setting the mutation operation.
  21587. func (m *ServerMutation) SetOp(op Op) {
  21588. m.op = op
  21589. }
  21590. // Type returns the node type of this mutation (Server).
  21591. func (m *ServerMutation) Type() string {
  21592. return m.typ
  21593. }
  21594. // Fields returns all fields that were changed during this mutation. Note that in
  21595. // order to get all numeric fields that were incremented/decremented, call
  21596. // AddedFields().
  21597. func (m *ServerMutation) Fields() []string {
  21598. fields := make([]string, 0, 8)
  21599. if m.created_at != nil {
  21600. fields = append(fields, server.FieldCreatedAt)
  21601. }
  21602. if m.updated_at != nil {
  21603. fields = append(fields, server.FieldUpdatedAt)
  21604. }
  21605. if m.status != nil {
  21606. fields = append(fields, server.FieldStatus)
  21607. }
  21608. if m.deleted_at != nil {
  21609. fields = append(fields, server.FieldDeletedAt)
  21610. }
  21611. if m.name != nil {
  21612. fields = append(fields, server.FieldName)
  21613. }
  21614. if m.public_ip != nil {
  21615. fields = append(fields, server.FieldPublicIP)
  21616. }
  21617. if m.private_ip != nil {
  21618. fields = append(fields, server.FieldPrivateIP)
  21619. }
  21620. if m.admin_port != nil {
  21621. fields = append(fields, server.FieldAdminPort)
  21622. }
  21623. return fields
  21624. }
  21625. // Field returns the value of a field with the given name. The second boolean
  21626. // return value indicates that this field was not set, or was not defined in the
  21627. // schema.
  21628. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  21629. switch name {
  21630. case server.FieldCreatedAt:
  21631. return m.CreatedAt()
  21632. case server.FieldUpdatedAt:
  21633. return m.UpdatedAt()
  21634. case server.FieldStatus:
  21635. return m.Status()
  21636. case server.FieldDeletedAt:
  21637. return m.DeletedAt()
  21638. case server.FieldName:
  21639. return m.Name()
  21640. case server.FieldPublicIP:
  21641. return m.PublicIP()
  21642. case server.FieldPrivateIP:
  21643. return m.PrivateIP()
  21644. case server.FieldAdminPort:
  21645. return m.AdminPort()
  21646. }
  21647. return nil, false
  21648. }
  21649. // OldField returns the old value of the field from the database. An error is
  21650. // returned if the mutation operation is not UpdateOne, or the query to the
  21651. // database failed.
  21652. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21653. switch name {
  21654. case server.FieldCreatedAt:
  21655. return m.OldCreatedAt(ctx)
  21656. case server.FieldUpdatedAt:
  21657. return m.OldUpdatedAt(ctx)
  21658. case server.FieldStatus:
  21659. return m.OldStatus(ctx)
  21660. case server.FieldDeletedAt:
  21661. return m.OldDeletedAt(ctx)
  21662. case server.FieldName:
  21663. return m.OldName(ctx)
  21664. case server.FieldPublicIP:
  21665. return m.OldPublicIP(ctx)
  21666. case server.FieldPrivateIP:
  21667. return m.OldPrivateIP(ctx)
  21668. case server.FieldAdminPort:
  21669. return m.OldAdminPort(ctx)
  21670. }
  21671. return nil, fmt.Errorf("unknown Server field %s", name)
  21672. }
  21673. // SetField sets the value of a field with the given name. It returns an error if
  21674. // the field is not defined in the schema, or if the type mismatched the field
  21675. // type.
  21676. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  21677. switch name {
  21678. case server.FieldCreatedAt:
  21679. v, ok := value.(time.Time)
  21680. if !ok {
  21681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21682. }
  21683. m.SetCreatedAt(v)
  21684. return nil
  21685. case server.FieldUpdatedAt:
  21686. v, ok := value.(time.Time)
  21687. if !ok {
  21688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21689. }
  21690. m.SetUpdatedAt(v)
  21691. return nil
  21692. case server.FieldStatus:
  21693. v, ok := value.(uint8)
  21694. if !ok {
  21695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21696. }
  21697. m.SetStatus(v)
  21698. return nil
  21699. case server.FieldDeletedAt:
  21700. v, ok := value.(time.Time)
  21701. if !ok {
  21702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21703. }
  21704. m.SetDeletedAt(v)
  21705. return nil
  21706. case server.FieldName:
  21707. v, ok := value.(string)
  21708. if !ok {
  21709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21710. }
  21711. m.SetName(v)
  21712. return nil
  21713. case server.FieldPublicIP:
  21714. v, ok := value.(string)
  21715. if !ok {
  21716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21717. }
  21718. m.SetPublicIP(v)
  21719. return nil
  21720. case server.FieldPrivateIP:
  21721. v, ok := value.(string)
  21722. if !ok {
  21723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21724. }
  21725. m.SetPrivateIP(v)
  21726. return nil
  21727. case server.FieldAdminPort:
  21728. v, ok := value.(string)
  21729. if !ok {
  21730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21731. }
  21732. m.SetAdminPort(v)
  21733. return nil
  21734. }
  21735. return fmt.Errorf("unknown Server field %s", name)
  21736. }
  21737. // AddedFields returns all numeric fields that were incremented/decremented during
  21738. // this mutation.
  21739. func (m *ServerMutation) AddedFields() []string {
  21740. var fields []string
  21741. if m.addstatus != nil {
  21742. fields = append(fields, server.FieldStatus)
  21743. }
  21744. return fields
  21745. }
  21746. // AddedField returns the numeric value that was incremented/decremented on a field
  21747. // with the given name. The second boolean return value indicates that this field
  21748. // was not set, or was not defined in the schema.
  21749. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  21750. switch name {
  21751. case server.FieldStatus:
  21752. return m.AddedStatus()
  21753. }
  21754. return nil, false
  21755. }
  21756. // AddField adds the value to the field with the given name. It returns an error if
  21757. // the field is not defined in the schema, or if the type mismatched the field
  21758. // type.
  21759. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  21760. switch name {
  21761. case server.FieldStatus:
  21762. v, ok := value.(int8)
  21763. if !ok {
  21764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21765. }
  21766. m.AddStatus(v)
  21767. return nil
  21768. }
  21769. return fmt.Errorf("unknown Server numeric field %s", name)
  21770. }
  21771. // ClearedFields returns all nullable fields that were cleared during this
  21772. // mutation.
  21773. func (m *ServerMutation) ClearedFields() []string {
  21774. var fields []string
  21775. if m.FieldCleared(server.FieldStatus) {
  21776. fields = append(fields, server.FieldStatus)
  21777. }
  21778. if m.FieldCleared(server.FieldDeletedAt) {
  21779. fields = append(fields, server.FieldDeletedAt)
  21780. }
  21781. return fields
  21782. }
  21783. // FieldCleared returns a boolean indicating if a field with the given name was
  21784. // cleared in this mutation.
  21785. func (m *ServerMutation) FieldCleared(name string) bool {
  21786. _, ok := m.clearedFields[name]
  21787. return ok
  21788. }
  21789. // ClearField clears the value of the field with the given name. It returns an
  21790. // error if the field is not defined in the schema.
  21791. func (m *ServerMutation) ClearField(name string) error {
  21792. switch name {
  21793. case server.FieldStatus:
  21794. m.ClearStatus()
  21795. return nil
  21796. case server.FieldDeletedAt:
  21797. m.ClearDeletedAt()
  21798. return nil
  21799. }
  21800. return fmt.Errorf("unknown Server nullable field %s", name)
  21801. }
  21802. // ResetField resets all changes in the mutation for the field with the given name.
  21803. // It returns an error if the field is not defined in the schema.
  21804. func (m *ServerMutation) ResetField(name string) error {
  21805. switch name {
  21806. case server.FieldCreatedAt:
  21807. m.ResetCreatedAt()
  21808. return nil
  21809. case server.FieldUpdatedAt:
  21810. m.ResetUpdatedAt()
  21811. return nil
  21812. case server.FieldStatus:
  21813. m.ResetStatus()
  21814. return nil
  21815. case server.FieldDeletedAt:
  21816. m.ResetDeletedAt()
  21817. return nil
  21818. case server.FieldName:
  21819. m.ResetName()
  21820. return nil
  21821. case server.FieldPublicIP:
  21822. m.ResetPublicIP()
  21823. return nil
  21824. case server.FieldPrivateIP:
  21825. m.ResetPrivateIP()
  21826. return nil
  21827. case server.FieldAdminPort:
  21828. m.ResetAdminPort()
  21829. return nil
  21830. }
  21831. return fmt.Errorf("unknown Server field %s", name)
  21832. }
  21833. // AddedEdges returns all edge names that were set/added in this mutation.
  21834. func (m *ServerMutation) AddedEdges() []string {
  21835. edges := make([]string, 0, 1)
  21836. if m.wxs != nil {
  21837. edges = append(edges, server.EdgeWxs)
  21838. }
  21839. return edges
  21840. }
  21841. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21842. // name in this mutation.
  21843. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  21844. switch name {
  21845. case server.EdgeWxs:
  21846. ids := make([]ent.Value, 0, len(m.wxs))
  21847. for id := range m.wxs {
  21848. ids = append(ids, id)
  21849. }
  21850. return ids
  21851. }
  21852. return nil
  21853. }
  21854. // RemovedEdges returns all edge names that were removed in this mutation.
  21855. func (m *ServerMutation) RemovedEdges() []string {
  21856. edges := make([]string, 0, 1)
  21857. if m.removedwxs != nil {
  21858. edges = append(edges, server.EdgeWxs)
  21859. }
  21860. return edges
  21861. }
  21862. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21863. // the given name in this mutation.
  21864. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  21865. switch name {
  21866. case server.EdgeWxs:
  21867. ids := make([]ent.Value, 0, len(m.removedwxs))
  21868. for id := range m.removedwxs {
  21869. ids = append(ids, id)
  21870. }
  21871. return ids
  21872. }
  21873. return nil
  21874. }
  21875. // ClearedEdges returns all edge names that were cleared in this mutation.
  21876. func (m *ServerMutation) ClearedEdges() []string {
  21877. edges := make([]string, 0, 1)
  21878. if m.clearedwxs {
  21879. edges = append(edges, server.EdgeWxs)
  21880. }
  21881. return edges
  21882. }
  21883. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21884. // was cleared in this mutation.
  21885. func (m *ServerMutation) EdgeCleared(name string) bool {
  21886. switch name {
  21887. case server.EdgeWxs:
  21888. return m.clearedwxs
  21889. }
  21890. return false
  21891. }
  21892. // ClearEdge clears the value of the edge with the given name. It returns an error
  21893. // if that edge is not defined in the schema.
  21894. func (m *ServerMutation) ClearEdge(name string) error {
  21895. switch name {
  21896. }
  21897. return fmt.Errorf("unknown Server unique edge %s", name)
  21898. }
  21899. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21900. // It returns an error if the edge is not defined in the schema.
  21901. func (m *ServerMutation) ResetEdge(name string) error {
  21902. switch name {
  21903. case server.EdgeWxs:
  21904. m.ResetWxs()
  21905. return nil
  21906. }
  21907. return fmt.Errorf("unknown Server edge %s", name)
  21908. }
  21909. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  21910. type SopNodeMutation struct {
  21911. config
  21912. op Op
  21913. typ string
  21914. id *uint64
  21915. created_at *time.Time
  21916. updated_at *time.Time
  21917. status *uint8
  21918. addstatus *int8
  21919. deleted_at *time.Time
  21920. parent_id *uint64
  21921. addparent_id *int64
  21922. name *string
  21923. condition_type *int
  21924. addcondition_type *int
  21925. condition_list *[]string
  21926. appendcondition_list []string
  21927. no_reply_condition *uint64
  21928. addno_reply_condition *int64
  21929. no_reply_unit *string
  21930. action_message *[]custom_types.Action
  21931. appendaction_message []custom_types.Action
  21932. action_label_add *[]uint64
  21933. appendaction_label_add []uint64
  21934. action_label_del *[]uint64
  21935. appendaction_label_del []uint64
  21936. action_forward **custom_types.ActionForward
  21937. clearedFields map[string]struct{}
  21938. sop_stage *uint64
  21939. clearedsop_stage bool
  21940. node_messages map[uint64]struct{}
  21941. removednode_messages map[uint64]struct{}
  21942. clearednode_messages bool
  21943. done bool
  21944. oldValue func(context.Context) (*SopNode, error)
  21945. predicates []predicate.SopNode
  21946. }
  21947. var _ ent.Mutation = (*SopNodeMutation)(nil)
  21948. // sopnodeOption allows management of the mutation configuration using functional options.
  21949. type sopnodeOption func(*SopNodeMutation)
  21950. // newSopNodeMutation creates new mutation for the SopNode entity.
  21951. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  21952. m := &SopNodeMutation{
  21953. config: c,
  21954. op: op,
  21955. typ: TypeSopNode,
  21956. clearedFields: make(map[string]struct{}),
  21957. }
  21958. for _, opt := range opts {
  21959. opt(m)
  21960. }
  21961. return m
  21962. }
  21963. // withSopNodeID sets the ID field of the mutation.
  21964. func withSopNodeID(id uint64) sopnodeOption {
  21965. return func(m *SopNodeMutation) {
  21966. var (
  21967. err error
  21968. once sync.Once
  21969. value *SopNode
  21970. )
  21971. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  21972. once.Do(func() {
  21973. if m.done {
  21974. err = errors.New("querying old values post mutation is not allowed")
  21975. } else {
  21976. value, err = m.Client().SopNode.Get(ctx, id)
  21977. }
  21978. })
  21979. return value, err
  21980. }
  21981. m.id = &id
  21982. }
  21983. }
  21984. // withSopNode sets the old SopNode of the mutation.
  21985. func withSopNode(node *SopNode) sopnodeOption {
  21986. return func(m *SopNodeMutation) {
  21987. m.oldValue = func(context.Context) (*SopNode, error) {
  21988. return node, nil
  21989. }
  21990. m.id = &node.ID
  21991. }
  21992. }
  21993. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21994. // executed in a transaction (ent.Tx), a transactional client is returned.
  21995. func (m SopNodeMutation) Client() *Client {
  21996. client := &Client{config: m.config}
  21997. client.init()
  21998. return client
  21999. }
  22000. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22001. // it returns an error otherwise.
  22002. func (m SopNodeMutation) Tx() (*Tx, error) {
  22003. if _, ok := m.driver.(*txDriver); !ok {
  22004. return nil, errors.New("ent: mutation is not running in a transaction")
  22005. }
  22006. tx := &Tx{config: m.config}
  22007. tx.init()
  22008. return tx, nil
  22009. }
  22010. // SetID sets the value of the id field. Note that this
  22011. // operation is only accepted on creation of SopNode entities.
  22012. func (m *SopNodeMutation) SetID(id uint64) {
  22013. m.id = &id
  22014. }
  22015. // ID returns the ID value in the mutation. Note that the ID is only available
  22016. // if it was provided to the builder or after it was returned from the database.
  22017. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  22018. if m.id == nil {
  22019. return
  22020. }
  22021. return *m.id, true
  22022. }
  22023. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22024. // That means, if the mutation is applied within a transaction with an isolation level such
  22025. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22026. // or updated by the mutation.
  22027. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  22028. switch {
  22029. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22030. id, exists := m.ID()
  22031. if exists {
  22032. return []uint64{id}, nil
  22033. }
  22034. fallthrough
  22035. case m.op.Is(OpUpdate | OpDelete):
  22036. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  22037. default:
  22038. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22039. }
  22040. }
  22041. // SetCreatedAt sets the "created_at" field.
  22042. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  22043. m.created_at = &t
  22044. }
  22045. // CreatedAt returns the value of the "created_at" field in the mutation.
  22046. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  22047. v := m.created_at
  22048. if v == nil {
  22049. return
  22050. }
  22051. return *v, true
  22052. }
  22053. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  22054. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22056. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22057. if !m.op.Is(OpUpdateOne) {
  22058. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22059. }
  22060. if m.id == nil || m.oldValue == nil {
  22061. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22062. }
  22063. oldValue, err := m.oldValue(ctx)
  22064. if err != nil {
  22065. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22066. }
  22067. return oldValue.CreatedAt, nil
  22068. }
  22069. // ResetCreatedAt resets all changes to the "created_at" field.
  22070. func (m *SopNodeMutation) ResetCreatedAt() {
  22071. m.created_at = nil
  22072. }
  22073. // SetUpdatedAt sets the "updated_at" field.
  22074. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  22075. m.updated_at = &t
  22076. }
  22077. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22078. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  22079. v := m.updated_at
  22080. if v == nil {
  22081. return
  22082. }
  22083. return *v, true
  22084. }
  22085. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  22086. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22088. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22089. if !m.op.Is(OpUpdateOne) {
  22090. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22091. }
  22092. if m.id == nil || m.oldValue == nil {
  22093. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22094. }
  22095. oldValue, err := m.oldValue(ctx)
  22096. if err != nil {
  22097. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22098. }
  22099. return oldValue.UpdatedAt, nil
  22100. }
  22101. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22102. func (m *SopNodeMutation) ResetUpdatedAt() {
  22103. m.updated_at = nil
  22104. }
  22105. // SetStatus sets the "status" field.
  22106. func (m *SopNodeMutation) SetStatus(u uint8) {
  22107. m.status = &u
  22108. m.addstatus = nil
  22109. }
  22110. // Status returns the value of the "status" field in the mutation.
  22111. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  22112. v := m.status
  22113. if v == nil {
  22114. return
  22115. }
  22116. return *v, true
  22117. }
  22118. // OldStatus returns the old "status" field's value of the SopNode entity.
  22119. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22121. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22122. if !m.op.Is(OpUpdateOne) {
  22123. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22124. }
  22125. if m.id == nil || m.oldValue == nil {
  22126. return v, errors.New("OldStatus requires an ID field in the mutation")
  22127. }
  22128. oldValue, err := m.oldValue(ctx)
  22129. if err != nil {
  22130. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22131. }
  22132. return oldValue.Status, nil
  22133. }
  22134. // AddStatus adds u to the "status" field.
  22135. func (m *SopNodeMutation) AddStatus(u int8) {
  22136. if m.addstatus != nil {
  22137. *m.addstatus += u
  22138. } else {
  22139. m.addstatus = &u
  22140. }
  22141. }
  22142. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22143. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  22144. v := m.addstatus
  22145. if v == nil {
  22146. return
  22147. }
  22148. return *v, true
  22149. }
  22150. // ClearStatus clears the value of the "status" field.
  22151. func (m *SopNodeMutation) ClearStatus() {
  22152. m.status = nil
  22153. m.addstatus = nil
  22154. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  22155. }
  22156. // StatusCleared returns if the "status" field was cleared in this mutation.
  22157. func (m *SopNodeMutation) StatusCleared() bool {
  22158. _, ok := m.clearedFields[sopnode.FieldStatus]
  22159. return ok
  22160. }
  22161. // ResetStatus resets all changes to the "status" field.
  22162. func (m *SopNodeMutation) ResetStatus() {
  22163. m.status = nil
  22164. m.addstatus = nil
  22165. delete(m.clearedFields, sopnode.FieldStatus)
  22166. }
  22167. // SetDeletedAt sets the "deleted_at" field.
  22168. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  22169. m.deleted_at = &t
  22170. }
  22171. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22172. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  22173. v := m.deleted_at
  22174. if v == nil {
  22175. return
  22176. }
  22177. return *v, true
  22178. }
  22179. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  22180. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22182. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22183. if !m.op.Is(OpUpdateOne) {
  22184. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22185. }
  22186. if m.id == nil || m.oldValue == nil {
  22187. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22188. }
  22189. oldValue, err := m.oldValue(ctx)
  22190. if err != nil {
  22191. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22192. }
  22193. return oldValue.DeletedAt, nil
  22194. }
  22195. // ClearDeletedAt clears the value of the "deleted_at" field.
  22196. func (m *SopNodeMutation) ClearDeletedAt() {
  22197. m.deleted_at = nil
  22198. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  22199. }
  22200. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22201. func (m *SopNodeMutation) DeletedAtCleared() bool {
  22202. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  22203. return ok
  22204. }
  22205. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22206. func (m *SopNodeMutation) ResetDeletedAt() {
  22207. m.deleted_at = nil
  22208. delete(m.clearedFields, sopnode.FieldDeletedAt)
  22209. }
  22210. // SetStageID sets the "stage_id" field.
  22211. func (m *SopNodeMutation) SetStageID(u uint64) {
  22212. m.sop_stage = &u
  22213. }
  22214. // StageID returns the value of the "stage_id" field in the mutation.
  22215. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  22216. v := m.sop_stage
  22217. if v == nil {
  22218. return
  22219. }
  22220. return *v, true
  22221. }
  22222. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  22223. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22225. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  22226. if !m.op.Is(OpUpdateOne) {
  22227. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  22228. }
  22229. if m.id == nil || m.oldValue == nil {
  22230. return v, errors.New("OldStageID requires an ID field in the mutation")
  22231. }
  22232. oldValue, err := m.oldValue(ctx)
  22233. if err != nil {
  22234. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  22235. }
  22236. return oldValue.StageID, nil
  22237. }
  22238. // ResetStageID resets all changes to the "stage_id" field.
  22239. func (m *SopNodeMutation) ResetStageID() {
  22240. m.sop_stage = nil
  22241. }
  22242. // SetParentID sets the "parent_id" field.
  22243. func (m *SopNodeMutation) SetParentID(u uint64) {
  22244. m.parent_id = &u
  22245. m.addparent_id = nil
  22246. }
  22247. // ParentID returns the value of the "parent_id" field in the mutation.
  22248. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  22249. v := m.parent_id
  22250. if v == nil {
  22251. return
  22252. }
  22253. return *v, true
  22254. }
  22255. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  22256. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22258. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  22259. if !m.op.Is(OpUpdateOne) {
  22260. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  22261. }
  22262. if m.id == nil || m.oldValue == nil {
  22263. return v, errors.New("OldParentID requires an ID field in the mutation")
  22264. }
  22265. oldValue, err := m.oldValue(ctx)
  22266. if err != nil {
  22267. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  22268. }
  22269. return oldValue.ParentID, nil
  22270. }
  22271. // AddParentID adds u to the "parent_id" field.
  22272. func (m *SopNodeMutation) AddParentID(u int64) {
  22273. if m.addparent_id != nil {
  22274. *m.addparent_id += u
  22275. } else {
  22276. m.addparent_id = &u
  22277. }
  22278. }
  22279. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  22280. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  22281. v := m.addparent_id
  22282. if v == nil {
  22283. return
  22284. }
  22285. return *v, true
  22286. }
  22287. // ResetParentID resets all changes to the "parent_id" field.
  22288. func (m *SopNodeMutation) ResetParentID() {
  22289. m.parent_id = nil
  22290. m.addparent_id = nil
  22291. }
  22292. // SetName sets the "name" field.
  22293. func (m *SopNodeMutation) SetName(s string) {
  22294. m.name = &s
  22295. }
  22296. // Name returns the value of the "name" field in the mutation.
  22297. func (m *SopNodeMutation) Name() (r string, exists bool) {
  22298. v := m.name
  22299. if v == nil {
  22300. return
  22301. }
  22302. return *v, true
  22303. }
  22304. // OldName returns the old "name" field's value of the SopNode entity.
  22305. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22307. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  22308. if !m.op.Is(OpUpdateOne) {
  22309. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22310. }
  22311. if m.id == nil || m.oldValue == nil {
  22312. return v, errors.New("OldName requires an ID field in the mutation")
  22313. }
  22314. oldValue, err := m.oldValue(ctx)
  22315. if err != nil {
  22316. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22317. }
  22318. return oldValue.Name, nil
  22319. }
  22320. // ResetName resets all changes to the "name" field.
  22321. func (m *SopNodeMutation) ResetName() {
  22322. m.name = nil
  22323. }
  22324. // SetConditionType sets the "condition_type" field.
  22325. func (m *SopNodeMutation) SetConditionType(i int) {
  22326. m.condition_type = &i
  22327. m.addcondition_type = nil
  22328. }
  22329. // ConditionType returns the value of the "condition_type" field in the mutation.
  22330. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  22331. v := m.condition_type
  22332. if v == nil {
  22333. return
  22334. }
  22335. return *v, true
  22336. }
  22337. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  22338. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22340. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22341. if !m.op.Is(OpUpdateOne) {
  22342. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22343. }
  22344. if m.id == nil || m.oldValue == nil {
  22345. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22346. }
  22347. oldValue, err := m.oldValue(ctx)
  22348. if err != nil {
  22349. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22350. }
  22351. return oldValue.ConditionType, nil
  22352. }
  22353. // AddConditionType adds i to the "condition_type" field.
  22354. func (m *SopNodeMutation) AddConditionType(i int) {
  22355. if m.addcondition_type != nil {
  22356. *m.addcondition_type += i
  22357. } else {
  22358. m.addcondition_type = &i
  22359. }
  22360. }
  22361. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22362. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  22363. v := m.addcondition_type
  22364. if v == nil {
  22365. return
  22366. }
  22367. return *v, true
  22368. }
  22369. // ResetConditionType resets all changes to the "condition_type" field.
  22370. func (m *SopNodeMutation) ResetConditionType() {
  22371. m.condition_type = nil
  22372. m.addcondition_type = nil
  22373. }
  22374. // SetConditionList sets the "condition_list" field.
  22375. func (m *SopNodeMutation) SetConditionList(s []string) {
  22376. m.condition_list = &s
  22377. m.appendcondition_list = nil
  22378. }
  22379. // ConditionList returns the value of the "condition_list" field in the mutation.
  22380. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  22381. v := m.condition_list
  22382. if v == nil {
  22383. return
  22384. }
  22385. return *v, true
  22386. }
  22387. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  22388. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22390. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  22391. if !m.op.Is(OpUpdateOne) {
  22392. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22393. }
  22394. if m.id == nil || m.oldValue == nil {
  22395. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22396. }
  22397. oldValue, err := m.oldValue(ctx)
  22398. if err != nil {
  22399. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22400. }
  22401. return oldValue.ConditionList, nil
  22402. }
  22403. // AppendConditionList adds s to the "condition_list" field.
  22404. func (m *SopNodeMutation) AppendConditionList(s []string) {
  22405. m.appendcondition_list = append(m.appendcondition_list, s...)
  22406. }
  22407. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22408. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  22409. if len(m.appendcondition_list) == 0 {
  22410. return nil, false
  22411. }
  22412. return m.appendcondition_list, true
  22413. }
  22414. // ClearConditionList clears the value of the "condition_list" field.
  22415. func (m *SopNodeMutation) ClearConditionList() {
  22416. m.condition_list = nil
  22417. m.appendcondition_list = nil
  22418. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  22419. }
  22420. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  22421. func (m *SopNodeMutation) ConditionListCleared() bool {
  22422. _, ok := m.clearedFields[sopnode.FieldConditionList]
  22423. return ok
  22424. }
  22425. // ResetConditionList resets all changes to the "condition_list" field.
  22426. func (m *SopNodeMutation) ResetConditionList() {
  22427. m.condition_list = nil
  22428. m.appendcondition_list = nil
  22429. delete(m.clearedFields, sopnode.FieldConditionList)
  22430. }
  22431. // SetNoReplyCondition sets the "no_reply_condition" field.
  22432. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  22433. m.no_reply_condition = &u
  22434. m.addno_reply_condition = nil
  22435. }
  22436. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  22437. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  22438. v := m.no_reply_condition
  22439. if v == nil {
  22440. return
  22441. }
  22442. return *v, true
  22443. }
  22444. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  22445. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22447. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  22448. if !m.op.Is(OpUpdateOne) {
  22449. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  22450. }
  22451. if m.id == nil || m.oldValue == nil {
  22452. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  22453. }
  22454. oldValue, err := m.oldValue(ctx)
  22455. if err != nil {
  22456. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  22457. }
  22458. return oldValue.NoReplyCondition, nil
  22459. }
  22460. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  22461. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  22462. if m.addno_reply_condition != nil {
  22463. *m.addno_reply_condition += u
  22464. } else {
  22465. m.addno_reply_condition = &u
  22466. }
  22467. }
  22468. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  22469. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  22470. v := m.addno_reply_condition
  22471. if v == nil {
  22472. return
  22473. }
  22474. return *v, true
  22475. }
  22476. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  22477. func (m *SopNodeMutation) ResetNoReplyCondition() {
  22478. m.no_reply_condition = nil
  22479. m.addno_reply_condition = nil
  22480. }
  22481. // SetNoReplyUnit sets the "no_reply_unit" field.
  22482. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  22483. m.no_reply_unit = &s
  22484. }
  22485. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  22486. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  22487. v := m.no_reply_unit
  22488. if v == nil {
  22489. return
  22490. }
  22491. return *v, true
  22492. }
  22493. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  22494. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22496. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  22497. if !m.op.Is(OpUpdateOne) {
  22498. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  22499. }
  22500. if m.id == nil || m.oldValue == nil {
  22501. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  22502. }
  22503. oldValue, err := m.oldValue(ctx)
  22504. if err != nil {
  22505. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  22506. }
  22507. return oldValue.NoReplyUnit, nil
  22508. }
  22509. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  22510. func (m *SopNodeMutation) ResetNoReplyUnit() {
  22511. m.no_reply_unit = nil
  22512. }
  22513. // SetActionMessage sets the "action_message" field.
  22514. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  22515. m.action_message = &ct
  22516. m.appendaction_message = nil
  22517. }
  22518. // ActionMessage returns the value of the "action_message" field in the mutation.
  22519. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22520. v := m.action_message
  22521. if v == nil {
  22522. return
  22523. }
  22524. return *v, true
  22525. }
  22526. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  22527. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22529. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22530. if !m.op.Is(OpUpdateOne) {
  22531. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22532. }
  22533. if m.id == nil || m.oldValue == nil {
  22534. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22535. }
  22536. oldValue, err := m.oldValue(ctx)
  22537. if err != nil {
  22538. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22539. }
  22540. return oldValue.ActionMessage, nil
  22541. }
  22542. // AppendActionMessage adds ct to the "action_message" field.
  22543. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  22544. m.appendaction_message = append(m.appendaction_message, ct...)
  22545. }
  22546. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22547. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22548. if len(m.appendaction_message) == 0 {
  22549. return nil, false
  22550. }
  22551. return m.appendaction_message, true
  22552. }
  22553. // ClearActionMessage clears the value of the "action_message" field.
  22554. func (m *SopNodeMutation) ClearActionMessage() {
  22555. m.action_message = nil
  22556. m.appendaction_message = nil
  22557. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  22558. }
  22559. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22560. func (m *SopNodeMutation) ActionMessageCleared() bool {
  22561. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  22562. return ok
  22563. }
  22564. // ResetActionMessage resets all changes to the "action_message" field.
  22565. func (m *SopNodeMutation) ResetActionMessage() {
  22566. m.action_message = nil
  22567. m.appendaction_message = nil
  22568. delete(m.clearedFields, sopnode.FieldActionMessage)
  22569. }
  22570. // SetActionLabelAdd sets the "action_label_add" field.
  22571. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  22572. m.action_label_add = &u
  22573. m.appendaction_label_add = nil
  22574. }
  22575. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22576. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22577. v := m.action_label_add
  22578. if v == nil {
  22579. return
  22580. }
  22581. return *v, true
  22582. }
  22583. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  22584. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22586. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22587. if !m.op.Is(OpUpdateOne) {
  22588. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22589. }
  22590. if m.id == nil || m.oldValue == nil {
  22591. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22592. }
  22593. oldValue, err := m.oldValue(ctx)
  22594. if err != nil {
  22595. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22596. }
  22597. return oldValue.ActionLabelAdd, nil
  22598. }
  22599. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22600. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  22601. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22602. }
  22603. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22604. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22605. if len(m.appendaction_label_add) == 0 {
  22606. return nil, false
  22607. }
  22608. return m.appendaction_label_add, true
  22609. }
  22610. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22611. func (m *SopNodeMutation) ClearActionLabelAdd() {
  22612. m.action_label_add = nil
  22613. m.appendaction_label_add = nil
  22614. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  22615. }
  22616. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22617. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  22618. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  22619. return ok
  22620. }
  22621. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22622. func (m *SopNodeMutation) ResetActionLabelAdd() {
  22623. m.action_label_add = nil
  22624. m.appendaction_label_add = nil
  22625. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  22626. }
  22627. // SetActionLabelDel sets the "action_label_del" field.
  22628. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  22629. m.action_label_del = &u
  22630. m.appendaction_label_del = nil
  22631. }
  22632. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22633. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  22634. v := m.action_label_del
  22635. if v == nil {
  22636. return
  22637. }
  22638. return *v, true
  22639. }
  22640. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  22641. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22643. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22644. if !m.op.Is(OpUpdateOne) {
  22645. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22646. }
  22647. if m.id == nil || m.oldValue == nil {
  22648. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22649. }
  22650. oldValue, err := m.oldValue(ctx)
  22651. if err != nil {
  22652. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22653. }
  22654. return oldValue.ActionLabelDel, nil
  22655. }
  22656. // AppendActionLabelDel adds u to the "action_label_del" field.
  22657. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  22658. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22659. }
  22660. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22661. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22662. if len(m.appendaction_label_del) == 0 {
  22663. return nil, false
  22664. }
  22665. return m.appendaction_label_del, true
  22666. }
  22667. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22668. func (m *SopNodeMutation) ClearActionLabelDel() {
  22669. m.action_label_del = nil
  22670. m.appendaction_label_del = nil
  22671. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  22672. }
  22673. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22674. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  22675. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  22676. return ok
  22677. }
  22678. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22679. func (m *SopNodeMutation) ResetActionLabelDel() {
  22680. m.action_label_del = nil
  22681. m.appendaction_label_del = nil
  22682. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  22683. }
  22684. // SetActionForward sets the "action_forward" field.
  22685. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22686. m.action_forward = &ctf
  22687. }
  22688. // ActionForward returns the value of the "action_forward" field in the mutation.
  22689. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22690. v := m.action_forward
  22691. if v == nil {
  22692. return
  22693. }
  22694. return *v, true
  22695. }
  22696. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  22697. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22699. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22700. if !m.op.Is(OpUpdateOne) {
  22701. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22702. }
  22703. if m.id == nil || m.oldValue == nil {
  22704. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22705. }
  22706. oldValue, err := m.oldValue(ctx)
  22707. if err != nil {
  22708. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22709. }
  22710. return oldValue.ActionForward, nil
  22711. }
  22712. // ClearActionForward clears the value of the "action_forward" field.
  22713. func (m *SopNodeMutation) ClearActionForward() {
  22714. m.action_forward = nil
  22715. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  22716. }
  22717. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22718. func (m *SopNodeMutation) ActionForwardCleared() bool {
  22719. _, ok := m.clearedFields[sopnode.FieldActionForward]
  22720. return ok
  22721. }
  22722. // ResetActionForward resets all changes to the "action_forward" field.
  22723. func (m *SopNodeMutation) ResetActionForward() {
  22724. m.action_forward = nil
  22725. delete(m.clearedFields, sopnode.FieldActionForward)
  22726. }
  22727. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22728. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  22729. m.sop_stage = &id
  22730. }
  22731. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22732. func (m *SopNodeMutation) ClearSopStage() {
  22733. m.clearedsop_stage = true
  22734. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  22735. }
  22736. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22737. func (m *SopNodeMutation) SopStageCleared() bool {
  22738. return m.clearedsop_stage
  22739. }
  22740. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22741. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  22742. if m.sop_stage != nil {
  22743. return *m.sop_stage, true
  22744. }
  22745. return
  22746. }
  22747. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22748. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22749. // SopStageID instead. It exists only for internal usage by the builders.
  22750. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  22751. if id := m.sop_stage; id != nil {
  22752. ids = append(ids, *id)
  22753. }
  22754. return
  22755. }
  22756. // ResetSopStage resets all changes to the "sop_stage" edge.
  22757. func (m *SopNodeMutation) ResetSopStage() {
  22758. m.sop_stage = nil
  22759. m.clearedsop_stage = false
  22760. }
  22761. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  22762. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  22763. if m.node_messages == nil {
  22764. m.node_messages = make(map[uint64]struct{})
  22765. }
  22766. for i := range ids {
  22767. m.node_messages[ids[i]] = struct{}{}
  22768. }
  22769. }
  22770. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  22771. func (m *SopNodeMutation) ClearNodeMessages() {
  22772. m.clearednode_messages = true
  22773. }
  22774. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  22775. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  22776. return m.clearednode_messages
  22777. }
  22778. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  22779. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  22780. if m.removednode_messages == nil {
  22781. m.removednode_messages = make(map[uint64]struct{})
  22782. }
  22783. for i := range ids {
  22784. delete(m.node_messages, ids[i])
  22785. m.removednode_messages[ids[i]] = struct{}{}
  22786. }
  22787. }
  22788. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  22789. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  22790. for id := range m.removednode_messages {
  22791. ids = append(ids, id)
  22792. }
  22793. return
  22794. }
  22795. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  22796. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  22797. for id := range m.node_messages {
  22798. ids = append(ids, id)
  22799. }
  22800. return
  22801. }
  22802. // ResetNodeMessages resets all changes to the "node_messages" edge.
  22803. func (m *SopNodeMutation) ResetNodeMessages() {
  22804. m.node_messages = nil
  22805. m.clearednode_messages = false
  22806. m.removednode_messages = nil
  22807. }
  22808. // Where appends a list predicates to the SopNodeMutation builder.
  22809. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  22810. m.predicates = append(m.predicates, ps...)
  22811. }
  22812. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  22813. // users can use type-assertion to append predicates that do not depend on any generated package.
  22814. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  22815. p := make([]predicate.SopNode, len(ps))
  22816. for i := range ps {
  22817. p[i] = ps[i]
  22818. }
  22819. m.Where(p...)
  22820. }
  22821. // Op returns the operation name.
  22822. func (m *SopNodeMutation) Op() Op {
  22823. return m.op
  22824. }
  22825. // SetOp allows setting the mutation operation.
  22826. func (m *SopNodeMutation) SetOp(op Op) {
  22827. m.op = op
  22828. }
  22829. // Type returns the node type of this mutation (SopNode).
  22830. func (m *SopNodeMutation) Type() string {
  22831. return m.typ
  22832. }
  22833. // Fields returns all fields that were changed during this mutation. Note that in
  22834. // order to get all numeric fields that were incremented/decremented, call
  22835. // AddedFields().
  22836. func (m *SopNodeMutation) Fields() []string {
  22837. fields := make([]string, 0, 15)
  22838. if m.created_at != nil {
  22839. fields = append(fields, sopnode.FieldCreatedAt)
  22840. }
  22841. if m.updated_at != nil {
  22842. fields = append(fields, sopnode.FieldUpdatedAt)
  22843. }
  22844. if m.status != nil {
  22845. fields = append(fields, sopnode.FieldStatus)
  22846. }
  22847. if m.deleted_at != nil {
  22848. fields = append(fields, sopnode.FieldDeletedAt)
  22849. }
  22850. if m.sop_stage != nil {
  22851. fields = append(fields, sopnode.FieldStageID)
  22852. }
  22853. if m.parent_id != nil {
  22854. fields = append(fields, sopnode.FieldParentID)
  22855. }
  22856. if m.name != nil {
  22857. fields = append(fields, sopnode.FieldName)
  22858. }
  22859. if m.condition_type != nil {
  22860. fields = append(fields, sopnode.FieldConditionType)
  22861. }
  22862. if m.condition_list != nil {
  22863. fields = append(fields, sopnode.FieldConditionList)
  22864. }
  22865. if m.no_reply_condition != nil {
  22866. fields = append(fields, sopnode.FieldNoReplyCondition)
  22867. }
  22868. if m.no_reply_unit != nil {
  22869. fields = append(fields, sopnode.FieldNoReplyUnit)
  22870. }
  22871. if m.action_message != nil {
  22872. fields = append(fields, sopnode.FieldActionMessage)
  22873. }
  22874. if m.action_label_add != nil {
  22875. fields = append(fields, sopnode.FieldActionLabelAdd)
  22876. }
  22877. if m.action_label_del != nil {
  22878. fields = append(fields, sopnode.FieldActionLabelDel)
  22879. }
  22880. if m.action_forward != nil {
  22881. fields = append(fields, sopnode.FieldActionForward)
  22882. }
  22883. return fields
  22884. }
  22885. // Field returns the value of a field with the given name. The second boolean
  22886. // return value indicates that this field was not set, or was not defined in the
  22887. // schema.
  22888. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  22889. switch name {
  22890. case sopnode.FieldCreatedAt:
  22891. return m.CreatedAt()
  22892. case sopnode.FieldUpdatedAt:
  22893. return m.UpdatedAt()
  22894. case sopnode.FieldStatus:
  22895. return m.Status()
  22896. case sopnode.FieldDeletedAt:
  22897. return m.DeletedAt()
  22898. case sopnode.FieldStageID:
  22899. return m.StageID()
  22900. case sopnode.FieldParentID:
  22901. return m.ParentID()
  22902. case sopnode.FieldName:
  22903. return m.Name()
  22904. case sopnode.FieldConditionType:
  22905. return m.ConditionType()
  22906. case sopnode.FieldConditionList:
  22907. return m.ConditionList()
  22908. case sopnode.FieldNoReplyCondition:
  22909. return m.NoReplyCondition()
  22910. case sopnode.FieldNoReplyUnit:
  22911. return m.NoReplyUnit()
  22912. case sopnode.FieldActionMessage:
  22913. return m.ActionMessage()
  22914. case sopnode.FieldActionLabelAdd:
  22915. return m.ActionLabelAdd()
  22916. case sopnode.FieldActionLabelDel:
  22917. return m.ActionLabelDel()
  22918. case sopnode.FieldActionForward:
  22919. return m.ActionForward()
  22920. }
  22921. return nil, false
  22922. }
  22923. // OldField returns the old value of the field from the database. An error is
  22924. // returned if the mutation operation is not UpdateOne, or the query to the
  22925. // database failed.
  22926. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22927. switch name {
  22928. case sopnode.FieldCreatedAt:
  22929. return m.OldCreatedAt(ctx)
  22930. case sopnode.FieldUpdatedAt:
  22931. return m.OldUpdatedAt(ctx)
  22932. case sopnode.FieldStatus:
  22933. return m.OldStatus(ctx)
  22934. case sopnode.FieldDeletedAt:
  22935. return m.OldDeletedAt(ctx)
  22936. case sopnode.FieldStageID:
  22937. return m.OldStageID(ctx)
  22938. case sopnode.FieldParentID:
  22939. return m.OldParentID(ctx)
  22940. case sopnode.FieldName:
  22941. return m.OldName(ctx)
  22942. case sopnode.FieldConditionType:
  22943. return m.OldConditionType(ctx)
  22944. case sopnode.FieldConditionList:
  22945. return m.OldConditionList(ctx)
  22946. case sopnode.FieldNoReplyCondition:
  22947. return m.OldNoReplyCondition(ctx)
  22948. case sopnode.FieldNoReplyUnit:
  22949. return m.OldNoReplyUnit(ctx)
  22950. case sopnode.FieldActionMessage:
  22951. return m.OldActionMessage(ctx)
  22952. case sopnode.FieldActionLabelAdd:
  22953. return m.OldActionLabelAdd(ctx)
  22954. case sopnode.FieldActionLabelDel:
  22955. return m.OldActionLabelDel(ctx)
  22956. case sopnode.FieldActionForward:
  22957. return m.OldActionForward(ctx)
  22958. }
  22959. return nil, fmt.Errorf("unknown SopNode field %s", name)
  22960. }
  22961. // SetField sets the value of a field with the given name. It returns an error if
  22962. // the field is not defined in the schema, or if the type mismatched the field
  22963. // type.
  22964. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  22965. switch name {
  22966. case sopnode.FieldCreatedAt:
  22967. v, ok := value.(time.Time)
  22968. if !ok {
  22969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22970. }
  22971. m.SetCreatedAt(v)
  22972. return nil
  22973. case sopnode.FieldUpdatedAt:
  22974. v, ok := value.(time.Time)
  22975. if !ok {
  22976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22977. }
  22978. m.SetUpdatedAt(v)
  22979. return nil
  22980. case sopnode.FieldStatus:
  22981. v, ok := value.(uint8)
  22982. if !ok {
  22983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22984. }
  22985. m.SetStatus(v)
  22986. return nil
  22987. case sopnode.FieldDeletedAt:
  22988. v, ok := value.(time.Time)
  22989. if !ok {
  22990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22991. }
  22992. m.SetDeletedAt(v)
  22993. return nil
  22994. case sopnode.FieldStageID:
  22995. v, ok := value.(uint64)
  22996. if !ok {
  22997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22998. }
  22999. m.SetStageID(v)
  23000. return nil
  23001. case sopnode.FieldParentID:
  23002. v, ok := value.(uint64)
  23003. if !ok {
  23004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23005. }
  23006. m.SetParentID(v)
  23007. return nil
  23008. case sopnode.FieldName:
  23009. v, ok := value.(string)
  23010. if !ok {
  23011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23012. }
  23013. m.SetName(v)
  23014. return nil
  23015. case sopnode.FieldConditionType:
  23016. v, ok := value.(int)
  23017. if !ok {
  23018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23019. }
  23020. m.SetConditionType(v)
  23021. return nil
  23022. case sopnode.FieldConditionList:
  23023. v, ok := value.([]string)
  23024. if !ok {
  23025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23026. }
  23027. m.SetConditionList(v)
  23028. return nil
  23029. case sopnode.FieldNoReplyCondition:
  23030. v, ok := value.(uint64)
  23031. if !ok {
  23032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23033. }
  23034. m.SetNoReplyCondition(v)
  23035. return nil
  23036. case sopnode.FieldNoReplyUnit:
  23037. v, ok := value.(string)
  23038. if !ok {
  23039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23040. }
  23041. m.SetNoReplyUnit(v)
  23042. return nil
  23043. case sopnode.FieldActionMessage:
  23044. v, ok := value.([]custom_types.Action)
  23045. if !ok {
  23046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23047. }
  23048. m.SetActionMessage(v)
  23049. return nil
  23050. case sopnode.FieldActionLabelAdd:
  23051. v, ok := value.([]uint64)
  23052. if !ok {
  23053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23054. }
  23055. m.SetActionLabelAdd(v)
  23056. return nil
  23057. case sopnode.FieldActionLabelDel:
  23058. v, ok := value.([]uint64)
  23059. if !ok {
  23060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23061. }
  23062. m.SetActionLabelDel(v)
  23063. return nil
  23064. case sopnode.FieldActionForward:
  23065. v, ok := value.(*custom_types.ActionForward)
  23066. if !ok {
  23067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23068. }
  23069. m.SetActionForward(v)
  23070. return nil
  23071. }
  23072. return fmt.Errorf("unknown SopNode field %s", name)
  23073. }
  23074. // AddedFields returns all numeric fields that were incremented/decremented during
  23075. // this mutation.
  23076. func (m *SopNodeMutation) AddedFields() []string {
  23077. var fields []string
  23078. if m.addstatus != nil {
  23079. fields = append(fields, sopnode.FieldStatus)
  23080. }
  23081. if m.addparent_id != nil {
  23082. fields = append(fields, sopnode.FieldParentID)
  23083. }
  23084. if m.addcondition_type != nil {
  23085. fields = append(fields, sopnode.FieldConditionType)
  23086. }
  23087. if m.addno_reply_condition != nil {
  23088. fields = append(fields, sopnode.FieldNoReplyCondition)
  23089. }
  23090. return fields
  23091. }
  23092. // AddedField returns the numeric value that was incremented/decremented on a field
  23093. // with the given name. The second boolean return value indicates that this field
  23094. // was not set, or was not defined in the schema.
  23095. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  23096. switch name {
  23097. case sopnode.FieldStatus:
  23098. return m.AddedStatus()
  23099. case sopnode.FieldParentID:
  23100. return m.AddedParentID()
  23101. case sopnode.FieldConditionType:
  23102. return m.AddedConditionType()
  23103. case sopnode.FieldNoReplyCondition:
  23104. return m.AddedNoReplyCondition()
  23105. }
  23106. return nil, false
  23107. }
  23108. // AddField adds the value to the field with the given name. It returns an error if
  23109. // the field is not defined in the schema, or if the type mismatched the field
  23110. // type.
  23111. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  23112. switch name {
  23113. case sopnode.FieldStatus:
  23114. v, ok := value.(int8)
  23115. if !ok {
  23116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23117. }
  23118. m.AddStatus(v)
  23119. return nil
  23120. case sopnode.FieldParentID:
  23121. v, ok := value.(int64)
  23122. if !ok {
  23123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23124. }
  23125. m.AddParentID(v)
  23126. return nil
  23127. case sopnode.FieldConditionType:
  23128. v, ok := value.(int)
  23129. if !ok {
  23130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23131. }
  23132. m.AddConditionType(v)
  23133. return nil
  23134. case sopnode.FieldNoReplyCondition:
  23135. v, ok := value.(int64)
  23136. if !ok {
  23137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23138. }
  23139. m.AddNoReplyCondition(v)
  23140. return nil
  23141. }
  23142. return fmt.Errorf("unknown SopNode numeric field %s", name)
  23143. }
  23144. // ClearedFields returns all nullable fields that were cleared during this
  23145. // mutation.
  23146. func (m *SopNodeMutation) ClearedFields() []string {
  23147. var fields []string
  23148. if m.FieldCleared(sopnode.FieldStatus) {
  23149. fields = append(fields, sopnode.FieldStatus)
  23150. }
  23151. if m.FieldCleared(sopnode.FieldDeletedAt) {
  23152. fields = append(fields, sopnode.FieldDeletedAt)
  23153. }
  23154. if m.FieldCleared(sopnode.FieldConditionList) {
  23155. fields = append(fields, sopnode.FieldConditionList)
  23156. }
  23157. if m.FieldCleared(sopnode.FieldActionMessage) {
  23158. fields = append(fields, sopnode.FieldActionMessage)
  23159. }
  23160. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  23161. fields = append(fields, sopnode.FieldActionLabelAdd)
  23162. }
  23163. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  23164. fields = append(fields, sopnode.FieldActionLabelDel)
  23165. }
  23166. if m.FieldCleared(sopnode.FieldActionForward) {
  23167. fields = append(fields, sopnode.FieldActionForward)
  23168. }
  23169. return fields
  23170. }
  23171. // FieldCleared returns a boolean indicating if a field with the given name was
  23172. // cleared in this mutation.
  23173. func (m *SopNodeMutation) FieldCleared(name string) bool {
  23174. _, ok := m.clearedFields[name]
  23175. return ok
  23176. }
  23177. // ClearField clears the value of the field with the given name. It returns an
  23178. // error if the field is not defined in the schema.
  23179. func (m *SopNodeMutation) ClearField(name string) error {
  23180. switch name {
  23181. case sopnode.FieldStatus:
  23182. m.ClearStatus()
  23183. return nil
  23184. case sopnode.FieldDeletedAt:
  23185. m.ClearDeletedAt()
  23186. return nil
  23187. case sopnode.FieldConditionList:
  23188. m.ClearConditionList()
  23189. return nil
  23190. case sopnode.FieldActionMessage:
  23191. m.ClearActionMessage()
  23192. return nil
  23193. case sopnode.FieldActionLabelAdd:
  23194. m.ClearActionLabelAdd()
  23195. return nil
  23196. case sopnode.FieldActionLabelDel:
  23197. m.ClearActionLabelDel()
  23198. return nil
  23199. case sopnode.FieldActionForward:
  23200. m.ClearActionForward()
  23201. return nil
  23202. }
  23203. return fmt.Errorf("unknown SopNode nullable field %s", name)
  23204. }
  23205. // ResetField resets all changes in the mutation for the field with the given name.
  23206. // It returns an error if the field is not defined in the schema.
  23207. func (m *SopNodeMutation) ResetField(name string) error {
  23208. switch name {
  23209. case sopnode.FieldCreatedAt:
  23210. m.ResetCreatedAt()
  23211. return nil
  23212. case sopnode.FieldUpdatedAt:
  23213. m.ResetUpdatedAt()
  23214. return nil
  23215. case sopnode.FieldStatus:
  23216. m.ResetStatus()
  23217. return nil
  23218. case sopnode.FieldDeletedAt:
  23219. m.ResetDeletedAt()
  23220. return nil
  23221. case sopnode.FieldStageID:
  23222. m.ResetStageID()
  23223. return nil
  23224. case sopnode.FieldParentID:
  23225. m.ResetParentID()
  23226. return nil
  23227. case sopnode.FieldName:
  23228. m.ResetName()
  23229. return nil
  23230. case sopnode.FieldConditionType:
  23231. m.ResetConditionType()
  23232. return nil
  23233. case sopnode.FieldConditionList:
  23234. m.ResetConditionList()
  23235. return nil
  23236. case sopnode.FieldNoReplyCondition:
  23237. m.ResetNoReplyCondition()
  23238. return nil
  23239. case sopnode.FieldNoReplyUnit:
  23240. m.ResetNoReplyUnit()
  23241. return nil
  23242. case sopnode.FieldActionMessage:
  23243. m.ResetActionMessage()
  23244. return nil
  23245. case sopnode.FieldActionLabelAdd:
  23246. m.ResetActionLabelAdd()
  23247. return nil
  23248. case sopnode.FieldActionLabelDel:
  23249. m.ResetActionLabelDel()
  23250. return nil
  23251. case sopnode.FieldActionForward:
  23252. m.ResetActionForward()
  23253. return nil
  23254. }
  23255. return fmt.Errorf("unknown SopNode field %s", name)
  23256. }
  23257. // AddedEdges returns all edge names that were set/added in this mutation.
  23258. func (m *SopNodeMutation) AddedEdges() []string {
  23259. edges := make([]string, 0, 2)
  23260. if m.sop_stage != nil {
  23261. edges = append(edges, sopnode.EdgeSopStage)
  23262. }
  23263. if m.node_messages != nil {
  23264. edges = append(edges, sopnode.EdgeNodeMessages)
  23265. }
  23266. return edges
  23267. }
  23268. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23269. // name in this mutation.
  23270. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  23271. switch name {
  23272. case sopnode.EdgeSopStage:
  23273. if id := m.sop_stage; id != nil {
  23274. return []ent.Value{*id}
  23275. }
  23276. case sopnode.EdgeNodeMessages:
  23277. ids := make([]ent.Value, 0, len(m.node_messages))
  23278. for id := range m.node_messages {
  23279. ids = append(ids, id)
  23280. }
  23281. return ids
  23282. }
  23283. return nil
  23284. }
  23285. // RemovedEdges returns all edge names that were removed in this mutation.
  23286. func (m *SopNodeMutation) RemovedEdges() []string {
  23287. edges := make([]string, 0, 2)
  23288. if m.removednode_messages != nil {
  23289. edges = append(edges, sopnode.EdgeNodeMessages)
  23290. }
  23291. return edges
  23292. }
  23293. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23294. // the given name in this mutation.
  23295. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  23296. switch name {
  23297. case sopnode.EdgeNodeMessages:
  23298. ids := make([]ent.Value, 0, len(m.removednode_messages))
  23299. for id := range m.removednode_messages {
  23300. ids = append(ids, id)
  23301. }
  23302. return ids
  23303. }
  23304. return nil
  23305. }
  23306. // ClearedEdges returns all edge names that were cleared in this mutation.
  23307. func (m *SopNodeMutation) ClearedEdges() []string {
  23308. edges := make([]string, 0, 2)
  23309. if m.clearedsop_stage {
  23310. edges = append(edges, sopnode.EdgeSopStage)
  23311. }
  23312. if m.clearednode_messages {
  23313. edges = append(edges, sopnode.EdgeNodeMessages)
  23314. }
  23315. return edges
  23316. }
  23317. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23318. // was cleared in this mutation.
  23319. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  23320. switch name {
  23321. case sopnode.EdgeSopStage:
  23322. return m.clearedsop_stage
  23323. case sopnode.EdgeNodeMessages:
  23324. return m.clearednode_messages
  23325. }
  23326. return false
  23327. }
  23328. // ClearEdge clears the value of the edge with the given name. It returns an error
  23329. // if that edge is not defined in the schema.
  23330. func (m *SopNodeMutation) ClearEdge(name string) error {
  23331. switch name {
  23332. case sopnode.EdgeSopStage:
  23333. m.ClearSopStage()
  23334. return nil
  23335. }
  23336. return fmt.Errorf("unknown SopNode unique edge %s", name)
  23337. }
  23338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23339. // It returns an error if the edge is not defined in the schema.
  23340. func (m *SopNodeMutation) ResetEdge(name string) error {
  23341. switch name {
  23342. case sopnode.EdgeSopStage:
  23343. m.ResetSopStage()
  23344. return nil
  23345. case sopnode.EdgeNodeMessages:
  23346. m.ResetNodeMessages()
  23347. return nil
  23348. }
  23349. return fmt.Errorf("unknown SopNode edge %s", name)
  23350. }
  23351. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  23352. type SopStageMutation struct {
  23353. config
  23354. op Op
  23355. typ string
  23356. id *uint64
  23357. created_at *time.Time
  23358. updated_at *time.Time
  23359. status *uint8
  23360. addstatus *int8
  23361. deleted_at *time.Time
  23362. name *string
  23363. condition_type *int
  23364. addcondition_type *int
  23365. condition_operator *int
  23366. addcondition_operator *int
  23367. condition_list *[]custom_types.Condition
  23368. appendcondition_list []custom_types.Condition
  23369. action_message *[]custom_types.Action
  23370. appendaction_message []custom_types.Action
  23371. action_label_add *[]uint64
  23372. appendaction_label_add []uint64
  23373. action_label_del *[]uint64
  23374. appendaction_label_del []uint64
  23375. action_forward **custom_types.ActionForward
  23376. index_sort *int
  23377. addindex_sort *int
  23378. clearedFields map[string]struct{}
  23379. sop_task *uint64
  23380. clearedsop_task bool
  23381. stage_nodes map[uint64]struct{}
  23382. removedstage_nodes map[uint64]struct{}
  23383. clearedstage_nodes bool
  23384. stage_messages map[uint64]struct{}
  23385. removedstage_messages map[uint64]struct{}
  23386. clearedstage_messages bool
  23387. done bool
  23388. oldValue func(context.Context) (*SopStage, error)
  23389. predicates []predicate.SopStage
  23390. }
  23391. var _ ent.Mutation = (*SopStageMutation)(nil)
  23392. // sopstageOption allows management of the mutation configuration using functional options.
  23393. type sopstageOption func(*SopStageMutation)
  23394. // newSopStageMutation creates new mutation for the SopStage entity.
  23395. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  23396. m := &SopStageMutation{
  23397. config: c,
  23398. op: op,
  23399. typ: TypeSopStage,
  23400. clearedFields: make(map[string]struct{}),
  23401. }
  23402. for _, opt := range opts {
  23403. opt(m)
  23404. }
  23405. return m
  23406. }
  23407. // withSopStageID sets the ID field of the mutation.
  23408. func withSopStageID(id uint64) sopstageOption {
  23409. return func(m *SopStageMutation) {
  23410. var (
  23411. err error
  23412. once sync.Once
  23413. value *SopStage
  23414. )
  23415. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  23416. once.Do(func() {
  23417. if m.done {
  23418. err = errors.New("querying old values post mutation is not allowed")
  23419. } else {
  23420. value, err = m.Client().SopStage.Get(ctx, id)
  23421. }
  23422. })
  23423. return value, err
  23424. }
  23425. m.id = &id
  23426. }
  23427. }
  23428. // withSopStage sets the old SopStage of the mutation.
  23429. func withSopStage(node *SopStage) sopstageOption {
  23430. return func(m *SopStageMutation) {
  23431. m.oldValue = func(context.Context) (*SopStage, error) {
  23432. return node, nil
  23433. }
  23434. m.id = &node.ID
  23435. }
  23436. }
  23437. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23438. // executed in a transaction (ent.Tx), a transactional client is returned.
  23439. func (m SopStageMutation) Client() *Client {
  23440. client := &Client{config: m.config}
  23441. client.init()
  23442. return client
  23443. }
  23444. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23445. // it returns an error otherwise.
  23446. func (m SopStageMutation) Tx() (*Tx, error) {
  23447. if _, ok := m.driver.(*txDriver); !ok {
  23448. return nil, errors.New("ent: mutation is not running in a transaction")
  23449. }
  23450. tx := &Tx{config: m.config}
  23451. tx.init()
  23452. return tx, nil
  23453. }
  23454. // SetID sets the value of the id field. Note that this
  23455. // operation is only accepted on creation of SopStage entities.
  23456. func (m *SopStageMutation) SetID(id uint64) {
  23457. m.id = &id
  23458. }
  23459. // ID returns the ID value in the mutation. Note that the ID is only available
  23460. // if it was provided to the builder or after it was returned from the database.
  23461. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  23462. if m.id == nil {
  23463. return
  23464. }
  23465. return *m.id, true
  23466. }
  23467. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23468. // That means, if the mutation is applied within a transaction with an isolation level such
  23469. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23470. // or updated by the mutation.
  23471. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  23472. switch {
  23473. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23474. id, exists := m.ID()
  23475. if exists {
  23476. return []uint64{id}, nil
  23477. }
  23478. fallthrough
  23479. case m.op.Is(OpUpdate | OpDelete):
  23480. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  23481. default:
  23482. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23483. }
  23484. }
  23485. // SetCreatedAt sets the "created_at" field.
  23486. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  23487. m.created_at = &t
  23488. }
  23489. // CreatedAt returns the value of the "created_at" field in the mutation.
  23490. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  23491. v := m.created_at
  23492. if v == nil {
  23493. return
  23494. }
  23495. return *v, true
  23496. }
  23497. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  23498. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23500. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23501. if !m.op.Is(OpUpdateOne) {
  23502. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23503. }
  23504. if m.id == nil || m.oldValue == nil {
  23505. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23506. }
  23507. oldValue, err := m.oldValue(ctx)
  23508. if err != nil {
  23509. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23510. }
  23511. return oldValue.CreatedAt, nil
  23512. }
  23513. // ResetCreatedAt resets all changes to the "created_at" field.
  23514. func (m *SopStageMutation) ResetCreatedAt() {
  23515. m.created_at = nil
  23516. }
  23517. // SetUpdatedAt sets the "updated_at" field.
  23518. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  23519. m.updated_at = &t
  23520. }
  23521. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23522. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  23523. v := m.updated_at
  23524. if v == nil {
  23525. return
  23526. }
  23527. return *v, true
  23528. }
  23529. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  23530. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23532. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23533. if !m.op.Is(OpUpdateOne) {
  23534. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23535. }
  23536. if m.id == nil || m.oldValue == nil {
  23537. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23538. }
  23539. oldValue, err := m.oldValue(ctx)
  23540. if err != nil {
  23541. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23542. }
  23543. return oldValue.UpdatedAt, nil
  23544. }
  23545. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23546. func (m *SopStageMutation) ResetUpdatedAt() {
  23547. m.updated_at = nil
  23548. }
  23549. // SetStatus sets the "status" field.
  23550. func (m *SopStageMutation) SetStatus(u uint8) {
  23551. m.status = &u
  23552. m.addstatus = nil
  23553. }
  23554. // Status returns the value of the "status" field in the mutation.
  23555. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  23556. v := m.status
  23557. if v == nil {
  23558. return
  23559. }
  23560. return *v, true
  23561. }
  23562. // OldStatus returns the old "status" field's value of the SopStage entity.
  23563. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23565. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23566. if !m.op.Is(OpUpdateOne) {
  23567. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23568. }
  23569. if m.id == nil || m.oldValue == nil {
  23570. return v, errors.New("OldStatus requires an ID field in the mutation")
  23571. }
  23572. oldValue, err := m.oldValue(ctx)
  23573. if err != nil {
  23574. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23575. }
  23576. return oldValue.Status, nil
  23577. }
  23578. // AddStatus adds u to the "status" field.
  23579. func (m *SopStageMutation) AddStatus(u int8) {
  23580. if m.addstatus != nil {
  23581. *m.addstatus += u
  23582. } else {
  23583. m.addstatus = &u
  23584. }
  23585. }
  23586. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23587. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  23588. v := m.addstatus
  23589. if v == nil {
  23590. return
  23591. }
  23592. return *v, true
  23593. }
  23594. // ClearStatus clears the value of the "status" field.
  23595. func (m *SopStageMutation) ClearStatus() {
  23596. m.status = nil
  23597. m.addstatus = nil
  23598. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  23599. }
  23600. // StatusCleared returns if the "status" field was cleared in this mutation.
  23601. func (m *SopStageMutation) StatusCleared() bool {
  23602. _, ok := m.clearedFields[sopstage.FieldStatus]
  23603. return ok
  23604. }
  23605. // ResetStatus resets all changes to the "status" field.
  23606. func (m *SopStageMutation) ResetStatus() {
  23607. m.status = nil
  23608. m.addstatus = nil
  23609. delete(m.clearedFields, sopstage.FieldStatus)
  23610. }
  23611. // SetDeletedAt sets the "deleted_at" field.
  23612. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  23613. m.deleted_at = &t
  23614. }
  23615. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23616. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  23617. v := m.deleted_at
  23618. if v == nil {
  23619. return
  23620. }
  23621. return *v, true
  23622. }
  23623. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  23624. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23626. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23627. if !m.op.Is(OpUpdateOne) {
  23628. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23629. }
  23630. if m.id == nil || m.oldValue == nil {
  23631. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23632. }
  23633. oldValue, err := m.oldValue(ctx)
  23634. if err != nil {
  23635. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23636. }
  23637. return oldValue.DeletedAt, nil
  23638. }
  23639. // ClearDeletedAt clears the value of the "deleted_at" field.
  23640. func (m *SopStageMutation) ClearDeletedAt() {
  23641. m.deleted_at = nil
  23642. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  23643. }
  23644. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23645. func (m *SopStageMutation) DeletedAtCleared() bool {
  23646. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  23647. return ok
  23648. }
  23649. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23650. func (m *SopStageMutation) ResetDeletedAt() {
  23651. m.deleted_at = nil
  23652. delete(m.clearedFields, sopstage.FieldDeletedAt)
  23653. }
  23654. // SetTaskID sets the "task_id" field.
  23655. func (m *SopStageMutation) SetTaskID(u uint64) {
  23656. m.sop_task = &u
  23657. }
  23658. // TaskID returns the value of the "task_id" field in the mutation.
  23659. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  23660. v := m.sop_task
  23661. if v == nil {
  23662. return
  23663. }
  23664. return *v, true
  23665. }
  23666. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  23667. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23669. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  23670. if !m.op.Is(OpUpdateOne) {
  23671. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  23672. }
  23673. if m.id == nil || m.oldValue == nil {
  23674. return v, errors.New("OldTaskID requires an ID field in the mutation")
  23675. }
  23676. oldValue, err := m.oldValue(ctx)
  23677. if err != nil {
  23678. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  23679. }
  23680. return oldValue.TaskID, nil
  23681. }
  23682. // ResetTaskID resets all changes to the "task_id" field.
  23683. func (m *SopStageMutation) ResetTaskID() {
  23684. m.sop_task = nil
  23685. }
  23686. // SetName sets the "name" field.
  23687. func (m *SopStageMutation) SetName(s string) {
  23688. m.name = &s
  23689. }
  23690. // Name returns the value of the "name" field in the mutation.
  23691. func (m *SopStageMutation) Name() (r string, exists bool) {
  23692. v := m.name
  23693. if v == nil {
  23694. return
  23695. }
  23696. return *v, true
  23697. }
  23698. // OldName returns the old "name" field's value of the SopStage entity.
  23699. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23701. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  23702. if !m.op.Is(OpUpdateOne) {
  23703. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23704. }
  23705. if m.id == nil || m.oldValue == nil {
  23706. return v, errors.New("OldName requires an ID field in the mutation")
  23707. }
  23708. oldValue, err := m.oldValue(ctx)
  23709. if err != nil {
  23710. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23711. }
  23712. return oldValue.Name, nil
  23713. }
  23714. // ResetName resets all changes to the "name" field.
  23715. func (m *SopStageMutation) ResetName() {
  23716. m.name = nil
  23717. }
  23718. // SetConditionType sets the "condition_type" field.
  23719. func (m *SopStageMutation) SetConditionType(i int) {
  23720. m.condition_type = &i
  23721. m.addcondition_type = nil
  23722. }
  23723. // ConditionType returns the value of the "condition_type" field in the mutation.
  23724. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  23725. v := m.condition_type
  23726. if v == nil {
  23727. return
  23728. }
  23729. return *v, true
  23730. }
  23731. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  23732. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23734. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23735. if !m.op.Is(OpUpdateOne) {
  23736. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23737. }
  23738. if m.id == nil || m.oldValue == nil {
  23739. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23740. }
  23741. oldValue, err := m.oldValue(ctx)
  23742. if err != nil {
  23743. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23744. }
  23745. return oldValue.ConditionType, nil
  23746. }
  23747. // AddConditionType adds i to the "condition_type" field.
  23748. func (m *SopStageMutation) AddConditionType(i int) {
  23749. if m.addcondition_type != nil {
  23750. *m.addcondition_type += i
  23751. } else {
  23752. m.addcondition_type = &i
  23753. }
  23754. }
  23755. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23756. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  23757. v := m.addcondition_type
  23758. if v == nil {
  23759. return
  23760. }
  23761. return *v, true
  23762. }
  23763. // ResetConditionType resets all changes to the "condition_type" field.
  23764. func (m *SopStageMutation) ResetConditionType() {
  23765. m.condition_type = nil
  23766. m.addcondition_type = nil
  23767. }
  23768. // SetConditionOperator sets the "condition_operator" field.
  23769. func (m *SopStageMutation) SetConditionOperator(i int) {
  23770. m.condition_operator = &i
  23771. m.addcondition_operator = nil
  23772. }
  23773. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  23774. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  23775. v := m.condition_operator
  23776. if v == nil {
  23777. return
  23778. }
  23779. return *v, true
  23780. }
  23781. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  23782. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23784. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  23785. if !m.op.Is(OpUpdateOne) {
  23786. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  23787. }
  23788. if m.id == nil || m.oldValue == nil {
  23789. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  23790. }
  23791. oldValue, err := m.oldValue(ctx)
  23792. if err != nil {
  23793. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  23794. }
  23795. return oldValue.ConditionOperator, nil
  23796. }
  23797. // AddConditionOperator adds i to the "condition_operator" field.
  23798. func (m *SopStageMutation) AddConditionOperator(i int) {
  23799. if m.addcondition_operator != nil {
  23800. *m.addcondition_operator += i
  23801. } else {
  23802. m.addcondition_operator = &i
  23803. }
  23804. }
  23805. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  23806. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  23807. v := m.addcondition_operator
  23808. if v == nil {
  23809. return
  23810. }
  23811. return *v, true
  23812. }
  23813. // ResetConditionOperator resets all changes to the "condition_operator" field.
  23814. func (m *SopStageMutation) ResetConditionOperator() {
  23815. m.condition_operator = nil
  23816. m.addcondition_operator = nil
  23817. }
  23818. // SetConditionList sets the "condition_list" field.
  23819. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  23820. m.condition_list = &ct
  23821. m.appendcondition_list = nil
  23822. }
  23823. // ConditionList returns the value of the "condition_list" field in the mutation.
  23824. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  23825. v := m.condition_list
  23826. if v == nil {
  23827. return
  23828. }
  23829. return *v, true
  23830. }
  23831. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  23832. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23834. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  23835. if !m.op.Is(OpUpdateOne) {
  23836. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23837. }
  23838. if m.id == nil || m.oldValue == nil {
  23839. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23840. }
  23841. oldValue, err := m.oldValue(ctx)
  23842. if err != nil {
  23843. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23844. }
  23845. return oldValue.ConditionList, nil
  23846. }
  23847. // AppendConditionList adds ct to the "condition_list" field.
  23848. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  23849. m.appendcondition_list = append(m.appendcondition_list, ct...)
  23850. }
  23851. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23852. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  23853. if len(m.appendcondition_list) == 0 {
  23854. return nil, false
  23855. }
  23856. return m.appendcondition_list, true
  23857. }
  23858. // ResetConditionList resets all changes to the "condition_list" field.
  23859. func (m *SopStageMutation) ResetConditionList() {
  23860. m.condition_list = nil
  23861. m.appendcondition_list = nil
  23862. }
  23863. // SetActionMessage sets the "action_message" field.
  23864. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  23865. m.action_message = &ct
  23866. m.appendaction_message = nil
  23867. }
  23868. // ActionMessage returns the value of the "action_message" field in the mutation.
  23869. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23870. v := m.action_message
  23871. if v == nil {
  23872. return
  23873. }
  23874. return *v, true
  23875. }
  23876. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  23877. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23879. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23880. if !m.op.Is(OpUpdateOne) {
  23881. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23882. }
  23883. if m.id == nil || m.oldValue == nil {
  23884. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23885. }
  23886. oldValue, err := m.oldValue(ctx)
  23887. if err != nil {
  23888. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23889. }
  23890. return oldValue.ActionMessage, nil
  23891. }
  23892. // AppendActionMessage adds ct to the "action_message" field.
  23893. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  23894. m.appendaction_message = append(m.appendaction_message, ct...)
  23895. }
  23896. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23897. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23898. if len(m.appendaction_message) == 0 {
  23899. return nil, false
  23900. }
  23901. return m.appendaction_message, true
  23902. }
  23903. // ClearActionMessage clears the value of the "action_message" field.
  23904. func (m *SopStageMutation) ClearActionMessage() {
  23905. m.action_message = nil
  23906. m.appendaction_message = nil
  23907. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  23908. }
  23909. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23910. func (m *SopStageMutation) ActionMessageCleared() bool {
  23911. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  23912. return ok
  23913. }
  23914. // ResetActionMessage resets all changes to the "action_message" field.
  23915. func (m *SopStageMutation) ResetActionMessage() {
  23916. m.action_message = nil
  23917. m.appendaction_message = nil
  23918. delete(m.clearedFields, sopstage.FieldActionMessage)
  23919. }
  23920. // SetActionLabelAdd sets the "action_label_add" field.
  23921. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  23922. m.action_label_add = &u
  23923. m.appendaction_label_add = nil
  23924. }
  23925. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23926. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23927. v := m.action_label_add
  23928. if v == nil {
  23929. return
  23930. }
  23931. return *v, true
  23932. }
  23933. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  23934. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23936. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23937. if !m.op.Is(OpUpdateOne) {
  23938. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23939. }
  23940. if m.id == nil || m.oldValue == nil {
  23941. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23942. }
  23943. oldValue, err := m.oldValue(ctx)
  23944. if err != nil {
  23945. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23946. }
  23947. return oldValue.ActionLabelAdd, nil
  23948. }
  23949. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23950. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  23951. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23952. }
  23953. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23954. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23955. if len(m.appendaction_label_add) == 0 {
  23956. return nil, false
  23957. }
  23958. return m.appendaction_label_add, true
  23959. }
  23960. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23961. func (m *SopStageMutation) ClearActionLabelAdd() {
  23962. m.action_label_add = nil
  23963. m.appendaction_label_add = nil
  23964. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  23965. }
  23966. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23967. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  23968. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  23969. return ok
  23970. }
  23971. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23972. func (m *SopStageMutation) ResetActionLabelAdd() {
  23973. m.action_label_add = nil
  23974. m.appendaction_label_add = nil
  23975. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  23976. }
  23977. // SetActionLabelDel sets the "action_label_del" field.
  23978. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  23979. m.action_label_del = &u
  23980. m.appendaction_label_del = nil
  23981. }
  23982. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23983. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  23984. v := m.action_label_del
  23985. if v == nil {
  23986. return
  23987. }
  23988. return *v, true
  23989. }
  23990. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  23991. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23993. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23994. if !m.op.Is(OpUpdateOne) {
  23995. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23996. }
  23997. if m.id == nil || m.oldValue == nil {
  23998. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23999. }
  24000. oldValue, err := m.oldValue(ctx)
  24001. if err != nil {
  24002. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  24003. }
  24004. return oldValue.ActionLabelDel, nil
  24005. }
  24006. // AppendActionLabelDel adds u to the "action_label_del" field.
  24007. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  24008. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  24009. }
  24010. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  24011. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  24012. if len(m.appendaction_label_del) == 0 {
  24013. return nil, false
  24014. }
  24015. return m.appendaction_label_del, true
  24016. }
  24017. // ClearActionLabelDel clears the value of the "action_label_del" field.
  24018. func (m *SopStageMutation) ClearActionLabelDel() {
  24019. m.action_label_del = nil
  24020. m.appendaction_label_del = nil
  24021. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  24022. }
  24023. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  24024. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  24025. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  24026. return ok
  24027. }
  24028. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  24029. func (m *SopStageMutation) ResetActionLabelDel() {
  24030. m.action_label_del = nil
  24031. m.appendaction_label_del = nil
  24032. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  24033. }
  24034. // SetActionForward sets the "action_forward" field.
  24035. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  24036. m.action_forward = &ctf
  24037. }
  24038. // ActionForward returns the value of the "action_forward" field in the mutation.
  24039. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24040. v := m.action_forward
  24041. if v == nil {
  24042. return
  24043. }
  24044. return *v, true
  24045. }
  24046. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  24047. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24049. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24050. if !m.op.Is(OpUpdateOne) {
  24051. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24052. }
  24053. if m.id == nil || m.oldValue == nil {
  24054. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24055. }
  24056. oldValue, err := m.oldValue(ctx)
  24057. if err != nil {
  24058. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24059. }
  24060. return oldValue.ActionForward, nil
  24061. }
  24062. // ClearActionForward clears the value of the "action_forward" field.
  24063. func (m *SopStageMutation) ClearActionForward() {
  24064. m.action_forward = nil
  24065. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  24066. }
  24067. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24068. func (m *SopStageMutation) ActionForwardCleared() bool {
  24069. _, ok := m.clearedFields[sopstage.FieldActionForward]
  24070. return ok
  24071. }
  24072. // ResetActionForward resets all changes to the "action_forward" field.
  24073. func (m *SopStageMutation) ResetActionForward() {
  24074. m.action_forward = nil
  24075. delete(m.clearedFields, sopstage.FieldActionForward)
  24076. }
  24077. // SetIndexSort sets the "index_sort" field.
  24078. func (m *SopStageMutation) SetIndexSort(i int) {
  24079. m.index_sort = &i
  24080. m.addindex_sort = nil
  24081. }
  24082. // IndexSort returns the value of the "index_sort" field in the mutation.
  24083. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  24084. v := m.index_sort
  24085. if v == nil {
  24086. return
  24087. }
  24088. return *v, true
  24089. }
  24090. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  24091. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24093. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  24094. if !m.op.Is(OpUpdateOne) {
  24095. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  24096. }
  24097. if m.id == nil || m.oldValue == nil {
  24098. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  24099. }
  24100. oldValue, err := m.oldValue(ctx)
  24101. if err != nil {
  24102. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  24103. }
  24104. return oldValue.IndexSort, nil
  24105. }
  24106. // AddIndexSort adds i to the "index_sort" field.
  24107. func (m *SopStageMutation) AddIndexSort(i int) {
  24108. if m.addindex_sort != nil {
  24109. *m.addindex_sort += i
  24110. } else {
  24111. m.addindex_sort = &i
  24112. }
  24113. }
  24114. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  24115. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  24116. v := m.addindex_sort
  24117. if v == nil {
  24118. return
  24119. }
  24120. return *v, true
  24121. }
  24122. // ClearIndexSort clears the value of the "index_sort" field.
  24123. func (m *SopStageMutation) ClearIndexSort() {
  24124. m.index_sort = nil
  24125. m.addindex_sort = nil
  24126. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  24127. }
  24128. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  24129. func (m *SopStageMutation) IndexSortCleared() bool {
  24130. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  24131. return ok
  24132. }
  24133. // ResetIndexSort resets all changes to the "index_sort" field.
  24134. func (m *SopStageMutation) ResetIndexSort() {
  24135. m.index_sort = nil
  24136. m.addindex_sort = nil
  24137. delete(m.clearedFields, sopstage.FieldIndexSort)
  24138. }
  24139. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  24140. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  24141. m.sop_task = &id
  24142. }
  24143. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  24144. func (m *SopStageMutation) ClearSopTask() {
  24145. m.clearedsop_task = true
  24146. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  24147. }
  24148. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  24149. func (m *SopStageMutation) SopTaskCleared() bool {
  24150. return m.clearedsop_task
  24151. }
  24152. // SopTaskID returns the "sop_task" edge ID in the mutation.
  24153. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  24154. if m.sop_task != nil {
  24155. return *m.sop_task, true
  24156. }
  24157. return
  24158. }
  24159. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  24160. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24161. // SopTaskID instead. It exists only for internal usage by the builders.
  24162. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  24163. if id := m.sop_task; id != nil {
  24164. ids = append(ids, *id)
  24165. }
  24166. return
  24167. }
  24168. // ResetSopTask resets all changes to the "sop_task" edge.
  24169. func (m *SopStageMutation) ResetSopTask() {
  24170. m.sop_task = nil
  24171. m.clearedsop_task = false
  24172. }
  24173. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  24174. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  24175. if m.stage_nodes == nil {
  24176. m.stage_nodes = make(map[uint64]struct{})
  24177. }
  24178. for i := range ids {
  24179. m.stage_nodes[ids[i]] = struct{}{}
  24180. }
  24181. }
  24182. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  24183. func (m *SopStageMutation) ClearStageNodes() {
  24184. m.clearedstage_nodes = true
  24185. }
  24186. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  24187. func (m *SopStageMutation) StageNodesCleared() bool {
  24188. return m.clearedstage_nodes
  24189. }
  24190. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  24191. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  24192. if m.removedstage_nodes == nil {
  24193. m.removedstage_nodes = make(map[uint64]struct{})
  24194. }
  24195. for i := range ids {
  24196. delete(m.stage_nodes, ids[i])
  24197. m.removedstage_nodes[ids[i]] = struct{}{}
  24198. }
  24199. }
  24200. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  24201. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  24202. for id := range m.removedstage_nodes {
  24203. ids = append(ids, id)
  24204. }
  24205. return
  24206. }
  24207. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  24208. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  24209. for id := range m.stage_nodes {
  24210. ids = append(ids, id)
  24211. }
  24212. return
  24213. }
  24214. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  24215. func (m *SopStageMutation) ResetStageNodes() {
  24216. m.stage_nodes = nil
  24217. m.clearedstage_nodes = false
  24218. m.removedstage_nodes = nil
  24219. }
  24220. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  24221. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  24222. if m.stage_messages == nil {
  24223. m.stage_messages = make(map[uint64]struct{})
  24224. }
  24225. for i := range ids {
  24226. m.stage_messages[ids[i]] = struct{}{}
  24227. }
  24228. }
  24229. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  24230. func (m *SopStageMutation) ClearStageMessages() {
  24231. m.clearedstage_messages = true
  24232. }
  24233. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  24234. func (m *SopStageMutation) StageMessagesCleared() bool {
  24235. return m.clearedstage_messages
  24236. }
  24237. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  24238. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  24239. if m.removedstage_messages == nil {
  24240. m.removedstage_messages = make(map[uint64]struct{})
  24241. }
  24242. for i := range ids {
  24243. delete(m.stage_messages, ids[i])
  24244. m.removedstage_messages[ids[i]] = struct{}{}
  24245. }
  24246. }
  24247. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  24248. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  24249. for id := range m.removedstage_messages {
  24250. ids = append(ids, id)
  24251. }
  24252. return
  24253. }
  24254. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  24255. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  24256. for id := range m.stage_messages {
  24257. ids = append(ids, id)
  24258. }
  24259. return
  24260. }
  24261. // ResetStageMessages resets all changes to the "stage_messages" edge.
  24262. func (m *SopStageMutation) ResetStageMessages() {
  24263. m.stage_messages = nil
  24264. m.clearedstage_messages = false
  24265. m.removedstage_messages = nil
  24266. }
  24267. // Where appends a list predicates to the SopStageMutation builder.
  24268. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  24269. m.predicates = append(m.predicates, ps...)
  24270. }
  24271. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  24272. // users can use type-assertion to append predicates that do not depend on any generated package.
  24273. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  24274. p := make([]predicate.SopStage, len(ps))
  24275. for i := range ps {
  24276. p[i] = ps[i]
  24277. }
  24278. m.Where(p...)
  24279. }
  24280. // Op returns the operation name.
  24281. func (m *SopStageMutation) Op() Op {
  24282. return m.op
  24283. }
  24284. // SetOp allows setting the mutation operation.
  24285. func (m *SopStageMutation) SetOp(op Op) {
  24286. m.op = op
  24287. }
  24288. // Type returns the node type of this mutation (SopStage).
  24289. func (m *SopStageMutation) Type() string {
  24290. return m.typ
  24291. }
  24292. // Fields returns all fields that were changed during this mutation. Note that in
  24293. // order to get all numeric fields that were incremented/decremented, call
  24294. // AddedFields().
  24295. func (m *SopStageMutation) Fields() []string {
  24296. fields := make([]string, 0, 14)
  24297. if m.created_at != nil {
  24298. fields = append(fields, sopstage.FieldCreatedAt)
  24299. }
  24300. if m.updated_at != nil {
  24301. fields = append(fields, sopstage.FieldUpdatedAt)
  24302. }
  24303. if m.status != nil {
  24304. fields = append(fields, sopstage.FieldStatus)
  24305. }
  24306. if m.deleted_at != nil {
  24307. fields = append(fields, sopstage.FieldDeletedAt)
  24308. }
  24309. if m.sop_task != nil {
  24310. fields = append(fields, sopstage.FieldTaskID)
  24311. }
  24312. if m.name != nil {
  24313. fields = append(fields, sopstage.FieldName)
  24314. }
  24315. if m.condition_type != nil {
  24316. fields = append(fields, sopstage.FieldConditionType)
  24317. }
  24318. if m.condition_operator != nil {
  24319. fields = append(fields, sopstage.FieldConditionOperator)
  24320. }
  24321. if m.condition_list != nil {
  24322. fields = append(fields, sopstage.FieldConditionList)
  24323. }
  24324. if m.action_message != nil {
  24325. fields = append(fields, sopstage.FieldActionMessage)
  24326. }
  24327. if m.action_label_add != nil {
  24328. fields = append(fields, sopstage.FieldActionLabelAdd)
  24329. }
  24330. if m.action_label_del != nil {
  24331. fields = append(fields, sopstage.FieldActionLabelDel)
  24332. }
  24333. if m.action_forward != nil {
  24334. fields = append(fields, sopstage.FieldActionForward)
  24335. }
  24336. if m.index_sort != nil {
  24337. fields = append(fields, sopstage.FieldIndexSort)
  24338. }
  24339. return fields
  24340. }
  24341. // Field returns the value of a field with the given name. The second boolean
  24342. // return value indicates that this field was not set, or was not defined in the
  24343. // schema.
  24344. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  24345. switch name {
  24346. case sopstage.FieldCreatedAt:
  24347. return m.CreatedAt()
  24348. case sopstage.FieldUpdatedAt:
  24349. return m.UpdatedAt()
  24350. case sopstage.FieldStatus:
  24351. return m.Status()
  24352. case sopstage.FieldDeletedAt:
  24353. return m.DeletedAt()
  24354. case sopstage.FieldTaskID:
  24355. return m.TaskID()
  24356. case sopstage.FieldName:
  24357. return m.Name()
  24358. case sopstage.FieldConditionType:
  24359. return m.ConditionType()
  24360. case sopstage.FieldConditionOperator:
  24361. return m.ConditionOperator()
  24362. case sopstage.FieldConditionList:
  24363. return m.ConditionList()
  24364. case sopstage.FieldActionMessage:
  24365. return m.ActionMessage()
  24366. case sopstage.FieldActionLabelAdd:
  24367. return m.ActionLabelAdd()
  24368. case sopstage.FieldActionLabelDel:
  24369. return m.ActionLabelDel()
  24370. case sopstage.FieldActionForward:
  24371. return m.ActionForward()
  24372. case sopstage.FieldIndexSort:
  24373. return m.IndexSort()
  24374. }
  24375. return nil, false
  24376. }
  24377. // OldField returns the old value of the field from the database. An error is
  24378. // returned if the mutation operation is not UpdateOne, or the query to the
  24379. // database failed.
  24380. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24381. switch name {
  24382. case sopstage.FieldCreatedAt:
  24383. return m.OldCreatedAt(ctx)
  24384. case sopstage.FieldUpdatedAt:
  24385. return m.OldUpdatedAt(ctx)
  24386. case sopstage.FieldStatus:
  24387. return m.OldStatus(ctx)
  24388. case sopstage.FieldDeletedAt:
  24389. return m.OldDeletedAt(ctx)
  24390. case sopstage.FieldTaskID:
  24391. return m.OldTaskID(ctx)
  24392. case sopstage.FieldName:
  24393. return m.OldName(ctx)
  24394. case sopstage.FieldConditionType:
  24395. return m.OldConditionType(ctx)
  24396. case sopstage.FieldConditionOperator:
  24397. return m.OldConditionOperator(ctx)
  24398. case sopstage.FieldConditionList:
  24399. return m.OldConditionList(ctx)
  24400. case sopstage.FieldActionMessage:
  24401. return m.OldActionMessage(ctx)
  24402. case sopstage.FieldActionLabelAdd:
  24403. return m.OldActionLabelAdd(ctx)
  24404. case sopstage.FieldActionLabelDel:
  24405. return m.OldActionLabelDel(ctx)
  24406. case sopstage.FieldActionForward:
  24407. return m.OldActionForward(ctx)
  24408. case sopstage.FieldIndexSort:
  24409. return m.OldIndexSort(ctx)
  24410. }
  24411. return nil, fmt.Errorf("unknown SopStage field %s", name)
  24412. }
  24413. // SetField sets the value of a field with the given name. It returns an error if
  24414. // the field is not defined in the schema, or if the type mismatched the field
  24415. // type.
  24416. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  24417. switch name {
  24418. case sopstage.FieldCreatedAt:
  24419. v, ok := value.(time.Time)
  24420. if !ok {
  24421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24422. }
  24423. m.SetCreatedAt(v)
  24424. return nil
  24425. case sopstage.FieldUpdatedAt:
  24426. v, ok := value.(time.Time)
  24427. if !ok {
  24428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24429. }
  24430. m.SetUpdatedAt(v)
  24431. return nil
  24432. case sopstage.FieldStatus:
  24433. v, ok := value.(uint8)
  24434. if !ok {
  24435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24436. }
  24437. m.SetStatus(v)
  24438. return nil
  24439. case sopstage.FieldDeletedAt:
  24440. v, ok := value.(time.Time)
  24441. if !ok {
  24442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24443. }
  24444. m.SetDeletedAt(v)
  24445. return nil
  24446. case sopstage.FieldTaskID:
  24447. v, ok := value.(uint64)
  24448. if !ok {
  24449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24450. }
  24451. m.SetTaskID(v)
  24452. return nil
  24453. case sopstage.FieldName:
  24454. v, ok := value.(string)
  24455. if !ok {
  24456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24457. }
  24458. m.SetName(v)
  24459. return nil
  24460. case sopstage.FieldConditionType:
  24461. v, ok := value.(int)
  24462. if !ok {
  24463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24464. }
  24465. m.SetConditionType(v)
  24466. return nil
  24467. case sopstage.FieldConditionOperator:
  24468. v, ok := value.(int)
  24469. if !ok {
  24470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24471. }
  24472. m.SetConditionOperator(v)
  24473. return nil
  24474. case sopstage.FieldConditionList:
  24475. v, ok := value.([]custom_types.Condition)
  24476. if !ok {
  24477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24478. }
  24479. m.SetConditionList(v)
  24480. return nil
  24481. case sopstage.FieldActionMessage:
  24482. v, ok := value.([]custom_types.Action)
  24483. if !ok {
  24484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24485. }
  24486. m.SetActionMessage(v)
  24487. return nil
  24488. case sopstage.FieldActionLabelAdd:
  24489. v, ok := value.([]uint64)
  24490. if !ok {
  24491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24492. }
  24493. m.SetActionLabelAdd(v)
  24494. return nil
  24495. case sopstage.FieldActionLabelDel:
  24496. v, ok := value.([]uint64)
  24497. if !ok {
  24498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24499. }
  24500. m.SetActionLabelDel(v)
  24501. return nil
  24502. case sopstage.FieldActionForward:
  24503. v, ok := value.(*custom_types.ActionForward)
  24504. if !ok {
  24505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24506. }
  24507. m.SetActionForward(v)
  24508. return nil
  24509. case sopstage.FieldIndexSort:
  24510. v, ok := value.(int)
  24511. if !ok {
  24512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24513. }
  24514. m.SetIndexSort(v)
  24515. return nil
  24516. }
  24517. return fmt.Errorf("unknown SopStage field %s", name)
  24518. }
  24519. // AddedFields returns all numeric fields that were incremented/decremented during
  24520. // this mutation.
  24521. func (m *SopStageMutation) AddedFields() []string {
  24522. var fields []string
  24523. if m.addstatus != nil {
  24524. fields = append(fields, sopstage.FieldStatus)
  24525. }
  24526. if m.addcondition_type != nil {
  24527. fields = append(fields, sopstage.FieldConditionType)
  24528. }
  24529. if m.addcondition_operator != nil {
  24530. fields = append(fields, sopstage.FieldConditionOperator)
  24531. }
  24532. if m.addindex_sort != nil {
  24533. fields = append(fields, sopstage.FieldIndexSort)
  24534. }
  24535. return fields
  24536. }
  24537. // AddedField returns the numeric value that was incremented/decremented on a field
  24538. // with the given name. The second boolean return value indicates that this field
  24539. // was not set, or was not defined in the schema.
  24540. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  24541. switch name {
  24542. case sopstage.FieldStatus:
  24543. return m.AddedStatus()
  24544. case sopstage.FieldConditionType:
  24545. return m.AddedConditionType()
  24546. case sopstage.FieldConditionOperator:
  24547. return m.AddedConditionOperator()
  24548. case sopstage.FieldIndexSort:
  24549. return m.AddedIndexSort()
  24550. }
  24551. return nil, false
  24552. }
  24553. // AddField adds the value to the field with the given name. It returns an error if
  24554. // the field is not defined in the schema, or if the type mismatched the field
  24555. // type.
  24556. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  24557. switch name {
  24558. case sopstage.FieldStatus:
  24559. v, ok := value.(int8)
  24560. if !ok {
  24561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24562. }
  24563. m.AddStatus(v)
  24564. return nil
  24565. case sopstage.FieldConditionType:
  24566. v, ok := value.(int)
  24567. if !ok {
  24568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24569. }
  24570. m.AddConditionType(v)
  24571. return nil
  24572. case sopstage.FieldConditionOperator:
  24573. v, ok := value.(int)
  24574. if !ok {
  24575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24576. }
  24577. m.AddConditionOperator(v)
  24578. return nil
  24579. case sopstage.FieldIndexSort:
  24580. v, ok := value.(int)
  24581. if !ok {
  24582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24583. }
  24584. m.AddIndexSort(v)
  24585. return nil
  24586. }
  24587. return fmt.Errorf("unknown SopStage numeric field %s", name)
  24588. }
  24589. // ClearedFields returns all nullable fields that were cleared during this
  24590. // mutation.
  24591. func (m *SopStageMutation) ClearedFields() []string {
  24592. var fields []string
  24593. if m.FieldCleared(sopstage.FieldStatus) {
  24594. fields = append(fields, sopstage.FieldStatus)
  24595. }
  24596. if m.FieldCleared(sopstage.FieldDeletedAt) {
  24597. fields = append(fields, sopstage.FieldDeletedAt)
  24598. }
  24599. if m.FieldCleared(sopstage.FieldActionMessage) {
  24600. fields = append(fields, sopstage.FieldActionMessage)
  24601. }
  24602. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  24603. fields = append(fields, sopstage.FieldActionLabelAdd)
  24604. }
  24605. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  24606. fields = append(fields, sopstage.FieldActionLabelDel)
  24607. }
  24608. if m.FieldCleared(sopstage.FieldActionForward) {
  24609. fields = append(fields, sopstage.FieldActionForward)
  24610. }
  24611. if m.FieldCleared(sopstage.FieldIndexSort) {
  24612. fields = append(fields, sopstage.FieldIndexSort)
  24613. }
  24614. return fields
  24615. }
  24616. // FieldCleared returns a boolean indicating if a field with the given name was
  24617. // cleared in this mutation.
  24618. func (m *SopStageMutation) FieldCleared(name string) bool {
  24619. _, ok := m.clearedFields[name]
  24620. return ok
  24621. }
  24622. // ClearField clears the value of the field with the given name. It returns an
  24623. // error if the field is not defined in the schema.
  24624. func (m *SopStageMutation) ClearField(name string) error {
  24625. switch name {
  24626. case sopstage.FieldStatus:
  24627. m.ClearStatus()
  24628. return nil
  24629. case sopstage.FieldDeletedAt:
  24630. m.ClearDeletedAt()
  24631. return nil
  24632. case sopstage.FieldActionMessage:
  24633. m.ClearActionMessage()
  24634. return nil
  24635. case sopstage.FieldActionLabelAdd:
  24636. m.ClearActionLabelAdd()
  24637. return nil
  24638. case sopstage.FieldActionLabelDel:
  24639. m.ClearActionLabelDel()
  24640. return nil
  24641. case sopstage.FieldActionForward:
  24642. m.ClearActionForward()
  24643. return nil
  24644. case sopstage.FieldIndexSort:
  24645. m.ClearIndexSort()
  24646. return nil
  24647. }
  24648. return fmt.Errorf("unknown SopStage nullable field %s", name)
  24649. }
  24650. // ResetField resets all changes in the mutation for the field with the given name.
  24651. // It returns an error if the field is not defined in the schema.
  24652. func (m *SopStageMutation) ResetField(name string) error {
  24653. switch name {
  24654. case sopstage.FieldCreatedAt:
  24655. m.ResetCreatedAt()
  24656. return nil
  24657. case sopstage.FieldUpdatedAt:
  24658. m.ResetUpdatedAt()
  24659. return nil
  24660. case sopstage.FieldStatus:
  24661. m.ResetStatus()
  24662. return nil
  24663. case sopstage.FieldDeletedAt:
  24664. m.ResetDeletedAt()
  24665. return nil
  24666. case sopstage.FieldTaskID:
  24667. m.ResetTaskID()
  24668. return nil
  24669. case sopstage.FieldName:
  24670. m.ResetName()
  24671. return nil
  24672. case sopstage.FieldConditionType:
  24673. m.ResetConditionType()
  24674. return nil
  24675. case sopstage.FieldConditionOperator:
  24676. m.ResetConditionOperator()
  24677. return nil
  24678. case sopstage.FieldConditionList:
  24679. m.ResetConditionList()
  24680. return nil
  24681. case sopstage.FieldActionMessage:
  24682. m.ResetActionMessage()
  24683. return nil
  24684. case sopstage.FieldActionLabelAdd:
  24685. m.ResetActionLabelAdd()
  24686. return nil
  24687. case sopstage.FieldActionLabelDel:
  24688. m.ResetActionLabelDel()
  24689. return nil
  24690. case sopstage.FieldActionForward:
  24691. m.ResetActionForward()
  24692. return nil
  24693. case sopstage.FieldIndexSort:
  24694. m.ResetIndexSort()
  24695. return nil
  24696. }
  24697. return fmt.Errorf("unknown SopStage field %s", name)
  24698. }
  24699. // AddedEdges returns all edge names that were set/added in this mutation.
  24700. func (m *SopStageMutation) AddedEdges() []string {
  24701. edges := make([]string, 0, 3)
  24702. if m.sop_task != nil {
  24703. edges = append(edges, sopstage.EdgeSopTask)
  24704. }
  24705. if m.stage_nodes != nil {
  24706. edges = append(edges, sopstage.EdgeStageNodes)
  24707. }
  24708. if m.stage_messages != nil {
  24709. edges = append(edges, sopstage.EdgeStageMessages)
  24710. }
  24711. return edges
  24712. }
  24713. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24714. // name in this mutation.
  24715. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  24716. switch name {
  24717. case sopstage.EdgeSopTask:
  24718. if id := m.sop_task; id != nil {
  24719. return []ent.Value{*id}
  24720. }
  24721. case sopstage.EdgeStageNodes:
  24722. ids := make([]ent.Value, 0, len(m.stage_nodes))
  24723. for id := range m.stage_nodes {
  24724. ids = append(ids, id)
  24725. }
  24726. return ids
  24727. case sopstage.EdgeStageMessages:
  24728. ids := make([]ent.Value, 0, len(m.stage_messages))
  24729. for id := range m.stage_messages {
  24730. ids = append(ids, id)
  24731. }
  24732. return ids
  24733. }
  24734. return nil
  24735. }
  24736. // RemovedEdges returns all edge names that were removed in this mutation.
  24737. func (m *SopStageMutation) RemovedEdges() []string {
  24738. edges := make([]string, 0, 3)
  24739. if m.removedstage_nodes != nil {
  24740. edges = append(edges, sopstage.EdgeStageNodes)
  24741. }
  24742. if m.removedstage_messages != nil {
  24743. edges = append(edges, sopstage.EdgeStageMessages)
  24744. }
  24745. return edges
  24746. }
  24747. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24748. // the given name in this mutation.
  24749. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  24750. switch name {
  24751. case sopstage.EdgeStageNodes:
  24752. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  24753. for id := range m.removedstage_nodes {
  24754. ids = append(ids, id)
  24755. }
  24756. return ids
  24757. case sopstage.EdgeStageMessages:
  24758. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  24759. for id := range m.removedstage_messages {
  24760. ids = append(ids, id)
  24761. }
  24762. return ids
  24763. }
  24764. return nil
  24765. }
  24766. // ClearedEdges returns all edge names that were cleared in this mutation.
  24767. func (m *SopStageMutation) ClearedEdges() []string {
  24768. edges := make([]string, 0, 3)
  24769. if m.clearedsop_task {
  24770. edges = append(edges, sopstage.EdgeSopTask)
  24771. }
  24772. if m.clearedstage_nodes {
  24773. edges = append(edges, sopstage.EdgeStageNodes)
  24774. }
  24775. if m.clearedstage_messages {
  24776. edges = append(edges, sopstage.EdgeStageMessages)
  24777. }
  24778. return edges
  24779. }
  24780. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24781. // was cleared in this mutation.
  24782. func (m *SopStageMutation) EdgeCleared(name string) bool {
  24783. switch name {
  24784. case sopstage.EdgeSopTask:
  24785. return m.clearedsop_task
  24786. case sopstage.EdgeStageNodes:
  24787. return m.clearedstage_nodes
  24788. case sopstage.EdgeStageMessages:
  24789. return m.clearedstage_messages
  24790. }
  24791. return false
  24792. }
  24793. // ClearEdge clears the value of the edge with the given name. It returns an error
  24794. // if that edge is not defined in the schema.
  24795. func (m *SopStageMutation) ClearEdge(name string) error {
  24796. switch name {
  24797. case sopstage.EdgeSopTask:
  24798. m.ClearSopTask()
  24799. return nil
  24800. }
  24801. return fmt.Errorf("unknown SopStage unique edge %s", name)
  24802. }
  24803. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24804. // It returns an error if the edge is not defined in the schema.
  24805. func (m *SopStageMutation) ResetEdge(name string) error {
  24806. switch name {
  24807. case sopstage.EdgeSopTask:
  24808. m.ResetSopTask()
  24809. return nil
  24810. case sopstage.EdgeStageNodes:
  24811. m.ResetStageNodes()
  24812. return nil
  24813. case sopstage.EdgeStageMessages:
  24814. m.ResetStageMessages()
  24815. return nil
  24816. }
  24817. return fmt.Errorf("unknown SopStage edge %s", name)
  24818. }
  24819. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  24820. type SopTaskMutation struct {
  24821. config
  24822. op Op
  24823. typ string
  24824. id *uint64
  24825. created_at *time.Time
  24826. updated_at *time.Time
  24827. status *uint8
  24828. addstatus *int8
  24829. deleted_at *time.Time
  24830. name *string
  24831. bot_wxid_list *[]string
  24832. appendbot_wxid_list []string
  24833. _type *int
  24834. add_type *int
  24835. plan_start_time *time.Time
  24836. plan_end_time *time.Time
  24837. creator_id *string
  24838. organization_id *uint64
  24839. addorganization_id *int64
  24840. token *[]string
  24841. appendtoken []string
  24842. clearedFields map[string]struct{}
  24843. task_stages map[uint64]struct{}
  24844. removedtask_stages map[uint64]struct{}
  24845. clearedtask_stages bool
  24846. done bool
  24847. oldValue func(context.Context) (*SopTask, error)
  24848. predicates []predicate.SopTask
  24849. }
  24850. var _ ent.Mutation = (*SopTaskMutation)(nil)
  24851. // soptaskOption allows management of the mutation configuration using functional options.
  24852. type soptaskOption func(*SopTaskMutation)
  24853. // newSopTaskMutation creates new mutation for the SopTask entity.
  24854. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  24855. m := &SopTaskMutation{
  24856. config: c,
  24857. op: op,
  24858. typ: TypeSopTask,
  24859. clearedFields: make(map[string]struct{}),
  24860. }
  24861. for _, opt := range opts {
  24862. opt(m)
  24863. }
  24864. return m
  24865. }
  24866. // withSopTaskID sets the ID field of the mutation.
  24867. func withSopTaskID(id uint64) soptaskOption {
  24868. return func(m *SopTaskMutation) {
  24869. var (
  24870. err error
  24871. once sync.Once
  24872. value *SopTask
  24873. )
  24874. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  24875. once.Do(func() {
  24876. if m.done {
  24877. err = errors.New("querying old values post mutation is not allowed")
  24878. } else {
  24879. value, err = m.Client().SopTask.Get(ctx, id)
  24880. }
  24881. })
  24882. return value, err
  24883. }
  24884. m.id = &id
  24885. }
  24886. }
  24887. // withSopTask sets the old SopTask of the mutation.
  24888. func withSopTask(node *SopTask) soptaskOption {
  24889. return func(m *SopTaskMutation) {
  24890. m.oldValue = func(context.Context) (*SopTask, error) {
  24891. return node, nil
  24892. }
  24893. m.id = &node.ID
  24894. }
  24895. }
  24896. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24897. // executed in a transaction (ent.Tx), a transactional client is returned.
  24898. func (m SopTaskMutation) Client() *Client {
  24899. client := &Client{config: m.config}
  24900. client.init()
  24901. return client
  24902. }
  24903. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24904. // it returns an error otherwise.
  24905. func (m SopTaskMutation) Tx() (*Tx, error) {
  24906. if _, ok := m.driver.(*txDriver); !ok {
  24907. return nil, errors.New("ent: mutation is not running in a transaction")
  24908. }
  24909. tx := &Tx{config: m.config}
  24910. tx.init()
  24911. return tx, nil
  24912. }
  24913. // SetID sets the value of the id field. Note that this
  24914. // operation is only accepted on creation of SopTask entities.
  24915. func (m *SopTaskMutation) SetID(id uint64) {
  24916. m.id = &id
  24917. }
  24918. // ID returns the ID value in the mutation. Note that the ID is only available
  24919. // if it was provided to the builder or after it was returned from the database.
  24920. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  24921. if m.id == nil {
  24922. return
  24923. }
  24924. return *m.id, true
  24925. }
  24926. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24927. // That means, if the mutation is applied within a transaction with an isolation level such
  24928. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24929. // or updated by the mutation.
  24930. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  24931. switch {
  24932. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24933. id, exists := m.ID()
  24934. if exists {
  24935. return []uint64{id}, nil
  24936. }
  24937. fallthrough
  24938. case m.op.Is(OpUpdate | OpDelete):
  24939. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  24940. default:
  24941. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24942. }
  24943. }
  24944. // SetCreatedAt sets the "created_at" field.
  24945. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  24946. m.created_at = &t
  24947. }
  24948. // CreatedAt returns the value of the "created_at" field in the mutation.
  24949. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  24950. v := m.created_at
  24951. if v == nil {
  24952. return
  24953. }
  24954. return *v, true
  24955. }
  24956. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  24957. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24959. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24960. if !m.op.Is(OpUpdateOne) {
  24961. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24962. }
  24963. if m.id == nil || m.oldValue == nil {
  24964. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24965. }
  24966. oldValue, err := m.oldValue(ctx)
  24967. if err != nil {
  24968. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24969. }
  24970. return oldValue.CreatedAt, nil
  24971. }
  24972. // ResetCreatedAt resets all changes to the "created_at" field.
  24973. func (m *SopTaskMutation) ResetCreatedAt() {
  24974. m.created_at = nil
  24975. }
  24976. // SetUpdatedAt sets the "updated_at" field.
  24977. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  24978. m.updated_at = &t
  24979. }
  24980. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24981. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  24982. v := m.updated_at
  24983. if v == nil {
  24984. return
  24985. }
  24986. return *v, true
  24987. }
  24988. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  24989. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24991. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24992. if !m.op.Is(OpUpdateOne) {
  24993. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24994. }
  24995. if m.id == nil || m.oldValue == nil {
  24996. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24997. }
  24998. oldValue, err := m.oldValue(ctx)
  24999. if err != nil {
  25000. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25001. }
  25002. return oldValue.UpdatedAt, nil
  25003. }
  25004. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25005. func (m *SopTaskMutation) ResetUpdatedAt() {
  25006. m.updated_at = nil
  25007. }
  25008. // SetStatus sets the "status" field.
  25009. func (m *SopTaskMutation) SetStatus(u uint8) {
  25010. m.status = &u
  25011. m.addstatus = nil
  25012. }
  25013. // Status returns the value of the "status" field in the mutation.
  25014. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  25015. v := m.status
  25016. if v == nil {
  25017. return
  25018. }
  25019. return *v, true
  25020. }
  25021. // OldStatus returns the old "status" field's value of the SopTask entity.
  25022. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25024. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25025. if !m.op.Is(OpUpdateOne) {
  25026. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25027. }
  25028. if m.id == nil || m.oldValue == nil {
  25029. return v, errors.New("OldStatus requires an ID field in the mutation")
  25030. }
  25031. oldValue, err := m.oldValue(ctx)
  25032. if err != nil {
  25033. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25034. }
  25035. return oldValue.Status, nil
  25036. }
  25037. // AddStatus adds u to the "status" field.
  25038. func (m *SopTaskMutation) AddStatus(u int8) {
  25039. if m.addstatus != nil {
  25040. *m.addstatus += u
  25041. } else {
  25042. m.addstatus = &u
  25043. }
  25044. }
  25045. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25046. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  25047. v := m.addstatus
  25048. if v == nil {
  25049. return
  25050. }
  25051. return *v, true
  25052. }
  25053. // ClearStatus clears the value of the "status" field.
  25054. func (m *SopTaskMutation) ClearStatus() {
  25055. m.status = nil
  25056. m.addstatus = nil
  25057. m.clearedFields[soptask.FieldStatus] = struct{}{}
  25058. }
  25059. // StatusCleared returns if the "status" field was cleared in this mutation.
  25060. func (m *SopTaskMutation) StatusCleared() bool {
  25061. _, ok := m.clearedFields[soptask.FieldStatus]
  25062. return ok
  25063. }
  25064. // ResetStatus resets all changes to the "status" field.
  25065. func (m *SopTaskMutation) ResetStatus() {
  25066. m.status = nil
  25067. m.addstatus = nil
  25068. delete(m.clearedFields, soptask.FieldStatus)
  25069. }
  25070. // SetDeletedAt sets the "deleted_at" field.
  25071. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  25072. m.deleted_at = &t
  25073. }
  25074. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25075. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  25076. v := m.deleted_at
  25077. if v == nil {
  25078. return
  25079. }
  25080. return *v, true
  25081. }
  25082. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  25083. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25085. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25086. if !m.op.Is(OpUpdateOne) {
  25087. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25088. }
  25089. if m.id == nil || m.oldValue == nil {
  25090. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25091. }
  25092. oldValue, err := m.oldValue(ctx)
  25093. if err != nil {
  25094. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25095. }
  25096. return oldValue.DeletedAt, nil
  25097. }
  25098. // ClearDeletedAt clears the value of the "deleted_at" field.
  25099. func (m *SopTaskMutation) ClearDeletedAt() {
  25100. m.deleted_at = nil
  25101. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  25102. }
  25103. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25104. func (m *SopTaskMutation) DeletedAtCleared() bool {
  25105. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  25106. return ok
  25107. }
  25108. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25109. func (m *SopTaskMutation) ResetDeletedAt() {
  25110. m.deleted_at = nil
  25111. delete(m.clearedFields, soptask.FieldDeletedAt)
  25112. }
  25113. // SetName sets the "name" field.
  25114. func (m *SopTaskMutation) SetName(s string) {
  25115. m.name = &s
  25116. }
  25117. // Name returns the value of the "name" field in the mutation.
  25118. func (m *SopTaskMutation) Name() (r string, exists bool) {
  25119. v := m.name
  25120. if v == nil {
  25121. return
  25122. }
  25123. return *v, true
  25124. }
  25125. // OldName returns the old "name" field's value of the SopTask entity.
  25126. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25128. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  25129. if !m.op.Is(OpUpdateOne) {
  25130. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25131. }
  25132. if m.id == nil || m.oldValue == nil {
  25133. return v, errors.New("OldName requires an ID field in the mutation")
  25134. }
  25135. oldValue, err := m.oldValue(ctx)
  25136. if err != nil {
  25137. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25138. }
  25139. return oldValue.Name, nil
  25140. }
  25141. // ResetName resets all changes to the "name" field.
  25142. func (m *SopTaskMutation) ResetName() {
  25143. m.name = nil
  25144. }
  25145. // SetBotWxidList sets the "bot_wxid_list" field.
  25146. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  25147. m.bot_wxid_list = &s
  25148. m.appendbot_wxid_list = nil
  25149. }
  25150. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  25151. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  25152. v := m.bot_wxid_list
  25153. if v == nil {
  25154. return
  25155. }
  25156. return *v, true
  25157. }
  25158. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  25159. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25161. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  25162. if !m.op.Is(OpUpdateOne) {
  25163. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  25164. }
  25165. if m.id == nil || m.oldValue == nil {
  25166. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  25167. }
  25168. oldValue, err := m.oldValue(ctx)
  25169. if err != nil {
  25170. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  25171. }
  25172. return oldValue.BotWxidList, nil
  25173. }
  25174. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  25175. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  25176. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  25177. }
  25178. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  25179. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  25180. if len(m.appendbot_wxid_list) == 0 {
  25181. return nil, false
  25182. }
  25183. return m.appendbot_wxid_list, true
  25184. }
  25185. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  25186. func (m *SopTaskMutation) ClearBotWxidList() {
  25187. m.bot_wxid_list = nil
  25188. m.appendbot_wxid_list = nil
  25189. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  25190. }
  25191. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  25192. func (m *SopTaskMutation) BotWxidListCleared() bool {
  25193. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  25194. return ok
  25195. }
  25196. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  25197. func (m *SopTaskMutation) ResetBotWxidList() {
  25198. m.bot_wxid_list = nil
  25199. m.appendbot_wxid_list = nil
  25200. delete(m.clearedFields, soptask.FieldBotWxidList)
  25201. }
  25202. // SetType sets the "type" field.
  25203. func (m *SopTaskMutation) SetType(i int) {
  25204. m._type = &i
  25205. m.add_type = nil
  25206. }
  25207. // GetType returns the value of the "type" field in the mutation.
  25208. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  25209. v := m._type
  25210. if v == nil {
  25211. return
  25212. }
  25213. return *v, true
  25214. }
  25215. // OldType returns the old "type" field's value of the SopTask entity.
  25216. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25218. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  25219. if !m.op.Is(OpUpdateOne) {
  25220. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25221. }
  25222. if m.id == nil || m.oldValue == nil {
  25223. return v, errors.New("OldType requires an ID field in the mutation")
  25224. }
  25225. oldValue, err := m.oldValue(ctx)
  25226. if err != nil {
  25227. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25228. }
  25229. return oldValue.Type, nil
  25230. }
  25231. // AddType adds i to the "type" field.
  25232. func (m *SopTaskMutation) AddType(i int) {
  25233. if m.add_type != nil {
  25234. *m.add_type += i
  25235. } else {
  25236. m.add_type = &i
  25237. }
  25238. }
  25239. // AddedType returns the value that was added to the "type" field in this mutation.
  25240. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  25241. v := m.add_type
  25242. if v == nil {
  25243. return
  25244. }
  25245. return *v, true
  25246. }
  25247. // ResetType resets all changes to the "type" field.
  25248. func (m *SopTaskMutation) ResetType() {
  25249. m._type = nil
  25250. m.add_type = nil
  25251. }
  25252. // SetPlanStartTime sets the "plan_start_time" field.
  25253. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  25254. m.plan_start_time = &t
  25255. }
  25256. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  25257. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  25258. v := m.plan_start_time
  25259. if v == nil {
  25260. return
  25261. }
  25262. return *v, true
  25263. }
  25264. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  25265. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25267. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  25268. if !m.op.Is(OpUpdateOne) {
  25269. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  25270. }
  25271. if m.id == nil || m.oldValue == nil {
  25272. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  25273. }
  25274. oldValue, err := m.oldValue(ctx)
  25275. if err != nil {
  25276. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  25277. }
  25278. return oldValue.PlanStartTime, nil
  25279. }
  25280. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  25281. func (m *SopTaskMutation) ClearPlanStartTime() {
  25282. m.plan_start_time = nil
  25283. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  25284. }
  25285. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  25286. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  25287. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  25288. return ok
  25289. }
  25290. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  25291. func (m *SopTaskMutation) ResetPlanStartTime() {
  25292. m.plan_start_time = nil
  25293. delete(m.clearedFields, soptask.FieldPlanStartTime)
  25294. }
  25295. // SetPlanEndTime sets the "plan_end_time" field.
  25296. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  25297. m.plan_end_time = &t
  25298. }
  25299. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  25300. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  25301. v := m.plan_end_time
  25302. if v == nil {
  25303. return
  25304. }
  25305. return *v, true
  25306. }
  25307. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  25308. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25310. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  25311. if !m.op.Is(OpUpdateOne) {
  25312. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  25313. }
  25314. if m.id == nil || m.oldValue == nil {
  25315. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  25316. }
  25317. oldValue, err := m.oldValue(ctx)
  25318. if err != nil {
  25319. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  25320. }
  25321. return oldValue.PlanEndTime, nil
  25322. }
  25323. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  25324. func (m *SopTaskMutation) ClearPlanEndTime() {
  25325. m.plan_end_time = nil
  25326. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  25327. }
  25328. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  25329. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  25330. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  25331. return ok
  25332. }
  25333. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  25334. func (m *SopTaskMutation) ResetPlanEndTime() {
  25335. m.plan_end_time = nil
  25336. delete(m.clearedFields, soptask.FieldPlanEndTime)
  25337. }
  25338. // SetCreatorID sets the "creator_id" field.
  25339. func (m *SopTaskMutation) SetCreatorID(s string) {
  25340. m.creator_id = &s
  25341. }
  25342. // CreatorID returns the value of the "creator_id" field in the mutation.
  25343. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  25344. v := m.creator_id
  25345. if v == nil {
  25346. return
  25347. }
  25348. return *v, true
  25349. }
  25350. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  25351. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25353. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  25354. if !m.op.Is(OpUpdateOne) {
  25355. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  25356. }
  25357. if m.id == nil || m.oldValue == nil {
  25358. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  25359. }
  25360. oldValue, err := m.oldValue(ctx)
  25361. if err != nil {
  25362. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  25363. }
  25364. return oldValue.CreatorID, nil
  25365. }
  25366. // ClearCreatorID clears the value of the "creator_id" field.
  25367. func (m *SopTaskMutation) ClearCreatorID() {
  25368. m.creator_id = nil
  25369. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  25370. }
  25371. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  25372. func (m *SopTaskMutation) CreatorIDCleared() bool {
  25373. _, ok := m.clearedFields[soptask.FieldCreatorID]
  25374. return ok
  25375. }
  25376. // ResetCreatorID resets all changes to the "creator_id" field.
  25377. func (m *SopTaskMutation) ResetCreatorID() {
  25378. m.creator_id = nil
  25379. delete(m.clearedFields, soptask.FieldCreatorID)
  25380. }
  25381. // SetOrganizationID sets the "organization_id" field.
  25382. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  25383. m.organization_id = &u
  25384. m.addorganization_id = nil
  25385. }
  25386. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25387. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  25388. v := m.organization_id
  25389. if v == nil {
  25390. return
  25391. }
  25392. return *v, true
  25393. }
  25394. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  25395. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25397. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25398. if !m.op.Is(OpUpdateOne) {
  25399. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25400. }
  25401. if m.id == nil || m.oldValue == nil {
  25402. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25403. }
  25404. oldValue, err := m.oldValue(ctx)
  25405. if err != nil {
  25406. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25407. }
  25408. return oldValue.OrganizationID, nil
  25409. }
  25410. // AddOrganizationID adds u to the "organization_id" field.
  25411. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  25412. if m.addorganization_id != nil {
  25413. *m.addorganization_id += u
  25414. } else {
  25415. m.addorganization_id = &u
  25416. }
  25417. }
  25418. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25419. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  25420. v := m.addorganization_id
  25421. if v == nil {
  25422. return
  25423. }
  25424. return *v, true
  25425. }
  25426. // ClearOrganizationID clears the value of the "organization_id" field.
  25427. func (m *SopTaskMutation) ClearOrganizationID() {
  25428. m.organization_id = nil
  25429. m.addorganization_id = nil
  25430. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  25431. }
  25432. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25433. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  25434. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  25435. return ok
  25436. }
  25437. // ResetOrganizationID resets all changes to the "organization_id" field.
  25438. func (m *SopTaskMutation) ResetOrganizationID() {
  25439. m.organization_id = nil
  25440. m.addorganization_id = nil
  25441. delete(m.clearedFields, soptask.FieldOrganizationID)
  25442. }
  25443. // SetToken sets the "token" field.
  25444. func (m *SopTaskMutation) SetToken(s []string) {
  25445. m.token = &s
  25446. m.appendtoken = nil
  25447. }
  25448. // Token returns the value of the "token" field in the mutation.
  25449. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  25450. v := m.token
  25451. if v == nil {
  25452. return
  25453. }
  25454. return *v, true
  25455. }
  25456. // OldToken returns the old "token" field's value of the SopTask entity.
  25457. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25459. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  25460. if !m.op.Is(OpUpdateOne) {
  25461. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25462. }
  25463. if m.id == nil || m.oldValue == nil {
  25464. return v, errors.New("OldToken requires an ID field in the mutation")
  25465. }
  25466. oldValue, err := m.oldValue(ctx)
  25467. if err != nil {
  25468. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25469. }
  25470. return oldValue.Token, nil
  25471. }
  25472. // AppendToken adds s to the "token" field.
  25473. func (m *SopTaskMutation) AppendToken(s []string) {
  25474. m.appendtoken = append(m.appendtoken, s...)
  25475. }
  25476. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  25477. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  25478. if len(m.appendtoken) == 0 {
  25479. return nil, false
  25480. }
  25481. return m.appendtoken, true
  25482. }
  25483. // ClearToken clears the value of the "token" field.
  25484. func (m *SopTaskMutation) ClearToken() {
  25485. m.token = nil
  25486. m.appendtoken = nil
  25487. m.clearedFields[soptask.FieldToken] = struct{}{}
  25488. }
  25489. // TokenCleared returns if the "token" field was cleared in this mutation.
  25490. func (m *SopTaskMutation) TokenCleared() bool {
  25491. _, ok := m.clearedFields[soptask.FieldToken]
  25492. return ok
  25493. }
  25494. // ResetToken resets all changes to the "token" field.
  25495. func (m *SopTaskMutation) ResetToken() {
  25496. m.token = nil
  25497. m.appendtoken = nil
  25498. delete(m.clearedFields, soptask.FieldToken)
  25499. }
  25500. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  25501. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  25502. if m.task_stages == nil {
  25503. m.task_stages = make(map[uint64]struct{})
  25504. }
  25505. for i := range ids {
  25506. m.task_stages[ids[i]] = struct{}{}
  25507. }
  25508. }
  25509. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  25510. func (m *SopTaskMutation) ClearTaskStages() {
  25511. m.clearedtask_stages = true
  25512. }
  25513. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  25514. func (m *SopTaskMutation) TaskStagesCleared() bool {
  25515. return m.clearedtask_stages
  25516. }
  25517. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  25518. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  25519. if m.removedtask_stages == nil {
  25520. m.removedtask_stages = make(map[uint64]struct{})
  25521. }
  25522. for i := range ids {
  25523. delete(m.task_stages, ids[i])
  25524. m.removedtask_stages[ids[i]] = struct{}{}
  25525. }
  25526. }
  25527. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  25528. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  25529. for id := range m.removedtask_stages {
  25530. ids = append(ids, id)
  25531. }
  25532. return
  25533. }
  25534. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  25535. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  25536. for id := range m.task_stages {
  25537. ids = append(ids, id)
  25538. }
  25539. return
  25540. }
  25541. // ResetTaskStages resets all changes to the "task_stages" edge.
  25542. func (m *SopTaskMutation) ResetTaskStages() {
  25543. m.task_stages = nil
  25544. m.clearedtask_stages = false
  25545. m.removedtask_stages = nil
  25546. }
  25547. // Where appends a list predicates to the SopTaskMutation builder.
  25548. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  25549. m.predicates = append(m.predicates, ps...)
  25550. }
  25551. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  25552. // users can use type-assertion to append predicates that do not depend on any generated package.
  25553. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  25554. p := make([]predicate.SopTask, len(ps))
  25555. for i := range ps {
  25556. p[i] = ps[i]
  25557. }
  25558. m.Where(p...)
  25559. }
  25560. // Op returns the operation name.
  25561. func (m *SopTaskMutation) Op() Op {
  25562. return m.op
  25563. }
  25564. // SetOp allows setting the mutation operation.
  25565. func (m *SopTaskMutation) SetOp(op Op) {
  25566. m.op = op
  25567. }
  25568. // Type returns the node type of this mutation (SopTask).
  25569. func (m *SopTaskMutation) Type() string {
  25570. return m.typ
  25571. }
  25572. // Fields returns all fields that were changed during this mutation. Note that in
  25573. // order to get all numeric fields that were incremented/decremented, call
  25574. // AddedFields().
  25575. func (m *SopTaskMutation) Fields() []string {
  25576. fields := make([]string, 0, 12)
  25577. if m.created_at != nil {
  25578. fields = append(fields, soptask.FieldCreatedAt)
  25579. }
  25580. if m.updated_at != nil {
  25581. fields = append(fields, soptask.FieldUpdatedAt)
  25582. }
  25583. if m.status != nil {
  25584. fields = append(fields, soptask.FieldStatus)
  25585. }
  25586. if m.deleted_at != nil {
  25587. fields = append(fields, soptask.FieldDeletedAt)
  25588. }
  25589. if m.name != nil {
  25590. fields = append(fields, soptask.FieldName)
  25591. }
  25592. if m.bot_wxid_list != nil {
  25593. fields = append(fields, soptask.FieldBotWxidList)
  25594. }
  25595. if m._type != nil {
  25596. fields = append(fields, soptask.FieldType)
  25597. }
  25598. if m.plan_start_time != nil {
  25599. fields = append(fields, soptask.FieldPlanStartTime)
  25600. }
  25601. if m.plan_end_time != nil {
  25602. fields = append(fields, soptask.FieldPlanEndTime)
  25603. }
  25604. if m.creator_id != nil {
  25605. fields = append(fields, soptask.FieldCreatorID)
  25606. }
  25607. if m.organization_id != nil {
  25608. fields = append(fields, soptask.FieldOrganizationID)
  25609. }
  25610. if m.token != nil {
  25611. fields = append(fields, soptask.FieldToken)
  25612. }
  25613. return fields
  25614. }
  25615. // Field returns the value of a field with the given name. The second boolean
  25616. // return value indicates that this field was not set, or was not defined in the
  25617. // schema.
  25618. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  25619. switch name {
  25620. case soptask.FieldCreatedAt:
  25621. return m.CreatedAt()
  25622. case soptask.FieldUpdatedAt:
  25623. return m.UpdatedAt()
  25624. case soptask.FieldStatus:
  25625. return m.Status()
  25626. case soptask.FieldDeletedAt:
  25627. return m.DeletedAt()
  25628. case soptask.FieldName:
  25629. return m.Name()
  25630. case soptask.FieldBotWxidList:
  25631. return m.BotWxidList()
  25632. case soptask.FieldType:
  25633. return m.GetType()
  25634. case soptask.FieldPlanStartTime:
  25635. return m.PlanStartTime()
  25636. case soptask.FieldPlanEndTime:
  25637. return m.PlanEndTime()
  25638. case soptask.FieldCreatorID:
  25639. return m.CreatorID()
  25640. case soptask.FieldOrganizationID:
  25641. return m.OrganizationID()
  25642. case soptask.FieldToken:
  25643. return m.Token()
  25644. }
  25645. return nil, false
  25646. }
  25647. // OldField returns the old value of the field from the database. An error is
  25648. // returned if the mutation operation is not UpdateOne, or the query to the
  25649. // database failed.
  25650. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25651. switch name {
  25652. case soptask.FieldCreatedAt:
  25653. return m.OldCreatedAt(ctx)
  25654. case soptask.FieldUpdatedAt:
  25655. return m.OldUpdatedAt(ctx)
  25656. case soptask.FieldStatus:
  25657. return m.OldStatus(ctx)
  25658. case soptask.FieldDeletedAt:
  25659. return m.OldDeletedAt(ctx)
  25660. case soptask.FieldName:
  25661. return m.OldName(ctx)
  25662. case soptask.FieldBotWxidList:
  25663. return m.OldBotWxidList(ctx)
  25664. case soptask.FieldType:
  25665. return m.OldType(ctx)
  25666. case soptask.FieldPlanStartTime:
  25667. return m.OldPlanStartTime(ctx)
  25668. case soptask.FieldPlanEndTime:
  25669. return m.OldPlanEndTime(ctx)
  25670. case soptask.FieldCreatorID:
  25671. return m.OldCreatorID(ctx)
  25672. case soptask.FieldOrganizationID:
  25673. return m.OldOrganizationID(ctx)
  25674. case soptask.FieldToken:
  25675. return m.OldToken(ctx)
  25676. }
  25677. return nil, fmt.Errorf("unknown SopTask field %s", name)
  25678. }
  25679. // SetField sets the value of a field with the given name. It returns an error if
  25680. // the field is not defined in the schema, or if the type mismatched the field
  25681. // type.
  25682. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  25683. switch name {
  25684. case soptask.FieldCreatedAt:
  25685. v, ok := value.(time.Time)
  25686. if !ok {
  25687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25688. }
  25689. m.SetCreatedAt(v)
  25690. return nil
  25691. case soptask.FieldUpdatedAt:
  25692. v, ok := value.(time.Time)
  25693. if !ok {
  25694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25695. }
  25696. m.SetUpdatedAt(v)
  25697. return nil
  25698. case soptask.FieldStatus:
  25699. v, ok := value.(uint8)
  25700. if !ok {
  25701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25702. }
  25703. m.SetStatus(v)
  25704. return nil
  25705. case soptask.FieldDeletedAt:
  25706. v, ok := value.(time.Time)
  25707. if !ok {
  25708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25709. }
  25710. m.SetDeletedAt(v)
  25711. return nil
  25712. case soptask.FieldName:
  25713. v, ok := value.(string)
  25714. if !ok {
  25715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25716. }
  25717. m.SetName(v)
  25718. return nil
  25719. case soptask.FieldBotWxidList:
  25720. v, ok := value.([]string)
  25721. if !ok {
  25722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25723. }
  25724. m.SetBotWxidList(v)
  25725. return nil
  25726. case soptask.FieldType:
  25727. v, ok := value.(int)
  25728. if !ok {
  25729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25730. }
  25731. m.SetType(v)
  25732. return nil
  25733. case soptask.FieldPlanStartTime:
  25734. v, ok := value.(time.Time)
  25735. if !ok {
  25736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25737. }
  25738. m.SetPlanStartTime(v)
  25739. return nil
  25740. case soptask.FieldPlanEndTime:
  25741. v, ok := value.(time.Time)
  25742. if !ok {
  25743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25744. }
  25745. m.SetPlanEndTime(v)
  25746. return nil
  25747. case soptask.FieldCreatorID:
  25748. v, ok := value.(string)
  25749. if !ok {
  25750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25751. }
  25752. m.SetCreatorID(v)
  25753. return nil
  25754. case soptask.FieldOrganizationID:
  25755. v, ok := value.(uint64)
  25756. if !ok {
  25757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25758. }
  25759. m.SetOrganizationID(v)
  25760. return nil
  25761. case soptask.FieldToken:
  25762. v, ok := value.([]string)
  25763. if !ok {
  25764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25765. }
  25766. m.SetToken(v)
  25767. return nil
  25768. }
  25769. return fmt.Errorf("unknown SopTask field %s", name)
  25770. }
  25771. // AddedFields returns all numeric fields that were incremented/decremented during
  25772. // this mutation.
  25773. func (m *SopTaskMutation) AddedFields() []string {
  25774. var fields []string
  25775. if m.addstatus != nil {
  25776. fields = append(fields, soptask.FieldStatus)
  25777. }
  25778. if m.add_type != nil {
  25779. fields = append(fields, soptask.FieldType)
  25780. }
  25781. if m.addorganization_id != nil {
  25782. fields = append(fields, soptask.FieldOrganizationID)
  25783. }
  25784. return fields
  25785. }
  25786. // AddedField returns the numeric value that was incremented/decremented on a field
  25787. // with the given name. The second boolean return value indicates that this field
  25788. // was not set, or was not defined in the schema.
  25789. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  25790. switch name {
  25791. case soptask.FieldStatus:
  25792. return m.AddedStatus()
  25793. case soptask.FieldType:
  25794. return m.AddedType()
  25795. case soptask.FieldOrganizationID:
  25796. return m.AddedOrganizationID()
  25797. }
  25798. return nil, false
  25799. }
  25800. // AddField adds the value to the field with the given name. It returns an error if
  25801. // the field is not defined in the schema, or if the type mismatched the field
  25802. // type.
  25803. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  25804. switch name {
  25805. case soptask.FieldStatus:
  25806. v, ok := value.(int8)
  25807. if !ok {
  25808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25809. }
  25810. m.AddStatus(v)
  25811. return nil
  25812. case soptask.FieldType:
  25813. v, ok := value.(int)
  25814. if !ok {
  25815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25816. }
  25817. m.AddType(v)
  25818. return nil
  25819. case soptask.FieldOrganizationID:
  25820. v, ok := value.(int64)
  25821. if !ok {
  25822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25823. }
  25824. m.AddOrganizationID(v)
  25825. return nil
  25826. }
  25827. return fmt.Errorf("unknown SopTask numeric field %s", name)
  25828. }
  25829. // ClearedFields returns all nullable fields that were cleared during this
  25830. // mutation.
  25831. func (m *SopTaskMutation) ClearedFields() []string {
  25832. var fields []string
  25833. if m.FieldCleared(soptask.FieldStatus) {
  25834. fields = append(fields, soptask.FieldStatus)
  25835. }
  25836. if m.FieldCleared(soptask.FieldDeletedAt) {
  25837. fields = append(fields, soptask.FieldDeletedAt)
  25838. }
  25839. if m.FieldCleared(soptask.FieldBotWxidList) {
  25840. fields = append(fields, soptask.FieldBotWxidList)
  25841. }
  25842. if m.FieldCleared(soptask.FieldPlanStartTime) {
  25843. fields = append(fields, soptask.FieldPlanStartTime)
  25844. }
  25845. if m.FieldCleared(soptask.FieldPlanEndTime) {
  25846. fields = append(fields, soptask.FieldPlanEndTime)
  25847. }
  25848. if m.FieldCleared(soptask.FieldCreatorID) {
  25849. fields = append(fields, soptask.FieldCreatorID)
  25850. }
  25851. if m.FieldCleared(soptask.FieldOrganizationID) {
  25852. fields = append(fields, soptask.FieldOrganizationID)
  25853. }
  25854. if m.FieldCleared(soptask.FieldToken) {
  25855. fields = append(fields, soptask.FieldToken)
  25856. }
  25857. return fields
  25858. }
  25859. // FieldCleared returns a boolean indicating if a field with the given name was
  25860. // cleared in this mutation.
  25861. func (m *SopTaskMutation) FieldCleared(name string) bool {
  25862. _, ok := m.clearedFields[name]
  25863. return ok
  25864. }
  25865. // ClearField clears the value of the field with the given name. It returns an
  25866. // error if the field is not defined in the schema.
  25867. func (m *SopTaskMutation) ClearField(name string) error {
  25868. switch name {
  25869. case soptask.FieldStatus:
  25870. m.ClearStatus()
  25871. return nil
  25872. case soptask.FieldDeletedAt:
  25873. m.ClearDeletedAt()
  25874. return nil
  25875. case soptask.FieldBotWxidList:
  25876. m.ClearBotWxidList()
  25877. return nil
  25878. case soptask.FieldPlanStartTime:
  25879. m.ClearPlanStartTime()
  25880. return nil
  25881. case soptask.FieldPlanEndTime:
  25882. m.ClearPlanEndTime()
  25883. return nil
  25884. case soptask.FieldCreatorID:
  25885. m.ClearCreatorID()
  25886. return nil
  25887. case soptask.FieldOrganizationID:
  25888. m.ClearOrganizationID()
  25889. return nil
  25890. case soptask.FieldToken:
  25891. m.ClearToken()
  25892. return nil
  25893. }
  25894. return fmt.Errorf("unknown SopTask nullable field %s", name)
  25895. }
  25896. // ResetField resets all changes in the mutation for the field with the given name.
  25897. // It returns an error if the field is not defined in the schema.
  25898. func (m *SopTaskMutation) ResetField(name string) error {
  25899. switch name {
  25900. case soptask.FieldCreatedAt:
  25901. m.ResetCreatedAt()
  25902. return nil
  25903. case soptask.FieldUpdatedAt:
  25904. m.ResetUpdatedAt()
  25905. return nil
  25906. case soptask.FieldStatus:
  25907. m.ResetStatus()
  25908. return nil
  25909. case soptask.FieldDeletedAt:
  25910. m.ResetDeletedAt()
  25911. return nil
  25912. case soptask.FieldName:
  25913. m.ResetName()
  25914. return nil
  25915. case soptask.FieldBotWxidList:
  25916. m.ResetBotWxidList()
  25917. return nil
  25918. case soptask.FieldType:
  25919. m.ResetType()
  25920. return nil
  25921. case soptask.FieldPlanStartTime:
  25922. m.ResetPlanStartTime()
  25923. return nil
  25924. case soptask.FieldPlanEndTime:
  25925. m.ResetPlanEndTime()
  25926. return nil
  25927. case soptask.FieldCreatorID:
  25928. m.ResetCreatorID()
  25929. return nil
  25930. case soptask.FieldOrganizationID:
  25931. m.ResetOrganizationID()
  25932. return nil
  25933. case soptask.FieldToken:
  25934. m.ResetToken()
  25935. return nil
  25936. }
  25937. return fmt.Errorf("unknown SopTask field %s", name)
  25938. }
  25939. // AddedEdges returns all edge names that were set/added in this mutation.
  25940. func (m *SopTaskMutation) AddedEdges() []string {
  25941. edges := make([]string, 0, 1)
  25942. if m.task_stages != nil {
  25943. edges = append(edges, soptask.EdgeTaskStages)
  25944. }
  25945. return edges
  25946. }
  25947. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25948. // name in this mutation.
  25949. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  25950. switch name {
  25951. case soptask.EdgeTaskStages:
  25952. ids := make([]ent.Value, 0, len(m.task_stages))
  25953. for id := range m.task_stages {
  25954. ids = append(ids, id)
  25955. }
  25956. return ids
  25957. }
  25958. return nil
  25959. }
  25960. // RemovedEdges returns all edge names that were removed in this mutation.
  25961. func (m *SopTaskMutation) RemovedEdges() []string {
  25962. edges := make([]string, 0, 1)
  25963. if m.removedtask_stages != nil {
  25964. edges = append(edges, soptask.EdgeTaskStages)
  25965. }
  25966. return edges
  25967. }
  25968. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25969. // the given name in this mutation.
  25970. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  25971. switch name {
  25972. case soptask.EdgeTaskStages:
  25973. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  25974. for id := range m.removedtask_stages {
  25975. ids = append(ids, id)
  25976. }
  25977. return ids
  25978. }
  25979. return nil
  25980. }
  25981. // ClearedEdges returns all edge names that were cleared in this mutation.
  25982. func (m *SopTaskMutation) ClearedEdges() []string {
  25983. edges := make([]string, 0, 1)
  25984. if m.clearedtask_stages {
  25985. edges = append(edges, soptask.EdgeTaskStages)
  25986. }
  25987. return edges
  25988. }
  25989. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25990. // was cleared in this mutation.
  25991. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  25992. switch name {
  25993. case soptask.EdgeTaskStages:
  25994. return m.clearedtask_stages
  25995. }
  25996. return false
  25997. }
  25998. // ClearEdge clears the value of the edge with the given name. It returns an error
  25999. // if that edge is not defined in the schema.
  26000. func (m *SopTaskMutation) ClearEdge(name string) error {
  26001. switch name {
  26002. }
  26003. return fmt.Errorf("unknown SopTask unique edge %s", name)
  26004. }
  26005. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26006. // It returns an error if the edge is not defined in the schema.
  26007. func (m *SopTaskMutation) ResetEdge(name string) error {
  26008. switch name {
  26009. case soptask.EdgeTaskStages:
  26010. m.ResetTaskStages()
  26011. return nil
  26012. }
  26013. return fmt.Errorf("unknown SopTask edge %s", name)
  26014. }
  26015. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  26016. type TokenMutation struct {
  26017. config
  26018. op Op
  26019. typ string
  26020. id *uint64
  26021. created_at *time.Time
  26022. updated_at *time.Time
  26023. deleted_at *time.Time
  26024. expire_at *time.Time
  26025. token *string
  26026. mac *string
  26027. organization_id *uint64
  26028. addorganization_id *int64
  26029. custom_agent_base *string
  26030. custom_agent_key *string
  26031. openai_base *string
  26032. openai_key *string
  26033. clearedFields map[string]struct{}
  26034. agent *uint64
  26035. clearedagent bool
  26036. done bool
  26037. oldValue func(context.Context) (*Token, error)
  26038. predicates []predicate.Token
  26039. }
  26040. var _ ent.Mutation = (*TokenMutation)(nil)
  26041. // tokenOption allows management of the mutation configuration using functional options.
  26042. type tokenOption func(*TokenMutation)
  26043. // newTokenMutation creates new mutation for the Token entity.
  26044. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  26045. m := &TokenMutation{
  26046. config: c,
  26047. op: op,
  26048. typ: TypeToken,
  26049. clearedFields: make(map[string]struct{}),
  26050. }
  26051. for _, opt := range opts {
  26052. opt(m)
  26053. }
  26054. return m
  26055. }
  26056. // withTokenID sets the ID field of the mutation.
  26057. func withTokenID(id uint64) tokenOption {
  26058. return func(m *TokenMutation) {
  26059. var (
  26060. err error
  26061. once sync.Once
  26062. value *Token
  26063. )
  26064. m.oldValue = func(ctx context.Context) (*Token, error) {
  26065. once.Do(func() {
  26066. if m.done {
  26067. err = errors.New("querying old values post mutation is not allowed")
  26068. } else {
  26069. value, err = m.Client().Token.Get(ctx, id)
  26070. }
  26071. })
  26072. return value, err
  26073. }
  26074. m.id = &id
  26075. }
  26076. }
  26077. // withToken sets the old Token of the mutation.
  26078. func withToken(node *Token) tokenOption {
  26079. return func(m *TokenMutation) {
  26080. m.oldValue = func(context.Context) (*Token, error) {
  26081. return node, nil
  26082. }
  26083. m.id = &node.ID
  26084. }
  26085. }
  26086. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26087. // executed in a transaction (ent.Tx), a transactional client is returned.
  26088. func (m TokenMutation) Client() *Client {
  26089. client := &Client{config: m.config}
  26090. client.init()
  26091. return client
  26092. }
  26093. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26094. // it returns an error otherwise.
  26095. func (m TokenMutation) Tx() (*Tx, error) {
  26096. if _, ok := m.driver.(*txDriver); !ok {
  26097. return nil, errors.New("ent: mutation is not running in a transaction")
  26098. }
  26099. tx := &Tx{config: m.config}
  26100. tx.init()
  26101. return tx, nil
  26102. }
  26103. // SetID sets the value of the id field. Note that this
  26104. // operation is only accepted on creation of Token entities.
  26105. func (m *TokenMutation) SetID(id uint64) {
  26106. m.id = &id
  26107. }
  26108. // ID returns the ID value in the mutation. Note that the ID is only available
  26109. // if it was provided to the builder or after it was returned from the database.
  26110. func (m *TokenMutation) ID() (id uint64, exists bool) {
  26111. if m.id == nil {
  26112. return
  26113. }
  26114. return *m.id, true
  26115. }
  26116. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26117. // That means, if the mutation is applied within a transaction with an isolation level such
  26118. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26119. // or updated by the mutation.
  26120. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  26121. switch {
  26122. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26123. id, exists := m.ID()
  26124. if exists {
  26125. return []uint64{id}, nil
  26126. }
  26127. fallthrough
  26128. case m.op.Is(OpUpdate | OpDelete):
  26129. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  26130. default:
  26131. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26132. }
  26133. }
  26134. // SetCreatedAt sets the "created_at" field.
  26135. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  26136. m.created_at = &t
  26137. }
  26138. // CreatedAt returns the value of the "created_at" field in the mutation.
  26139. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  26140. v := m.created_at
  26141. if v == nil {
  26142. return
  26143. }
  26144. return *v, true
  26145. }
  26146. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  26147. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26149. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26150. if !m.op.Is(OpUpdateOne) {
  26151. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26152. }
  26153. if m.id == nil || m.oldValue == nil {
  26154. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26155. }
  26156. oldValue, err := m.oldValue(ctx)
  26157. if err != nil {
  26158. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26159. }
  26160. return oldValue.CreatedAt, nil
  26161. }
  26162. // ResetCreatedAt resets all changes to the "created_at" field.
  26163. func (m *TokenMutation) ResetCreatedAt() {
  26164. m.created_at = nil
  26165. }
  26166. // SetUpdatedAt sets the "updated_at" field.
  26167. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  26168. m.updated_at = &t
  26169. }
  26170. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26171. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  26172. v := m.updated_at
  26173. if v == nil {
  26174. return
  26175. }
  26176. return *v, true
  26177. }
  26178. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  26179. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26181. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26182. if !m.op.Is(OpUpdateOne) {
  26183. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26184. }
  26185. if m.id == nil || m.oldValue == nil {
  26186. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26187. }
  26188. oldValue, err := m.oldValue(ctx)
  26189. if err != nil {
  26190. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26191. }
  26192. return oldValue.UpdatedAt, nil
  26193. }
  26194. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26195. func (m *TokenMutation) ResetUpdatedAt() {
  26196. m.updated_at = nil
  26197. }
  26198. // SetDeletedAt sets the "deleted_at" field.
  26199. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  26200. m.deleted_at = &t
  26201. }
  26202. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26203. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  26204. v := m.deleted_at
  26205. if v == nil {
  26206. return
  26207. }
  26208. return *v, true
  26209. }
  26210. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  26211. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26213. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26214. if !m.op.Is(OpUpdateOne) {
  26215. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26216. }
  26217. if m.id == nil || m.oldValue == nil {
  26218. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26219. }
  26220. oldValue, err := m.oldValue(ctx)
  26221. if err != nil {
  26222. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26223. }
  26224. return oldValue.DeletedAt, nil
  26225. }
  26226. // ClearDeletedAt clears the value of the "deleted_at" field.
  26227. func (m *TokenMutation) ClearDeletedAt() {
  26228. m.deleted_at = nil
  26229. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  26230. }
  26231. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26232. func (m *TokenMutation) DeletedAtCleared() bool {
  26233. _, ok := m.clearedFields[token.FieldDeletedAt]
  26234. return ok
  26235. }
  26236. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26237. func (m *TokenMutation) ResetDeletedAt() {
  26238. m.deleted_at = nil
  26239. delete(m.clearedFields, token.FieldDeletedAt)
  26240. }
  26241. // SetExpireAt sets the "expire_at" field.
  26242. func (m *TokenMutation) SetExpireAt(t time.Time) {
  26243. m.expire_at = &t
  26244. }
  26245. // ExpireAt returns the value of the "expire_at" field in the mutation.
  26246. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  26247. v := m.expire_at
  26248. if v == nil {
  26249. return
  26250. }
  26251. return *v, true
  26252. }
  26253. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  26254. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26256. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  26257. if !m.op.Is(OpUpdateOne) {
  26258. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  26259. }
  26260. if m.id == nil || m.oldValue == nil {
  26261. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  26262. }
  26263. oldValue, err := m.oldValue(ctx)
  26264. if err != nil {
  26265. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  26266. }
  26267. return oldValue.ExpireAt, nil
  26268. }
  26269. // ClearExpireAt clears the value of the "expire_at" field.
  26270. func (m *TokenMutation) ClearExpireAt() {
  26271. m.expire_at = nil
  26272. m.clearedFields[token.FieldExpireAt] = struct{}{}
  26273. }
  26274. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  26275. func (m *TokenMutation) ExpireAtCleared() bool {
  26276. _, ok := m.clearedFields[token.FieldExpireAt]
  26277. return ok
  26278. }
  26279. // ResetExpireAt resets all changes to the "expire_at" field.
  26280. func (m *TokenMutation) ResetExpireAt() {
  26281. m.expire_at = nil
  26282. delete(m.clearedFields, token.FieldExpireAt)
  26283. }
  26284. // SetToken sets the "token" field.
  26285. func (m *TokenMutation) SetToken(s string) {
  26286. m.token = &s
  26287. }
  26288. // Token returns the value of the "token" field in the mutation.
  26289. func (m *TokenMutation) Token() (r string, exists bool) {
  26290. v := m.token
  26291. if v == nil {
  26292. return
  26293. }
  26294. return *v, true
  26295. }
  26296. // OldToken returns the old "token" field's value of the Token entity.
  26297. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26299. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  26300. if !m.op.Is(OpUpdateOne) {
  26301. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26302. }
  26303. if m.id == nil || m.oldValue == nil {
  26304. return v, errors.New("OldToken requires an ID field in the mutation")
  26305. }
  26306. oldValue, err := m.oldValue(ctx)
  26307. if err != nil {
  26308. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26309. }
  26310. return oldValue.Token, nil
  26311. }
  26312. // ClearToken clears the value of the "token" field.
  26313. func (m *TokenMutation) ClearToken() {
  26314. m.token = nil
  26315. m.clearedFields[token.FieldToken] = struct{}{}
  26316. }
  26317. // TokenCleared returns if the "token" field was cleared in this mutation.
  26318. func (m *TokenMutation) TokenCleared() bool {
  26319. _, ok := m.clearedFields[token.FieldToken]
  26320. return ok
  26321. }
  26322. // ResetToken resets all changes to the "token" field.
  26323. func (m *TokenMutation) ResetToken() {
  26324. m.token = nil
  26325. delete(m.clearedFields, token.FieldToken)
  26326. }
  26327. // SetMAC sets the "mac" field.
  26328. func (m *TokenMutation) SetMAC(s string) {
  26329. m.mac = &s
  26330. }
  26331. // MAC returns the value of the "mac" field in the mutation.
  26332. func (m *TokenMutation) MAC() (r string, exists bool) {
  26333. v := m.mac
  26334. if v == nil {
  26335. return
  26336. }
  26337. return *v, true
  26338. }
  26339. // OldMAC returns the old "mac" field's value of the Token entity.
  26340. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26342. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  26343. if !m.op.Is(OpUpdateOne) {
  26344. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  26345. }
  26346. if m.id == nil || m.oldValue == nil {
  26347. return v, errors.New("OldMAC requires an ID field in the mutation")
  26348. }
  26349. oldValue, err := m.oldValue(ctx)
  26350. if err != nil {
  26351. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  26352. }
  26353. return oldValue.MAC, nil
  26354. }
  26355. // ClearMAC clears the value of the "mac" field.
  26356. func (m *TokenMutation) ClearMAC() {
  26357. m.mac = nil
  26358. m.clearedFields[token.FieldMAC] = struct{}{}
  26359. }
  26360. // MACCleared returns if the "mac" field was cleared in this mutation.
  26361. func (m *TokenMutation) MACCleared() bool {
  26362. _, ok := m.clearedFields[token.FieldMAC]
  26363. return ok
  26364. }
  26365. // ResetMAC resets all changes to the "mac" field.
  26366. func (m *TokenMutation) ResetMAC() {
  26367. m.mac = nil
  26368. delete(m.clearedFields, token.FieldMAC)
  26369. }
  26370. // SetOrganizationID sets the "organization_id" field.
  26371. func (m *TokenMutation) SetOrganizationID(u uint64) {
  26372. m.organization_id = &u
  26373. m.addorganization_id = nil
  26374. }
  26375. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26376. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  26377. v := m.organization_id
  26378. if v == nil {
  26379. return
  26380. }
  26381. return *v, true
  26382. }
  26383. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  26384. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26386. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26387. if !m.op.Is(OpUpdateOne) {
  26388. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26389. }
  26390. if m.id == nil || m.oldValue == nil {
  26391. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26392. }
  26393. oldValue, err := m.oldValue(ctx)
  26394. if err != nil {
  26395. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26396. }
  26397. return oldValue.OrganizationID, nil
  26398. }
  26399. // AddOrganizationID adds u to the "organization_id" field.
  26400. func (m *TokenMutation) AddOrganizationID(u int64) {
  26401. if m.addorganization_id != nil {
  26402. *m.addorganization_id += u
  26403. } else {
  26404. m.addorganization_id = &u
  26405. }
  26406. }
  26407. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26408. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  26409. v := m.addorganization_id
  26410. if v == nil {
  26411. return
  26412. }
  26413. return *v, true
  26414. }
  26415. // ResetOrganizationID resets all changes to the "organization_id" field.
  26416. func (m *TokenMutation) ResetOrganizationID() {
  26417. m.organization_id = nil
  26418. m.addorganization_id = nil
  26419. }
  26420. // SetAgentID sets the "agent_id" field.
  26421. func (m *TokenMutation) SetAgentID(u uint64) {
  26422. m.agent = &u
  26423. }
  26424. // AgentID returns the value of the "agent_id" field in the mutation.
  26425. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  26426. v := m.agent
  26427. if v == nil {
  26428. return
  26429. }
  26430. return *v, true
  26431. }
  26432. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  26433. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26435. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26436. if !m.op.Is(OpUpdateOne) {
  26437. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26438. }
  26439. if m.id == nil || m.oldValue == nil {
  26440. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26441. }
  26442. oldValue, err := m.oldValue(ctx)
  26443. if err != nil {
  26444. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26445. }
  26446. return oldValue.AgentID, nil
  26447. }
  26448. // ResetAgentID resets all changes to the "agent_id" field.
  26449. func (m *TokenMutation) ResetAgentID() {
  26450. m.agent = nil
  26451. }
  26452. // SetCustomAgentBase sets the "custom_agent_base" field.
  26453. func (m *TokenMutation) SetCustomAgentBase(s string) {
  26454. m.custom_agent_base = &s
  26455. }
  26456. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  26457. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  26458. v := m.custom_agent_base
  26459. if v == nil {
  26460. return
  26461. }
  26462. return *v, true
  26463. }
  26464. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  26465. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26467. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  26468. if !m.op.Is(OpUpdateOne) {
  26469. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  26470. }
  26471. if m.id == nil || m.oldValue == nil {
  26472. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  26473. }
  26474. oldValue, err := m.oldValue(ctx)
  26475. if err != nil {
  26476. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  26477. }
  26478. return oldValue.CustomAgentBase, nil
  26479. }
  26480. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  26481. func (m *TokenMutation) ClearCustomAgentBase() {
  26482. m.custom_agent_base = nil
  26483. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  26484. }
  26485. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  26486. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  26487. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  26488. return ok
  26489. }
  26490. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  26491. func (m *TokenMutation) ResetCustomAgentBase() {
  26492. m.custom_agent_base = nil
  26493. delete(m.clearedFields, token.FieldCustomAgentBase)
  26494. }
  26495. // SetCustomAgentKey sets the "custom_agent_key" field.
  26496. func (m *TokenMutation) SetCustomAgentKey(s string) {
  26497. m.custom_agent_key = &s
  26498. }
  26499. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  26500. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  26501. v := m.custom_agent_key
  26502. if v == nil {
  26503. return
  26504. }
  26505. return *v, true
  26506. }
  26507. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  26508. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26510. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  26511. if !m.op.Is(OpUpdateOne) {
  26512. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  26513. }
  26514. if m.id == nil || m.oldValue == nil {
  26515. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  26516. }
  26517. oldValue, err := m.oldValue(ctx)
  26518. if err != nil {
  26519. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  26520. }
  26521. return oldValue.CustomAgentKey, nil
  26522. }
  26523. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  26524. func (m *TokenMutation) ClearCustomAgentKey() {
  26525. m.custom_agent_key = nil
  26526. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  26527. }
  26528. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  26529. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  26530. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  26531. return ok
  26532. }
  26533. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  26534. func (m *TokenMutation) ResetCustomAgentKey() {
  26535. m.custom_agent_key = nil
  26536. delete(m.clearedFields, token.FieldCustomAgentKey)
  26537. }
  26538. // SetOpenaiBase sets the "openai_base" field.
  26539. func (m *TokenMutation) SetOpenaiBase(s string) {
  26540. m.openai_base = &s
  26541. }
  26542. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  26543. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  26544. v := m.openai_base
  26545. if v == nil {
  26546. return
  26547. }
  26548. return *v, true
  26549. }
  26550. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  26551. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26553. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  26554. if !m.op.Is(OpUpdateOne) {
  26555. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  26556. }
  26557. if m.id == nil || m.oldValue == nil {
  26558. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  26559. }
  26560. oldValue, err := m.oldValue(ctx)
  26561. if err != nil {
  26562. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  26563. }
  26564. return oldValue.OpenaiBase, nil
  26565. }
  26566. // ClearOpenaiBase clears the value of the "openai_base" field.
  26567. func (m *TokenMutation) ClearOpenaiBase() {
  26568. m.openai_base = nil
  26569. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  26570. }
  26571. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  26572. func (m *TokenMutation) OpenaiBaseCleared() bool {
  26573. _, ok := m.clearedFields[token.FieldOpenaiBase]
  26574. return ok
  26575. }
  26576. // ResetOpenaiBase resets all changes to the "openai_base" field.
  26577. func (m *TokenMutation) ResetOpenaiBase() {
  26578. m.openai_base = nil
  26579. delete(m.clearedFields, token.FieldOpenaiBase)
  26580. }
  26581. // SetOpenaiKey sets the "openai_key" field.
  26582. func (m *TokenMutation) SetOpenaiKey(s string) {
  26583. m.openai_key = &s
  26584. }
  26585. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  26586. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  26587. v := m.openai_key
  26588. if v == nil {
  26589. return
  26590. }
  26591. return *v, true
  26592. }
  26593. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  26594. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26596. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  26597. if !m.op.Is(OpUpdateOne) {
  26598. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  26599. }
  26600. if m.id == nil || m.oldValue == nil {
  26601. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  26602. }
  26603. oldValue, err := m.oldValue(ctx)
  26604. if err != nil {
  26605. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  26606. }
  26607. return oldValue.OpenaiKey, nil
  26608. }
  26609. // ClearOpenaiKey clears the value of the "openai_key" field.
  26610. func (m *TokenMutation) ClearOpenaiKey() {
  26611. m.openai_key = nil
  26612. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  26613. }
  26614. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  26615. func (m *TokenMutation) OpenaiKeyCleared() bool {
  26616. _, ok := m.clearedFields[token.FieldOpenaiKey]
  26617. return ok
  26618. }
  26619. // ResetOpenaiKey resets all changes to the "openai_key" field.
  26620. func (m *TokenMutation) ResetOpenaiKey() {
  26621. m.openai_key = nil
  26622. delete(m.clearedFields, token.FieldOpenaiKey)
  26623. }
  26624. // ClearAgent clears the "agent" edge to the Agent entity.
  26625. func (m *TokenMutation) ClearAgent() {
  26626. m.clearedagent = true
  26627. m.clearedFields[token.FieldAgentID] = struct{}{}
  26628. }
  26629. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26630. func (m *TokenMutation) AgentCleared() bool {
  26631. return m.clearedagent
  26632. }
  26633. // AgentIDs returns the "agent" edge IDs in the mutation.
  26634. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26635. // AgentID instead. It exists only for internal usage by the builders.
  26636. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  26637. if id := m.agent; id != nil {
  26638. ids = append(ids, *id)
  26639. }
  26640. return
  26641. }
  26642. // ResetAgent resets all changes to the "agent" edge.
  26643. func (m *TokenMutation) ResetAgent() {
  26644. m.agent = nil
  26645. m.clearedagent = false
  26646. }
  26647. // Where appends a list predicates to the TokenMutation builder.
  26648. func (m *TokenMutation) Where(ps ...predicate.Token) {
  26649. m.predicates = append(m.predicates, ps...)
  26650. }
  26651. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  26652. // users can use type-assertion to append predicates that do not depend on any generated package.
  26653. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  26654. p := make([]predicate.Token, len(ps))
  26655. for i := range ps {
  26656. p[i] = ps[i]
  26657. }
  26658. m.Where(p...)
  26659. }
  26660. // Op returns the operation name.
  26661. func (m *TokenMutation) Op() Op {
  26662. return m.op
  26663. }
  26664. // SetOp allows setting the mutation operation.
  26665. func (m *TokenMutation) SetOp(op Op) {
  26666. m.op = op
  26667. }
  26668. // Type returns the node type of this mutation (Token).
  26669. func (m *TokenMutation) Type() string {
  26670. return m.typ
  26671. }
  26672. // Fields returns all fields that were changed during this mutation. Note that in
  26673. // order to get all numeric fields that were incremented/decremented, call
  26674. // AddedFields().
  26675. func (m *TokenMutation) Fields() []string {
  26676. fields := make([]string, 0, 12)
  26677. if m.created_at != nil {
  26678. fields = append(fields, token.FieldCreatedAt)
  26679. }
  26680. if m.updated_at != nil {
  26681. fields = append(fields, token.FieldUpdatedAt)
  26682. }
  26683. if m.deleted_at != nil {
  26684. fields = append(fields, token.FieldDeletedAt)
  26685. }
  26686. if m.expire_at != nil {
  26687. fields = append(fields, token.FieldExpireAt)
  26688. }
  26689. if m.token != nil {
  26690. fields = append(fields, token.FieldToken)
  26691. }
  26692. if m.mac != nil {
  26693. fields = append(fields, token.FieldMAC)
  26694. }
  26695. if m.organization_id != nil {
  26696. fields = append(fields, token.FieldOrganizationID)
  26697. }
  26698. if m.agent != nil {
  26699. fields = append(fields, token.FieldAgentID)
  26700. }
  26701. if m.custom_agent_base != nil {
  26702. fields = append(fields, token.FieldCustomAgentBase)
  26703. }
  26704. if m.custom_agent_key != nil {
  26705. fields = append(fields, token.FieldCustomAgentKey)
  26706. }
  26707. if m.openai_base != nil {
  26708. fields = append(fields, token.FieldOpenaiBase)
  26709. }
  26710. if m.openai_key != nil {
  26711. fields = append(fields, token.FieldOpenaiKey)
  26712. }
  26713. return fields
  26714. }
  26715. // Field returns the value of a field with the given name. The second boolean
  26716. // return value indicates that this field was not set, or was not defined in the
  26717. // schema.
  26718. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  26719. switch name {
  26720. case token.FieldCreatedAt:
  26721. return m.CreatedAt()
  26722. case token.FieldUpdatedAt:
  26723. return m.UpdatedAt()
  26724. case token.FieldDeletedAt:
  26725. return m.DeletedAt()
  26726. case token.FieldExpireAt:
  26727. return m.ExpireAt()
  26728. case token.FieldToken:
  26729. return m.Token()
  26730. case token.FieldMAC:
  26731. return m.MAC()
  26732. case token.FieldOrganizationID:
  26733. return m.OrganizationID()
  26734. case token.FieldAgentID:
  26735. return m.AgentID()
  26736. case token.FieldCustomAgentBase:
  26737. return m.CustomAgentBase()
  26738. case token.FieldCustomAgentKey:
  26739. return m.CustomAgentKey()
  26740. case token.FieldOpenaiBase:
  26741. return m.OpenaiBase()
  26742. case token.FieldOpenaiKey:
  26743. return m.OpenaiKey()
  26744. }
  26745. return nil, false
  26746. }
  26747. // OldField returns the old value of the field from the database. An error is
  26748. // returned if the mutation operation is not UpdateOne, or the query to the
  26749. // database failed.
  26750. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26751. switch name {
  26752. case token.FieldCreatedAt:
  26753. return m.OldCreatedAt(ctx)
  26754. case token.FieldUpdatedAt:
  26755. return m.OldUpdatedAt(ctx)
  26756. case token.FieldDeletedAt:
  26757. return m.OldDeletedAt(ctx)
  26758. case token.FieldExpireAt:
  26759. return m.OldExpireAt(ctx)
  26760. case token.FieldToken:
  26761. return m.OldToken(ctx)
  26762. case token.FieldMAC:
  26763. return m.OldMAC(ctx)
  26764. case token.FieldOrganizationID:
  26765. return m.OldOrganizationID(ctx)
  26766. case token.FieldAgentID:
  26767. return m.OldAgentID(ctx)
  26768. case token.FieldCustomAgentBase:
  26769. return m.OldCustomAgentBase(ctx)
  26770. case token.FieldCustomAgentKey:
  26771. return m.OldCustomAgentKey(ctx)
  26772. case token.FieldOpenaiBase:
  26773. return m.OldOpenaiBase(ctx)
  26774. case token.FieldOpenaiKey:
  26775. return m.OldOpenaiKey(ctx)
  26776. }
  26777. return nil, fmt.Errorf("unknown Token field %s", name)
  26778. }
  26779. // SetField sets the value of a field with the given name. It returns an error if
  26780. // the field is not defined in the schema, or if the type mismatched the field
  26781. // type.
  26782. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  26783. switch name {
  26784. case token.FieldCreatedAt:
  26785. v, ok := value.(time.Time)
  26786. if !ok {
  26787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26788. }
  26789. m.SetCreatedAt(v)
  26790. return nil
  26791. case token.FieldUpdatedAt:
  26792. v, ok := value.(time.Time)
  26793. if !ok {
  26794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26795. }
  26796. m.SetUpdatedAt(v)
  26797. return nil
  26798. case token.FieldDeletedAt:
  26799. v, ok := value.(time.Time)
  26800. if !ok {
  26801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26802. }
  26803. m.SetDeletedAt(v)
  26804. return nil
  26805. case token.FieldExpireAt:
  26806. v, ok := value.(time.Time)
  26807. if !ok {
  26808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26809. }
  26810. m.SetExpireAt(v)
  26811. return nil
  26812. case token.FieldToken:
  26813. v, ok := value.(string)
  26814. if !ok {
  26815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26816. }
  26817. m.SetToken(v)
  26818. return nil
  26819. case token.FieldMAC:
  26820. v, ok := value.(string)
  26821. if !ok {
  26822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26823. }
  26824. m.SetMAC(v)
  26825. return nil
  26826. case token.FieldOrganizationID:
  26827. v, ok := value.(uint64)
  26828. if !ok {
  26829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26830. }
  26831. m.SetOrganizationID(v)
  26832. return nil
  26833. case token.FieldAgentID:
  26834. v, ok := value.(uint64)
  26835. if !ok {
  26836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26837. }
  26838. m.SetAgentID(v)
  26839. return nil
  26840. case token.FieldCustomAgentBase:
  26841. v, ok := value.(string)
  26842. if !ok {
  26843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26844. }
  26845. m.SetCustomAgentBase(v)
  26846. return nil
  26847. case token.FieldCustomAgentKey:
  26848. v, ok := value.(string)
  26849. if !ok {
  26850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26851. }
  26852. m.SetCustomAgentKey(v)
  26853. return nil
  26854. case token.FieldOpenaiBase:
  26855. v, ok := value.(string)
  26856. if !ok {
  26857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26858. }
  26859. m.SetOpenaiBase(v)
  26860. return nil
  26861. case token.FieldOpenaiKey:
  26862. v, ok := value.(string)
  26863. if !ok {
  26864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26865. }
  26866. m.SetOpenaiKey(v)
  26867. return nil
  26868. }
  26869. return fmt.Errorf("unknown Token field %s", name)
  26870. }
  26871. // AddedFields returns all numeric fields that were incremented/decremented during
  26872. // this mutation.
  26873. func (m *TokenMutation) AddedFields() []string {
  26874. var fields []string
  26875. if m.addorganization_id != nil {
  26876. fields = append(fields, token.FieldOrganizationID)
  26877. }
  26878. return fields
  26879. }
  26880. // AddedField returns the numeric value that was incremented/decremented on a field
  26881. // with the given name. The second boolean return value indicates that this field
  26882. // was not set, or was not defined in the schema.
  26883. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  26884. switch name {
  26885. case token.FieldOrganizationID:
  26886. return m.AddedOrganizationID()
  26887. }
  26888. return nil, false
  26889. }
  26890. // AddField adds the value to the field with the given name. It returns an error if
  26891. // the field is not defined in the schema, or if the type mismatched the field
  26892. // type.
  26893. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  26894. switch name {
  26895. case token.FieldOrganizationID:
  26896. v, ok := value.(int64)
  26897. if !ok {
  26898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26899. }
  26900. m.AddOrganizationID(v)
  26901. return nil
  26902. }
  26903. return fmt.Errorf("unknown Token numeric field %s", name)
  26904. }
  26905. // ClearedFields returns all nullable fields that were cleared during this
  26906. // mutation.
  26907. func (m *TokenMutation) ClearedFields() []string {
  26908. var fields []string
  26909. if m.FieldCleared(token.FieldDeletedAt) {
  26910. fields = append(fields, token.FieldDeletedAt)
  26911. }
  26912. if m.FieldCleared(token.FieldExpireAt) {
  26913. fields = append(fields, token.FieldExpireAt)
  26914. }
  26915. if m.FieldCleared(token.FieldToken) {
  26916. fields = append(fields, token.FieldToken)
  26917. }
  26918. if m.FieldCleared(token.FieldMAC) {
  26919. fields = append(fields, token.FieldMAC)
  26920. }
  26921. if m.FieldCleared(token.FieldCustomAgentBase) {
  26922. fields = append(fields, token.FieldCustomAgentBase)
  26923. }
  26924. if m.FieldCleared(token.FieldCustomAgentKey) {
  26925. fields = append(fields, token.FieldCustomAgentKey)
  26926. }
  26927. if m.FieldCleared(token.FieldOpenaiBase) {
  26928. fields = append(fields, token.FieldOpenaiBase)
  26929. }
  26930. if m.FieldCleared(token.FieldOpenaiKey) {
  26931. fields = append(fields, token.FieldOpenaiKey)
  26932. }
  26933. return fields
  26934. }
  26935. // FieldCleared returns a boolean indicating if a field with the given name was
  26936. // cleared in this mutation.
  26937. func (m *TokenMutation) FieldCleared(name string) bool {
  26938. _, ok := m.clearedFields[name]
  26939. return ok
  26940. }
  26941. // ClearField clears the value of the field with the given name. It returns an
  26942. // error if the field is not defined in the schema.
  26943. func (m *TokenMutation) ClearField(name string) error {
  26944. switch name {
  26945. case token.FieldDeletedAt:
  26946. m.ClearDeletedAt()
  26947. return nil
  26948. case token.FieldExpireAt:
  26949. m.ClearExpireAt()
  26950. return nil
  26951. case token.FieldToken:
  26952. m.ClearToken()
  26953. return nil
  26954. case token.FieldMAC:
  26955. m.ClearMAC()
  26956. return nil
  26957. case token.FieldCustomAgentBase:
  26958. m.ClearCustomAgentBase()
  26959. return nil
  26960. case token.FieldCustomAgentKey:
  26961. m.ClearCustomAgentKey()
  26962. return nil
  26963. case token.FieldOpenaiBase:
  26964. m.ClearOpenaiBase()
  26965. return nil
  26966. case token.FieldOpenaiKey:
  26967. m.ClearOpenaiKey()
  26968. return nil
  26969. }
  26970. return fmt.Errorf("unknown Token nullable field %s", name)
  26971. }
  26972. // ResetField resets all changes in the mutation for the field with the given name.
  26973. // It returns an error if the field is not defined in the schema.
  26974. func (m *TokenMutation) ResetField(name string) error {
  26975. switch name {
  26976. case token.FieldCreatedAt:
  26977. m.ResetCreatedAt()
  26978. return nil
  26979. case token.FieldUpdatedAt:
  26980. m.ResetUpdatedAt()
  26981. return nil
  26982. case token.FieldDeletedAt:
  26983. m.ResetDeletedAt()
  26984. return nil
  26985. case token.FieldExpireAt:
  26986. m.ResetExpireAt()
  26987. return nil
  26988. case token.FieldToken:
  26989. m.ResetToken()
  26990. return nil
  26991. case token.FieldMAC:
  26992. m.ResetMAC()
  26993. return nil
  26994. case token.FieldOrganizationID:
  26995. m.ResetOrganizationID()
  26996. return nil
  26997. case token.FieldAgentID:
  26998. m.ResetAgentID()
  26999. return nil
  27000. case token.FieldCustomAgentBase:
  27001. m.ResetCustomAgentBase()
  27002. return nil
  27003. case token.FieldCustomAgentKey:
  27004. m.ResetCustomAgentKey()
  27005. return nil
  27006. case token.FieldOpenaiBase:
  27007. m.ResetOpenaiBase()
  27008. return nil
  27009. case token.FieldOpenaiKey:
  27010. m.ResetOpenaiKey()
  27011. return nil
  27012. }
  27013. return fmt.Errorf("unknown Token field %s", name)
  27014. }
  27015. // AddedEdges returns all edge names that were set/added in this mutation.
  27016. func (m *TokenMutation) AddedEdges() []string {
  27017. edges := make([]string, 0, 1)
  27018. if m.agent != nil {
  27019. edges = append(edges, token.EdgeAgent)
  27020. }
  27021. return edges
  27022. }
  27023. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27024. // name in this mutation.
  27025. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  27026. switch name {
  27027. case token.EdgeAgent:
  27028. if id := m.agent; id != nil {
  27029. return []ent.Value{*id}
  27030. }
  27031. }
  27032. return nil
  27033. }
  27034. // RemovedEdges returns all edge names that were removed in this mutation.
  27035. func (m *TokenMutation) RemovedEdges() []string {
  27036. edges := make([]string, 0, 1)
  27037. return edges
  27038. }
  27039. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27040. // the given name in this mutation.
  27041. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  27042. return nil
  27043. }
  27044. // ClearedEdges returns all edge names that were cleared in this mutation.
  27045. func (m *TokenMutation) ClearedEdges() []string {
  27046. edges := make([]string, 0, 1)
  27047. if m.clearedagent {
  27048. edges = append(edges, token.EdgeAgent)
  27049. }
  27050. return edges
  27051. }
  27052. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27053. // was cleared in this mutation.
  27054. func (m *TokenMutation) EdgeCleared(name string) bool {
  27055. switch name {
  27056. case token.EdgeAgent:
  27057. return m.clearedagent
  27058. }
  27059. return false
  27060. }
  27061. // ClearEdge clears the value of the edge with the given name. It returns an error
  27062. // if that edge is not defined in the schema.
  27063. func (m *TokenMutation) ClearEdge(name string) error {
  27064. switch name {
  27065. case token.EdgeAgent:
  27066. m.ClearAgent()
  27067. return nil
  27068. }
  27069. return fmt.Errorf("unknown Token unique edge %s", name)
  27070. }
  27071. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27072. // It returns an error if the edge is not defined in the schema.
  27073. func (m *TokenMutation) ResetEdge(name string) error {
  27074. switch name {
  27075. case token.EdgeAgent:
  27076. m.ResetAgent()
  27077. return nil
  27078. }
  27079. return fmt.Errorf("unknown Token edge %s", name)
  27080. }
  27081. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  27082. type TutorialMutation struct {
  27083. config
  27084. op Op
  27085. typ string
  27086. id *uint64
  27087. created_at *time.Time
  27088. updated_at *time.Time
  27089. deleted_at *time.Time
  27090. index *int
  27091. addindex *int
  27092. title *string
  27093. content *string
  27094. organization_id *uint64
  27095. addorganization_id *int64
  27096. clearedFields map[string]struct{}
  27097. employee *uint64
  27098. clearedemployee bool
  27099. done bool
  27100. oldValue func(context.Context) (*Tutorial, error)
  27101. predicates []predicate.Tutorial
  27102. }
  27103. var _ ent.Mutation = (*TutorialMutation)(nil)
  27104. // tutorialOption allows management of the mutation configuration using functional options.
  27105. type tutorialOption func(*TutorialMutation)
  27106. // newTutorialMutation creates new mutation for the Tutorial entity.
  27107. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  27108. m := &TutorialMutation{
  27109. config: c,
  27110. op: op,
  27111. typ: TypeTutorial,
  27112. clearedFields: make(map[string]struct{}),
  27113. }
  27114. for _, opt := range opts {
  27115. opt(m)
  27116. }
  27117. return m
  27118. }
  27119. // withTutorialID sets the ID field of the mutation.
  27120. func withTutorialID(id uint64) tutorialOption {
  27121. return func(m *TutorialMutation) {
  27122. var (
  27123. err error
  27124. once sync.Once
  27125. value *Tutorial
  27126. )
  27127. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  27128. once.Do(func() {
  27129. if m.done {
  27130. err = errors.New("querying old values post mutation is not allowed")
  27131. } else {
  27132. value, err = m.Client().Tutorial.Get(ctx, id)
  27133. }
  27134. })
  27135. return value, err
  27136. }
  27137. m.id = &id
  27138. }
  27139. }
  27140. // withTutorial sets the old Tutorial of the mutation.
  27141. func withTutorial(node *Tutorial) tutorialOption {
  27142. return func(m *TutorialMutation) {
  27143. m.oldValue = func(context.Context) (*Tutorial, error) {
  27144. return node, nil
  27145. }
  27146. m.id = &node.ID
  27147. }
  27148. }
  27149. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27150. // executed in a transaction (ent.Tx), a transactional client is returned.
  27151. func (m TutorialMutation) Client() *Client {
  27152. client := &Client{config: m.config}
  27153. client.init()
  27154. return client
  27155. }
  27156. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27157. // it returns an error otherwise.
  27158. func (m TutorialMutation) Tx() (*Tx, error) {
  27159. if _, ok := m.driver.(*txDriver); !ok {
  27160. return nil, errors.New("ent: mutation is not running in a transaction")
  27161. }
  27162. tx := &Tx{config: m.config}
  27163. tx.init()
  27164. return tx, nil
  27165. }
  27166. // SetID sets the value of the id field. Note that this
  27167. // operation is only accepted on creation of Tutorial entities.
  27168. func (m *TutorialMutation) SetID(id uint64) {
  27169. m.id = &id
  27170. }
  27171. // ID returns the ID value in the mutation. Note that the ID is only available
  27172. // if it was provided to the builder or after it was returned from the database.
  27173. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  27174. if m.id == nil {
  27175. return
  27176. }
  27177. return *m.id, true
  27178. }
  27179. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27180. // That means, if the mutation is applied within a transaction with an isolation level such
  27181. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27182. // or updated by the mutation.
  27183. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  27184. switch {
  27185. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27186. id, exists := m.ID()
  27187. if exists {
  27188. return []uint64{id}, nil
  27189. }
  27190. fallthrough
  27191. case m.op.Is(OpUpdate | OpDelete):
  27192. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  27193. default:
  27194. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27195. }
  27196. }
  27197. // SetCreatedAt sets the "created_at" field.
  27198. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  27199. m.created_at = &t
  27200. }
  27201. // CreatedAt returns the value of the "created_at" field in the mutation.
  27202. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  27203. v := m.created_at
  27204. if v == nil {
  27205. return
  27206. }
  27207. return *v, true
  27208. }
  27209. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  27210. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27212. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27213. if !m.op.Is(OpUpdateOne) {
  27214. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27215. }
  27216. if m.id == nil || m.oldValue == nil {
  27217. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27218. }
  27219. oldValue, err := m.oldValue(ctx)
  27220. if err != nil {
  27221. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27222. }
  27223. return oldValue.CreatedAt, nil
  27224. }
  27225. // ResetCreatedAt resets all changes to the "created_at" field.
  27226. func (m *TutorialMutation) ResetCreatedAt() {
  27227. m.created_at = nil
  27228. }
  27229. // SetUpdatedAt sets the "updated_at" field.
  27230. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  27231. m.updated_at = &t
  27232. }
  27233. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27234. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  27235. v := m.updated_at
  27236. if v == nil {
  27237. return
  27238. }
  27239. return *v, true
  27240. }
  27241. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  27242. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27244. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27245. if !m.op.Is(OpUpdateOne) {
  27246. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27247. }
  27248. if m.id == nil || m.oldValue == nil {
  27249. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27250. }
  27251. oldValue, err := m.oldValue(ctx)
  27252. if err != nil {
  27253. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27254. }
  27255. return oldValue.UpdatedAt, nil
  27256. }
  27257. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27258. func (m *TutorialMutation) ResetUpdatedAt() {
  27259. m.updated_at = nil
  27260. }
  27261. // SetDeletedAt sets the "deleted_at" field.
  27262. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  27263. m.deleted_at = &t
  27264. }
  27265. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27266. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  27267. v := m.deleted_at
  27268. if v == nil {
  27269. return
  27270. }
  27271. return *v, true
  27272. }
  27273. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  27274. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27276. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27277. if !m.op.Is(OpUpdateOne) {
  27278. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27279. }
  27280. if m.id == nil || m.oldValue == nil {
  27281. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27282. }
  27283. oldValue, err := m.oldValue(ctx)
  27284. if err != nil {
  27285. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27286. }
  27287. return oldValue.DeletedAt, nil
  27288. }
  27289. // ClearDeletedAt clears the value of the "deleted_at" field.
  27290. func (m *TutorialMutation) ClearDeletedAt() {
  27291. m.deleted_at = nil
  27292. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  27293. }
  27294. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27295. func (m *TutorialMutation) DeletedAtCleared() bool {
  27296. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  27297. return ok
  27298. }
  27299. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27300. func (m *TutorialMutation) ResetDeletedAt() {
  27301. m.deleted_at = nil
  27302. delete(m.clearedFields, tutorial.FieldDeletedAt)
  27303. }
  27304. // SetEmployeeID sets the "employee_id" field.
  27305. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  27306. m.employee = &u
  27307. }
  27308. // EmployeeID returns the value of the "employee_id" field in the mutation.
  27309. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  27310. v := m.employee
  27311. if v == nil {
  27312. return
  27313. }
  27314. return *v, true
  27315. }
  27316. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  27317. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27319. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  27320. if !m.op.Is(OpUpdateOne) {
  27321. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  27322. }
  27323. if m.id == nil || m.oldValue == nil {
  27324. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  27325. }
  27326. oldValue, err := m.oldValue(ctx)
  27327. if err != nil {
  27328. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  27329. }
  27330. return oldValue.EmployeeID, nil
  27331. }
  27332. // ResetEmployeeID resets all changes to the "employee_id" field.
  27333. func (m *TutorialMutation) ResetEmployeeID() {
  27334. m.employee = nil
  27335. }
  27336. // SetIndex sets the "index" field.
  27337. func (m *TutorialMutation) SetIndex(i int) {
  27338. m.index = &i
  27339. m.addindex = nil
  27340. }
  27341. // Index returns the value of the "index" field in the mutation.
  27342. func (m *TutorialMutation) Index() (r int, exists bool) {
  27343. v := m.index
  27344. if v == nil {
  27345. return
  27346. }
  27347. return *v, true
  27348. }
  27349. // OldIndex returns the old "index" field's value of the Tutorial entity.
  27350. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27352. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  27353. if !m.op.Is(OpUpdateOne) {
  27354. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  27355. }
  27356. if m.id == nil || m.oldValue == nil {
  27357. return v, errors.New("OldIndex requires an ID field in the mutation")
  27358. }
  27359. oldValue, err := m.oldValue(ctx)
  27360. if err != nil {
  27361. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  27362. }
  27363. return oldValue.Index, nil
  27364. }
  27365. // AddIndex adds i to the "index" field.
  27366. func (m *TutorialMutation) AddIndex(i int) {
  27367. if m.addindex != nil {
  27368. *m.addindex += i
  27369. } else {
  27370. m.addindex = &i
  27371. }
  27372. }
  27373. // AddedIndex returns the value that was added to the "index" field in this mutation.
  27374. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  27375. v := m.addindex
  27376. if v == nil {
  27377. return
  27378. }
  27379. return *v, true
  27380. }
  27381. // ResetIndex resets all changes to the "index" field.
  27382. func (m *TutorialMutation) ResetIndex() {
  27383. m.index = nil
  27384. m.addindex = nil
  27385. }
  27386. // SetTitle sets the "title" field.
  27387. func (m *TutorialMutation) SetTitle(s string) {
  27388. m.title = &s
  27389. }
  27390. // Title returns the value of the "title" field in the mutation.
  27391. func (m *TutorialMutation) Title() (r string, exists bool) {
  27392. v := m.title
  27393. if v == nil {
  27394. return
  27395. }
  27396. return *v, true
  27397. }
  27398. // OldTitle returns the old "title" field's value of the Tutorial entity.
  27399. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27401. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  27402. if !m.op.Is(OpUpdateOne) {
  27403. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  27404. }
  27405. if m.id == nil || m.oldValue == nil {
  27406. return v, errors.New("OldTitle requires an ID field in the mutation")
  27407. }
  27408. oldValue, err := m.oldValue(ctx)
  27409. if err != nil {
  27410. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  27411. }
  27412. return oldValue.Title, nil
  27413. }
  27414. // ResetTitle resets all changes to the "title" field.
  27415. func (m *TutorialMutation) ResetTitle() {
  27416. m.title = nil
  27417. }
  27418. // SetContent sets the "content" field.
  27419. func (m *TutorialMutation) SetContent(s string) {
  27420. m.content = &s
  27421. }
  27422. // Content returns the value of the "content" field in the mutation.
  27423. func (m *TutorialMutation) Content() (r string, exists bool) {
  27424. v := m.content
  27425. if v == nil {
  27426. return
  27427. }
  27428. return *v, true
  27429. }
  27430. // OldContent returns the old "content" field's value of the Tutorial entity.
  27431. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27433. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  27434. if !m.op.Is(OpUpdateOne) {
  27435. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  27436. }
  27437. if m.id == nil || m.oldValue == nil {
  27438. return v, errors.New("OldContent requires an ID field in the mutation")
  27439. }
  27440. oldValue, err := m.oldValue(ctx)
  27441. if err != nil {
  27442. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  27443. }
  27444. return oldValue.Content, nil
  27445. }
  27446. // ResetContent resets all changes to the "content" field.
  27447. func (m *TutorialMutation) ResetContent() {
  27448. m.content = nil
  27449. }
  27450. // SetOrganizationID sets the "organization_id" field.
  27451. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  27452. m.organization_id = &u
  27453. m.addorganization_id = nil
  27454. }
  27455. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27456. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  27457. v := m.organization_id
  27458. if v == nil {
  27459. return
  27460. }
  27461. return *v, true
  27462. }
  27463. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  27464. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27466. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27467. if !m.op.Is(OpUpdateOne) {
  27468. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27469. }
  27470. if m.id == nil || m.oldValue == nil {
  27471. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27472. }
  27473. oldValue, err := m.oldValue(ctx)
  27474. if err != nil {
  27475. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27476. }
  27477. return oldValue.OrganizationID, nil
  27478. }
  27479. // AddOrganizationID adds u to the "organization_id" field.
  27480. func (m *TutorialMutation) AddOrganizationID(u int64) {
  27481. if m.addorganization_id != nil {
  27482. *m.addorganization_id += u
  27483. } else {
  27484. m.addorganization_id = &u
  27485. }
  27486. }
  27487. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27488. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  27489. v := m.addorganization_id
  27490. if v == nil {
  27491. return
  27492. }
  27493. return *v, true
  27494. }
  27495. // ResetOrganizationID resets all changes to the "organization_id" field.
  27496. func (m *TutorialMutation) ResetOrganizationID() {
  27497. m.organization_id = nil
  27498. m.addorganization_id = nil
  27499. }
  27500. // ClearEmployee clears the "employee" edge to the Employee entity.
  27501. func (m *TutorialMutation) ClearEmployee() {
  27502. m.clearedemployee = true
  27503. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  27504. }
  27505. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  27506. func (m *TutorialMutation) EmployeeCleared() bool {
  27507. return m.clearedemployee
  27508. }
  27509. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  27510. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27511. // EmployeeID instead. It exists only for internal usage by the builders.
  27512. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  27513. if id := m.employee; id != nil {
  27514. ids = append(ids, *id)
  27515. }
  27516. return
  27517. }
  27518. // ResetEmployee resets all changes to the "employee" edge.
  27519. func (m *TutorialMutation) ResetEmployee() {
  27520. m.employee = nil
  27521. m.clearedemployee = false
  27522. }
  27523. // Where appends a list predicates to the TutorialMutation builder.
  27524. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  27525. m.predicates = append(m.predicates, ps...)
  27526. }
  27527. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  27528. // users can use type-assertion to append predicates that do not depend on any generated package.
  27529. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  27530. p := make([]predicate.Tutorial, len(ps))
  27531. for i := range ps {
  27532. p[i] = ps[i]
  27533. }
  27534. m.Where(p...)
  27535. }
  27536. // Op returns the operation name.
  27537. func (m *TutorialMutation) Op() Op {
  27538. return m.op
  27539. }
  27540. // SetOp allows setting the mutation operation.
  27541. func (m *TutorialMutation) SetOp(op Op) {
  27542. m.op = op
  27543. }
  27544. // Type returns the node type of this mutation (Tutorial).
  27545. func (m *TutorialMutation) Type() string {
  27546. return m.typ
  27547. }
  27548. // Fields returns all fields that were changed during this mutation. Note that in
  27549. // order to get all numeric fields that were incremented/decremented, call
  27550. // AddedFields().
  27551. func (m *TutorialMutation) Fields() []string {
  27552. fields := make([]string, 0, 8)
  27553. if m.created_at != nil {
  27554. fields = append(fields, tutorial.FieldCreatedAt)
  27555. }
  27556. if m.updated_at != nil {
  27557. fields = append(fields, tutorial.FieldUpdatedAt)
  27558. }
  27559. if m.deleted_at != nil {
  27560. fields = append(fields, tutorial.FieldDeletedAt)
  27561. }
  27562. if m.employee != nil {
  27563. fields = append(fields, tutorial.FieldEmployeeID)
  27564. }
  27565. if m.index != nil {
  27566. fields = append(fields, tutorial.FieldIndex)
  27567. }
  27568. if m.title != nil {
  27569. fields = append(fields, tutorial.FieldTitle)
  27570. }
  27571. if m.content != nil {
  27572. fields = append(fields, tutorial.FieldContent)
  27573. }
  27574. if m.organization_id != nil {
  27575. fields = append(fields, tutorial.FieldOrganizationID)
  27576. }
  27577. return fields
  27578. }
  27579. // Field returns the value of a field with the given name. The second boolean
  27580. // return value indicates that this field was not set, or was not defined in the
  27581. // schema.
  27582. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  27583. switch name {
  27584. case tutorial.FieldCreatedAt:
  27585. return m.CreatedAt()
  27586. case tutorial.FieldUpdatedAt:
  27587. return m.UpdatedAt()
  27588. case tutorial.FieldDeletedAt:
  27589. return m.DeletedAt()
  27590. case tutorial.FieldEmployeeID:
  27591. return m.EmployeeID()
  27592. case tutorial.FieldIndex:
  27593. return m.Index()
  27594. case tutorial.FieldTitle:
  27595. return m.Title()
  27596. case tutorial.FieldContent:
  27597. return m.Content()
  27598. case tutorial.FieldOrganizationID:
  27599. return m.OrganizationID()
  27600. }
  27601. return nil, false
  27602. }
  27603. // OldField returns the old value of the field from the database. An error is
  27604. // returned if the mutation operation is not UpdateOne, or the query to the
  27605. // database failed.
  27606. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27607. switch name {
  27608. case tutorial.FieldCreatedAt:
  27609. return m.OldCreatedAt(ctx)
  27610. case tutorial.FieldUpdatedAt:
  27611. return m.OldUpdatedAt(ctx)
  27612. case tutorial.FieldDeletedAt:
  27613. return m.OldDeletedAt(ctx)
  27614. case tutorial.FieldEmployeeID:
  27615. return m.OldEmployeeID(ctx)
  27616. case tutorial.FieldIndex:
  27617. return m.OldIndex(ctx)
  27618. case tutorial.FieldTitle:
  27619. return m.OldTitle(ctx)
  27620. case tutorial.FieldContent:
  27621. return m.OldContent(ctx)
  27622. case tutorial.FieldOrganizationID:
  27623. return m.OldOrganizationID(ctx)
  27624. }
  27625. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  27626. }
  27627. // SetField sets the value of a field with the given name. It returns an error if
  27628. // the field is not defined in the schema, or if the type mismatched the field
  27629. // type.
  27630. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  27631. switch name {
  27632. case tutorial.FieldCreatedAt:
  27633. v, ok := value.(time.Time)
  27634. if !ok {
  27635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27636. }
  27637. m.SetCreatedAt(v)
  27638. return nil
  27639. case tutorial.FieldUpdatedAt:
  27640. v, ok := value.(time.Time)
  27641. if !ok {
  27642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27643. }
  27644. m.SetUpdatedAt(v)
  27645. return nil
  27646. case tutorial.FieldDeletedAt:
  27647. v, ok := value.(time.Time)
  27648. if !ok {
  27649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27650. }
  27651. m.SetDeletedAt(v)
  27652. return nil
  27653. case tutorial.FieldEmployeeID:
  27654. v, ok := value.(uint64)
  27655. if !ok {
  27656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27657. }
  27658. m.SetEmployeeID(v)
  27659. return nil
  27660. case tutorial.FieldIndex:
  27661. v, ok := value.(int)
  27662. if !ok {
  27663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27664. }
  27665. m.SetIndex(v)
  27666. return nil
  27667. case tutorial.FieldTitle:
  27668. v, ok := value.(string)
  27669. if !ok {
  27670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27671. }
  27672. m.SetTitle(v)
  27673. return nil
  27674. case tutorial.FieldContent:
  27675. v, ok := value.(string)
  27676. if !ok {
  27677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27678. }
  27679. m.SetContent(v)
  27680. return nil
  27681. case tutorial.FieldOrganizationID:
  27682. v, ok := value.(uint64)
  27683. if !ok {
  27684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27685. }
  27686. m.SetOrganizationID(v)
  27687. return nil
  27688. }
  27689. return fmt.Errorf("unknown Tutorial field %s", name)
  27690. }
  27691. // AddedFields returns all numeric fields that were incremented/decremented during
  27692. // this mutation.
  27693. func (m *TutorialMutation) AddedFields() []string {
  27694. var fields []string
  27695. if m.addindex != nil {
  27696. fields = append(fields, tutorial.FieldIndex)
  27697. }
  27698. if m.addorganization_id != nil {
  27699. fields = append(fields, tutorial.FieldOrganizationID)
  27700. }
  27701. return fields
  27702. }
  27703. // AddedField returns the numeric value that was incremented/decremented on a field
  27704. // with the given name. The second boolean return value indicates that this field
  27705. // was not set, or was not defined in the schema.
  27706. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  27707. switch name {
  27708. case tutorial.FieldIndex:
  27709. return m.AddedIndex()
  27710. case tutorial.FieldOrganizationID:
  27711. return m.AddedOrganizationID()
  27712. }
  27713. return nil, false
  27714. }
  27715. // AddField adds the value to the field with the given name. It returns an error if
  27716. // the field is not defined in the schema, or if the type mismatched the field
  27717. // type.
  27718. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  27719. switch name {
  27720. case tutorial.FieldIndex:
  27721. v, ok := value.(int)
  27722. if !ok {
  27723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27724. }
  27725. m.AddIndex(v)
  27726. return nil
  27727. case tutorial.FieldOrganizationID:
  27728. v, ok := value.(int64)
  27729. if !ok {
  27730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27731. }
  27732. m.AddOrganizationID(v)
  27733. return nil
  27734. }
  27735. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  27736. }
  27737. // ClearedFields returns all nullable fields that were cleared during this
  27738. // mutation.
  27739. func (m *TutorialMutation) ClearedFields() []string {
  27740. var fields []string
  27741. if m.FieldCleared(tutorial.FieldDeletedAt) {
  27742. fields = append(fields, tutorial.FieldDeletedAt)
  27743. }
  27744. return fields
  27745. }
  27746. // FieldCleared returns a boolean indicating if a field with the given name was
  27747. // cleared in this mutation.
  27748. func (m *TutorialMutation) FieldCleared(name string) bool {
  27749. _, ok := m.clearedFields[name]
  27750. return ok
  27751. }
  27752. // ClearField clears the value of the field with the given name. It returns an
  27753. // error if the field is not defined in the schema.
  27754. func (m *TutorialMutation) ClearField(name string) error {
  27755. switch name {
  27756. case tutorial.FieldDeletedAt:
  27757. m.ClearDeletedAt()
  27758. return nil
  27759. }
  27760. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  27761. }
  27762. // ResetField resets all changes in the mutation for the field with the given name.
  27763. // It returns an error if the field is not defined in the schema.
  27764. func (m *TutorialMutation) ResetField(name string) error {
  27765. switch name {
  27766. case tutorial.FieldCreatedAt:
  27767. m.ResetCreatedAt()
  27768. return nil
  27769. case tutorial.FieldUpdatedAt:
  27770. m.ResetUpdatedAt()
  27771. return nil
  27772. case tutorial.FieldDeletedAt:
  27773. m.ResetDeletedAt()
  27774. return nil
  27775. case tutorial.FieldEmployeeID:
  27776. m.ResetEmployeeID()
  27777. return nil
  27778. case tutorial.FieldIndex:
  27779. m.ResetIndex()
  27780. return nil
  27781. case tutorial.FieldTitle:
  27782. m.ResetTitle()
  27783. return nil
  27784. case tutorial.FieldContent:
  27785. m.ResetContent()
  27786. return nil
  27787. case tutorial.FieldOrganizationID:
  27788. m.ResetOrganizationID()
  27789. return nil
  27790. }
  27791. return fmt.Errorf("unknown Tutorial field %s", name)
  27792. }
  27793. // AddedEdges returns all edge names that were set/added in this mutation.
  27794. func (m *TutorialMutation) AddedEdges() []string {
  27795. edges := make([]string, 0, 1)
  27796. if m.employee != nil {
  27797. edges = append(edges, tutorial.EdgeEmployee)
  27798. }
  27799. return edges
  27800. }
  27801. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27802. // name in this mutation.
  27803. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  27804. switch name {
  27805. case tutorial.EdgeEmployee:
  27806. if id := m.employee; id != nil {
  27807. return []ent.Value{*id}
  27808. }
  27809. }
  27810. return nil
  27811. }
  27812. // RemovedEdges returns all edge names that were removed in this mutation.
  27813. func (m *TutorialMutation) RemovedEdges() []string {
  27814. edges := make([]string, 0, 1)
  27815. return edges
  27816. }
  27817. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27818. // the given name in this mutation.
  27819. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  27820. return nil
  27821. }
  27822. // ClearedEdges returns all edge names that were cleared in this mutation.
  27823. func (m *TutorialMutation) ClearedEdges() []string {
  27824. edges := make([]string, 0, 1)
  27825. if m.clearedemployee {
  27826. edges = append(edges, tutorial.EdgeEmployee)
  27827. }
  27828. return edges
  27829. }
  27830. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27831. // was cleared in this mutation.
  27832. func (m *TutorialMutation) EdgeCleared(name string) bool {
  27833. switch name {
  27834. case tutorial.EdgeEmployee:
  27835. return m.clearedemployee
  27836. }
  27837. return false
  27838. }
  27839. // ClearEdge clears the value of the edge with the given name. It returns an error
  27840. // if that edge is not defined in the schema.
  27841. func (m *TutorialMutation) ClearEdge(name string) error {
  27842. switch name {
  27843. case tutorial.EdgeEmployee:
  27844. m.ClearEmployee()
  27845. return nil
  27846. }
  27847. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  27848. }
  27849. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27850. // It returns an error if the edge is not defined in the schema.
  27851. func (m *TutorialMutation) ResetEdge(name string) error {
  27852. switch name {
  27853. case tutorial.EdgeEmployee:
  27854. m.ResetEmployee()
  27855. return nil
  27856. }
  27857. return fmt.Errorf("unknown Tutorial edge %s", name)
  27858. }
  27859. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  27860. type UsageDetailMutation struct {
  27861. config
  27862. op Op
  27863. typ string
  27864. id *uint64
  27865. created_at *time.Time
  27866. updated_at *time.Time
  27867. status *uint8
  27868. addstatus *int8
  27869. _type *int
  27870. add_type *int
  27871. bot_id *string
  27872. receiver_id *string
  27873. app *int
  27874. addapp *int
  27875. session_id *uint64
  27876. addsession_id *int64
  27877. request *string
  27878. response *string
  27879. original_data *custom_types.OriginalData
  27880. total_tokens *uint64
  27881. addtotal_tokens *int64
  27882. prompt_tokens *uint64
  27883. addprompt_tokens *int64
  27884. completion_tokens *uint64
  27885. addcompletion_tokens *int64
  27886. organization_id *uint64
  27887. addorganization_id *int64
  27888. clearedFields map[string]struct{}
  27889. done bool
  27890. oldValue func(context.Context) (*UsageDetail, error)
  27891. predicates []predicate.UsageDetail
  27892. }
  27893. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  27894. // usagedetailOption allows management of the mutation configuration using functional options.
  27895. type usagedetailOption func(*UsageDetailMutation)
  27896. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  27897. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  27898. m := &UsageDetailMutation{
  27899. config: c,
  27900. op: op,
  27901. typ: TypeUsageDetail,
  27902. clearedFields: make(map[string]struct{}),
  27903. }
  27904. for _, opt := range opts {
  27905. opt(m)
  27906. }
  27907. return m
  27908. }
  27909. // withUsageDetailID sets the ID field of the mutation.
  27910. func withUsageDetailID(id uint64) usagedetailOption {
  27911. return func(m *UsageDetailMutation) {
  27912. var (
  27913. err error
  27914. once sync.Once
  27915. value *UsageDetail
  27916. )
  27917. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  27918. once.Do(func() {
  27919. if m.done {
  27920. err = errors.New("querying old values post mutation is not allowed")
  27921. } else {
  27922. value, err = m.Client().UsageDetail.Get(ctx, id)
  27923. }
  27924. })
  27925. return value, err
  27926. }
  27927. m.id = &id
  27928. }
  27929. }
  27930. // withUsageDetail sets the old UsageDetail of the mutation.
  27931. func withUsageDetail(node *UsageDetail) usagedetailOption {
  27932. return func(m *UsageDetailMutation) {
  27933. m.oldValue = func(context.Context) (*UsageDetail, error) {
  27934. return node, nil
  27935. }
  27936. m.id = &node.ID
  27937. }
  27938. }
  27939. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27940. // executed in a transaction (ent.Tx), a transactional client is returned.
  27941. func (m UsageDetailMutation) Client() *Client {
  27942. client := &Client{config: m.config}
  27943. client.init()
  27944. return client
  27945. }
  27946. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27947. // it returns an error otherwise.
  27948. func (m UsageDetailMutation) Tx() (*Tx, error) {
  27949. if _, ok := m.driver.(*txDriver); !ok {
  27950. return nil, errors.New("ent: mutation is not running in a transaction")
  27951. }
  27952. tx := &Tx{config: m.config}
  27953. tx.init()
  27954. return tx, nil
  27955. }
  27956. // SetID sets the value of the id field. Note that this
  27957. // operation is only accepted on creation of UsageDetail entities.
  27958. func (m *UsageDetailMutation) SetID(id uint64) {
  27959. m.id = &id
  27960. }
  27961. // ID returns the ID value in the mutation. Note that the ID is only available
  27962. // if it was provided to the builder or after it was returned from the database.
  27963. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  27964. if m.id == nil {
  27965. return
  27966. }
  27967. return *m.id, true
  27968. }
  27969. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27970. // That means, if the mutation is applied within a transaction with an isolation level such
  27971. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27972. // or updated by the mutation.
  27973. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  27974. switch {
  27975. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27976. id, exists := m.ID()
  27977. if exists {
  27978. return []uint64{id}, nil
  27979. }
  27980. fallthrough
  27981. case m.op.Is(OpUpdate | OpDelete):
  27982. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  27983. default:
  27984. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27985. }
  27986. }
  27987. // SetCreatedAt sets the "created_at" field.
  27988. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  27989. m.created_at = &t
  27990. }
  27991. // CreatedAt returns the value of the "created_at" field in the mutation.
  27992. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  27993. v := m.created_at
  27994. if v == nil {
  27995. return
  27996. }
  27997. return *v, true
  27998. }
  27999. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  28000. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28002. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28003. if !m.op.Is(OpUpdateOne) {
  28004. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28005. }
  28006. if m.id == nil || m.oldValue == nil {
  28007. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28008. }
  28009. oldValue, err := m.oldValue(ctx)
  28010. if err != nil {
  28011. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28012. }
  28013. return oldValue.CreatedAt, nil
  28014. }
  28015. // ResetCreatedAt resets all changes to the "created_at" field.
  28016. func (m *UsageDetailMutation) ResetCreatedAt() {
  28017. m.created_at = nil
  28018. }
  28019. // SetUpdatedAt sets the "updated_at" field.
  28020. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  28021. m.updated_at = &t
  28022. }
  28023. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28024. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  28025. v := m.updated_at
  28026. if v == nil {
  28027. return
  28028. }
  28029. return *v, true
  28030. }
  28031. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  28032. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28034. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28035. if !m.op.Is(OpUpdateOne) {
  28036. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28037. }
  28038. if m.id == nil || m.oldValue == nil {
  28039. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28040. }
  28041. oldValue, err := m.oldValue(ctx)
  28042. if err != nil {
  28043. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28044. }
  28045. return oldValue.UpdatedAt, nil
  28046. }
  28047. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28048. func (m *UsageDetailMutation) ResetUpdatedAt() {
  28049. m.updated_at = nil
  28050. }
  28051. // SetStatus sets the "status" field.
  28052. func (m *UsageDetailMutation) SetStatus(u uint8) {
  28053. m.status = &u
  28054. m.addstatus = nil
  28055. }
  28056. // Status returns the value of the "status" field in the mutation.
  28057. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  28058. v := m.status
  28059. if v == nil {
  28060. return
  28061. }
  28062. return *v, true
  28063. }
  28064. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  28065. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28067. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28068. if !m.op.Is(OpUpdateOne) {
  28069. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28070. }
  28071. if m.id == nil || m.oldValue == nil {
  28072. return v, errors.New("OldStatus requires an ID field in the mutation")
  28073. }
  28074. oldValue, err := m.oldValue(ctx)
  28075. if err != nil {
  28076. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28077. }
  28078. return oldValue.Status, nil
  28079. }
  28080. // AddStatus adds u to the "status" field.
  28081. func (m *UsageDetailMutation) AddStatus(u int8) {
  28082. if m.addstatus != nil {
  28083. *m.addstatus += u
  28084. } else {
  28085. m.addstatus = &u
  28086. }
  28087. }
  28088. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28089. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  28090. v := m.addstatus
  28091. if v == nil {
  28092. return
  28093. }
  28094. return *v, true
  28095. }
  28096. // ClearStatus clears the value of the "status" field.
  28097. func (m *UsageDetailMutation) ClearStatus() {
  28098. m.status = nil
  28099. m.addstatus = nil
  28100. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  28101. }
  28102. // StatusCleared returns if the "status" field was cleared in this mutation.
  28103. func (m *UsageDetailMutation) StatusCleared() bool {
  28104. _, ok := m.clearedFields[usagedetail.FieldStatus]
  28105. return ok
  28106. }
  28107. // ResetStatus resets all changes to the "status" field.
  28108. func (m *UsageDetailMutation) ResetStatus() {
  28109. m.status = nil
  28110. m.addstatus = nil
  28111. delete(m.clearedFields, usagedetail.FieldStatus)
  28112. }
  28113. // SetType sets the "type" field.
  28114. func (m *UsageDetailMutation) SetType(i int) {
  28115. m._type = &i
  28116. m.add_type = nil
  28117. }
  28118. // GetType returns the value of the "type" field in the mutation.
  28119. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  28120. v := m._type
  28121. if v == nil {
  28122. return
  28123. }
  28124. return *v, true
  28125. }
  28126. // OldType returns the old "type" field's value of the UsageDetail entity.
  28127. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28129. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  28130. if !m.op.Is(OpUpdateOne) {
  28131. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28132. }
  28133. if m.id == nil || m.oldValue == nil {
  28134. return v, errors.New("OldType requires an ID field in the mutation")
  28135. }
  28136. oldValue, err := m.oldValue(ctx)
  28137. if err != nil {
  28138. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28139. }
  28140. return oldValue.Type, nil
  28141. }
  28142. // AddType adds i to the "type" field.
  28143. func (m *UsageDetailMutation) AddType(i int) {
  28144. if m.add_type != nil {
  28145. *m.add_type += i
  28146. } else {
  28147. m.add_type = &i
  28148. }
  28149. }
  28150. // AddedType returns the value that was added to the "type" field in this mutation.
  28151. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  28152. v := m.add_type
  28153. if v == nil {
  28154. return
  28155. }
  28156. return *v, true
  28157. }
  28158. // ClearType clears the value of the "type" field.
  28159. func (m *UsageDetailMutation) ClearType() {
  28160. m._type = nil
  28161. m.add_type = nil
  28162. m.clearedFields[usagedetail.FieldType] = struct{}{}
  28163. }
  28164. // TypeCleared returns if the "type" field was cleared in this mutation.
  28165. func (m *UsageDetailMutation) TypeCleared() bool {
  28166. _, ok := m.clearedFields[usagedetail.FieldType]
  28167. return ok
  28168. }
  28169. // ResetType resets all changes to the "type" field.
  28170. func (m *UsageDetailMutation) ResetType() {
  28171. m._type = nil
  28172. m.add_type = nil
  28173. delete(m.clearedFields, usagedetail.FieldType)
  28174. }
  28175. // SetBotID sets the "bot_id" field.
  28176. func (m *UsageDetailMutation) SetBotID(s string) {
  28177. m.bot_id = &s
  28178. }
  28179. // BotID returns the value of the "bot_id" field in the mutation.
  28180. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  28181. v := m.bot_id
  28182. if v == nil {
  28183. return
  28184. }
  28185. return *v, true
  28186. }
  28187. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  28188. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28190. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  28191. if !m.op.Is(OpUpdateOne) {
  28192. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28193. }
  28194. if m.id == nil || m.oldValue == nil {
  28195. return v, errors.New("OldBotID requires an ID field in the mutation")
  28196. }
  28197. oldValue, err := m.oldValue(ctx)
  28198. if err != nil {
  28199. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28200. }
  28201. return oldValue.BotID, nil
  28202. }
  28203. // ResetBotID resets all changes to the "bot_id" field.
  28204. func (m *UsageDetailMutation) ResetBotID() {
  28205. m.bot_id = nil
  28206. }
  28207. // SetReceiverID sets the "receiver_id" field.
  28208. func (m *UsageDetailMutation) SetReceiverID(s string) {
  28209. m.receiver_id = &s
  28210. }
  28211. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  28212. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  28213. v := m.receiver_id
  28214. if v == nil {
  28215. return
  28216. }
  28217. return *v, true
  28218. }
  28219. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  28220. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28222. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  28223. if !m.op.Is(OpUpdateOne) {
  28224. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  28225. }
  28226. if m.id == nil || m.oldValue == nil {
  28227. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  28228. }
  28229. oldValue, err := m.oldValue(ctx)
  28230. if err != nil {
  28231. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  28232. }
  28233. return oldValue.ReceiverID, nil
  28234. }
  28235. // ResetReceiverID resets all changes to the "receiver_id" field.
  28236. func (m *UsageDetailMutation) ResetReceiverID() {
  28237. m.receiver_id = nil
  28238. }
  28239. // SetApp sets the "app" field.
  28240. func (m *UsageDetailMutation) SetApp(i int) {
  28241. m.app = &i
  28242. m.addapp = nil
  28243. }
  28244. // App returns the value of the "app" field in the mutation.
  28245. func (m *UsageDetailMutation) App() (r int, exists bool) {
  28246. v := m.app
  28247. if v == nil {
  28248. return
  28249. }
  28250. return *v, true
  28251. }
  28252. // OldApp returns the old "app" field's value of the UsageDetail entity.
  28253. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28255. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  28256. if !m.op.Is(OpUpdateOne) {
  28257. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  28258. }
  28259. if m.id == nil || m.oldValue == nil {
  28260. return v, errors.New("OldApp requires an ID field in the mutation")
  28261. }
  28262. oldValue, err := m.oldValue(ctx)
  28263. if err != nil {
  28264. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  28265. }
  28266. return oldValue.App, nil
  28267. }
  28268. // AddApp adds i to the "app" field.
  28269. func (m *UsageDetailMutation) AddApp(i int) {
  28270. if m.addapp != nil {
  28271. *m.addapp += i
  28272. } else {
  28273. m.addapp = &i
  28274. }
  28275. }
  28276. // AddedApp returns the value that was added to the "app" field in this mutation.
  28277. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  28278. v := m.addapp
  28279. if v == nil {
  28280. return
  28281. }
  28282. return *v, true
  28283. }
  28284. // ClearApp clears the value of the "app" field.
  28285. func (m *UsageDetailMutation) ClearApp() {
  28286. m.app = nil
  28287. m.addapp = nil
  28288. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  28289. }
  28290. // AppCleared returns if the "app" field was cleared in this mutation.
  28291. func (m *UsageDetailMutation) AppCleared() bool {
  28292. _, ok := m.clearedFields[usagedetail.FieldApp]
  28293. return ok
  28294. }
  28295. // ResetApp resets all changes to the "app" field.
  28296. func (m *UsageDetailMutation) ResetApp() {
  28297. m.app = nil
  28298. m.addapp = nil
  28299. delete(m.clearedFields, usagedetail.FieldApp)
  28300. }
  28301. // SetSessionID sets the "session_id" field.
  28302. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  28303. m.session_id = &u
  28304. m.addsession_id = nil
  28305. }
  28306. // SessionID returns the value of the "session_id" field in the mutation.
  28307. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  28308. v := m.session_id
  28309. if v == nil {
  28310. return
  28311. }
  28312. return *v, true
  28313. }
  28314. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  28315. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28317. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  28318. if !m.op.Is(OpUpdateOne) {
  28319. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  28320. }
  28321. if m.id == nil || m.oldValue == nil {
  28322. return v, errors.New("OldSessionID requires an ID field in the mutation")
  28323. }
  28324. oldValue, err := m.oldValue(ctx)
  28325. if err != nil {
  28326. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  28327. }
  28328. return oldValue.SessionID, nil
  28329. }
  28330. // AddSessionID adds u to the "session_id" field.
  28331. func (m *UsageDetailMutation) AddSessionID(u int64) {
  28332. if m.addsession_id != nil {
  28333. *m.addsession_id += u
  28334. } else {
  28335. m.addsession_id = &u
  28336. }
  28337. }
  28338. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  28339. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  28340. v := m.addsession_id
  28341. if v == nil {
  28342. return
  28343. }
  28344. return *v, true
  28345. }
  28346. // ClearSessionID clears the value of the "session_id" field.
  28347. func (m *UsageDetailMutation) ClearSessionID() {
  28348. m.session_id = nil
  28349. m.addsession_id = nil
  28350. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  28351. }
  28352. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  28353. func (m *UsageDetailMutation) SessionIDCleared() bool {
  28354. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  28355. return ok
  28356. }
  28357. // ResetSessionID resets all changes to the "session_id" field.
  28358. func (m *UsageDetailMutation) ResetSessionID() {
  28359. m.session_id = nil
  28360. m.addsession_id = nil
  28361. delete(m.clearedFields, usagedetail.FieldSessionID)
  28362. }
  28363. // SetRequest sets the "request" field.
  28364. func (m *UsageDetailMutation) SetRequest(s string) {
  28365. m.request = &s
  28366. }
  28367. // Request returns the value of the "request" field in the mutation.
  28368. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  28369. v := m.request
  28370. if v == nil {
  28371. return
  28372. }
  28373. return *v, true
  28374. }
  28375. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  28376. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28378. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  28379. if !m.op.Is(OpUpdateOne) {
  28380. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  28381. }
  28382. if m.id == nil || m.oldValue == nil {
  28383. return v, errors.New("OldRequest requires an ID field in the mutation")
  28384. }
  28385. oldValue, err := m.oldValue(ctx)
  28386. if err != nil {
  28387. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  28388. }
  28389. return oldValue.Request, nil
  28390. }
  28391. // ResetRequest resets all changes to the "request" field.
  28392. func (m *UsageDetailMutation) ResetRequest() {
  28393. m.request = nil
  28394. }
  28395. // SetResponse sets the "response" field.
  28396. func (m *UsageDetailMutation) SetResponse(s string) {
  28397. m.response = &s
  28398. }
  28399. // Response returns the value of the "response" field in the mutation.
  28400. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  28401. v := m.response
  28402. if v == nil {
  28403. return
  28404. }
  28405. return *v, true
  28406. }
  28407. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  28408. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28410. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  28411. if !m.op.Is(OpUpdateOne) {
  28412. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  28413. }
  28414. if m.id == nil || m.oldValue == nil {
  28415. return v, errors.New("OldResponse requires an ID field in the mutation")
  28416. }
  28417. oldValue, err := m.oldValue(ctx)
  28418. if err != nil {
  28419. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  28420. }
  28421. return oldValue.Response, nil
  28422. }
  28423. // ResetResponse resets all changes to the "response" field.
  28424. func (m *UsageDetailMutation) ResetResponse() {
  28425. m.response = nil
  28426. }
  28427. // SetOriginalData sets the "original_data" field.
  28428. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  28429. m.original_data = &ctd
  28430. }
  28431. // OriginalData returns the value of the "original_data" field in the mutation.
  28432. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  28433. v := m.original_data
  28434. if v == nil {
  28435. return
  28436. }
  28437. return *v, true
  28438. }
  28439. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  28440. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28442. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  28443. if !m.op.Is(OpUpdateOne) {
  28444. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  28445. }
  28446. if m.id == nil || m.oldValue == nil {
  28447. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  28448. }
  28449. oldValue, err := m.oldValue(ctx)
  28450. if err != nil {
  28451. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  28452. }
  28453. return oldValue.OriginalData, nil
  28454. }
  28455. // ResetOriginalData resets all changes to the "original_data" field.
  28456. func (m *UsageDetailMutation) ResetOriginalData() {
  28457. m.original_data = nil
  28458. }
  28459. // SetTotalTokens sets the "total_tokens" field.
  28460. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  28461. m.total_tokens = &u
  28462. m.addtotal_tokens = nil
  28463. }
  28464. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28465. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  28466. v := m.total_tokens
  28467. if v == nil {
  28468. return
  28469. }
  28470. return *v, true
  28471. }
  28472. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  28473. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28475. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28476. if !m.op.Is(OpUpdateOne) {
  28477. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28478. }
  28479. if m.id == nil || m.oldValue == nil {
  28480. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28481. }
  28482. oldValue, err := m.oldValue(ctx)
  28483. if err != nil {
  28484. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28485. }
  28486. return oldValue.TotalTokens, nil
  28487. }
  28488. // AddTotalTokens adds u to the "total_tokens" field.
  28489. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  28490. if m.addtotal_tokens != nil {
  28491. *m.addtotal_tokens += u
  28492. } else {
  28493. m.addtotal_tokens = &u
  28494. }
  28495. }
  28496. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28497. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  28498. v := m.addtotal_tokens
  28499. if v == nil {
  28500. return
  28501. }
  28502. return *v, true
  28503. }
  28504. // ClearTotalTokens clears the value of the "total_tokens" field.
  28505. func (m *UsageDetailMutation) ClearTotalTokens() {
  28506. m.total_tokens = nil
  28507. m.addtotal_tokens = nil
  28508. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  28509. }
  28510. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28511. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  28512. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  28513. return ok
  28514. }
  28515. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28516. func (m *UsageDetailMutation) ResetTotalTokens() {
  28517. m.total_tokens = nil
  28518. m.addtotal_tokens = nil
  28519. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  28520. }
  28521. // SetPromptTokens sets the "prompt_tokens" field.
  28522. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  28523. m.prompt_tokens = &u
  28524. m.addprompt_tokens = nil
  28525. }
  28526. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  28527. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  28528. v := m.prompt_tokens
  28529. if v == nil {
  28530. return
  28531. }
  28532. return *v, true
  28533. }
  28534. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  28535. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28537. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  28538. if !m.op.Is(OpUpdateOne) {
  28539. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  28540. }
  28541. if m.id == nil || m.oldValue == nil {
  28542. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  28543. }
  28544. oldValue, err := m.oldValue(ctx)
  28545. if err != nil {
  28546. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  28547. }
  28548. return oldValue.PromptTokens, nil
  28549. }
  28550. // AddPromptTokens adds u to the "prompt_tokens" field.
  28551. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  28552. if m.addprompt_tokens != nil {
  28553. *m.addprompt_tokens += u
  28554. } else {
  28555. m.addprompt_tokens = &u
  28556. }
  28557. }
  28558. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  28559. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  28560. v := m.addprompt_tokens
  28561. if v == nil {
  28562. return
  28563. }
  28564. return *v, true
  28565. }
  28566. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  28567. func (m *UsageDetailMutation) ClearPromptTokens() {
  28568. m.prompt_tokens = nil
  28569. m.addprompt_tokens = nil
  28570. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  28571. }
  28572. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  28573. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  28574. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  28575. return ok
  28576. }
  28577. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  28578. func (m *UsageDetailMutation) ResetPromptTokens() {
  28579. m.prompt_tokens = nil
  28580. m.addprompt_tokens = nil
  28581. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  28582. }
  28583. // SetCompletionTokens sets the "completion_tokens" field.
  28584. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  28585. m.completion_tokens = &u
  28586. m.addcompletion_tokens = nil
  28587. }
  28588. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  28589. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  28590. v := m.completion_tokens
  28591. if v == nil {
  28592. return
  28593. }
  28594. return *v, true
  28595. }
  28596. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  28597. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28599. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  28600. if !m.op.Is(OpUpdateOne) {
  28601. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  28602. }
  28603. if m.id == nil || m.oldValue == nil {
  28604. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  28605. }
  28606. oldValue, err := m.oldValue(ctx)
  28607. if err != nil {
  28608. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  28609. }
  28610. return oldValue.CompletionTokens, nil
  28611. }
  28612. // AddCompletionTokens adds u to the "completion_tokens" field.
  28613. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  28614. if m.addcompletion_tokens != nil {
  28615. *m.addcompletion_tokens += u
  28616. } else {
  28617. m.addcompletion_tokens = &u
  28618. }
  28619. }
  28620. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  28621. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  28622. v := m.addcompletion_tokens
  28623. if v == nil {
  28624. return
  28625. }
  28626. return *v, true
  28627. }
  28628. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  28629. func (m *UsageDetailMutation) ClearCompletionTokens() {
  28630. m.completion_tokens = nil
  28631. m.addcompletion_tokens = nil
  28632. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  28633. }
  28634. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  28635. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  28636. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  28637. return ok
  28638. }
  28639. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  28640. func (m *UsageDetailMutation) ResetCompletionTokens() {
  28641. m.completion_tokens = nil
  28642. m.addcompletion_tokens = nil
  28643. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  28644. }
  28645. // SetOrganizationID sets the "organization_id" field.
  28646. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  28647. m.organization_id = &u
  28648. m.addorganization_id = nil
  28649. }
  28650. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28651. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  28652. v := m.organization_id
  28653. if v == nil {
  28654. return
  28655. }
  28656. return *v, true
  28657. }
  28658. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  28659. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28661. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28662. if !m.op.Is(OpUpdateOne) {
  28663. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28664. }
  28665. if m.id == nil || m.oldValue == nil {
  28666. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28667. }
  28668. oldValue, err := m.oldValue(ctx)
  28669. if err != nil {
  28670. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28671. }
  28672. return oldValue.OrganizationID, nil
  28673. }
  28674. // AddOrganizationID adds u to the "organization_id" field.
  28675. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  28676. if m.addorganization_id != nil {
  28677. *m.addorganization_id += u
  28678. } else {
  28679. m.addorganization_id = &u
  28680. }
  28681. }
  28682. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28683. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  28684. v := m.addorganization_id
  28685. if v == nil {
  28686. return
  28687. }
  28688. return *v, true
  28689. }
  28690. // ClearOrganizationID clears the value of the "organization_id" field.
  28691. func (m *UsageDetailMutation) ClearOrganizationID() {
  28692. m.organization_id = nil
  28693. m.addorganization_id = nil
  28694. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  28695. }
  28696. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28697. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  28698. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  28699. return ok
  28700. }
  28701. // ResetOrganizationID resets all changes to the "organization_id" field.
  28702. func (m *UsageDetailMutation) ResetOrganizationID() {
  28703. m.organization_id = nil
  28704. m.addorganization_id = nil
  28705. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  28706. }
  28707. // Where appends a list predicates to the UsageDetailMutation builder.
  28708. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  28709. m.predicates = append(m.predicates, ps...)
  28710. }
  28711. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  28712. // users can use type-assertion to append predicates that do not depend on any generated package.
  28713. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  28714. p := make([]predicate.UsageDetail, len(ps))
  28715. for i := range ps {
  28716. p[i] = ps[i]
  28717. }
  28718. m.Where(p...)
  28719. }
  28720. // Op returns the operation name.
  28721. func (m *UsageDetailMutation) Op() Op {
  28722. return m.op
  28723. }
  28724. // SetOp allows setting the mutation operation.
  28725. func (m *UsageDetailMutation) SetOp(op Op) {
  28726. m.op = op
  28727. }
  28728. // Type returns the node type of this mutation (UsageDetail).
  28729. func (m *UsageDetailMutation) Type() string {
  28730. return m.typ
  28731. }
  28732. // Fields returns all fields that were changed during this mutation. Note that in
  28733. // order to get all numeric fields that were incremented/decremented, call
  28734. // AddedFields().
  28735. func (m *UsageDetailMutation) Fields() []string {
  28736. fields := make([]string, 0, 15)
  28737. if m.created_at != nil {
  28738. fields = append(fields, usagedetail.FieldCreatedAt)
  28739. }
  28740. if m.updated_at != nil {
  28741. fields = append(fields, usagedetail.FieldUpdatedAt)
  28742. }
  28743. if m.status != nil {
  28744. fields = append(fields, usagedetail.FieldStatus)
  28745. }
  28746. if m._type != nil {
  28747. fields = append(fields, usagedetail.FieldType)
  28748. }
  28749. if m.bot_id != nil {
  28750. fields = append(fields, usagedetail.FieldBotID)
  28751. }
  28752. if m.receiver_id != nil {
  28753. fields = append(fields, usagedetail.FieldReceiverID)
  28754. }
  28755. if m.app != nil {
  28756. fields = append(fields, usagedetail.FieldApp)
  28757. }
  28758. if m.session_id != nil {
  28759. fields = append(fields, usagedetail.FieldSessionID)
  28760. }
  28761. if m.request != nil {
  28762. fields = append(fields, usagedetail.FieldRequest)
  28763. }
  28764. if m.response != nil {
  28765. fields = append(fields, usagedetail.FieldResponse)
  28766. }
  28767. if m.original_data != nil {
  28768. fields = append(fields, usagedetail.FieldOriginalData)
  28769. }
  28770. if m.total_tokens != nil {
  28771. fields = append(fields, usagedetail.FieldTotalTokens)
  28772. }
  28773. if m.prompt_tokens != nil {
  28774. fields = append(fields, usagedetail.FieldPromptTokens)
  28775. }
  28776. if m.completion_tokens != nil {
  28777. fields = append(fields, usagedetail.FieldCompletionTokens)
  28778. }
  28779. if m.organization_id != nil {
  28780. fields = append(fields, usagedetail.FieldOrganizationID)
  28781. }
  28782. return fields
  28783. }
  28784. // Field returns the value of a field with the given name. The second boolean
  28785. // return value indicates that this field was not set, or was not defined in the
  28786. // schema.
  28787. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  28788. switch name {
  28789. case usagedetail.FieldCreatedAt:
  28790. return m.CreatedAt()
  28791. case usagedetail.FieldUpdatedAt:
  28792. return m.UpdatedAt()
  28793. case usagedetail.FieldStatus:
  28794. return m.Status()
  28795. case usagedetail.FieldType:
  28796. return m.GetType()
  28797. case usagedetail.FieldBotID:
  28798. return m.BotID()
  28799. case usagedetail.FieldReceiverID:
  28800. return m.ReceiverID()
  28801. case usagedetail.FieldApp:
  28802. return m.App()
  28803. case usagedetail.FieldSessionID:
  28804. return m.SessionID()
  28805. case usagedetail.FieldRequest:
  28806. return m.Request()
  28807. case usagedetail.FieldResponse:
  28808. return m.Response()
  28809. case usagedetail.FieldOriginalData:
  28810. return m.OriginalData()
  28811. case usagedetail.FieldTotalTokens:
  28812. return m.TotalTokens()
  28813. case usagedetail.FieldPromptTokens:
  28814. return m.PromptTokens()
  28815. case usagedetail.FieldCompletionTokens:
  28816. return m.CompletionTokens()
  28817. case usagedetail.FieldOrganizationID:
  28818. return m.OrganizationID()
  28819. }
  28820. return nil, false
  28821. }
  28822. // OldField returns the old value of the field from the database. An error is
  28823. // returned if the mutation operation is not UpdateOne, or the query to the
  28824. // database failed.
  28825. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28826. switch name {
  28827. case usagedetail.FieldCreatedAt:
  28828. return m.OldCreatedAt(ctx)
  28829. case usagedetail.FieldUpdatedAt:
  28830. return m.OldUpdatedAt(ctx)
  28831. case usagedetail.FieldStatus:
  28832. return m.OldStatus(ctx)
  28833. case usagedetail.FieldType:
  28834. return m.OldType(ctx)
  28835. case usagedetail.FieldBotID:
  28836. return m.OldBotID(ctx)
  28837. case usagedetail.FieldReceiverID:
  28838. return m.OldReceiverID(ctx)
  28839. case usagedetail.FieldApp:
  28840. return m.OldApp(ctx)
  28841. case usagedetail.FieldSessionID:
  28842. return m.OldSessionID(ctx)
  28843. case usagedetail.FieldRequest:
  28844. return m.OldRequest(ctx)
  28845. case usagedetail.FieldResponse:
  28846. return m.OldResponse(ctx)
  28847. case usagedetail.FieldOriginalData:
  28848. return m.OldOriginalData(ctx)
  28849. case usagedetail.FieldTotalTokens:
  28850. return m.OldTotalTokens(ctx)
  28851. case usagedetail.FieldPromptTokens:
  28852. return m.OldPromptTokens(ctx)
  28853. case usagedetail.FieldCompletionTokens:
  28854. return m.OldCompletionTokens(ctx)
  28855. case usagedetail.FieldOrganizationID:
  28856. return m.OldOrganizationID(ctx)
  28857. }
  28858. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  28859. }
  28860. // SetField sets the value of a field with the given name. It returns an error if
  28861. // the field is not defined in the schema, or if the type mismatched the field
  28862. // type.
  28863. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  28864. switch name {
  28865. case usagedetail.FieldCreatedAt:
  28866. v, ok := value.(time.Time)
  28867. if !ok {
  28868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28869. }
  28870. m.SetCreatedAt(v)
  28871. return nil
  28872. case usagedetail.FieldUpdatedAt:
  28873. v, ok := value.(time.Time)
  28874. if !ok {
  28875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28876. }
  28877. m.SetUpdatedAt(v)
  28878. return nil
  28879. case usagedetail.FieldStatus:
  28880. v, ok := value.(uint8)
  28881. if !ok {
  28882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28883. }
  28884. m.SetStatus(v)
  28885. return nil
  28886. case usagedetail.FieldType:
  28887. v, ok := value.(int)
  28888. if !ok {
  28889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28890. }
  28891. m.SetType(v)
  28892. return nil
  28893. case usagedetail.FieldBotID:
  28894. v, ok := value.(string)
  28895. if !ok {
  28896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28897. }
  28898. m.SetBotID(v)
  28899. return nil
  28900. case usagedetail.FieldReceiverID:
  28901. v, ok := value.(string)
  28902. if !ok {
  28903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28904. }
  28905. m.SetReceiverID(v)
  28906. return nil
  28907. case usagedetail.FieldApp:
  28908. v, ok := value.(int)
  28909. if !ok {
  28910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28911. }
  28912. m.SetApp(v)
  28913. return nil
  28914. case usagedetail.FieldSessionID:
  28915. v, ok := value.(uint64)
  28916. if !ok {
  28917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28918. }
  28919. m.SetSessionID(v)
  28920. return nil
  28921. case usagedetail.FieldRequest:
  28922. v, ok := value.(string)
  28923. if !ok {
  28924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28925. }
  28926. m.SetRequest(v)
  28927. return nil
  28928. case usagedetail.FieldResponse:
  28929. v, ok := value.(string)
  28930. if !ok {
  28931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28932. }
  28933. m.SetResponse(v)
  28934. return nil
  28935. case usagedetail.FieldOriginalData:
  28936. v, ok := value.(custom_types.OriginalData)
  28937. if !ok {
  28938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28939. }
  28940. m.SetOriginalData(v)
  28941. return nil
  28942. case usagedetail.FieldTotalTokens:
  28943. v, ok := value.(uint64)
  28944. if !ok {
  28945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28946. }
  28947. m.SetTotalTokens(v)
  28948. return nil
  28949. case usagedetail.FieldPromptTokens:
  28950. v, ok := value.(uint64)
  28951. if !ok {
  28952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28953. }
  28954. m.SetPromptTokens(v)
  28955. return nil
  28956. case usagedetail.FieldCompletionTokens:
  28957. v, ok := value.(uint64)
  28958. if !ok {
  28959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28960. }
  28961. m.SetCompletionTokens(v)
  28962. return nil
  28963. case usagedetail.FieldOrganizationID:
  28964. v, ok := value.(uint64)
  28965. if !ok {
  28966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28967. }
  28968. m.SetOrganizationID(v)
  28969. return nil
  28970. }
  28971. return fmt.Errorf("unknown UsageDetail field %s", name)
  28972. }
  28973. // AddedFields returns all numeric fields that were incremented/decremented during
  28974. // this mutation.
  28975. func (m *UsageDetailMutation) AddedFields() []string {
  28976. var fields []string
  28977. if m.addstatus != nil {
  28978. fields = append(fields, usagedetail.FieldStatus)
  28979. }
  28980. if m.add_type != nil {
  28981. fields = append(fields, usagedetail.FieldType)
  28982. }
  28983. if m.addapp != nil {
  28984. fields = append(fields, usagedetail.FieldApp)
  28985. }
  28986. if m.addsession_id != nil {
  28987. fields = append(fields, usagedetail.FieldSessionID)
  28988. }
  28989. if m.addtotal_tokens != nil {
  28990. fields = append(fields, usagedetail.FieldTotalTokens)
  28991. }
  28992. if m.addprompt_tokens != nil {
  28993. fields = append(fields, usagedetail.FieldPromptTokens)
  28994. }
  28995. if m.addcompletion_tokens != nil {
  28996. fields = append(fields, usagedetail.FieldCompletionTokens)
  28997. }
  28998. if m.addorganization_id != nil {
  28999. fields = append(fields, usagedetail.FieldOrganizationID)
  29000. }
  29001. return fields
  29002. }
  29003. // AddedField returns the numeric value that was incremented/decremented on a field
  29004. // with the given name. The second boolean return value indicates that this field
  29005. // was not set, or was not defined in the schema.
  29006. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  29007. switch name {
  29008. case usagedetail.FieldStatus:
  29009. return m.AddedStatus()
  29010. case usagedetail.FieldType:
  29011. return m.AddedType()
  29012. case usagedetail.FieldApp:
  29013. return m.AddedApp()
  29014. case usagedetail.FieldSessionID:
  29015. return m.AddedSessionID()
  29016. case usagedetail.FieldTotalTokens:
  29017. return m.AddedTotalTokens()
  29018. case usagedetail.FieldPromptTokens:
  29019. return m.AddedPromptTokens()
  29020. case usagedetail.FieldCompletionTokens:
  29021. return m.AddedCompletionTokens()
  29022. case usagedetail.FieldOrganizationID:
  29023. return m.AddedOrganizationID()
  29024. }
  29025. return nil, false
  29026. }
  29027. // AddField adds the value to the field with the given name. It returns an error if
  29028. // the field is not defined in the schema, or if the type mismatched the field
  29029. // type.
  29030. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  29031. switch name {
  29032. case usagedetail.FieldStatus:
  29033. v, ok := value.(int8)
  29034. if !ok {
  29035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29036. }
  29037. m.AddStatus(v)
  29038. return nil
  29039. case usagedetail.FieldType:
  29040. v, ok := value.(int)
  29041. if !ok {
  29042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29043. }
  29044. m.AddType(v)
  29045. return nil
  29046. case usagedetail.FieldApp:
  29047. v, ok := value.(int)
  29048. if !ok {
  29049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29050. }
  29051. m.AddApp(v)
  29052. return nil
  29053. case usagedetail.FieldSessionID:
  29054. v, ok := value.(int64)
  29055. if !ok {
  29056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29057. }
  29058. m.AddSessionID(v)
  29059. return nil
  29060. case usagedetail.FieldTotalTokens:
  29061. v, ok := value.(int64)
  29062. if !ok {
  29063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29064. }
  29065. m.AddTotalTokens(v)
  29066. return nil
  29067. case usagedetail.FieldPromptTokens:
  29068. v, ok := value.(int64)
  29069. if !ok {
  29070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29071. }
  29072. m.AddPromptTokens(v)
  29073. return nil
  29074. case usagedetail.FieldCompletionTokens:
  29075. v, ok := value.(int64)
  29076. if !ok {
  29077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29078. }
  29079. m.AddCompletionTokens(v)
  29080. return nil
  29081. case usagedetail.FieldOrganizationID:
  29082. v, ok := value.(int64)
  29083. if !ok {
  29084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29085. }
  29086. m.AddOrganizationID(v)
  29087. return nil
  29088. }
  29089. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  29090. }
  29091. // ClearedFields returns all nullable fields that were cleared during this
  29092. // mutation.
  29093. func (m *UsageDetailMutation) ClearedFields() []string {
  29094. var fields []string
  29095. if m.FieldCleared(usagedetail.FieldStatus) {
  29096. fields = append(fields, usagedetail.FieldStatus)
  29097. }
  29098. if m.FieldCleared(usagedetail.FieldType) {
  29099. fields = append(fields, usagedetail.FieldType)
  29100. }
  29101. if m.FieldCleared(usagedetail.FieldApp) {
  29102. fields = append(fields, usagedetail.FieldApp)
  29103. }
  29104. if m.FieldCleared(usagedetail.FieldSessionID) {
  29105. fields = append(fields, usagedetail.FieldSessionID)
  29106. }
  29107. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  29108. fields = append(fields, usagedetail.FieldTotalTokens)
  29109. }
  29110. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  29111. fields = append(fields, usagedetail.FieldPromptTokens)
  29112. }
  29113. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  29114. fields = append(fields, usagedetail.FieldCompletionTokens)
  29115. }
  29116. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  29117. fields = append(fields, usagedetail.FieldOrganizationID)
  29118. }
  29119. return fields
  29120. }
  29121. // FieldCleared returns a boolean indicating if a field with the given name was
  29122. // cleared in this mutation.
  29123. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  29124. _, ok := m.clearedFields[name]
  29125. return ok
  29126. }
  29127. // ClearField clears the value of the field with the given name. It returns an
  29128. // error if the field is not defined in the schema.
  29129. func (m *UsageDetailMutation) ClearField(name string) error {
  29130. switch name {
  29131. case usagedetail.FieldStatus:
  29132. m.ClearStatus()
  29133. return nil
  29134. case usagedetail.FieldType:
  29135. m.ClearType()
  29136. return nil
  29137. case usagedetail.FieldApp:
  29138. m.ClearApp()
  29139. return nil
  29140. case usagedetail.FieldSessionID:
  29141. m.ClearSessionID()
  29142. return nil
  29143. case usagedetail.FieldTotalTokens:
  29144. m.ClearTotalTokens()
  29145. return nil
  29146. case usagedetail.FieldPromptTokens:
  29147. m.ClearPromptTokens()
  29148. return nil
  29149. case usagedetail.FieldCompletionTokens:
  29150. m.ClearCompletionTokens()
  29151. return nil
  29152. case usagedetail.FieldOrganizationID:
  29153. m.ClearOrganizationID()
  29154. return nil
  29155. }
  29156. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  29157. }
  29158. // ResetField resets all changes in the mutation for the field with the given name.
  29159. // It returns an error if the field is not defined in the schema.
  29160. func (m *UsageDetailMutation) ResetField(name string) error {
  29161. switch name {
  29162. case usagedetail.FieldCreatedAt:
  29163. m.ResetCreatedAt()
  29164. return nil
  29165. case usagedetail.FieldUpdatedAt:
  29166. m.ResetUpdatedAt()
  29167. return nil
  29168. case usagedetail.FieldStatus:
  29169. m.ResetStatus()
  29170. return nil
  29171. case usagedetail.FieldType:
  29172. m.ResetType()
  29173. return nil
  29174. case usagedetail.FieldBotID:
  29175. m.ResetBotID()
  29176. return nil
  29177. case usagedetail.FieldReceiverID:
  29178. m.ResetReceiverID()
  29179. return nil
  29180. case usagedetail.FieldApp:
  29181. m.ResetApp()
  29182. return nil
  29183. case usagedetail.FieldSessionID:
  29184. m.ResetSessionID()
  29185. return nil
  29186. case usagedetail.FieldRequest:
  29187. m.ResetRequest()
  29188. return nil
  29189. case usagedetail.FieldResponse:
  29190. m.ResetResponse()
  29191. return nil
  29192. case usagedetail.FieldOriginalData:
  29193. m.ResetOriginalData()
  29194. return nil
  29195. case usagedetail.FieldTotalTokens:
  29196. m.ResetTotalTokens()
  29197. return nil
  29198. case usagedetail.FieldPromptTokens:
  29199. m.ResetPromptTokens()
  29200. return nil
  29201. case usagedetail.FieldCompletionTokens:
  29202. m.ResetCompletionTokens()
  29203. return nil
  29204. case usagedetail.FieldOrganizationID:
  29205. m.ResetOrganizationID()
  29206. return nil
  29207. }
  29208. return fmt.Errorf("unknown UsageDetail field %s", name)
  29209. }
  29210. // AddedEdges returns all edge names that were set/added in this mutation.
  29211. func (m *UsageDetailMutation) AddedEdges() []string {
  29212. edges := make([]string, 0, 0)
  29213. return edges
  29214. }
  29215. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29216. // name in this mutation.
  29217. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  29218. return nil
  29219. }
  29220. // RemovedEdges returns all edge names that were removed in this mutation.
  29221. func (m *UsageDetailMutation) RemovedEdges() []string {
  29222. edges := make([]string, 0, 0)
  29223. return edges
  29224. }
  29225. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29226. // the given name in this mutation.
  29227. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  29228. return nil
  29229. }
  29230. // ClearedEdges returns all edge names that were cleared in this mutation.
  29231. func (m *UsageDetailMutation) ClearedEdges() []string {
  29232. edges := make([]string, 0, 0)
  29233. return edges
  29234. }
  29235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29236. // was cleared in this mutation.
  29237. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  29238. return false
  29239. }
  29240. // ClearEdge clears the value of the edge with the given name. It returns an error
  29241. // if that edge is not defined in the schema.
  29242. func (m *UsageDetailMutation) ClearEdge(name string) error {
  29243. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  29244. }
  29245. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29246. // It returns an error if the edge is not defined in the schema.
  29247. func (m *UsageDetailMutation) ResetEdge(name string) error {
  29248. return fmt.Errorf("unknown UsageDetail edge %s", name)
  29249. }
  29250. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  29251. type UsageStatisticDayMutation struct {
  29252. config
  29253. op Op
  29254. typ string
  29255. id *uint64
  29256. created_at *time.Time
  29257. updated_at *time.Time
  29258. status *uint8
  29259. addstatus *int8
  29260. deleted_at *time.Time
  29261. addtime *uint64
  29262. addaddtime *int64
  29263. _type *int
  29264. add_type *int
  29265. bot_id *string
  29266. organization_id *uint64
  29267. addorganization_id *int64
  29268. ai_response *uint64
  29269. addai_response *int64
  29270. sop_run *uint64
  29271. addsop_run *int64
  29272. total_friend *uint64
  29273. addtotal_friend *int64
  29274. total_group *uint64
  29275. addtotal_group *int64
  29276. account_balance *uint64
  29277. addaccount_balance *int64
  29278. consume_token *uint64
  29279. addconsume_token *int64
  29280. active_user *uint64
  29281. addactive_user *int64
  29282. new_user *int64
  29283. addnew_user *int64
  29284. label_dist *[]custom_types.LabelDist
  29285. appendlabel_dist []custom_types.LabelDist
  29286. clearedFields map[string]struct{}
  29287. done bool
  29288. oldValue func(context.Context) (*UsageStatisticDay, error)
  29289. predicates []predicate.UsageStatisticDay
  29290. }
  29291. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  29292. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  29293. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  29294. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  29295. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  29296. m := &UsageStatisticDayMutation{
  29297. config: c,
  29298. op: op,
  29299. typ: TypeUsageStatisticDay,
  29300. clearedFields: make(map[string]struct{}),
  29301. }
  29302. for _, opt := range opts {
  29303. opt(m)
  29304. }
  29305. return m
  29306. }
  29307. // withUsageStatisticDayID sets the ID field of the mutation.
  29308. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  29309. return func(m *UsageStatisticDayMutation) {
  29310. var (
  29311. err error
  29312. once sync.Once
  29313. value *UsageStatisticDay
  29314. )
  29315. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  29316. once.Do(func() {
  29317. if m.done {
  29318. err = errors.New("querying old values post mutation is not allowed")
  29319. } else {
  29320. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  29321. }
  29322. })
  29323. return value, err
  29324. }
  29325. m.id = &id
  29326. }
  29327. }
  29328. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  29329. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  29330. return func(m *UsageStatisticDayMutation) {
  29331. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  29332. return node, nil
  29333. }
  29334. m.id = &node.ID
  29335. }
  29336. }
  29337. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29338. // executed in a transaction (ent.Tx), a transactional client is returned.
  29339. func (m UsageStatisticDayMutation) Client() *Client {
  29340. client := &Client{config: m.config}
  29341. client.init()
  29342. return client
  29343. }
  29344. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29345. // it returns an error otherwise.
  29346. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  29347. if _, ok := m.driver.(*txDriver); !ok {
  29348. return nil, errors.New("ent: mutation is not running in a transaction")
  29349. }
  29350. tx := &Tx{config: m.config}
  29351. tx.init()
  29352. return tx, nil
  29353. }
  29354. // SetID sets the value of the id field. Note that this
  29355. // operation is only accepted on creation of UsageStatisticDay entities.
  29356. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  29357. m.id = &id
  29358. }
  29359. // ID returns the ID value in the mutation. Note that the ID is only available
  29360. // if it was provided to the builder or after it was returned from the database.
  29361. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  29362. if m.id == nil {
  29363. return
  29364. }
  29365. return *m.id, true
  29366. }
  29367. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29368. // That means, if the mutation is applied within a transaction with an isolation level such
  29369. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29370. // or updated by the mutation.
  29371. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  29372. switch {
  29373. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29374. id, exists := m.ID()
  29375. if exists {
  29376. return []uint64{id}, nil
  29377. }
  29378. fallthrough
  29379. case m.op.Is(OpUpdate | OpDelete):
  29380. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  29381. default:
  29382. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29383. }
  29384. }
  29385. // SetCreatedAt sets the "created_at" field.
  29386. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  29387. m.created_at = &t
  29388. }
  29389. // CreatedAt returns the value of the "created_at" field in the mutation.
  29390. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  29391. v := m.created_at
  29392. if v == nil {
  29393. return
  29394. }
  29395. return *v, true
  29396. }
  29397. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  29398. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29400. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29401. if !m.op.Is(OpUpdateOne) {
  29402. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29403. }
  29404. if m.id == nil || m.oldValue == nil {
  29405. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29406. }
  29407. oldValue, err := m.oldValue(ctx)
  29408. if err != nil {
  29409. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29410. }
  29411. return oldValue.CreatedAt, nil
  29412. }
  29413. // ResetCreatedAt resets all changes to the "created_at" field.
  29414. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  29415. m.created_at = nil
  29416. }
  29417. // SetUpdatedAt sets the "updated_at" field.
  29418. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  29419. m.updated_at = &t
  29420. }
  29421. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29422. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  29423. v := m.updated_at
  29424. if v == nil {
  29425. return
  29426. }
  29427. return *v, true
  29428. }
  29429. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  29430. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29432. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29433. if !m.op.Is(OpUpdateOne) {
  29434. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29435. }
  29436. if m.id == nil || m.oldValue == nil {
  29437. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29438. }
  29439. oldValue, err := m.oldValue(ctx)
  29440. if err != nil {
  29441. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29442. }
  29443. return oldValue.UpdatedAt, nil
  29444. }
  29445. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29446. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  29447. m.updated_at = nil
  29448. }
  29449. // SetStatus sets the "status" field.
  29450. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  29451. m.status = &u
  29452. m.addstatus = nil
  29453. }
  29454. // Status returns the value of the "status" field in the mutation.
  29455. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  29456. v := m.status
  29457. if v == nil {
  29458. return
  29459. }
  29460. return *v, true
  29461. }
  29462. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  29463. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29465. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29466. if !m.op.Is(OpUpdateOne) {
  29467. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29468. }
  29469. if m.id == nil || m.oldValue == nil {
  29470. return v, errors.New("OldStatus requires an ID field in the mutation")
  29471. }
  29472. oldValue, err := m.oldValue(ctx)
  29473. if err != nil {
  29474. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29475. }
  29476. return oldValue.Status, nil
  29477. }
  29478. // AddStatus adds u to the "status" field.
  29479. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  29480. if m.addstatus != nil {
  29481. *m.addstatus += u
  29482. } else {
  29483. m.addstatus = &u
  29484. }
  29485. }
  29486. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29487. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  29488. v := m.addstatus
  29489. if v == nil {
  29490. return
  29491. }
  29492. return *v, true
  29493. }
  29494. // ClearStatus clears the value of the "status" field.
  29495. func (m *UsageStatisticDayMutation) ClearStatus() {
  29496. m.status = nil
  29497. m.addstatus = nil
  29498. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  29499. }
  29500. // StatusCleared returns if the "status" field was cleared in this mutation.
  29501. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  29502. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  29503. return ok
  29504. }
  29505. // ResetStatus resets all changes to the "status" field.
  29506. func (m *UsageStatisticDayMutation) ResetStatus() {
  29507. m.status = nil
  29508. m.addstatus = nil
  29509. delete(m.clearedFields, usagestatisticday.FieldStatus)
  29510. }
  29511. // SetDeletedAt sets the "deleted_at" field.
  29512. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  29513. m.deleted_at = &t
  29514. }
  29515. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29516. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  29517. v := m.deleted_at
  29518. if v == nil {
  29519. return
  29520. }
  29521. return *v, true
  29522. }
  29523. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  29524. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29526. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29527. if !m.op.Is(OpUpdateOne) {
  29528. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29529. }
  29530. if m.id == nil || m.oldValue == nil {
  29531. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29532. }
  29533. oldValue, err := m.oldValue(ctx)
  29534. if err != nil {
  29535. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29536. }
  29537. return oldValue.DeletedAt, nil
  29538. }
  29539. // ClearDeletedAt clears the value of the "deleted_at" field.
  29540. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  29541. m.deleted_at = nil
  29542. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  29543. }
  29544. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29545. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  29546. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  29547. return ok
  29548. }
  29549. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29550. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  29551. m.deleted_at = nil
  29552. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  29553. }
  29554. // SetAddtime sets the "addtime" field.
  29555. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  29556. m.addtime = &u
  29557. m.addaddtime = nil
  29558. }
  29559. // Addtime returns the value of the "addtime" field in the mutation.
  29560. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  29561. v := m.addtime
  29562. if v == nil {
  29563. return
  29564. }
  29565. return *v, true
  29566. }
  29567. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  29568. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29570. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29571. if !m.op.Is(OpUpdateOne) {
  29572. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29573. }
  29574. if m.id == nil || m.oldValue == nil {
  29575. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29576. }
  29577. oldValue, err := m.oldValue(ctx)
  29578. if err != nil {
  29579. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29580. }
  29581. return oldValue.Addtime, nil
  29582. }
  29583. // AddAddtime adds u to the "addtime" field.
  29584. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  29585. if m.addaddtime != nil {
  29586. *m.addaddtime += u
  29587. } else {
  29588. m.addaddtime = &u
  29589. }
  29590. }
  29591. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29592. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  29593. v := m.addaddtime
  29594. if v == nil {
  29595. return
  29596. }
  29597. return *v, true
  29598. }
  29599. // ResetAddtime resets all changes to the "addtime" field.
  29600. func (m *UsageStatisticDayMutation) ResetAddtime() {
  29601. m.addtime = nil
  29602. m.addaddtime = nil
  29603. }
  29604. // SetType sets the "type" field.
  29605. func (m *UsageStatisticDayMutation) SetType(i int) {
  29606. m._type = &i
  29607. m.add_type = nil
  29608. }
  29609. // GetType returns the value of the "type" field in the mutation.
  29610. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  29611. v := m._type
  29612. if v == nil {
  29613. return
  29614. }
  29615. return *v, true
  29616. }
  29617. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  29618. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29620. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  29621. if !m.op.Is(OpUpdateOne) {
  29622. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29623. }
  29624. if m.id == nil || m.oldValue == nil {
  29625. return v, errors.New("OldType requires an ID field in the mutation")
  29626. }
  29627. oldValue, err := m.oldValue(ctx)
  29628. if err != nil {
  29629. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29630. }
  29631. return oldValue.Type, nil
  29632. }
  29633. // AddType adds i to the "type" field.
  29634. func (m *UsageStatisticDayMutation) AddType(i int) {
  29635. if m.add_type != nil {
  29636. *m.add_type += i
  29637. } else {
  29638. m.add_type = &i
  29639. }
  29640. }
  29641. // AddedType returns the value that was added to the "type" field in this mutation.
  29642. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  29643. v := m.add_type
  29644. if v == nil {
  29645. return
  29646. }
  29647. return *v, true
  29648. }
  29649. // ResetType resets all changes to the "type" field.
  29650. func (m *UsageStatisticDayMutation) ResetType() {
  29651. m._type = nil
  29652. m.add_type = nil
  29653. }
  29654. // SetBotID sets the "bot_id" field.
  29655. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  29656. m.bot_id = &s
  29657. }
  29658. // BotID returns the value of the "bot_id" field in the mutation.
  29659. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  29660. v := m.bot_id
  29661. if v == nil {
  29662. return
  29663. }
  29664. return *v, true
  29665. }
  29666. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  29667. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29669. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  29670. if !m.op.Is(OpUpdateOne) {
  29671. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29672. }
  29673. if m.id == nil || m.oldValue == nil {
  29674. return v, errors.New("OldBotID requires an ID field in the mutation")
  29675. }
  29676. oldValue, err := m.oldValue(ctx)
  29677. if err != nil {
  29678. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29679. }
  29680. return oldValue.BotID, nil
  29681. }
  29682. // ClearBotID clears the value of the "bot_id" field.
  29683. func (m *UsageStatisticDayMutation) ClearBotID() {
  29684. m.bot_id = nil
  29685. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  29686. }
  29687. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29688. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  29689. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  29690. return ok
  29691. }
  29692. // ResetBotID resets all changes to the "bot_id" field.
  29693. func (m *UsageStatisticDayMutation) ResetBotID() {
  29694. m.bot_id = nil
  29695. delete(m.clearedFields, usagestatisticday.FieldBotID)
  29696. }
  29697. // SetOrganizationID sets the "organization_id" field.
  29698. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  29699. m.organization_id = &u
  29700. m.addorganization_id = nil
  29701. }
  29702. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29703. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  29704. v := m.organization_id
  29705. if v == nil {
  29706. return
  29707. }
  29708. return *v, true
  29709. }
  29710. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  29711. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29713. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29714. if !m.op.Is(OpUpdateOne) {
  29715. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29716. }
  29717. if m.id == nil || m.oldValue == nil {
  29718. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29719. }
  29720. oldValue, err := m.oldValue(ctx)
  29721. if err != nil {
  29722. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29723. }
  29724. return oldValue.OrganizationID, nil
  29725. }
  29726. // AddOrganizationID adds u to the "organization_id" field.
  29727. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  29728. if m.addorganization_id != nil {
  29729. *m.addorganization_id += u
  29730. } else {
  29731. m.addorganization_id = &u
  29732. }
  29733. }
  29734. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29735. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  29736. v := m.addorganization_id
  29737. if v == nil {
  29738. return
  29739. }
  29740. return *v, true
  29741. }
  29742. // ClearOrganizationID clears the value of the "organization_id" field.
  29743. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  29744. m.organization_id = nil
  29745. m.addorganization_id = nil
  29746. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  29747. }
  29748. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29749. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  29750. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  29751. return ok
  29752. }
  29753. // ResetOrganizationID resets all changes to the "organization_id" field.
  29754. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  29755. m.organization_id = nil
  29756. m.addorganization_id = nil
  29757. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  29758. }
  29759. // SetAiResponse sets the "ai_response" field.
  29760. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  29761. m.ai_response = &u
  29762. m.addai_response = nil
  29763. }
  29764. // AiResponse returns the value of the "ai_response" field in the mutation.
  29765. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  29766. v := m.ai_response
  29767. if v == nil {
  29768. return
  29769. }
  29770. return *v, true
  29771. }
  29772. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  29773. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29775. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29776. if !m.op.Is(OpUpdateOne) {
  29777. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29778. }
  29779. if m.id == nil || m.oldValue == nil {
  29780. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29781. }
  29782. oldValue, err := m.oldValue(ctx)
  29783. if err != nil {
  29784. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29785. }
  29786. return oldValue.AiResponse, nil
  29787. }
  29788. // AddAiResponse adds u to the "ai_response" field.
  29789. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  29790. if m.addai_response != nil {
  29791. *m.addai_response += u
  29792. } else {
  29793. m.addai_response = &u
  29794. }
  29795. }
  29796. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29797. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  29798. v := m.addai_response
  29799. if v == nil {
  29800. return
  29801. }
  29802. return *v, true
  29803. }
  29804. // ResetAiResponse resets all changes to the "ai_response" field.
  29805. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  29806. m.ai_response = nil
  29807. m.addai_response = nil
  29808. }
  29809. // SetSopRun sets the "sop_run" field.
  29810. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  29811. m.sop_run = &u
  29812. m.addsop_run = nil
  29813. }
  29814. // SopRun returns the value of the "sop_run" field in the mutation.
  29815. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  29816. v := m.sop_run
  29817. if v == nil {
  29818. return
  29819. }
  29820. return *v, true
  29821. }
  29822. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  29823. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29825. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29826. if !m.op.Is(OpUpdateOne) {
  29827. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29828. }
  29829. if m.id == nil || m.oldValue == nil {
  29830. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29831. }
  29832. oldValue, err := m.oldValue(ctx)
  29833. if err != nil {
  29834. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29835. }
  29836. return oldValue.SopRun, nil
  29837. }
  29838. // AddSopRun adds u to the "sop_run" field.
  29839. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  29840. if m.addsop_run != nil {
  29841. *m.addsop_run += u
  29842. } else {
  29843. m.addsop_run = &u
  29844. }
  29845. }
  29846. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29847. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  29848. v := m.addsop_run
  29849. if v == nil {
  29850. return
  29851. }
  29852. return *v, true
  29853. }
  29854. // ResetSopRun resets all changes to the "sop_run" field.
  29855. func (m *UsageStatisticDayMutation) ResetSopRun() {
  29856. m.sop_run = nil
  29857. m.addsop_run = nil
  29858. }
  29859. // SetTotalFriend sets the "total_friend" field.
  29860. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  29861. m.total_friend = &u
  29862. m.addtotal_friend = nil
  29863. }
  29864. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29865. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  29866. v := m.total_friend
  29867. if v == nil {
  29868. return
  29869. }
  29870. return *v, true
  29871. }
  29872. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  29873. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29875. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29876. if !m.op.Is(OpUpdateOne) {
  29877. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29878. }
  29879. if m.id == nil || m.oldValue == nil {
  29880. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29881. }
  29882. oldValue, err := m.oldValue(ctx)
  29883. if err != nil {
  29884. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29885. }
  29886. return oldValue.TotalFriend, nil
  29887. }
  29888. // AddTotalFriend adds u to the "total_friend" field.
  29889. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  29890. if m.addtotal_friend != nil {
  29891. *m.addtotal_friend += u
  29892. } else {
  29893. m.addtotal_friend = &u
  29894. }
  29895. }
  29896. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29897. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  29898. v := m.addtotal_friend
  29899. if v == nil {
  29900. return
  29901. }
  29902. return *v, true
  29903. }
  29904. // ResetTotalFriend resets all changes to the "total_friend" field.
  29905. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  29906. m.total_friend = nil
  29907. m.addtotal_friend = nil
  29908. }
  29909. // SetTotalGroup sets the "total_group" field.
  29910. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  29911. m.total_group = &u
  29912. m.addtotal_group = nil
  29913. }
  29914. // TotalGroup returns the value of the "total_group" field in the mutation.
  29915. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  29916. v := m.total_group
  29917. if v == nil {
  29918. return
  29919. }
  29920. return *v, true
  29921. }
  29922. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  29923. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29925. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29926. if !m.op.Is(OpUpdateOne) {
  29927. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29928. }
  29929. if m.id == nil || m.oldValue == nil {
  29930. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29931. }
  29932. oldValue, err := m.oldValue(ctx)
  29933. if err != nil {
  29934. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29935. }
  29936. return oldValue.TotalGroup, nil
  29937. }
  29938. // AddTotalGroup adds u to the "total_group" field.
  29939. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  29940. if m.addtotal_group != nil {
  29941. *m.addtotal_group += u
  29942. } else {
  29943. m.addtotal_group = &u
  29944. }
  29945. }
  29946. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29947. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  29948. v := m.addtotal_group
  29949. if v == nil {
  29950. return
  29951. }
  29952. return *v, true
  29953. }
  29954. // ResetTotalGroup resets all changes to the "total_group" field.
  29955. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  29956. m.total_group = nil
  29957. m.addtotal_group = nil
  29958. }
  29959. // SetAccountBalance sets the "account_balance" field.
  29960. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  29961. m.account_balance = &u
  29962. m.addaccount_balance = nil
  29963. }
  29964. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29965. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  29966. v := m.account_balance
  29967. if v == nil {
  29968. return
  29969. }
  29970. return *v, true
  29971. }
  29972. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  29973. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29975. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29976. if !m.op.Is(OpUpdateOne) {
  29977. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29978. }
  29979. if m.id == nil || m.oldValue == nil {
  29980. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29981. }
  29982. oldValue, err := m.oldValue(ctx)
  29983. if err != nil {
  29984. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29985. }
  29986. return oldValue.AccountBalance, nil
  29987. }
  29988. // AddAccountBalance adds u to the "account_balance" field.
  29989. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  29990. if m.addaccount_balance != nil {
  29991. *m.addaccount_balance += u
  29992. } else {
  29993. m.addaccount_balance = &u
  29994. }
  29995. }
  29996. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29997. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  29998. v := m.addaccount_balance
  29999. if v == nil {
  30000. return
  30001. }
  30002. return *v, true
  30003. }
  30004. // ResetAccountBalance resets all changes to the "account_balance" field.
  30005. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  30006. m.account_balance = nil
  30007. m.addaccount_balance = nil
  30008. }
  30009. // SetConsumeToken sets the "consume_token" field.
  30010. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  30011. m.consume_token = &u
  30012. m.addconsume_token = nil
  30013. }
  30014. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30015. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  30016. v := m.consume_token
  30017. if v == nil {
  30018. return
  30019. }
  30020. return *v, true
  30021. }
  30022. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  30023. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30025. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30026. if !m.op.Is(OpUpdateOne) {
  30027. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30028. }
  30029. if m.id == nil || m.oldValue == nil {
  30030. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30031. }
  30032. oldValue, err := m.oldValue(ctx)
  30033. if err != nil {
  30034. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30035. }
  30036. return oldValue.ConsumeToken, nil
  30037. }
  30038. // AddConsumeToken adds u to the "consume_token" field.
  30039. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  30040. if m.addconsume_token != nil {
  30041. *m.addconsume_token += u
  30042. } else {
  30043. m.addconsume_token = &u
  30044. }
  30045. }
  30046. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30047. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  30048. v := m.addconsume_token
  30049. if v == nil {
  30050. return
  30051. }
  30052. return *v, true
  30053. }
  30054. // ResetConsumeToken resets all changes to the "consume_token" field.
  30055. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  30056. m.consume_token = nil
  30057. m.addconsume_token = nil
  30058. }
  30059. // SetActiveUser sets the "active_user" field.
  30060. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  30061. m.active_user = &u
  30062. m.addactive_user = nil
  30063. }
  30064. // ActiveUser returns the value of the "active_user" field in the mutation.
  30065. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  30066. v := m.active_user
  30067. if v == nil {
  30068. return
  30069. }
  30070. return *v, true
  30071. }
  30072. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  30073. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30075. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30076. if !m.op.Is(OpUpdateOne) {
  30077. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30078. }
  30079. if m.id == nil || m.oldValue == nil {
  30080. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30081. }
  30082. oldValue, err := m.oldValue(ctx)
  30083. if err != nil {
  30084. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30085. }
  30086. return oldValue.ActiveUser, nil
  30087. }
  30088. // AddActiveUser adds u to the "active_user" field.
  30089. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  30090. if m.addactive_user != nil {
  30091. *m.addactive_user += u
  30092. } else {
  30093. m.addactive_user = &u
  30094. }
  30095. }
  30096. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30097. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  30098. v := m.addactive_user
  30099. if v == nil {
  30100. return
  30101. }
  30102. return *v, true
  30103. }
  30104. // ResetActiveUser resets all changes to the "active_user" field.
  30105. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  30106. m.active_user = nil
  30107. m.addactive_user = nil
  30108. }
  30109. // SetNewUser sets the "new_user" field.
  30110. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  30111. m.new_user = &i
  30112. m.addnew_user = nil
  30113. }
  30114. // NewUser returns the value of the "new_user" field in the mutation.
  30115. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  30116. v := m.new_user
  30117. if v == nil {
  30118. return
  30119. }
  30120. return *v, true
  30121. }
  30122. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  30123. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30125. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30126. if !m.op.Is(OpUpdateOne) {
  30127. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30128. }
  30129. if m.id == nil || m.oldValue == nil {
  30130. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30131. }
  30132. oldValue, err := m.oldValue(ctx)
  30133. if err != nil {
  30134. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30135. }
  30136. return oldValue.NewUser, nil
  30137. }
  30138. // AddNewUser adds i to the "new_user" field.
  30139. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  30140. if m.addnew_user != nil {
  30141. *m.addnew_user += i
  30142. } else {
  30143. m.addnew_user = &i
  30144. }
  30145. }
  30146. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30147. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  30148. v := m.addnew_user
  30149. if v == nil {
  30150. return
  30151. }
  30152. return *v, true
  30153. }
  30154. // ResetNewUser resets all changes to the "new_user" field.
  30155. func (m *UsageStatisticDayMutation) ResetNewUser() {
  30156. m.new_user = nil
  30157. m.addnew_user = nil
  30158. }
  30159. // SetLabelDist sets the "label_dist" field.
  30160. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30161. m.label_dist = &ctd
  30162. m.appendlabel_dist = nil
  30163. }
  30164. // LabelDist returns the value of the "label_dist" field in the mutation.
  30165. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30166. v := m.label_dist
  30167. if v == nil {
  30168. return
  30169. }
  30170. return *v, true
  30171. }
  30172. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  30173. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30175. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30176. if !m.op.Is(OpUpdateOne) {
  30177. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30178. }
  30179. if m.id == nil || m.oldValue == nil {
  30180. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30181. }
  30182. oldValue, err := m.oldValue(ctx)
  30183. if err != nil {
  30184. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30185. }
  30186. return oldValue.LabelDist, nil
  30187. }
  30188. // AppendLabelDist adds ctd to the "label_dist" field.
  30189. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30190. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30191. }
  30192. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30193. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30194. if len(m.appendlabel_dist) == 0 {
  30195. return nil, false
  30196. }
  30197. return m.appendlabel_dist, true
  30198. }
  30199. // ResetLabelDist resets all changes to the "label_dist" field.
  30200. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  30201. m.label_dist = nil
  30202. m.appendlabel_dist = nil
  30203. }
  30204. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  30205. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  30206. m.predicates = append(m.predicates, ps...)
  30207. }
  30208. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  30209. // users can use type-assertion to append predicates that do not depend on any generated package.
  30210. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  30211. p := make([]predicate.UsageStatisticDay, len(ps))
  30212. for i := range ps {
  30213. p[i] = ps[i]
  30214. }
  30215. m.Where(p...)
  30216. }
  30217. // Op returns the operation name.
  30218. func (m *UsageStatisticDayMutation) Op() Op {
  30219. return m.op
  30220. }
  30221. // SetOp allows setting the mutation operation.
  30222. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  30223. m.op = op
  30224. }
  30225. // Type returns the node type of this mutation (UsageStatisticDay).
  30226. func (m *UsageStatisticDayMutation) Type() string {
  30227. return m.typ
  30228. }
  30229. // Fields returns all fields that were changed during this mutation. Note that in
  30230. // order to get all numeric fields that were incremented/decremented, call
  30231. // AddedFields().
  30232. func (m *UsageStatisticDayMutation) Fields() []string {
  30233. fields := make([]string, 0, 17)
  30234. if m.created_at != nil {
  30235. fields = append(fields, usagestatisticday.FieldCreatedAt)
  30236. }
  30237. if m.updated_at != nil {
  30238. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  30239. }
  30240. if m.status != nil {
  30241. fields = append(fields, usagestatisticday.FieldStatus)
  30242. }
  30243. if m.deleted_at != nil {
  30244. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30245. }
  30246. if m.addtime != nil {
  30247. fields = append(fields, usagestatisticday.FieldAddtime)
  30248. }
  30249. if m._type != nil {
  30250. fields = append(fields, usagestatisticday.FieldType)
  30251. }
  30252. if m.bot_id != nil {
  30253. fields = append(fields, usagestatisticday.FieldBotID)
  30254. }
  30255. if m.organization_id != nil {
  30256. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30257. }
  30258. if m.ai_response != nil {
  30259. fields = append(fields, usagestatisticday.FieldAiResponse)
  30260. }
  30261. if m.sop_run != nil {
  30262. fields = append(fields, usagestatisticday.FieldSopRun)
  30263. }
  30264. if m.total_friend != nil {
  30265. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30266. }
  30267. if m.total_group != nil {
  30268. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30269. }
  30270. if m.account_balance != nil {
  30271. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30272. }
  30273. if m.consume_token != nil {
  30274. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30275. }
  30276. if m.active_user != nil {
  30277. fields = append(fields, usagestatisticday.FieldActiveUser)
  30278. }
  30279. if m.new_user != nil {
  30280. fields = append(fields, usagestatisticday.FieldNewUser)
  30281. }
  30282. if m.label_dist != nil {
  30283. fields = append(fields, usagestatisticday.FieldLabelDist)
  30284. }
  30285. return fields
  30286. }
  30287. // Field returns the value of a field with the given name. The second boolean
  30288. // return value indicates that this field was not set, or was not defined in the
  30289. // schema.
  30290. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  30291. switch name {
  30292. case usagestatisticday.FieldCreatedAt:
  30293. return m.CreatedAt()
  30294. case usagestatisticday.FieldUpdatedAt:
  30295. return m.UpdatedAt()
  30296. case usagestatisticday.FieldStatus:
  30297. return m.Status()
  30298. case usagestatisticday.FieldDeletedAt:
  30299. return m.DeletedAt()
  30300. case usagestatisticday.FieldAddtime:
  30301. return m.Addtime()
  30302. case usagestatisticday.FieldType:
  30303. return m.GetType()
  30304. case usagestatisticday.FieldBotID:
  30305. return m.BotID()
  30306. case usagestatisticday.FieldOrganizationID:
  30307. return m.OrganizationID()
  30308. case usagestatisticday.FieldAiResponse:
  30309. return m.AiResponse()
  30310. case usagestatisticday.FieldSopRun:
  30311. return m.SopRun()
  30312. case usagestatisticday.FieldTotalFriend:
  30313. return m.TotalFriend()
  30314. case usagestatisticday.FieldTotalGroup:
  30315. return m.TotalGroup()
  30316. case usagestatisticday.FieldAccountBalance:
  30317. return m.AccountBalance()
  30318. case usagestatisticday.FieldConsumeToken:
  30319. return m.ConsumeToken()
  30320. case usagestatisticday.FieldActiveUser:
  30321. return m.ActiveUser()
  30322. case usagestatisticday.FieldNewUser:
  30323. return m.NewUser()
  30324. case usagestatisticday.FieldLabelDist:
  30325. return m.LabelDist()
  30326. }
  30327. return nil, false
  30328. }
  30329. // OldField returns the old value of the field from the database. An error is
  30330. // returned if the mutation operation is not UpdateOne, or the query to the
  30331. // database failed.
  30332. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30333. switch name {
  30334. case usagestatisticday.FieldCreatedAt:
  30335. return m.OldCreatedAt(ctx)
  30336. case usagestatisticday.FieldUpdatedAt:
  30337. return m.OldUpdatedAt(ctx)
  30338. case usagestatisticday.FieldStatus:
  30339. return m.OldStatus(ctx)
  30340. case usagestatisticday.FieldDeletedAt:
  30341. return m.OldDeletedAt(ctx)
  30342. case usagestatisticday.FieldAddtime:
  30343. return m.OldAddtime(ctx)
  30344. case usagestatisticday.FieldType:
  30345. return m.OldType(ctx)
  30346. case usagestatisticday.FieldBotID:
  30347. return m.OldBotID(ctx)
  30348. case usagestatisticday.FieldOrganizationID:
  30349. return m.OldOrganizationID(ctx)
  30350. case usagestatisticday.FieldAiResponse:
  30351. return m.OldAiResponse(ctx)
  30352. case usagestatisticday.FieldSopRun:
  30353. return m.OldSopRun(ctx)
  30354. case usagestatisticday.FieldTotalFriend:
  30355. return m.OldTotalFriend(ctx)
  30356. case usagestatisticday.FieldTotalGroup:
  30357. return m.OldTotalGroup(ctx)
  30358. case usagestatisticday.FieldAccountBalance:
  30359. return m.OldAccountBalance(ctx)
  30360. case usagestatisticday.FieldConsumeToken:
  30361. return m.OldConsumeToken(ctx)
  30362. case usagestatisticday.FieldActiveUser:
  30363. return m.OldActiveUser(ctx)
  30364. case usagestatisticday.FieldNewUser:
  30365. return m.OldNewUser(ctx)
  30366. case usagestatisticday.FieldLabelDist:
  30367. return m.OldLabelDist(ctx)
  30368. }
  30369. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30370. }
  30371. // SetField sets the value of a field with the given name. It returns an error if
  30372. // the field is not defined in the schema, or if the type mismatched the field
  30373. // type.
  30374. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  30375. switch name {
  30376. case usagestatisticday.FieldCreatedAt:
  30377. v, ok := value.(time.Time)
  30378. if !ok {
  30379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30380. }
  30381. m.SetCreatedAt(v)
  30382. return nil
  30383. case usagestatisticday.FieldUpdatedAt:
  30384. v, ok := value.(time.Time)
  30385. if !ok {
  30386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30387. }
  30388. m.SetUpdatedAt(v)
  30389. return nil
  30390. case usagestatisticday.FieldStatus:
  30391. v, ok := value.(uint8)
  30392. if !ok {
  30393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30394. }
  30395. m.SetStatus(v)
  30396. return nil
  30397. case usagestatisticday.FieldDeletedAt:
  30398. v, ok := value.(time.Time)
  30399. if !ok {
  30400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30401. }
  30402. m.SetDeletedAt(v)
  30403. return nil
  30404. case usagestatisticday.FieldAddtime:
  30405. v, ok := value.(uint64)
  30406. if !ok {
  30407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30408. }
  30409. m.SetAddtime(v)
  30410. return nil
  30411. case usagestatisticday.FieldType:
  30412. v, ok := value.(int)
  30413. if !ok {
  30414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30415. }
  30416. m.SetType(v)
  30417. return nil
  30418. case usagestatisticday.FieldBotID:
  30419. v, ok := value.(string)
  30420. if !ok {
  30421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30422. }
  30423. m.SetBotID(v)
  30424. return nil
  30425. case usagestatisticday.FieldOrganizationID:
  30426. v, ok := value.(uint64)
  30427. if !ok {
  30428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30429. }
  30430. m.SetOrganizationID(v)
  30431. return nil
  30432. case usagestatisticday.FieldAiResponse:
  30433. v, ok := value.(uint64)
  30434. if !ok {
  30435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30436. }
  30437. m.SetAiResponse(v)
  30438. return nil
  30439. case usagestatisticday.FieldSopRun:
  30440. v, ok := value.(uint64)
  30441. if !ok {
  30442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30443. }
  30444. m.SetSopRun(v)
  30445. return nil
  30446. case usagestatisticday.FieldTotalFriend:
  30447. v, ok := value.(uint64)
  30448. if !ok {
  30449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30450. }
  30451. m.SetTotalFriend(v)
  30452. return nil
  30453. case usagestatisticday.FieldTotalGroup:
  30454. v, ok := value.(uint64)
  30455. if !ok {
  30456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30457. }
  30458. m.SetTotalGroup(v)
  30459. return nil
  30460. case usagestatisticday.FieldAccountBalance:
  30461. v, ok := value.(uint64)
  30462. if !ok {
  30463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30464. }
  30465. m.SetAccountBalance(v)
  30466. return nil
  30467. case usagestatisticday.FieldConsumeToken:
  30468. v, ok := value.(uint64)
  30469. if !ok {
  30470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30471. }
  30472. m.SetConsumeToken(v)
  30473. return nil
  30474. case usagestatisticday.FieldActiveUser:
  30475. v, ok := value.(uint64)
  30476. if !ok {
  30477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30478. }
  30479. m.SetActiveUser(v)
  30480. return nil
  30481. case usagestatisticday.FieldNewUser:
  30482. v, ok := value.(int64)
  30483. if !ok {
  30484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30485. }
  30486. m.SetNewUser(v)
  30487. return nil
  30488. case usagestatisticday.FieldLabelDist:
  30489. v, ok := value.([]custom_types.LabelDist)
  30490. if !ok {
  30491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30492. }
  30493. m.SetLabelDist(v)
  30494. return nil
  30495. }
  30496. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30497. }
  30498. // AddedFields returns all numeric fields that were incremented/decremented during
  30499. // this mutation.
  30500. func (m *UsageStatisticDayMutation) AddedFields() []string {
  30501. var fields []string
  30502. if m.addstatus != nil {
  30503. fields = append(fields, usagestatisticday.FieldStatus)
  30504. }
  30505. if m.addaddtime != nil {
  30506. fields = append(fields, usagestatisticday.FieldAddtime)
  30507. }
  30508. if m.add_type != nil {
  30509. fields = append(fields, usagestatisticday.FieldType)
  30510. }
  30511. if m.addorganization_id != nil {
  30512. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30513. }
  30514. if m.addai_response != nil {
  30515. fields = append(fields, usagestatisticday.FieldAiResponse)
  30516. }
  30517. if m.addsop_run != nil {
  30518. fields = append(fields, usagestatisticday.FieldSopRun)
  30519. }
  30520. if m.addtotal_friend != nil {
  30521. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30522. }
  30523. if m.addtotal_group != nil {
  30524. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30525. }
  30526. if m.addaccount_balance != nil {
  30527. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30528. }
  30529. if m.addconsume_token != nil {
  30530. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30531. }
  30532. if m.addactive_user != nil {
  30533. fields = append(fields, usagestatisticday.FieldActiveUser)
  30534. }
  30535. if m.addnew_user != nil {
  30536. fields = append(fields, usagestatisticday.FieldNewUser)
  30537. }
  30538. return fields
  30539. }
  30540. // AddedField returns the numeric value that was incremented/decremented on a field
  30541. // with the given name. The second boolean return value indicates that this field
  30542. // was not set, or was not defined in the schema.
  30543. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  30544. switch name {
  30545. case usagestatisticday.FieldStatus:
  30546. return m.AddedStatus()
  30547. case usagestatisticday.FieldAddtime:
  30548. return m.AddedAddtime()
  30549. case usagestatisticday.FieldType:
  30550. return m.AddedType()
  30551. case usagestatisticday.FieldOrganizationID:
  30552. return m.AddedOrganizationID()
  30553. case usagestatisticday.FieldAiResponse:
  30554. return m.AddedAiResponse()
  30555. case usagestatisticday.FieldSopRun:
  30556. return m.AddedSopRun()
  30557. case usagestatisticday.FieldTotalFriend:
  30558. return m.AddedTotalFriend()
  30559. case usagestatisticday.FieldTotalGroup:
  30560. return m.AddedTotalGroup()
  30561. case usagestatisticday.FieldAccountBalance:
  30562. return m.AddedAccountBalance()
  30563. case usagestatisticday.FieldConsumeToken:
  30564. return m.AddedConsumeToken()
  30565. case usagestatisticday.FieldActiveUser:
  30566. return m.AddedActiveUser()
  30567. case usagestatisticday.FieldNewUser:
  30568. return m.AddedNewUser()
  30569. }
  30570. return nil, false
  30571. }
  30572. // AddField adds the value to the field with the given name. It returns an error if
  30573. // the field is not defined in the schema, or if the type mismatched the field
  30574. // type.
  30575. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  30576. switch name {
  30577. case usagestatisticday.FieldStatus:
  30578. v, ok := value.(int8)
  30579. if !ok {
  30580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30581. }
  30582. m.AddStatus(v)
  30583. return nil
  30584. case usagestatisticday.FieldAddtime:
  30585. v, ok := value.(int64)
  30586. if !ok {
  30587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30588. }
  30589. m.AddAddtime(v)
  30590. return nil
  30591. case usagestatisticday.FieldType:
  30592. v, ok := value.(int)
  30593. if !ok {
  30594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30595. }
  30596. m.AddType(v)
  30597. return nil
  30598. case usagestatisticday.FieldOrganizationID:
  30599. v, ok := value.(int64)
  30600. if !ok {
  30601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30602. }
  30603. m.AddOrganizationID(v)
  30604. return nil
  30605. case usagestatisticday.FieldAiResponse:
  30606. v, ok := value.(int64)
  30607. if !ok {
  30608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30609. }
  30610. m.AddAiResponse(v)
  30611. return nil
  30612. case usagestatisticday.FieldSopRun:
  30613. v, ok := value.(int64)
  30614. if !ok {
  30615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30616. }
  30617. m.AddSopRun(v)
  30618. return nil
  30619. case usagestatisticday.FieldTotalFriend:
  30620. v, ok := value.(int64)
  30621. if !ok {
  30622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30623. }
  30624. m.AddTotalFriend(v)
  30625. return nil
  30626. case usagestatisticday.FieldTotalGroup:
  30627. v, ok := value.(int64)
  30628. if !ok {
  30629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30630. }
  30631. m.AddTotalGroup(v)
  30632. return nil
  30633. case usagestatisticday.FieldAccountBalance:
  30634. v, ok := value.(int64)
  30635. if !ok {
  30636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30637. }
  30638. m.AddAccountBalance(v)
  30639. return nil
  30640. case usagestatisticday.FieldConsumeToken:
  30641. v, ok := value.(int64)
  30642. if !ok {
  30643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30644. }
  30645. m.AddConsumeToken(v)
  30646. return nil
  30647. case usagestatisticday.FieldActiveUser:
  30648. v, ok := value.(int64)
  30649. if !ok {
  30650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30651. }
  30652. m.AddActiveUser(v)
  30653. return nil
  30654. case usagestatisticday.FieldNewUser:
  30655. v, ok := value.(int64)
  30656. if !ok {
  30657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30658. }
  30659. m.AddNewUser(v)
  30660. return nil
  30661. }
  30662. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  30663. }
  30664. // ClearedFields returns all nullable fields that were cleared during this
  30665. // mutation.
  30666. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  30667. var fields []string
  30668. if m.FieldCleared(usagestatisticday.FieldStatus) {
  30669. fields = append(fields, usagestatisticday.FieldStatus)
  30670. }
  30671. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  30672. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30673. }
  30674. if m.FieldCleared(usagestatisticday.FieldBotID) {
  30675. fields = append(fields, usagestatisticday.FieldBotID)
  30676. }
  30677. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  30678. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30679. }
  30680. return fields
  30681. }
  30682. // FieldCleared returns a boolean indicating if a field with the given name was
  30683. // cleared in this mutation.
  30684. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  30685. _, ok := m.clearedFields[name]
  30686. return ok
  30687. }
  30688. // ClearField clears the value of the field with the given name. It returns an
  30689. // error if the field is not defined in the schema.
  30690. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  30691. switch name {
  30692. case usagestatisticday.FieldStatus:
  30693. m.ClearStatus()
  30694. return nil
  30695. case usagestatisticday.FieldDeletedAt:
  30696. m.ClearDeletedAt()
  30697. return nil
  30698. case usagestatisticday.FieldBotID:
  30699. m.ClearBotID()
  30700. return nil
  30701. case usagestatisticday.FieldOrganizationID:
  30702. m.ClearOrganizationID()
  30703. return nil
  30704. }
  30705. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  30706. }
  30707. // ResetField resets all changes in the mutation for the field with the given name.
  30708. // It returns an error if the field is not defined in the schema.
  30709. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  30710. switch name {
  30711. case usagestatisticday.FieldCreatedAt:
  30712. m.ResetCreatedAt()
  30713. return nil
  30714. case usagestatisticday.FieldUpdatedAt:
  30715. m.ResetUpdatedAt()
  30716. return nil
  30717. case usagestatisticday.FieldStatus:
  30718. m.ResetStatus()
  30719. return nil
  30720. case usagestatisticday.FieldDeletedAt:
  30721. m.ResetDeletedAt()
  30722. return nil
  30723. case usagestatisticday.FieldAddtime:
  30724. m.ResetAddtime()
  30725. return nil
  30726. case usagestatisticday.FieldType:
  30727. m.ResetType()
  30728. return nil
  30729. case usagestatisticday.FieldBotID:
  30730. m.ResetBotID()
  30731. return nil
  30732. case usagestatisticday.FieldOrganizationID:
  30733. m.ResetOrganizationID()
  30734. return nil
  30735. case usagestatisticday.FieldAiResponse:
  30736. m.ResetAiResponse()
  30737. return nil
  30738. case usagestatisticday.FieldSopRun:
  30739. m.ResetSopRun()
  30740. return nil
  30741. case usagestatisticday.FieldTotalFriend:
  30742. m.ResetTotalFriend()
  30743. return nil
  30744. case usagestatisticday.FieldTotalGroup:
  30745. m.ResetTotalGroup()
  30746. return nil
  30747. case usagestatisticday.FieldAccountBalance:
  30748. m.ResetAccountBalance()
  30749. return nil
  30750. case usagestatisticday.FieldConsumeToken:
  30751. m.ResetConsumeToken()
  30752. return nil
  30753. case usagestatisticday.FieldActiveUser:
  30754. m.ResetActiveUser()
  30755. return nil
  30756. case usagestatisticday.FieldNewUser:
  30757. m.ResetNewUser()
  30758. return nil
  30759. case usagestatisticday.FieldLabelDist:
  30760. m.ResetLabelDist()
  30761. return nil
  30762. }
  30763. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30764. }
  30765. // AddedEdges returns all edge names that were set/added in this mutation.
  30766. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  30767. edges := make([]string, 0, 0)
  30768. return edges
  30769. }
  30770. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30771. // name in this mutation.
  30772. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  30773. return nil
  30774. }
  30775. // RemovedEdges returns all edge names that were removed in this mutation.
  30776. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  30777. edges := make([]string, 0, 0)
  30778. return edges
  30779. }
  30780. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30781. // the given name in this mutation.
  30782. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  30783. return nil
  30784. }
  30785. // ClearedEdges returns all edge names that were cleared in this mutation.
  30786. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  30787. edges := make([]string, 0, 0)
  30788. return edges
  30789. }
  30790. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30791. // was cleared in this mutation.
  30792. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  30793. return false
  30794. }
  30795. // ClearEdge clears the value of the edge with the given name. It returns an error
  30796. // if that edge is not defined in the schema.
  30797. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  30798. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  30799. }
  30800. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30801. // It returns an error if the edge is not defined in the schema.
  30802. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  30803. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  30804. }
  30805. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  30806. type UsageStatisticHourMutation struct {
  30807. config
  30808. op Op
  30809. typ string
  30810. id *uint64
  30811. created_at *time.Time
  30812. updated_at *time.Time
  30813. status *uint8
  30814. addstatus *int8
  30815. deleted_at *time.Time
  30816. addtime *uint64
  30817. addaddtime *int64
  30818. _type *int
  30819. add_type *int
  30820. bot_id *string
  30821. organization_id *uint64
  30822. addorganization_id *int64
  30823. ai_response *uint64
  30824. addai_response *int64
  30825. sop_run *uint64
  30826. addsop_run *int64
  30827. total_friend *uint64
  30828. addtotal_friend *int64
  30829. total_group *uint64
  30830. addtotal_group *int64
  30831. account_balance *uint64
  30832. addaccount_balance *int64
  30833. consume_token *uint64
  30834. addconsume_token *int64
  30835. active_user *uint64
  30836. addactive_user *int64
  30837. new_user *int64
  30838. addnew_user *int64
  30839. label_dist *[]custom_types.LabelDist
  30840. appendlabel_dist []custom_types.LabelDist
  30841. clearedFields map[string]struct{}
  30842. done bool
  30843. oldValue func(context.Context) (*UsageStatisticHour, error)
  30844. predicates []predicate.UsageStatisticHour
  30845. }
  30846. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  30847. // usagestatistichourOption allows management of the mutation configuration using functional options.
  30848. type usagestatistichourOption func(*UsageStatisticHourMutation)
  30849. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  30850. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  30851. m := &UsageStatisticHourMutation{
  30852. config: c,
  30853. op: op,
  30854. typ: TypeUsageStatisticHour,
  30855. clearedFields: make(map[string]struct{}),
  30856. }
  30857. for _, opt := range opts {
  30858. opt(m)
  30859. }
  30860. return m
  30861. }
  30862. // withUsageStatisticHourID sets the ID field of the mutation.
  30863. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  30864. return func(m *UsageStatisticHourMutation) {
  30865. var (
  30866. err error
  30867. once sync.Once
  30868. value *UsageStatisticHour
  30869. )
  30870. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  30871. once.Do(func() {
  30872. if m.done {
  30873. err = errors.New("querying old values post mutation is not allowed")
  30874. } else {
  30875. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  30876. }
  30877. })
  30878. return value, err
  30879. }
  30880. m.id = &id
  30881. }
  30882. }
  30883. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  30884. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  30885. return func(m *UsageStatisticHourMutation) {
  30886. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  30887. return node, nil
  30888. }
  30889. m.id = &node.ID
  30890. }
  30891. }
  30892. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30893. // executed in a transaction (ent.Tx), a transactional client is returned.
  30894. func (m UsageStatisticHourMutation) Client() *Client {
  30895. client := &Client{config: m.config}
  30896. client.init()
  30897. return client
  30898. }
  30899. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30900. // it returns an error otherwise.
  30901. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  30902. if _, ok := m.driver.(*txDriver); !ok {
  30903. return nil, errors.New("ent: mutation is not running in a transaction")
  30904. }
  30905. tx := &Tx{config: m.config}
  30906. tx.init()
  30907. return tx, nil
  30908. }
  30909. // SetID sets the value of the id field. Note that this
  30910. // operation is only accepted on creation of UsageStatisticHour entities.
  30911. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  30912. m.id = &id
  30913. }
  30914. // ID returns the ID value in the mutation. Note that the ID is only available
  30915. // if it was provided to the builder or after it was returned from the database.
  30916. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  30917. if m.id == nil {
  30918. return
  30919. }
  30920. return *m.id, true
  30921. }
  30922. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30923. // That means, if the mutation is applied within a transaction with an isolation level such
  30924. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30925. // or updated by the mutation.
  30926. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  30927. switch {
  30928. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30929. id, exists := m.ID()
  30930. if exists {
  30931. return []uint64{id}, nil
  30932. }
  30933. fallthrough
  30934. case m.op.Is(OpUpdate | OpDelete):
  30935. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  30936. default:
  30937. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30938. }
  30939. }
  30940. // SetCreatedAt sets the "created_at" field.
  30941. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  30942. m.created_at = &t
  30943. }
  30944. // CreatedAt returns the value of the "created_at" field in the mutation.
  30945. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  30946. v := m.created_at
  30947. if v == nil {
  30948. return
  30949. }
  30950. return *v, true
  30951. }
  30952. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  30953. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30955. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30956. if !m.op.Is(OpUpdateOne) {
  30957. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30958. }
  30959. if m.id == nil || m.oldValue == nil {
  30960. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30961. }
  30962. oldValue, err := m.oldValue(ctx)
  30963. if err != nil {
  30964. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30965. }
  30966. return oldValue.CreatedAt, nil
  30967. }
  30968. // ResetCreatedAt resets all changes to the "created_at" field.
  30969. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  30970. m.created_at = nil
  30971. }
  30972. // SetUpdatedAt sets the "updated_at" field.
  30973. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  30974. m.updated_at = &t
  30975. }
  30976. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30977. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  30978. v := m.updated_at
  30979. if v == nil {
  30980. return
  30981. }
  30982. return *v, true
  30983. }
  30984. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  30985. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30987. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30988. if !m.op.Is(OpUpdateOne) {
  30989. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30990. }
  30991. if m.id == nil || m.oldValue == nil {
  30992. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30993. }
  30994. oldValue, err := m.oldValue(ctx)
  30995. if err != nil {
  30996. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30997. }
  30998. return oldValue.UpdatedAt, nil
  30999. }
  31000. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31001. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  31002. m.updated_at = nil
  31003. }
  31004. // SetStatus sets the "status" field.
  31005. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  31006. m.status = &u
  31007. m.addstatus = nil
  31008. }
  31009. // Status returns the value of the "status" field in the mutation.
  31010. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  31011. v := m.status
  31012. if v == nil {
  31013. return
  31014. }
  31015. return *v, true
  31016. }
  31017. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  31018. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31020. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31021. if !m.op.Is(OpUpdateOne) {
  31022. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31023. }
  31024. if m.id == nil || m.oldValue == nil {
  31025. return v, errors.New("OldStatus requires an ID field in the mutation")
  31026. }
  31027. oldValue, err := m.oldValue(ctx)
  31028. if err != nil {
  31029. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31030. }
  31031. return oldValue.Status, nil
  31032. }
  31033. // AddStatus adds u to the "status" field.
  31034. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  31035. if m.addstatus != nil {
  31036. *m.addstatus += u
  31037. } else {
  31038. m.addstatus = &u
  31039. }
  31040. }
  31041. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31042. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  31043. v := m.addstatus
  31044. if v == nil {
  31045. return
  31046. }
  31047. return *v, true
  31048. }
  31049. // ClearStatus clears the value of the "status" field.
  31050. func (m *UsageStatisticHourMutation) ClearStatus() {
  31051. m.status = nil
  31052. m.addstatus = nil
  31053. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  31054. }
  31055. // StatusCleared returns if the "status" field was cleared in this mutation.
  31056. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  31057. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  31058. return ok
  31059. }
  31060. // ResetStatus resets all changes to the "status" field.
  31061. func (m *UsageStatisticHourMutation) ResetStatus() {
  31062. m.status = nil
  31063. m.addstatus = nil
  31064. delete(m.clearedFields, usagestatistichour.FieldStatus)
  31065. }
  31066. // SetDeletedAt sets the "deleted_at" field.
  31067. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  31068. m.deleted_at = &t
  31069. }
  31070. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31071. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  31072. v := m.deleted_at
  31073. if v == nil {
  31074. return
  31075. }
  31076. return *v, true
  31077. }
  31078. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  31079. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31081. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31082. if !m.op.Is(OpUpdateOne) {
  31083. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31084. }
  31085. if m.id == nil || m.oldValue == nil {
  31086. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31087. }
  31088. oldValue, err := m.oldValue(ctx)
  31089. if err != nil {
  31090. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31091. }
  31092. return oldValue.DeletedAt, nil
  31093. }
  31094. // ClearDeletedAt clears the value of the "deleted_at" field.
  31095. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  31096. m.deleted_at = nil
  31097. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  31098. }
  31099. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31100. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  31101. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  31102. return ok
  31103. }
  31104. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31105. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  31106. m.deleted_at = nil
  31107. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  31108. }
  31109. // SetAddtime sets the "addtime" field.
  31110. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  31111. m.addtime = &u
  31112. m.addaddtime = nil
  31113. }
  31114. // Addtime returns the value of the "addtime" field in the mutation.
  31115. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  31116. v := m.addtime
  31117. if v == nil {
  31118. return
  31119. }
  31120. return *v, true
  31121. }
  31122. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  31123. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31125. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31126. if !m.op.Is(OpUpdateOne) {
  31127. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31128. }
  31129. if m.id == nil || m.oldValue == nil {
  31130. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31131. }
  31132. oldValue, err := m.oldValue(ctx)
  31133. if err != nil {
  31134. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31135. }
  31136. return oldValue.Addtime, nil
  31137. }
  31138. // AddAddtime adds u to the "addtime" field.
  31139. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  31140. if m.addaddtime != nil {
  31141. *m.addaddtime += u
  31142. } else {
  31143. m.addaddtime = &u
  31144. }
  31145. }
  31146. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31147. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  31148. v := m.addaddtime
  31149. if v == nil {
  31150. return
  31151. }
  31152. return *v, true
  31153. }
  31154. // ResetAddtime resets all changes to the "addtime" field.
  31155. func (m *UsageStatisticHourMutation) ResetAddtime() {
  31156. m.addtime = nil
  31157. m.addaddtime = nil
  31158. }
  31159. // SetType sets the "type" field.
  31160. func (m *UsageStatisticHourMutation) SetType(i int) {
  31161. m._type = &i
  31162. m.add_type = nil
  31163. }
  31164. // GetType returns the value of the "type" field in the mutation.
  31165. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  31166. v := m._type
  31167. if v == nil {
  31168. return
  31169. }
  31170. return *v, true
  31171. }
  31172. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  31173. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31175. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  31176. if !m.op.Is(OpUpdateOne) {
  31177. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31178. }
  31179. if m.id == nil || m.oldValue == nil {
  31180. return v, errors.New("OldType requires an ID field in the mutation")
  31181. }
  31182. oldValue, err := m.oldValue(ctx)
  31183. if err != nil {
  31184. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31185. }
  31186. return oldValue.Type, nil
  31187. }
  31188. // AddType adds i to the "type" field.
  31189. func (m *UsageStatisticHourMutation) AddType(i int) {
  31190. if m.add_type != nil {
  31191. *m.add_type += i
  31192. } else {
  31193. m.add_type = &i
  31194. }
  31195. }
  31196. // AddedType returns the value that was added to the "type" field in this mutation.
  31197. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  31198. v := m.add_type
  31199. if v == nil {
  31200. return
  31201. }
  31202. return *v, true
  31203. }
  31204. // ResetType resets all changes to the "type" field.
  31205. func (m *UsageStatisticHourMutation) ResetType() {
  31206. m._type = nil
  31207. m.add_type = nil
  31208. }
  31209. // SetBotID sets the "bot_id" field.
  31210. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  31211. m.bot_id = &s
  31212. }
  31213. // BotID returns the value of the "bot_id" field in the mutation.
  31214. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  31215. v := m.bot_id
  31216. if v == nil {
  31217. return
  31218. }
  31219. return *v, true
  31220. }
  31221. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  31222. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31224. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  31225. if !m.op.Is(OpUpdateOne) {
  31226. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31227. }
  31228. if m.id == nil || m.oldValue == nil {
  31229. return v, errors.New("OldBotID requires an ID field in the mutation")
  31230. }
  31231. oldValue, err := m.oldValue(ctx)
  31232. if err != nil {
  31233. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31234. }
  31235. return oldValue.BotID, nil
  31236. }
  31237. // ClearBotID clears the value of the "bot_id" field.
  31238. func (m *UsageStatisticHourMutation) ClearBotID() {
  31239. m.bot_id = nil
  31240. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  31241. }
  31242. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31243. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  31244. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  31245. return ok
  31246. }
  31247. // ResetBotID resets all changes to the "bot_id" field.
  31248. func (m *UsageStatisticHourMutation) ResetBotID() {
  31249. m.bot_id = nil
  31250. delete(m.clearedFields, usagestatistichour.FieldBotID)
  31251. }
  31252. // SetOrganizationID sets the "organization_id" field.
  31253. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  31254. m.organization_id = &u
  31255. m.addorganization_id = nil
  31256. }
  31257. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31258. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  31259. v := m.organization_id
  31260. if v == nil {
  31261. return
  31262. }
  31263. return *v, true
  31264. }
  31265. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  31266. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31268. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31269. if !m.op.Is(OpUpdateOne) {
  31270. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31271. }
  31272. if m.id == nil || m.oldValue == nil {
  31273. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31274. }
  31275. oldValue, err := m.oldValue(ctx)
  31276. if err != nil {
  31277. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31278. }
  31279. return oldValue.OrganizationID, nil
  31280. }
  31281. // AddOrganizationID adds u to the "organization_id" field.
  31282. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  31283. if m.addorganization_id != nil {
  31284. *m.addorganization_id += u
  31285. } else {
  31286. m.addorganization_id = &u
  31287. }
  31288. }
  31289. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31290. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  31291. v := m.addorganization_id
  31292. if v == nil {
  31293. return
  31294. }
  31295. return *v, true
  31296. }
  31297. // ClearOrganizationID clears the value of the "organization_id" field.
  31298. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  31299. m.organization_id = nil
  31300. m.addorganization_id = nil
  31301. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  31302. }
  31303. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31304. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  31305. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  31306. return ok
  31307. }
  31308. // ResetOrganizationID resets all changes to the "organization_id" field.
  31309. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  31310. m.organization_id = nil
  31311. m.addorganization_id = nil
  31312. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  31313. }
  31314. // SetAiResponse sets the "ai_response" field.
  31315. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  31316. m.ai_response = &u
  31317. m.addai_response = nil
  31318. }
  31319. // AiResponse returns the value of the "ai_response" field in the mutation.
  31320. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  31321. v := m.ai_response
  31322. if v == nil {
  31323. return
  31324. }
  31325. return *v, true
  31326. }
  31327. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  31328. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31330. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31331. if !m.op.Is(OpUpdateOne) {
  31332. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31333. }
  31334. if m.id == nil || m.oldValue == nil {
  31335. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31336. }
  31337. oldValue, err := m.oldValue(ctx)
  31338. if err != nil {
  31339. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31340. }
  31341. return oldValue.AiResponse, nil
  31342. }
  31343. // AddAiResponse adds u to the "ai_response" field.
  31344. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  31345. if m.addai_response != nil {
  31346. *m.addai_response += u
  31347. } else {
  31348. m.addai_response = &u
  31349. }
  31350. }
  31351. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31352. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  31353. v := m.addai_response
  31354. if v == nil {
  31355. return
  31356. }
  31357. return *v, true
  31358. }
  31359. // ResetAiResponse resets all changes to the "ai_response" field.
  31360. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  31361. m.ai_response = nil
  31362. m.addai_response = nil
  31363. }
  31364. // SetSopRun sets the "sop_run" field.
  31365. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  31366. m.sop_run = &u
  31367. m.addsop_run = nil
  31368. }
  31369. // SopRun returns the value of the "sop_run" field in the mutation.
  31370. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  31371. v := m.sop_run
  31372. if v == nil {
  31373. return
  31374. }
  31375. return *v, true
  31376. }
  31377. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  31378. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31380. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31381. if !m.op.Is(OpUpdateOne) {
  31382. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31383. }
  31384. if m.id == nil || m.oldValue == nil {
  31385. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31386. }
  31387. oldValue, err := m.oldValue(ctx)
  31388. if err != nil {
  31389. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31390. }
  31391. return oldValue.SopRun, nil
  31392. }
  31393. // AddSopRun adds u to the "sop_run" field.
  31394. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  31395. if m.addsop_run != nil {
  31396. *m.addsop_run += u
  31397. } else {
  31398. m.addsop_run = &u
  31399. }
  31400. }
  31401. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31402. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  31403. v := m.addsop_run
  31404. if v == nil {
  31405. return
  31406. }
  31407. return *v, true
  31408. }
  31409. // ResetSopRun resets all changes to the "sop_run" field.
  31410. func (m *UsageStatisticHourMutation) ResetSopRun() {
  31411. m.sop_run = nil
  31412. m.addsop_run = nil
  31413. }
  31414. // SetTotalFriend sets the "total_friend" field.
  31415. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  31416. m.total_friend = &u
  31417. m.addtotal_friend = nil
  31418. }
  31419. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31420. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  31421. v := m.total_friend
  31422. if v == nil {
  31423. return
  31424. }
  31425. return *v, true
  31426. }
  31427. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  31428. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31430. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31431. if !m.op.Is(OpUpdateOne) {
  31432. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31433. }
  31434. if m.id == nil || m.oldValue == nil {
  31435. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31436. }
  31437. oldValue, err := m.oldValue(ctx)
  31438. if err != nil {
  31439. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31440. }
  31441. return oldValue.TotalFriend, nil
  31442. }
  31443. // AddTotalFriend adds u to the "total_friend" field.
  31444. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  31445. if m.addtotal_friend != nil {
  31446. *m.addtotal_friend += u
  31447. } else {
  31448. m.addtotal_friend = &u
  31449. }
  31450. }
  31451. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31452. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  31453. v := m.addtotal_friend
  31454. if v == nil {
  31455. return
  31456. }
  31457. return *v, true
  31458. }
  31459. // ResetTotalFriend resets all changes to the "total_friend" field.
  31460. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  31461. m.total_friend = nil
  31462. m.addtotal_friend = nil
  31463. }
  31464. // SetTotalGroup sets the "total_group" field.
  31465. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  31466. m.total_group = &u
  31467. m.addtotal_group = nil
  31468. }
  31469. // TotalGroup returns the value of the "total_group" field in the mutation.
  31470. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  31471. v := m.total_group
  31472. if v == nil {
  31473. return
  31474. }
  31475. return *v, true
  31476. }
  31477. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  31478. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31480. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31481. if !m.op.Is(OpUpdateOne) {
  31482. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31483. }
  31484. if m.id == nil || m.oldValue == nil {
  31485. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31486. }
  31487. oldValue, err := m.oldValue(ctx)
  31488. if err != nil {
  31489. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31490. }
  31491. return oldValue.TotalGroup, nil
  31492. }
  31493. // AddTotalGroup adds u to the "total_group" field.
  31494. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  31495. if m.addtotal_group != nil {
  31496. *m.addtotal_group += u
  31497. } else {
  31498. m.addtotal_group = &u
  31499. }
  31500. }
  31501. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31502. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  31503. v := m.addtotal_group
  31504. if v == nil {
  31505. return
  31506. }
  31507. return *v, true
  31508. }
  31509. // ResetTotalGroup resets all changes to the "total_group" field.
  31510. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  31511. m.total_group = nil
  31512. m.addtotal_group = nil
  31513. }
  31514. // SetAccountBalance sets the "account_balance" field.
  31515. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  31516. m.account_balance = &u
  31517. m.addaccount_balance = nil
  31518. }
  31519. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31520. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  31521. v := m.account_balance
  31522. if v == nil {
  31523. return
  31524. }
  31525. return *v, true
  31526. }
  31527. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  31528. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31530. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31531. if !m.op.Is(OpUpdateOne) {
  31532. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31533. }
  31534. if m.id == nil || m.oldValue == nil {
  31535. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31536. }
  31537. oldValue, err := m.oldValue(ctx)
  31538. if err != nil {
  31539. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31540. }
  31541. return oldValue.AccountBalance, nil
  31542. }
  31543. // AddAccountBalance adds u to the "account_balance" field.
  31544. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  31545. if m.addaccount_balance != nil {
  31546. *m.addaccount_balance += u
  31547. } else {
  31548. m.addaccount_balance = &u
  31549. }
  31550. }
  31551. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31552. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  31553. v := m.addaccount_balance
  31554. if v == nil {
  31555. return
  31556. }
  31557. return *v, true
  31558. }
  31559. // ResetAccountBalance resets all changes to the "account_balance" field.
  31560. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  31561. m.account_balance = nil
  31562. m.addaccount_balance = nil
  31563. }
  31564. // SetConsumeToken sets the "consume_token" field.
  31565. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  31566. m.consume_token = &u
  31567. m.addconsume_token = nil
  31568. }
  31569. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31570. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  31571. v := m.consume_token
  31572. if v == nil {
  31573. return
  31574. }
  31575. return *v, true
  31576. }
  31577. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  31578. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31580. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31581. if !m.op.Is(OpUpdateOne) {
  31582. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31583. }
  31584. if m.id == nil || m.oldValue == nil {
  31585. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31586. }
  31587. oldValue, err := m.oldValue(ctx)
  31588. if err != nil {
  31589. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31590. }
  31591. return oldValue.ConsumeToken, nil
  31592. }
  31593. // AddConsumeToken adds u to the "consume_token" field.
  31594. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  31595. if m.addconsume_token != nil {
  31596. *m.addconsume_token += u
  31597. } else {
  31598. m.addconsume_token = &u
  31599. }
  31600. }
  31601. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31602. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  31603. v := m.addconsume_token
  31604. if v == nil {
  31605. return
  31606. }
  31607. return *v, true
  31608. }
  31609. // ResetConsumeToken resets all changes to the "consume_token" field.
  31610. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  31611. m.consume_token = nil
  31612. m.addconsume_token = nil
  31613. }
  31614. // SetActiveUser sets the "active_user" field.
  31615. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  31616. m.active_user = &u
  31617. m.addactive_user = nil
  31618. }
  31619. // ActiveUser returns the value of the "active_user" field in the mutation.
  31620. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  31621. v := m.active_user
  31622. if v == nil {
  31623. return
  31624. }
  31625. return *v, true
  31626. }
  31627. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  31628. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31630. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31631. if !m.op.Is(OpUpdateOne) {
  31632. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31633. }
  31634. if m.id == nil || m.oldValue == nil {
  31635. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31636. }
  31637. oldValue, err := m.oldValue(ctx)
  31638. if err != nil {
  31639. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31640. }
  31641. return oldValue.ActiveUser, nil
  31642. }
  31643. // AddActiveUser adds u to the "active_user" field.
  31644. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  31645. if m.addactive_user != nil {
  31646. *m.addactive_user += u
  31647. } else {
  31648. m.addactive_user = &u
  31649. }
  31650. }
  31651. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31652. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  31653. v := m.addactive_user
  31654. if v == nil {
  31655. return
  31656. }
  31657. return *v, true
  31658. }
  31659. // ResetActiveUser resets all changes to the "active_user" field.
  31660. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  31661. m.active_user = nil
  31662. m.addactive_user = nil
  31663. }
  31664. // SetNewUser sets the "new_user" field.
  31665. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  31666. m.new_user = &i
  31667. m.addnew_user = nil
  31668. }
  31669. // NewUser returns the value of the "new_user" field in the mutation.
  31670. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  31671. v := m.new_user
  31672. if v == nil {
  31673. return
  31674. }
  31675. return *v, true
  31676. }
  31677. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  31678. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31680. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31681. if !m.op.Is(OpUpdateOne) {
  31682. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31683. }
  31684. if m.id == nil || m.oldValue == nil {
  31685. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31686. }
  31687. oldValue, err := m.oldValue(ctx)
  31688. if err != nil {
  31689. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31690. }
  31691. return oldValue.NewUser, nil
  31692. }
  31693. // AddNewUser adds i to the "new_user" field.
  31694. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  31695. if m.addnew_user != nil {
  31696. *m.addnew_user += i
  31697. } else {
  31698. m.addnew_user = &i
  31699. }
  31700. }
  31701. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31702. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  31703. v := m.addnew_user
  31704. if v == nil {
  31705. return
  31706. }
  31707. return *v, true
  31708. }
  31709. // ResetNewUser resets all changes to the "new_user" field.
  31710. func (m *UsageStatisticHourMutation) ResetNewUser() {
  31711. m.new_user = nil
  31712. m.addnew_user = nil
  31713. }
  31714. // SetLabelDist sets the "label_dist" field.
  31715. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31716. m.label_dist = &ctd
  31717. m.appendlabel_dist = nil
  31718. }
  31719. // LabelDist returns the value of the "label_dist" field in the mutation.
  31720. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31721. v := m.label_dist
  31722. if v == nil {
  31723. return
  31724. }
  31725. return *v, true
  31726. }
  31727. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  31728. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31730. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31731. if !m.op.Is(OpUpdateOne) {
  31732. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31733. }
  31734. if m.id == nil || m.oldValue == nil {
  31735. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31736. }
  31737. oldValue, err := m.oldValue(ctx)
  31738. if err != nil {
  31739. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31740. }
  31741. return oldValue.LabelDist, nil
  31742. }
  31743. // AppendLabelDist adds ctd to the "label_dist" field.
  31744. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31745. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31746. }
  31747. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31748. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31749. if len(m.appendlabel_dist) == 0 {
  31750. return nil, false
  31751. }
  31752. return m.appendlabel_dist, true
  31753. }
  31754. // ResetLabelDist resets all changes to the "label_dist" field.
  31755. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  31756. m.label_dist = nil
  31757. m.appendlabel_dist = nil
  31758. }
  31759. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  31760. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  31761. m.predicates = append(m.predicates, ps...)
  31762. }
  31763. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  31764. // users can use type-assertion to append predicates that do not depend on any generated package.
  31765. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  31766. p := make([]predicate.UsageStatisticHour, len(ps))
  31767. for i := range ps {
  31768. p[i] = ps[i]
  31769. }
  31770. m.Where(p...)
  31771. }
  31772. // Op returns the operation name.
  31773. func (m *UsageStatisticHourMutation) Op() Op {
  31774. return m.op
  31775. }
  31776. // SetOp allows setting the mutation operation.
  31777. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  31778. m.op = op
  31779. }
  31780. // Type returns the node type of this mutation (UsageStatisticHour).
  31781. func (m *UsageStatisticHourMutation) Type() string {
  31782. return m.typ
  31783. }
  31784. // Fields returns all fields that were changed during this mutation. Note that in
  31785. // order to get all numeric fields that were incremented/decremented, call
  31786. // AddedFields().
  31787. func (m *UsageStatisticHourMutation) Fields() []string {
  31788. fields := make([]string, 0, 17)
  31789. if m.created_at != nil {
  31790. fields = append(fields, usagestatistichour.FieldCreatedAt)
  31791. }
  31792. if m.updated_at != nil {
  31793. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  31794. }
  31795. if m.status != nil {
  31796. fields = append(fields, usagestatistichour.FieldStatus)
  31797. }
  31798. if m.deleted_at != nil {
  31799. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31800. }
  31801. if m.addtime != nil {
  31802. fields = append(fields, usagestatistichour.FieldAddtime)
  31803. }
  31804. if m._type != nil {
  31805. fields = append(fields, usagestatistichour.FieldType)
  31806. }
  31807. if m.bot_id != nil {
  31808. fields = append(fields, usagestatistichour.FieldBotID)
  31809. }
  31810. if m.organization_id != nil {
  31811. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31812. }
  31813. if m.ai_response != nil {
  31814. fields = append(fields, usagestatistichour.FieldAiResponse)
  31815. }
  31816. if m.sop_run != nil {
  31817. fields = append(fields, usagestatistichour.FieldSopRun)
  31818. }
  31819. if m.total_friend != nil {
  31820. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31821. }
  31822. if m.total_group != nil {
  31823. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31824. }
  31825. if m.account_balance != nil {
  31826. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31827. }
  31828. if m.consume_token != nil {
  31829. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31830. }
  31831. if m.active_user != nil {
  31832. fields = append(fields, usagestatistichour.FieldActiveUser)
  31833. }
  31834. if m.new_user != nil {
  31835. fields = append(fields, usagestatistichour.FieldNewUser)
  31836. }
  31837. if m.label_dist != nil {
  31838. fields = append(fields, usagestatistichour.FieldLabelDist)
  31839. }
  31840. return fields
  31841. }
  31842. // Field returns the value of a field with the given name. The second boolean
  31843. // return value indicates that this field was not set, or was not defined in the
  31844. // schema.
  31845. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  31846. switch name {
  31847. case usagestatistichour.FieldCreatedAt:
  31848. return m.CreatedAt()
  31849. case usagestatistichour.FieldUpdatedAt:
  31850. return m.UpdatedAt()
  31851. case usagestatistichour.FieldStatus:
  31852. return m.Status()
  31853. case usagestatistichour.FieldDeletedAt:
  31854. return m.DeletedAt()
  31855. case usagestatistichour.FieldAddtime:
  31856. return m.Addtime()
  31857. case usagestatistichour.FieldType:
  31858. return m.GetType()
  31859. case usagestatistichour.FieldBotID:
  31860. return m.BotID()
  31861. case usagestatistichour.FieldOrganizationID:
  31862. return m.OrganizationID()
  31863. case usagestatistichour.FieldAiResponse:
  31864. return m.AiResponse()
  31865. case usagestatistichour.FieldSopRun:
  31866. return m.SopRun()
  31867. case usagestatistichour.FieldTotalFriend:
  31868. return m.TotalFriend()
  31869. case usagestatistichour.FieldTotalGroup:
  31870. return m.TotalGroup()
  31871. case usagestatistichour.FieldAccountBalance:
  31872. return m.AccountBalance()
  31873. case usagestatistichour.FieldConsumeToken:
  31874. return m.ConsumeToken()
  31875. case usagestatistichour.FieldActiveUser:
  31876. return m.ActiveUser()
  31877. case usagestatistichour.FieldNewUser:
  31878. return m.NewUser()
  31879. case usagestatistichour.FieldLabelDist:
  31880. return m.LabelDist()
  31881. }
  31882. return nil, false
  31883. }
  31884. // OldField returns the old value of the field from the database. An error is
  31885. // returned if the mutation operation is not UpdateOne, or the query to the
  31886. // database failed.
  31887. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31888. switch name {
  31889. case usagestatistichour.FieldCreatedAt:
  31890. return m.OldCreatedAt(ctx)
  31891. case usagestatistichour.FieldUpdatedAt:
  31892. return m.OldUpdatedAt(ctx)
  31893. case usagestatistichour.FieldStatus:
  31894. return m.OldStatus(ctx)
  31895. case usagestatistichour.FieldDeletedAt:
  31896. return m.OldDeletedAt(ctx)
  31897. case usagestatistichour.FieldAddtime:
  31898. return m.OldAddtime(ctx)
  31899. case usagestatistichour.FieldType:
  31900. return m.OldType(ctx)
  31901. case usagestatistichour.FieldBotID:
  31902. return m.OldBotID(ctx)
  31903. case usagestatistichour.FieldOrganizationID:
  31904. return m.OldOrganizationID(ctx)
  31905. case usagestatistichour.FieldAiResponse:
  31906. return m.OldAiResponse(ctx)
  31907. case usagestatistichour.FieldSopRun:
  31908. return m.OldSopRun(ctx)
  31909. case usagestatistichour.FieldTotalFriend:
  31910. return m.OldTotalFriend(ctx)
  31911. case usagestatistichour.FieldTotalGroup:
  31912. return m.OldTotalGroup(ctx)
  31913. case usagestatistichour.FieldAccountBalance:
  31914. return m.OldAccountBalance(ctx)
  31915. case usagestatistichour.FieldConsumeToken:
  31916. return m.OldConsumeToken(ctx)
  31917. case usagestatistichour.FieldActiveUser:
  31918. return m.OldActiveUser(ctx)
  31919. case usagestatistichour.FieldNewUser:
  31920. return m.OldNewUser(ctx)
  31921. case usagestatistichour.FieldLabelDist:
  31922. return m.OldLabelDist(ctx)
  31923. }
  31924. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31925. }
  31926. // SetField sets the value of a field with the given name. It returns an error if
  31927. // the field is not defined in the schema, or if the type mismatched the field
  31928. // type.
  31929. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  31930. switch name {
  31931. case usagestatistichour.FieldCreatedAt:
  31932. v, ok := value.(time.Time)
  31933. if !ok {
  31934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31935. }
  31936. m.SetCreatedAt(v)
  31937. return nil
  31938. case usagestatistichour.FieldUpdatedAt:
  31939. v, ok := value.(time.Time)
  31940. if !ok {
  31941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31942. }
  31943. m.SetUpdatedAt(v)
  31944. return nil
  31945. case usagestatistichour.FieldStatus:
  31946. v, ok := value.(uint8)
  31947. if !ok {
  31948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31949. }
  31950. m.SetStatus(v)
  31951. return nil
  31952. case usagestatistichour.FieldDeletedAt:
  31953. v, ok := value.(time.Time)
  31954. if !ok {
  31955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31956. }
  31957. m.SetDeletedAt(v)
  31958. return nil
  31959. case usagestatistichour.FieldAddtime:
  31960. v, ok := value.(uint64)
  31961. if !ok {
  31962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31963. }
  31964. m.SetAddtime(v)
  31965. return nil
  31966. case usagestatistichour.FieldType:
  31967. v, ok := value.(int)
  31968. if !ok {
  31969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31970. }
  31971. m.SetType(v)
  31972. return nil
  31973. case usagestatistichour.FieldBotID:
  31974. v, ok := value.(string)
  31975. if !ok {
  31976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31977. }
  31978. m.SetBotID(v)
  31979. return nil
  31980. case usagestatistichour.FieldOrganizationID:
  31981. v, ok := value.(uint64)
  31982. if !ok {
  31983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31984. }
  31985. m.SetOrganizationID(v)
  31986. return nil
  31987. case usagestatistichour.FieldAiResponse:
  31988. v, ok := value.(uint64)
  31989. if !ok {
  31990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31991. }
  31992. m.SetAiResponse(v)
  31993. return nil
  31994. case usagestatistichour.FieldSopRun:
  31995. v, ok := value.(uint64)
  31996. if !ok {
  31997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31998. }
  31999. m.SetSopRun(v)
  32000. return nil
  32001. case usagestatistichour.FieldTotalFriend:
  32002. v, ok := value.(uint64)
  32003. if !ok {
  32004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32005. }
  32006. m.SetTotalFriend(v)
  32007. return nil
  32008. case usagestatistichour.FieldTotalGroup:
  32009. v, ok := value.(uint64)
  32010. if !ok {
  32011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32012. }
  32013. m.SetTotalGroup(v)
  32014. return nil
  32015. case usagestatistichour.FieldAccountBalance:
  32016. v, ok := value.(uint64)
  32017. if !ok {
  32018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32019. }
  32020. m.SetAccountBalance(v)
  32021. return nil
  32022. case usagestatistichour.FieldConsumeToken:
  32023. v, ok := value.(uint64)
  32024. if !ok {
  32025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32026. }
  32027. m.SetConsumeToken(v)
  32028. return nil
  32029. case usagestatistichour.FieldActiveUser:
  32030. v, ok := value.(uint64)
  32031. if !ok {
  32032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32033. }
  32034. m.SetActiveUser(v)
  32035. return nil
  32036. case usagestatistichour.FieldNewUser:
  32037. v, ok := value.(int64)
  32038. if !ok {
  32039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32040. }
  32041. m.SetNewUser(v)
  32042. return nil
  32043. case usagestatistichour.FieldLabelDist:
  32044. v, ok := value.([]custom_types.LabelDist)
  32045. if !ok {
  32046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32047. }
  32048. m.SetLabelDist(v)
  32049. return nil
  32050. }
  32051. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32052. }
  32053. // AddedFields returns all numeric fields that were incremented/decremented during
  32054. // this mutation.
  32055. func (m *UsageStatisticHourMutation) AddedFields() []string {
  32056. var fields []string
  32057. if m.addstatus != nil {
  32058. fields = append(fields, usagestatistichour.FieldStatus)
  32059. }
  32060. if m.addaddtime != nil {
  32061. fields = append(fields, usagestatistichour.FieldAddtime)
  32062. }
  32063. if m.add_type != nil {
  32064. fields = append(fields, usagestatistichour.FieldType)
  32065. }
  32066. if m.addorganization_id != nil {
  32067. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32068. }
  32069. if m.addai_response != nil {
  32070. fields = append(fields, usagestatistichour.FieldAiResponse)
  32071. }
  32072. if m.addsop_run != nil {
  32073. fields = append(fields, usagestatistichour.FieldSopRun)
  32074. }
  32075. if m.addtotal_friend != nil {
  32076. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32077. }
  32078. if m.addtotal_group != nil {
  32079. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32080. }
  32081. if m.addaccount_balance != nil {
  32082. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32083. }
  32084. if m.addconsume_token != nil {
  32085. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32086. }
  32087. if m.addactive_user != nil {
  32088. fields = append(fields, usagestatistichour.FieldActiveUser)
  32089. }
  32090. if m.addnew_user != nil {
  32091. fields = append(fields, usagestatistichour.FieldNewUser)
  32092. }
  32093. return fields
  32094. }
  32095. // AddedField returns the numeric value that was incremented/decremented on a field
  32096. // with the given name. The second boolean return value indicates that this field
  32097. // was not set, or was not defined in the schema.
  32098. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  32099. switch name {
  32100. case usagestatistichour.FieldStatus:
  32101. return m.AddedStatus()
  32102. case usagestatistichour.FieldAddtime:
  32103. return m.AddedAddtime()
  32104. case usagestatistichour.FieldType:
  32105. return m.AddedType()
  32106. case usagestatistichour.FieldOrganizationID:
  32107. return m.AddedOrganizationID()
  32108. case usagestatistichour.FieldAiResponse:
  32109. return m.AddedAiResponse()
  32110. case usagestatistichour.FieldSopRun:
  32111. return m.AddedSopRun()
  32112. case usagestatistichour.FieldTotalFriend:
  32113. return m.AddedTotalFriend()
  32114. case usagestatistichour.FieldTotalGroup:
  32115. return m.AddedTotalGroup()
  32116. case usagestatistichour.FieldAccountBalance:
  32117. return m.AddedAccountBalance()
  32118. case usagestatistichour.FieldConsumeToken:
  32119. return m.AddedConsumeToken()
  32120. case usagestatistichour.FieldActiveUser:
  32121. return m.AddedActiveUser()
  32122. case usagestatistichour.FieldNewUser:
  32123. return m.AddedNewUser()
  32124. }
  32125. return nil, false
  32126. }
  32127. // AddField adds the value to the field with the given name. It returns an error if
  32128. // the field is not defined in the schema, or if the type mismatched the field
  32129. // type.
  32130. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  32131. switch name {
  32132. case usagestatistichour.FieldStatus:
  32133. v, ok := value.(int8)
  32134. if !ok {
  32135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32136. }
  32137. m.AddStatus(v)
  32138. return nil
  32139. case usagestatistichour.FieldAddtime:
  32140. v, ok := value.(int64)
  32141. if !ok {
  32142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32143. }
  32144. m.AddAddtime(v)
  32145. return nil
  32146. case usagestatistichour.FieldType:
  32147. v, ok := value.(int)
  32148. if !ok {
  32149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32150. }
  32151. m.AddType(v)
  32152. return nil
  32153. case usagestatistichour.FieldOrganizationID:
  32154. v, ok := value.(int64)
  32155. if !ok {
  32156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32157. }
  32158. m.AddOrganizationID(v)
  32159. return nil
  32160. case usagestatistichour.FieldAiResponse:
  32161. v, ok := value.(int64)
  32162. if !ok {
  32163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32164. }
  32165. m.AddAiResponse(v)
  32166. return nil
  32167. case usagestatistichour.FieldSopRun:
  32168. v, ok := value.(int64)
  32169. if !ok {
  32170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32171. }
  32172. m.AddSopRun(v)
  32173. return nil
  32174. case usagestatistichour.FieldTotalFriend:
  32175. v, ok := value.(int64)
  32176. if !ok {
  32177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32178. }
  32179. m.AddTotalFriend(v)
  32180. return nil
  32181. case usagestatistichour.FieldTotalGroup:
  32182. v, ok := value.(int64)
  32183. if !ok {
  32184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32185. }
  32186. m.AddTotalGroup(v)
  32187. return nil
  32188. case usagestatistichour.FieldAccountBalance:
  32189. v, ok := value.(int64)
  32190. if !ok {
  32191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32192. }
  32193. m.AddAccountBalance(v)
  32194. return nil
  32195. case usagestatistichour.FieldConsumeToken:
  32196. v, ok := value.(int64)
  32197. if !ok {
  32198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32199. }
  32200. m.AddConsumeToken(v)
  32201. return nil
  32202. case usagestatistichour.FieldActiveUser:
  32203. v, ok := value.(int64)
  32204. if !ok {
  32205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32206. }
  32207. m.AddActiveUser(v)
  32208. return nil
  32209. case usagestatistichour.FieldNewUser:
  32210. v, ok := value.(int64)
  32211. if !ok {
  32212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32213. }
  32214. m.AddNewUser(v)
  32215. return nil
  32216. }
  32217. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  32218. }
  32219. // ClearedFields returns all nullable fields that were cleared during this
  32220. // mutation.
  32221. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  32222. var fields []string
  32223. if m.FieldCleared(usagestatistichour.FieldStatus) {
  32224. fields = append(fields, usagestatistichour.FieldStatus)
  32225. }
  32226. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  32227. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32228. }
  32229. if m.FieldCleared(usagestatistichour.FieldBotID) {
  32230. fields = append(fields, usagestatistichour.FieldBotID)
  32231. }
  32232. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  32233. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32234. }
  32235. return fields
  32236. }
  32237. // FieldCleared returns a boolean indicating if a field with the given name was
  32238. // cleared in this mutation.
  32239. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  32240. _, ok := m.clearedFields[name]
  32241. return ok
  32242. }
  32243. // ClearField clears the value of the field with the given name. It returns an
  32244. // error if the field is not defined in the schema.
  32245. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  32246. switch name {
  32247. case usagestatistichour.FieldStatus:
  32248. m.ClearStatus()
  32249. return nil
  32250. case usagestatistichour.FieldDeletedAt:
  32251. m.ClearDeletedAt()
  32252. return nil
  32253. case usagestatistichour.FieldBotID:
  32254. m.ClearBotID()
  32255. return nil
  32256. case usagestatistichour.FieldOrganizationID:
  32257. m.ClearOrganizationID()
  32258. return nil
  32259. }
  32260. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  32261. }
  32262. // ResetField resets all changes in the mutation for the field with the given name.
  32263. // It returns an error if the field is not defined in the schema.
  32264. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  32265. switch name {
  32266. case usagestatistichour.FieldCreatedAt:
  32267. m.ResetCreatedAt()
  32268. return nil
  32269. case usagestatistichour.FieldUpdatedAt:
  32270. m.ResetUpdatedAt()
  32271. return nil
  32272. case usagestatistichour.FieldStatus:
  32273. m.ResetStatus()
  32274. return nil
  32275. case usagestatistichour.FieldDeletedAt:
  32276. m.ResetDeletedAt()
  32277. return nil
  32278. case usagestatistichour.FieldAddtime:
  32279. m.ResetAddtime()
  32280. return nil
  32281. case usagestatistichour.FieldType:
  32282. m.ResetType()
  32283. return nil
  32284. case usagestatistichour.FieldBotID:
  32285. m.ResetBotID()
  32286. return nil
  32287. case usagestatistichour.FieldOrganizationID:
  32288. m.ResetOrganizationID()
  32289. return nil
  32290. case usagestatistichour.FieldAiResponse:
  32291. m.ResetAiResponse()
  32292. return nil
  32293. case usagestatistichour.FieldSopRun:
  32294. m.ResetSopRun()
  32295. return nil
  32296. case usagestatistichour.FieldTotalFriend:
  32297. m.ResetTotalFriend()
  32298. return nil
  32299. case usagestatistichour.FieldTotalGroup:
  32300. m.ResetTotalGroup()
  32301. return nil
  32302. case usagestatistichour.FieldAccountBalance:
  32303. m.ResetAccountBalance()
  32304. return nil
  32305. case usagestatistichour.FieldConsumeToken:
  32306. m.ResetConsumeToken()
  32307. return nil
  32308. case usagestatistichour.FieldActiveUser:
  32309. m.ResetActiveUser()
  32310. return nil
  32311. case usagestatistichour.FieldNewUser:
  32312. m.ResetNewUser()
  32313. return nil
  32314. case usagestatistichour.FieldLabelDist:
  32315. m.ResetLabelDist()
  32316. return nil
  32317. }
  32318. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32319. }
  32320. // AddedEdges returns all edge names that were set/added in this mutation.
  32321. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  32322. edges := make([]string, 0, 0)
  32323. return edges
  32324. }
  32325. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32326. // name in this mutation.
  32327. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  32328. return nil
  32329. }
  32330. // RemovedEdges returns all edge names that were removed in this mutation.
  32331. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  32332. edges := make([]string, 0, 0)
  32333. return edges
  32334. }
  32335. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32336. // the given name in this mutation.
  32337. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  32338. return nil
  32339. }
  32340. // ClearedEdges returns all edge names that were cleared in this mutation.
  32341. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  32342. edges := make([]string, 0, 0)
  32343. return edges
  32344. }
  32345. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32346. // was cleared in this mutation.
  32347. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  32348. return false
  32349. }
  32350. // ClearEdge clears the value of the edge with the given name. It returns an error
  32351. // if that edge is not defined in the schema.
  32352. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  32353. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  32354. }
  32355. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32356. // It returns an error if the edge is not defined in the schema.
  32357. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  32358. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  32359. }
  32360. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  32361. type UsageStatisticMonthMutation struct {
  32362. config
  32363. op Op
  32364. typ string
  32365. id *uint64
  32366. created_at *time.Time
  32367. updated_at *time.Time
  32368. status *uint8
  32369. addstatus *int8
  32370. deleted_at *time.Time
  32371. addtime *uint64
  32372. addaddtime *int64
  32373. _type *int
  32374. add_type *int
  32375. bot_id *string
  32376. organization_id *uint64
  32377. addorganization_id *int64
  32378. ai_response *uint64
  32379. addai_response *int64
  32380. sop_run *uint64
  32381. addsop_run *int64
  32382. total_friend *uint64
  32383. addtotal_friend *int64
  32384. total_group *uint64
  32385. addtotal_group *int64
  32386. account_balance *uint64
  32387. addaccount_balance *int64
  32388. consume_token *uint64
  32389. addconsume_token *int64
  32390. active_user *uint64
  32391. addactive_user *int64
  32392. new_user *int64
  32393. addnew_user *int64
  32394. label_dist *[]custom_types.LabelDist
  32395. appendlabel_dist []custom_types.LabelDist
  32396. clearedFields map[string]struct{}
  32397. done bool
  32398. oldValue func(context.Context) (*UsageStatisticMonth, error)
  32399. predicates []predicate.UsageStatisticMonth
  32400. }
  32401. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  32402. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  32403. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  32404. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  32405. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  32406. m := &UsageStatisticMonthMutation{
  32407. config: c,
  32408. op: op,
  32409. typ: TypeUsageStatisticMonth,
  32410. clearedFields: make(map[string]struct{}),
  32411. }
  32412. for _, opt := range opts {
  32413. opt(m)
  32414. }
  32415. return m
  32416. }
  32417. // withUsageStatisticMonthID sets the ID field of the mutation.
  32418. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  32419. return func(m *UsageStatisticMonthMutation) {
  32420. var (
  32421. err error
  32422. once sync.Once
  32423. value *UsageStatisticMonth
  32424. )
  32425. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  32426. once.Do(func() {
  32427. if m.done {
  32428. err = errors.New("querying old values post mutation is not allowed")
  32429. } else {
  32430. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  32431. }
  32432. })
  32433. return value, err
  32434. }
  32435. m.id = &id
  32436. }
  32437. }
  32438. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  32439. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  32440. return func(m *UsageStatisticMonthMutation) {
  32441. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  32442. return node, nil
  32443. }
  32444. m.id = &node.ID
  32445. }
  32446. }
  32447. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32448. // executed in a transaction (ent.Tx), a transactional client is returned.
  32449. func (m UsageStatisticMonthMutation) Client() *Client {
  32450. client := &Client{config: m.config}
  32451. client.init()
  32452. return client
  32453. }
  32454. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32455. // it returns an error otherwise.
  32456. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  32457. if _, ok := m.driver.(*txDriver); !ok {
  32458. return nil, errors.New("ent: mutation is not running in a transaction")
  32459. }
  32460. tx := &Tx{config: m.config}
  32461. tx.init()
  32462. return tx, nil
  32463. }
  32464. // SetID sets the value of the id field. Note that this
  32465. // operation is only accepted on creation of UsageStatisticMonth entities.
  32466. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  32467. m.id = &id
  32468. }
  32469. // ID returns the ID value in the mutation. Note that the ID is only available
  32470. // if it was provided to the builder or after it was returned from the database.
  32471. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  32472. if m.id == nil {
  32473. return
  32474. }
  32475. return *m.id, true
  32476. }
  32477. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32478. // That means, if the mutation is applied within a transaction with an isolation level such
  32479. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32480. // or updated by the mutation.
  32481. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  32482. switch {
  32483. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32484. id, exists := m.ID()
  32485. if exists {
  32486. return []uint64{id}, nil
  32487. }
  32488. fallthrough
  32489. case m.op.Is(OpUpdate | OpDelete):
  32490. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  32491. default:
  32492. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32493. }
  32494. }
  32495. // SetCreatedAt sets the "created_at" field.
  32496. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  32497. m.created_at = &t
  32498. }
  32499. // CreatedAt returns the value of the "created_at" field in the mutation.
  32500. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  32501. v := m.created_at
  32502. if v == nil {
  32503. return
  32504. }
  32505. return *v, true
  32506. }
  32507. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  32508. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32510. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32511. if !m.op.Is(OpUpdateOne) {
  32512. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32513. }
  32514. if m.id == nil || m.oldValue == nil {
  32515. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32516. }
  32517. oldValue, err := m.oldValue(ctx)
  32518. if err != nil {
  32519. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32520. }
  32521. return oldValue.CreatedAt, nil
  32522. }
  32523. // ResetCreatedAt resets all changes to the "created_at" field.
  32524. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  32525. m.created_at = nil
  32526. }
  32527. // SetUpdatedAt sets the "updated_at" field.
  32528. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  32529. m.updated_at = &t
  32530. }
  32531. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32532. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  32533. v := m.updated_at
  32534. if v == nil {
  32535. return
  32536. }
  32537. return *v, true
  32538. }
  32539. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  32540. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32542. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32543. if !m.op.Is(OpUpdateOne) {
  32544. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32545. }
  32546. if m.id == nil || m.oldValue == nil {
  32547. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32548. }
  32549. oldValue, err := m.oldValue(ctx)
  32550. if err != nil {
  32551. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32552. }
  32553. return oldValue.UpdatedAt, nil
  32554. }
  32555. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32556. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  32557. m.updated_at = nil
  32558. }
  32559. // SetStatus sets the "status" field.
  32560. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  32561. m.status = &u
  32562. m.addstatus = nil
  32563. }
  32564. // Status returns the value of the "status" field in the mutation.
  32565. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  32566. v := m.status
  32567. if v == nil {
  32568. return
  32569. }
  32570. return *v, true
  32571. }
  32572. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  32573. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32575. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32576. if !m.op.Is(OpUpdateOne) {
  32577. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32578. }
  32579. if m.id == nil || m.oldValue == nil {
  32580. return v, errors.New("OldStatus requires an ID field in the mutation")
  32581. }
  32582. oldValue, err := m.oldValue(ctx)
  32583. if err != nil {
  32584. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32585. }
  32586. return oldValue.Status, nil
  32587. }
  32588. // AddStatus adds u to the "status" field.
  32589. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  32590. if m.addstatus != nil {
  32591. *m.addstatus += u
  32592. } else {
  32593. m.addstatus = &u
  32594. }
  32595. }
  32596. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32597. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  32598. v := m.addstatus
  32599. if v == nil {
  32600. return
  32601. }
  32602. return *v, true
  32603. }
  32604. // ClearStatus clears the value of the "status" field.
  32605. func (m *UsageStatisticMonthMutation) ClearStatus() {
  32606. m.status = nil
  32607. m.addstatus = nil
  32608. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  32609. }
  32610. // StatusCleared returns if the "status" field was cleared in this mutation.
  32611. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  32612. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  32613. return ok
  32614. }
  32615. // ResetStatus resets all changes to the "status" field.
  32616. func (m *UsageStatisticMonthMutation) ResetStatus() {
  32617. m.status = nil
  32618. m.addstatus = nil
  32619. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  32620. }
  32621. // SetDeletedAt sets the "deleted_at" field.
  32622. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  32623. m.deleted_at = &t
  32624. }
  32625. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32626. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  32627. v := m.deleted_at
  32628. if v == nil {
  32629. return
  32630. }
  32631. return *v, true
  32632. }
  32633. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  32634. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32636. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32637. if !m.op.Is(OpUpdateOne) {
  32638. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32639. }
  32640. if m.id == nil || m.oldValue == nil {
  32641. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32642. }
  32643. oldValue, err := m.oldValue(ctx)
  32644. if err != nil {
  32645. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32646. }
  32647. return oldValue.DeletedAt, nil
  32648. }
  32649. // ClearDeletedAt clears the value of the "deleted_at" field.
  32650. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  32651. m.deleted_at = nil
  32652. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  32653. }
  32654. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32655. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  32656. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  32657. return ok
  32658. }
  32659. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32660. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  32661. m.deleted_at = nil
  32662. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  32663. }
  32664. // SetAddtime sets the "addtime" field.
  32665. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  32666. m.addtime = &u
  32667. m.addaddtime = nil
  32668. }
  32669. // Addtime returns the value of the "addtime" field in the mutation.
  32670. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  32671. v := m.addtime
  32672. if v == nil {
  32673. return
  32674. }
  32675. return *v, true
  32676. }
  32677. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  32678. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32680. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32681. if !m.op.Is(OpUpdateOne) {
  32682. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32683. }
  32684. if m.id == nil || m.oldValue == nil {
  32685. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32686. }
  32687. oldValue, err := m.oldValue(ctx)
  32688. if err != nil {
  32689. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32690. }
  32691. return oldValue.Addtime, nil
  32692. }
  32693. // AddAddtime adds u to the "addtime" field.
  32694. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  32695. if m.addaddtime != nil {
  32696. *m.addaddtime += u
  32697. } else {
  32698. m.addaddtime = &u
  32699. }
  32700. }
  32701. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32702. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  32703. v := m.addaddtime
  32704. if v == nil {
  32705. return
  32706. }
  32707. return *v, true
  32708. }
  32709. // ResetAddtime resets all changes to the "addtime" field.
  32710. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  32711. m.addtime = nil
  32712. m.addaddtime = nil
  32713. }
  32714. // SetType sets the "type" field.
  32715. func (m *UsageStatisticMonthMutation) SetType(i int) {
  32716. m._type = &i
  32717. m.add_type = nil
  32718. }
  32719. // GetType returns the value of the "type" field in the mutation.
  32720. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  32721. v := m._type
  32722. if v == nil {
  32723. return
  32724. }
  32725. return *v, true
  32726. }
  32727. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  32728. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32730. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  32731. if !m.op.Is(OpUpdateOne) {
  32732. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32733. }
  32734. if m.id == nil || m.oldValue == nil {
  32735. return v, errors.New("OldType requires an ID field in the mutation")
  32736. }
  32737. oldValue, err := m.oldValue(ctx)
  32738. if err != nil {
  32739. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32740. }
  32741. return oldValue.Type, nil
  32742. }
  32743. // AddType adds i to the "type" field.
  32744. func (m *UsageStatisticMonthMutation) AddType(i int) {
  32745. if m.add_type != nil {
  32746. *m.add_type += i
  32747. } else {
  32748. m.add_type = &i
  32749. }
  32750. }
  32751. // AddedType returns the value that was added to the "type" field in this mutation.
  32752. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  32753. v := m.add_type
  32754. if v == nil {
  32755. return
  32756. }
  32757. return *v, true
  32758. }
  32759. // ResetType resets all changes to the "type" field.
  32760. func (m *UsageStatisticMonthMutation) ResetType() {
  32761. m._type = nil
  32762. m.add_type = nil
  32763. }
  32764. // SetBotID sets the "bot_id" field.
  32765. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  32766. m.bot_id = &s
  32767. }
  32768. // BotID returns the value of the "bot_id" field in the mutation.
  32769. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  32770. v := m.bot_id
  32771. if v == nil {
  32772. return
  32773. }
  32774. return *v, true
  32775. }
  32776. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  32777. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32779. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  32780. if !m.op.Is(OpUpdateOne) {
  32781. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32782. }
  32783. if m.id == nil || m.oldValue == nil {
  32784. return v, errors.New("OldBotID requires an ID field in the mutation")
  32785. }
  32786. oldValue, err := m.oldValue(ctx)
  32787. if err != nil {
  32788. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32789. }
  32790. return oldValue.BotID, nil
  32791. }
  32792. // ClearBotID clears the value of the "bot_id" field.
  32793. func (m *UsageStatisticMonthMutation) ClearBotID() {
  32794. m.bot_id = nil
  32795. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  32796. }
  32797. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32798. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  32799. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  32800. return ok
  32801. }
  32802. // ResetBotID resets all changes to the "bot_id" field.
  32803. func (m *UsageStatisticMonthMutation) ResetBotID() {
  32804. m.bot_id = nil
  32805. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  32806. }
  32807. // SetOrganizationID sets the "organization_id" field.
  32808. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  32809. m.organization_id = &u
  32810. m.addorganization_id = nil
  32811. }
  32812. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32813. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  32814. v := m.organization_id
  32815. if v == nil {
  32816. return
  32817. }
  32818. return *v, true
  32819. }
  32820. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  32821. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32823. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32824. if !m.op.Is(OpUpdateOne) {
  32825. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32826. }
  32827. if m.id == nil || m.oldValue == nil {
  32828. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32829. }
  32830. oldValue, err := m.oldValue(ctx)
  32831. if err != nil {
  32832. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32833. }
  32834. return oldValue.OrganizationID, nil
  32835. }
  32836. // AddOrganizationID adds u to the "organization_id" field.
  32837. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  32838. if m.addorganization_id != nil {
  32839. *m.addorganization_id += u
  32840. } else {
  32841. m.addorganization_id = &u
  32842. }
  32843. }
  32844. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32845. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  32846. v := m.addorganization_id
  32847. if v == nil {
  32848. return
  32849. }
  32850. return *v, true
  32851. }
  32852. // ClearOrganizationID clears the value of the "organization_id" field.
  32853. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  32854. m.organization_id = nil
  32855. m.addorganization_id = nil
  32856. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  32857. }
  32858. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32859. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  32860. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  32861. return ok
  32862. }
  32863. // ResetOrganizationID resets all changes to the "organization_id" field.
  32864. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  32865. m.organization_id = nil
  32866. m.addorganization_id = nil
  32867. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  32868. }
  32869. // SetAiResponse sets the "ai_response" field.
  32870. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  32871. m.ai_response = &u
  32872. m.addai_response = nil
  32873. }
  32874. // AiResponse returns the value of the "ai_response" field in the mutation.
  32875. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  32876. v := m.ai_response
  32877. if v == nil {
  32878. return
  32879. }
  32880. return *v, true
  32881. }
  32882. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  32883. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32885. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32886. if !m.op.Is(OpUpdateOne) {
  32887. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32888. }
  32889. if m.id == nil || m.oldValue == nil {
  32890. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32891. }
  32892. oldValue, err := m.oldValue(ctx)
  32893. if err != nil {
  32894. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32895. }
  32896. return oldValue.AiResponse, nil
  32897. }
  32898. // AddAiResponse adds u to the "ai_response" field.
  32899. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  32900. if m.addai_response != nil {
  32901. *m.addai_response += u
  32902. } else {
  32903. m.addai_response = &u
  32904. }
  32905. }
  32906. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32907. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  32908. v := m.addai_response
  32909. if v == nil {
  32910. return
  32911. }
  32912. return *v, true
  32913. }
  32914. // ResetAiResponse resets all changes to the "ai_response" field.
  32915. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  32916. m.ai_response = nil
  32917. m.addai_response = nil
  32918. }
  32919. // SetSopRun sets the "sop_run" field.
  32920. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  32921. m.sop_run = &u
  32922. m.addsop_run = nil
  32923. }
  32924. // SopRun returns the value of the "sop_run" field in the mutation.
  32925. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  32926. v := m.sop_run
  32927. if v == nil {
  32928. return
  32929. }
  32930. return *v, true
  32931. }
  32932. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  32933. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32935. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32936. if !m.op.Is(OpUpdateOne) {
  32937. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32938. }
  32939. if m.id == nil || m.oldValue == nil {
  32940. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32941. }
  32942. oldValue, err := m.oldValue(ctx)
  32943. if err != nil {
  32944. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32945. }
  32946. return oldValue.SopRun, nil
  32947. }
  32948. // AddSopRun adds u to the "sop_run" field.
  32949. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  32950. if m.addsop_run != nil {
  32951. *m.addsop_run += u
  32952. } else {
  32953. m.addsop_run = &u
  32954. }
  32955. }
  32956. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32957. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  32958. v := m.addsop_run
  32959. if v == nil {
  32960. return
  32961. }
  32962. return *v, true
  32963. }
  32964. // ResetSopRun resets all changes to the "sop_run" field.
  32965. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  32966. m.sop_run = nil
  32967. m.addsop_run = nil
  32968. }
  32969. // SetTotalFriend sets the "total_friend" field.
  32970. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  32971. m.total_friend = &u
  32972. m.addtotal_friend = nil
  32973. }
  32974. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32975. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  32976. v := m.total_friend
  32977. if v == nil {
  32978. return
  32979. }
  32980. return *v, true
  32981. }
  32982. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  32983. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32985. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32986. if !m.op.Is(OpUpdateOne) {
  32987. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32988. }
  32989. if m.id == nil || m.oldValue == nil {
  32990. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32991. }
  32992. oldValue, err := m.oldValue(ctx)
  32993. if err != nil {
  32994. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32995. }
  32996. return oldValue.TotalFriend, nil
  32997. }
  32998. // AddTotalFriend adds u to the "total_friend" field.
  32999. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  33000. if m.addtotal_friend != nil {
  33001. *m.addtotal_friend += u
  33002. } else {
  33003. m.addtotal_friend = &u
  33004. }
  33005. }
  33006. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  33007. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  33008. v := m.addtotal_friend
  33009. if v == nil {
  33010. return
  33011. }
  33012. return *v, true
  33013. }
  33014. // ResetTotalFriend resets all changes to the "total_friend" field.
  33015. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  33016. m.total_friend = nil
  33017. m.addtotal_friend = nil
  33018. }
  33019. // SetTotalGroup sets the "total_group" field.
  33020. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  33021. m.total_group = &u
  33022. m.addtotal_group = nil
  33023. }
  33024. // TotalGroup returns the value of the "total_group" field in the mutation.
  33025. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  33026. v := m.total_group
  33027. if v == nil {
  33028. return
  33029. }
  33030. return *v, true
  33031. }
  33032. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  33033. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33035. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  33036. if !m.op.Is(OpUpdateOne) {
  33037. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33038. }
  33039. if m.id == nil || m.oldValue == nil {
  33040. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  33041. }
  33042. oldValue, err := m.oldValue(ctx)
  33043. if err != nil {
  33044. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  33045. }
  33046. return oldValue.TotalGroup, nil
  33047. }
  33048. // AddTotalGroup adds u to the "total_group" field.
  33049. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  33050. if m.addtotal_group != nil {
  33051. *m.addtotal_group += u
  33052. } else {
  33053. m.addtotal_group = &u
  33054. }
  33055. }
  33056. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33057. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  33058. v := m.addtotal_group
  33059. if v == nil {
  33060. return
  33061. }
  33062. return *v, true
  33063. }
  33064. // ResetTotalGroup resets all changes to the "total_group" field.
  33065. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  33066. m.total_group = nil
  33067. m.addtotal_group = nil
  33068. }
  33069. // SetAccountBalance sets the "account_balance" field.
  33070. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  33071. m.account_balance = &u
  33072. m.addaccount_balance = nil
  33073. }
  33074. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33075. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  33076. v := m.account_balance
  33077. if v == nil {
  33078. return
  33079. }
  33080. return *v, true
  33081. }
  33082. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  33083. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33085. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33086. if !m.op.Is(OpUpdateOne) {
  33087. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33088. }
  33089. if m.id == nil || m.oldValue == nil {
  33090. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33091. }
  33092. oldValue, err := m.oldValue(ctx)
  33093. if err != nil {
  33094. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33095. }
  33096. return oldValue.AccountBalance, nil
  33097. }
  33098. // AddAccountBalance adds u to the "account_balance" field.
  33099. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  33100. if m.addaccount_balance != nil {
  33101. *m.addaccount_balance += u
  33102. } else {
  33103. m.addaccount_balance = &u
  33104. }
  33105. }
  33106. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33107. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  33108. v := m.addaccount_balance
  33109. if v == nil {
  33110. return
  33111. }
  33112. return *v, true
  33113. }
  33114. // ResetAccountBalance resets all changes to the "account_balance" field.
  33115. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  33116. m.account_balance = nil
  33117. m.addaccount_balance = nil
  33118. }
  33119. // SetConsumeToken sets the "consume_token" field.
  33120. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  33121. m.consume_token = &u
  33122. m.addconsume_token = nil
  33123. }
  33124. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33125. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  33126. v := m.consume_token
  33127. if v == nil {
  33128. return
  33129. }
  33130. return *v, true
  33131. }
  33132. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  33133. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33135. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33136. if !m.op.Is(OpUpdateOne) {
  33137. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33138. }
  33139. if m.id == nil || m.oldValue == nil {
  33140. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33141. }
  33142. oldValue, err := m.oldValue(ctx)
  33143. if err != nil {
  33144. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33145. }
  33146. return oldValue.ConsumeToken, nil
  33147. }
  33148. // AddConsumeToken adds u to the "consume_token" field.
  33149. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  33150. if m.addconsume_token != nil {
  33151. *m.addconsume_token += u
  33152. } else {
  33153. m.addconsume_token = &u
  33154. }
  33155. }
  33156. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33157. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  33158. v := m.addconsume_token
  33159. if v == nil {
  33160. return
  33161. }
  33162. return *v, true
  33163. }
  33164. // ResetConsumeToken resets all changes to the "consume_token" field.
  33165. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  33166. m.consume_token = nil
  33167. m.addconsume_token = nil
  33168. }
  33169. // SetActiveUser sets the "active_user" field.
  33170. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  33171. m.active_user = &u
  33172. m.addactive_user = nil
  33173. }
  33174. // ActiveUser returns the value of the "active_user" field in the mutation.
  33175. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  33176. v := m.active_user
  33177. if v == nil {
  33178. return
  33179. }
  33180. return *v, true
  33181. }
  33182. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  33183. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33185. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33186. if !m.op.Is(OpUpdateOne) {
  33187. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33188. }
  33189. if m.id == nil || m.oldValue == nil {
  33190. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33191. }
  33192. oldValue, err := m.oldValue(ctx)
  33193. if err != nil {
  33194. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33195. }
  33196. return oldValue.ActiveUser, nil
  33197. }
  33198. // AddActiveUser adds u to the "active_user" field.
  33199. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  33200. if m.addactive_user != nil {
  33201. *m.addactive_user += u
  33202. } else {
  33203. m.addactive_user = &u
  33204. }
  33205. }
  33206. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33207. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  33208. v := m.addactive_user
  33209. if v == nil {
  33210. return
  33211. }
  33212. return *v, true
  33213. }
  33214. // ResetActiveUser resets all changes to the "active_user" field.
  33215. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  33216. m.active_user = nil
  33217. m.addactive_user = nil
  33218. }
  33219. // SetNewUser sets the "new_user" field.
  33220. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  33221. m.new_user = &i
  33222. m.addnew_user = nil
  33223. }
  33224. // NewUser returns the value of the "new_user" field in the mutation.
  33225. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  33226. v := m.new_user
  33227. if v == nil {
  33228. return
  33229. }
  33230. return *v, true
  33231. }
  33232. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  33233. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33235. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33236. if !m.op.Is(OpUpdateOne) {
  33237. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33238. }
  33239. if m.id == nil || m.oldValue == nil {
  33240. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33241. }
  33242. oldValue, err := m.oldValue(ctx)
  33243. if err != nil {
  33244. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33245. }
  33246. return oldValue.NewUser, nil
  33247. }
  33248. // AddNewUser adds i to the "new_user" field.
  33249. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  33250. if m.addnew_user != nil {
  33251. *m.addnew_user += i
  33252. } else {
  33253. m.addnew_user = &i
  33254. }
  33255. }
  33256. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33257. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  33258. v := m.addnew_user
  33259. if v == nil {
  33260. return
  33261. }
  33262. return *v, true
  33263. }
  33264. // ResetNewUser resets all changes to the "new_user" field.
  33265. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  33266. m.new_user = nil
  33267. m.addnew_user = nil
  33268. }
  33269. // SetLabelDist sets the "label_dist" field.
  33270. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33271. m.label_dist = &ctd
  33272. m.appendlabel_dist = nil
  33273. }
  33274. // LabelDist returns the value of the "label_dist" field in the mutation.
  33275. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33276. v := m.label_dist
  33277. if v == nil {
  33278. return
  33279. }
  33280. return *v, true
  33281. }
  33282. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  33283. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33285. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33286. if !m.op.Is(OpUpdateOne) {
  33287. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33288. }
  33289. if m.id == nil || m.oldValue == nil {
  33290. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33291. }
  33292. oldValue, err := m.oldValue(ctx)
  33293. if err != nil {
  33294. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33295. }
  33296. return oldValue.LabelDist, nil
  33297. }
  33298. // AppendLabelDist adds ctd to the "label_dist" field.
  33299. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33300. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33301. }
  33302. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33303. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33304. if len(m.appendlabel_dist) == 0 {
  33305. return nil, false
  33306. }
  33307. return m.appendlabel_dist, true
  33308. }
  33309. // ResetLabelDist resets all changes to the "label_dist" field.
  33310. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  33311. m.label_dist = nil
  33312. m.appendlabel_dist = nil
  33313. }
  33314. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  33315. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  33316. m.predicates = append(m.predicates, ps...)
  33317. }
  33318. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  33319. // users can use type-assertion to append predicates that do not depend on any generated package.
  33320. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  33321. p := make([]predicate.UsageStatisticMonth, len(ps))
  33322. for i := range ps {
  33323. p[i] = ps[i]
  33324. }
  33325. m.Where(p...)
  33326. }
  33327. // Op returns the operation name.
  33328. func (m *UsageStatisticMonthMutation) Op() Op {
  33329. return m.op
  33330. }
  33331. // SetOp allows setting the mutation operation.
  33332. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  33333. m.op = op
  33334. }
  33335. // Type returns the node type of this mutation (UsageStatisticMonth).
  33336. func (m *UsageStatisticMonthMutation) Type() string {
  33337. return m.typ
  33338. }
  33339. // Fields returns all fields that were changed during this mutation. Note that in
  33340. // order to get all numeric fields that were incremented/decremented, call
  33341. // AddedFields().
  33342. func (m *UsageStatisticMonthMutation) Fields() []string {
  33343. fields := make([]string, 0, 17)
  33344. if m.created_at != nil {
  33345. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  33346. }
  33347. if m.updated_at != nil {
  33348. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  33349. }
  33350. if m.status != nil {
  33351. fields = append(fields, usagestatisticmonth.FieldStatus)
  33352. }
  33353. if m.deleted_at != nil {
  33354. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33355. }
  33356. if m.addtime != nil {
  33357. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33358. }
  33359. if m._type != nil {
  33360. fields = append(fields, usagestatisticmonth.FieldType)
  33361. }
  33362. if m.bot_id != nil {
  33363. fields = append(fields, usagestatisticmonth.FieldBotID)
  33364. }
  33365. if m.organization_id != nil {
  33366. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33367. }
  33368. if m.ai_response != nil {
  33369. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33370. }
  33371. if m.sop_run != nil {
  33372. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33373. }
  33374. if m.total_friend != nil {
  33375. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33376. }
  33377. if m.total_group != nil {
  33378. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33379. }
  33380. if m.account_balance != nil {
  33381. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33382. }
  33383. if m.consume_token != nil {
  33384. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33385. }
  33386. if m.active_user != nil {
  33387. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33388. }
  33389. if m.new_user != nil {
  33390. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33391. }
  33392. if m.label_dist != nil {
  33393. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  33394. }
  33395. return fields
  33396. }
  33397. // Field returns the value of a field with the given name. The second boolean
  33398. // return value indicates that this field was not set, or was not defined in the
  33399. // schema.
  33400. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  33401. switch name {
  33402. case usagestatisticmonth.FieldCreatedAt:
  33403. return m.CreatedAt()
  33404. case usagestatisticmonth.FieldUpdatedAt:
  33405. return m.UpdatedAt()
  33406. case usagestatisticmonth.FieldStatus:
  33407. return m.Status()
  33408. case usagestatisticmonth.FieldDeletedAt:
  33409. return m.DeletedAt()
  33410. case usagestatisticmonth.FieldAddtime:
  33411. return m.Addtime()
  33412. case usagestatisticmonth.FieldType:
  33413. return m.GetType()
  33414. case usagestatisticmonth.FieldBotID:
  33415. return m.BotID()
  33416. case usagestatisticmonth.FieldOrganizationID:
  33417. return m.OrganizationID()
  33418. case usagestatisticmonth.FieldAiResponse:
  33419. return m.AiResponse()
  33420. case usagestatisticmonth.FieldSopRun:
  33421. return m.SopRun()
  33422. case usagestatisticmonth.FieldTotalFriend:
  33423. return m.TotalFriend()
  33424. case usagestatisticmonth.FieldTotalGroup:
  33425. return m.TotalGroup()
  33426. case usagestatisticmonth.FieldAccountBalance:
  33427. return m.AccountBalance()
  33428. case usagestatisticmonth.FieldConsumeToken:
  33429. return m.ConsumeToken()
  33430. case usagestatisticmonth.FieldActiveUser:
  33431. return m.ActiveUser()
  33432. case usagestatisticmonth.FieldNewUser:
  33433. return m.NewUser()
  33434. case usagestatisticmonth.FieldLabelDist:
  33435. return m.LabelDist()
  33436. }
  33437. return nil, false
  33438. }
  33439. // OldField returns the old value of the field from the database. An error is
  33440. // returned if the mutation operation is not UpdateOne, or the query to the
  33441. // database failed.
  33442. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33443. switch name {
  33444. case usagestatisticmonth.FieldCreatedAt:
  33445. return m.OldCreatedAt(ctx)
  33446. case usagestatisticmonth.FieldUpdatedAt:
  33447. return m.OldUpdatedAt(ctx)
  33448. case usagestatisticmonth.FieldStatus:
  33449. return m.OldStatus(ctx)
  33450. case usagestatisticmonth.FieldDeletedAt:
  33451. return m.OldDeletedAt(ctx)
  33452. case usagestatisticmonth.FieldAddtime:
  33453. return m.OldAddtime(ctx)
  33454. case usagestatisticmonth.FieldType:
  33455. return m.OldType(ctx)
  33456. case usagestatisticmonth.FieldBotID:
  33457. return m.OldBotID(ctx)
  33458. case usagestatisticmonth.FieldOrganizationID:
  33459. return m.OldOrganizationID(ctx)
  33460. case usagestatisticmonth.FieldAiResponse:
  33461. return m.OldAiResponse(ctx)
  33462. case usagestatisticmonth.FieldSopRun:
  33463. return m.OldSopRun(ctx)
  33464. case usagestatisticmonth.FieldTotalFriend:
  33465. return m.OldTotalFriend(ctx)
  33466. case usagestatisticmonth.FieldTotalGroup:
  33467. return m.OldTotalGroup(ctx)
  33468. case usagestatisticmonth.FieldAccountBalance:
  33469. return m.OldAccountBalance(ctx)
  33470. case usagestatisticmonth.FieldConsumeToken:
  33471. return m.OldConsumeToken(ctx)
  33472. case usagestatisticmonth.FieldActiveUser:
  33473. return m.OldActiveUser(ctx)
  33474. case usagestatisticmonth.FieldNewUser:
  33475. return m.OldNewUser(ctx)
  33476. case usagestatisticmonth.FieldLabelDist:
  33477. return m.OldLabelDist(ctx)
  33478. }
  33479. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33480. }
  33481. // SetField sets the value of a field with the given name. It returns an error if
  33482. // the field is not defined in the schema, or if the type mismatched the field
  33483. // type.
  33484. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  33485. switch name {
  33486. case usagestatisticmonth.FieldCreatedAt:
  33487. v, ok := value.(time.Time)
  33488. if !ok {
  33489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33490. }
  33491. m.SetCreatedAt(v)
  33492. return nil
  33493. case usagestatisticmonth.FieldUpdatedAt:
  33494. v, ok := value.(time.Time)
  33495. if !ok {
  33496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33497. }
  33498. m.SetUpdatedAt(v)
  33499. return nil
  33500. case usagestatisticmonth.FieldStatus:
  33501. v, ok := value.(uint8)
  33502. if !ok {
  33503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33504. }
  33505. m.SetStatus(v)
  33506. return nil
  33507. case usagestatisticmonth.FieldDeletedAt:
  33508. v, ok := value.(time.Time)
  33509. if !ok {
  33510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33511. }
  33512. m.SetDeletedAt(v)
  33513. return nil
  33514. case usagestatisticmonth.FieldAddtime:
  33515. v, ok := value.(uint64)
  33516. if !ok {
  33517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33518. }
  33519. m.SetAddtime(v)
  33520. return nil
  33521. case usagestatisticmonth.FieldType:
  33522. v, ok := value.(int)
  33523. if !ok {
  33524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33525. }
  33526. m.SetType(v)
  33527. return nil
  33528. case usagestatisticmonth.FieldBotID:
  33529. v, ok := value.(string)
  33530. if !ok {
  33531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33532. }
  33533. m.SetBotID(v)
  33534. return nil
  33535. case usagestatisticmonth.FieldOrganizationID:
  33536. v, ok := value.(uint64)
  33537. if !ok {
  33538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33539. }
  33540. m.SetOrganizationID(v)
  33541. return nil
  33542. case usagestatisticmonth.FieldAiResponse:
  33543. v, ok := value.(uint64)
  33544. if !ok {
  33545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33546. }
  33547. m.SetAiResponse(v)
  33548. return nil
  33549. case usagestatisticmonth.FieldSopRun:
  33550. v, ok := value.(uint64)
  33551. if !ok {
  33552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33553. }
  33554. m.SetSopRun(v)
  33555. return nil
  33556. case usagestatisticmonth.FieldTotalFriend:
  33557. v, ok := value.(uint64)
  33558. if !ok {
  33559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33560. }
  33561. m.SetTotalFriend(v)
  33562. return nil
  33563. case usagestatisticmonth.FieldTotalGroup:
  33564. v, ok := value.(uint64)
  33565. if !ok {
  33566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33567. }
  33568. m.SetTotalGroup(v)
  33569. return nil
  33570. case usagestatisticmonth.FieldAccountBalance:
  33571. v, ok := value.(uint64)
  33572. if !ok {
  33573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33574. }
  33575. m.SetAccountBalance(v)
  33576. return nil
  33577. case usagestatisticmonth.FieldConsumeToken:
  33578. v, ok := value.(uint64)
  33579. if !ok {
  33580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33581. }
  33582. m.SetConsumeToken(v)
  33583. return nil
  33584. case usagestatisticmonth.FieldActiveUser:
  33585. v, ok := value.(uint64)
  33586. if !ok {
  33587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33588. }
  33589. m.SetActiveUser(v)
  33590. return nil
  33591. case usagestatisticmonth.FieldNewUser:
  33592. v, ok := value.(int64)
  33593. if !ok {
  33594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33595. }
  33596. m.SetNewUser(v)
  33597. return nil
  33598. case usagestatisticmonth.FieldLabelDist:
  33599. v, ok := value.([]custom_types.LabelDist)
  33600. if !ok {
  33601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33602. }
  33603. m.SetLabelDist(v)
  33604. return nil
  33605. }
  33606. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33607. }
  33608. // AddedFields returns all numeric fields that were incremented/decremented during
  33609. // this mutation.
  33610. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  33611. var fields []string
  33612. if m.addstatus != nil {
  33613. fields = append(fields, usagestatisticmonth.FieldStatus)
  33614. }
  33615. if m.addaddtime != nil {
  33616. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33617. }
  33618. if m.add_type != nil {
  33619. fields = append(fields, usagestatisticmonth.FieldType)
  33620. }
  33621. if m.addorganization_id != nil {
  33622. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33623. }
  33624. if m.addai_response != nil {
  33625. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33626. }
  33627. if m.addsop_run != nil {
  33628. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33629. }
  33630. if m.addtotal_friend != nil {
  33631. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33632. }
  33633. if m.addtotal_group != nil {
  33634. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33635. }
  33636. if m.addaccount_balance != nil {
  33637. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33638. }
  33639. if m.addconsume_token != nil {
  33640. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33641. }
  33642. if m.addactive_user != nil {
  33643. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33644. }
  33645. if m.addnew_user != nil {
  33646. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33647. }
  33648. return fields
  33649. }
  33650. // AddedField returns the numeric value that was incremented/decremented on a field
  33651. // with the given name. The second boolean return value indicates that this field
  33652. // was not set, or was not defined in the schema.
  33653. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  33654. switch name {
  33655. case usagestatisticmonth.FieldStatus:
  33656. return m.AddedStatus()
  33657. case usagestatisticmonth.FieldAddtime:
  33658. return m.AddedAddtime()
  33659. case usagestatisticmonth.FieldType:
  33660. return m.AddedType()
  33661. case usagestatisticmonth.FieldOrganizationID:
  33662. return m.AddedOrganizationID()
  33663. case usagestatisticmonth.FieldAiResponse:
  33664. return m.AddedAiResponse()
  33665. case usagestatisticmonth.FieldSopRun:
  33666. return m.AddedSopRun()
  33667. case usagestatisticmonth.FieldTotalFriend:
  33668. return m.AddedTotalFriend()
  33669. case usagestatisticmonth.FieldTotalGroup:
  33670. return m.AddedTotalGroup()
  33671. case usagestatisticmonth.FieldAccountBalance:
  33672. return m.AddedAccountBalance()
  33673. case usagestatisticmonth.FieldConsumeToken:
  33674. return m.AddedConsumeToken()
  33675. case usagestatisticmonth.FieldActiveUser:
  33676. return m.AddedActiveUser()
  33677. case usagestatisticmonth.FieldNewUser:
  33678. return m.AddedNewUser()
  33679. }
  33680. return nil, false
  33681. }
  33682. // AddField adds the value to the field with the given name. It returns an error if
  33683. // the field is not defined in the schema, or if the type mismatched the field
  33684. // type.
  33685. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  33686. switch name {
  33687. case usagestatisticmonth.FieldStatus:
  33688. v, ok := value.(int8)
  33689. if !ok {
  33690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33691. }
  33692. m.AddStatus(v)
  33693. return nil
  33694. case usagestatisticmonth.FieldAddtime:
  33695. v, ok := value.(int64)
  33696. if !ok {
  33697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33698. }
  33699. m.AddAddtime(v)
  33700. return nil
  33701. case usagestatisticmonth.FieldType:
  33702. v, ok := value.(int)
  33703. if !ok {
  33704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33705. }
  33706. m.AddType(v)
  33707. return nil
  33708. case usagestatisticmonth.FieldOrganizationID:
  33709. v, ok := value.(int64)
  33710. if !ok {
  33711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33712. }
  33713. m.AddOrganizationID(v)
  33714. return nil
  33715. case usagestatisticmonth.FieldAiResponse:
  33716. v, ok := value.(int64)
  33717. if !ok {
  33718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33719. }
  33720. m.AddAiResponse(v)
  33721. return nil
  33722. case usagestatisticmonth.FieldSopRun:
  33723. v, ok := value.(int64)
  33724. if !ok {
  33725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33726. }
  33727. m.AddSopRun(v)
  33728. return nil
  33729. case usagestatisticmonth.FieldTotalFriend:
  33730. v, ok := value.(int64)
  33731. if !ok {
  33732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33733. }
  33734. m.AddTotalFriend(v)
  33735. return nil
  33736. case usagestatisticmonth.FieldTotalGroup:
  33737. v, ok := value.(int64)
  33738. if !ok {
  33739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33740. }
  33741. m.AddTotalGroup(v)
  33742. return nil
  33743. case usagestatisticmonth.FieldAccountBalance:
  33744. v, ok := value.(int64)
  33745. if !ok {
  33746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33747. }
  33748. m.AddAccountBalance(v)
  33749. return nil
  33750. case usagestatisticmonth.FieldConsumeToken:
  33751. v, ok := value.(int64)
  33752. if !ok {
  33753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33754. }
  33755. m.AddConsumeToken(v)
  33756. return nil
  33757. case usagestatisticmonth.FieldActiveUser:
  33758. v, ok := value.(int64)
  33759. if !ok {
  33760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33761. }
  33762. m.AddActiveUser(v)
  33763. return nil
  33764. case usagestatisticmonth.FieldNewUser:
  33765. v, ok := value.(int64)
  33766. if !ok {
  33767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33768. }
  33769. m.AddNewUser(v)
  33770. return nil
  33771. }
  33772. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  33773. }
  33774. // ClearedFields returns all nullable fields that were cleared during this
  33775. // mutation.
  33776. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  33777. var fields []string
  33778. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  33779. fields = append(fields, usagestatisticmonth.FieldStatus)
  33780. }
  33781. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  33782. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33783. }
  33784. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  33785. fields = append(fields, usagestatisticmonth.FieldBotID)
  33786. }
  33787. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  33788. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33789. }
  33790. return fields
  33791. }
  33792. // FieldCleared returns a boolean indicating if a field with the given name was
  33793. // cleared in this mutation.
  33794. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  33795. _, ok := m.clearedFields[name]
  33796. return ok
  33797. }
  33798. // ClearField clears the value of the field with the given name. It returns an
  33799. // error if the field is not defined in the schema.
  33800. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  33801. switch name {
  33802. case usagestatisticmonth.FieldStatus:
  33803. m.ClearStatus()
  33804. return nil
  33805. case usagestatisticmonth.FieldDeletedAt:
  33806. m.ClearDeletedAt()
  33807. return nil
  33808. case usagestatisticmonth.FieldBotID:
  33809. m.ClearBotID()
  33810. return nil
  33811. case usagestatisticmonth.FieldOrganizationID:
  33812. m.ClearOrganizationID()
  33813. return nil
  33814. }
  33815. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  33816. }
  33817. // ResetField resets all changes in the mutation for the field with the given name.
  33818. // It returns an error if the field is not defined in the schema.
  33819. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  33820. switch name {
  33821. case usagestatisticmonth.FieldCreatedAt:
  33822. m.ResetCreatedAt()
  33823. return nil
  33824. case usagestatisticmonth.FieldUpdatedAt:
  33825. m.ResetUpdatedAt()
  33826. return nil
  33827. case usagestatisticmonth.FieldStatus:
  33828. m.ResetStatus()
  33829. return nil
  33830. case usagestatisticmonth.FieldDeletedAt:
  33831. m.ResetDeletedAt()
  33832. return nil
  33833. case usagestatisticmonth.FieldAddtime:
  33834. m.ResetAddtime()
  33835. return nil
  33836. case usagestatisticmonth.FieldType:
  33837. m.ResetType()
  33838. return nil
  33839. case usagestatisticmonth.FieldBotID:
  33840. m.ResetBotID()
  33841. return nil
  33842. case usagestatisticmonth.FieldOrganizationID:
  33843. m.ResetOrganizationID()
  33844. return nil
  33845. case usagestatisticmonth.FieldAiResponse:
  33846. m.ResetAiResponse()
  33847. return nil
  33848. case usagestatisticmonth.FieldSopRun:
  33849. m.ResetSopRun()
  33850. return nil
  33851. case usagestatisticmonth.FieldTotalFriend:
  33852. m.ResetTotalFriend()
  33853. return nil
  33854. case usagestatisticmonth.FieldTotalGroup:
  33855. m.ResetTotalGroup()
  33856. return nil
  33857. case usagestatisticmonth.FieldAccountBalance:
  33858. m.ResetAccountBalance()
  33859. return nil
  33860. case usagestatisticmonth.FieldConsumeToken:
  33861. m.ResetConsumeToken()
  33862. return nil
  33863. case usagestatisticmonth.FieldActiveUser:
  33864. m.ResetActiveUser()
  33865. return nil
  33866. case usagestatisticmonth.FieldNewUser:
  33867. m.ResetNewUser()
  33868. return nil
  33869. case usagestatisticmonth.FieldLabelDist:
  33870. m.ResetLabelDist()
  33871. return nil
  33872. }
  33873. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33874. }
  33875. // AddedEdges returns all edge names that were set/added in this mutation.
  33876. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  33877. edges := make([]string, 0, 0)
  33878. return edges
  33879. }
  33880. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33881. // name in this mutation.
  33882. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  33883. return nil
  33884. }
  33885. // RemovedEdges returns all edge names that were removed in this mutation.
  33886. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  33887. edges := make([]string, 0, 0)
  33888. return edges
  33889. }
  33890. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33891. // the given name in this mutation.
  33892. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  33893. return nil
  33894. }
  33895. // ClearedEdges returns all edge names that were cleared in this mutation.
  33896. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  33897. edges := make([]string, 0, 0)
  33898. return edges
  33899. }
  33900. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33901. // was cleared in this mutation.
  33902. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  33903. return false
  33904. }
  33905. // ClearEdge clears the value of the edge with the given name. It returns an error
  33906. // if that edge is not defined in the schema.
  33907. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  33908. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  33909. }
  33910. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33911. // It returns an error if the edge is not defined in the schema.
  33912. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  33913. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  33914. }
  33915. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  33916. type UsageTotalMutation struct {
  33917. config
  33918. op Op
  33919. typ string
  33920. id *uint64
  33921. created_at *time.Time
  33922. updated_at *time.Time
  33923. status *uint8
  33924. addstatus *int8
  33925. _type *int
  33926. add_type *int
  33927. bot_id *string
  33928. total_tokens *uint64
  33929. addtotal_tokens *int64
  33930. start_index *uint64
  33931. addstart_index *int64
  33932. end_index *uint64
  33933. addend_index *int64
  33934. organization_id *uint64
  33935. addorganization_id *int64
  33936. clearedFields map[string]struct{}
  33937. done bool
  33938. oldValue func(context.Context) (*UsageTotal, error)
  33939. predicates []predicate.UsageTotal
  33940. }
  33941. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  33942. // usagetotalOption allows management of the mutation configuration using functional options.
  33943. type usagetotalOption func(*UsageTotalMutation)
  33944. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  33945. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  33946. m := &UsageTotalMutation{
  33947. config: c,
  33948. op: op,
  33949. typ: TypeUsageTotal,
  33950. clearedFields: make(map[string]struct{}),
  33951. }
  33952. for _, opt := range opts {
  33953. opt(m)
  33954. }
  33955. return m
  33956. }
  33957. // withUsageTotalID sets the ID field of the mutation.
  33958. func withUsageTotalID(id uint64) usagetotalOption {
  33959. return func(m *UsageTotalMutation) {
  33960. var (
  33961. err error
  33962. once sync.Once
  33963. value *UsageTotal
  33964. )
  33965. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  33966. once.Do(func() {
  33967. if m.done {
  33968. err = errors.New("querying old values post mutation is not allowed")
  33969. } else {
  33970. value, err = m.Client().UsageTotal.Get(ctx, id)
  33971. }
  33972. })
  33973. return value, err
  33974. }
  33975. m.id = &id
  33976. }
  33977. }
  33978. // withUsageTotal sets the old UsageTotal of the mutation.
  33979. func withUsageTotal(node *UsageTotal) usagetotalOption {
  33980. return func(m *UsageTotalMutation) {
  33981. m.oldValue = func(context.Context) (*UsageTotal, error) {
  33982. return node, nil
  33983. }
  33984. m.id = &node.ID
  33985. }
  33986. }
  33987. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33988. // executed in a transaction (ent.Tx), a transactional client is returned.
  33989. func (m UsageTotalMutation) Client() *Client {
  33990. client := &Client{config: m.config}
  33991. client.init()
  33992. return client
  33993. }
  33994. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33995. // it returns an error otherwise.
  33996. func (m UsageTotalMutation) Tx() (*Tx, error) {
  33997. if _, ok := m.driver.(*txDriver); !ok {
  33998. return nil, errors.New("ent: mutation is not running in a transaction")
  33999. }
  34000. tx := &Tx{config: m.config}
  34001. tx.init()
  34002. return tx, nil
  34003. }
  34004. // SetID sets the value of the id field. Note that this
  34005. // operation is only accepted on creation of UsageTotal entities.
  34006. func (m *UsageTotalMutation) SetID(id uint64) {
  34007. m.id = &id
  34008. }
  34009. // ID returns the ID value in the mutation. Note that the ID is only available
  34010. // if it was provided to the builder or after it was returned from the database.
  34011. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  34012. if m.id == nil {
  34013. return
  34014. }
  34015. return *m.id, true
  34016. }
  34017. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34018. // That means, if the mutation is applied within a transaction with an isolation level such
  34019. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34020. // or updated by the mutation.
  34021. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  34022. switch {
  34023. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34024. id, exists := m.ID()
  34025. if exists {
  34026. return []uint64{id}, nil
  34027. }
  34028. fallthrough
  34029. case m.op.Is(OpUpdate | OpDelete):
  34030. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  34031. default:
  34032. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34033. }
  34034. }
  34035. // SetCreatedAt sets the "created_at" field.
  34036. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  34037. m.created_at = &t
  34038. }
  34039. // CreatedAt returns the value of the "created_at" field in the mutation.
  34040. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  34041. v := m.created_at
  34042. if v == nil {
  34043. return
  34044. }
  34045. return *v, true
  34046. }
  34047. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  34048. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34050. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34051. if !m.op.Is(OpUpdateOne) {
  34052. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34053. }
  34054. if m.id == nil || m.oldValue == nil {
  34055. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34056. }
  34057. oldValue, err := m.oldValue(ctx)
  34058. if err != nil {
  34059. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34060. }
  34061. return oldValue.CreatedAt, nil
  34062. }
  34063. // ResetCreatedAt resets all changes to the "created_at" field.
  34064. func (m *UsageTotalMutation) ResetCreatedAt() {
  34065. m.created_at = nil
  34066. }
  34067. // SetUpdatedAt sets the "updated_at" field.
  34068. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  34069. m.updated_at = &t
  34070. }
  34071. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34072. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  34073. v := m.updated_at
  34074. if v == nil {
  34075. return
  34076. }
  34077. return *v, true
  34078. }
  34079. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  34080. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34082. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34083. if !m.op.Is(OpUpdateOne) {
  34084. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34085. }
  34086. if m.id == nil || m.oldValue == nil {
  34087. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34088. }
  34089. oldValue, err := m.oldValue(ctx)
  34090. if err != nil {
  34091. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34092. }
  34093. return oldValue.UpdatedAt, nil
  34094. }
  34095. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34096. func (m *UsageTotalMutation) ResetUpdatedAt() {
  34097. m.updated_at = nil
  34098. }
  34099. // SetStatus sets the "status" field.
  34100. func (m *UsageTotalMutation) SetStatus(u uint8) {
  34101. m.status = &u
  34102. m.addstatus = nil
  34103. }
  34104. // Status returns the value of the "status" field in the mutation.
  34105. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  34106. v := m.status
  34107. if v == nil {
  34108. return
  34109. }
  34110. return *v, true
  34111. }
  34112. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  34113. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34115. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34116. if !m.op.Is(OpUpdateOne) {
  34117. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34118. }
  34119. if m.id == nil || m.oldValue == nil {
  34120. return v, errors.New("OldStatus requires an ID field in the mutation")
  34121. }
  34122. oldValue, err := m.oldValue(ctx)
  34123. if err != nil {
  34124. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34125. }
  34126. return oldValue.Status, nil
  34127. }
  34128. // AddStatus adds u to the "status" field.
  34129. func (m *UsageTotalMutation) AddStatus(u int8) {
  34130. if m.addstatus != nil {
  34131. *m.addstatus += u
  34132. } else {
  34133. m.addstatus = &u
  34134. }
  34135. }
  34136. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34137. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  34138. v := m.addstatus
  34139. if v == nil {
  34140. return
  34141. }
  34142. return *v, true
  34143. }
  34144. // ClearStatus clears the value of the "status" field.
  34145. func (m *UsageTotalMutation) ClearStatus() {
  34146. m.status = nil
  34147. m.addstatus = nil
  34148. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  34149. }
  34150. // StatusCleared returns if the "status" field was cleared in this mutation.
  34151. func (m *UsageTotalMutation) StatusCleared() bool {
  34152. _, ok := m.clearedFields[usagetotal.FieldStatus]
  34153. return ok
  34154. }
  34155. // ResetStatus resets all changes to the "status" field.
  34156. func (m *UsageTotalMutation) ResetStatus() {
  34157. m.status = nil
  34158. m.addstatus = nil
  34159. delete(m.clearedFields, usagetotal.FieldStatus)
  34160. }
  34161. // SetType sets the "type" field.
  34162. func (m *UsageTotalMutation) SetType(i int) {
  34163. m._type = &i
  34164. m.add_type = nil
  34165. }
  34166. // GetType returns the value of the "type" field in the mutation.
  34167. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  34168. v := m._type
  34169. if v == nil {
  34170. return
  34171. }
  34172. return *v, true
  34173. }
  34174. // OldType returns the old "type" field's value of the UsageTotal entity.
  34175. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34177. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  34178. if !m.op.Is(OpUpdateOne) {
  34179. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34180. }
  34181. if m.id == nil || m.oldValue == nil {
  34182. return v, errors.New("OldType requires an ID field in the mutation")
  34183. }
  34184. oldValue, err := m.oldValue(ctx)
  34185. if err != nil {
  34186. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34187. }
  34188. return oldValue.Type, nil
  34189. }
  34190. // AddType adds i to the "type" field.
  34191. func (m *UsageTotalMutation) AddType(i int) {
  34192. if m.add_type != nil {
  34193. *m.add_type += i
  34194. } else {
  34195. m.add_type = &i
  34196. }
  34197. }
  34198. // AddedType returns the value that was added to the "type" field in this mutation.
  34199. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  34200. v := m.add_type
  34201. if v == nil {
  34202. return
  34203. }
  34204. return *v, true
  34205. }
  34206. // ClearType clears the value of the "type" field.
  34207. func (m *UsageTotalMutation) ClearType() {
  34208. m._type = nil
  34209. m.add_type = nil
  34210. m.clearedFields[usagetotal.FieldType] = struct{}{}
  34211. }
  34212. // TypeCleared returns if the "type" field was cleared in this mutation.
  34213. func (m *UsageTotalMutation) TypeCleared() bool {
  34214. _, ok := m.clearedFields[usagetotal.FieldType]
  34215. return ok
  34216. }
  34217. // ResetType resets all changes to the "type" field.
  34218. func (m *UsageTotalMutation) ResetType() {
  34219. m._type = nil
  34220. m.add_type = nil
  34221. delete(m.clearedFields, usagetotal.FieldType)
  34222. }
  34223. // SetBotID sets the "bot_id" field.
  34224. func (m *UsageTotalMutation) SetBotID(s string) {
  34225. m.bot_id = &s
  34226. }
  34227. // BotID returns the value of the "bot_id" field in the mutation.
  34228. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  34229. v := m.bot_id
  34230. if v == nil {
  34231. return
  34232. }
  34233. return *v, true
  34234. }
  34235. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  34236. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34238. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  34239. if !m.op.Is(OpUpdateOne) {
  34240. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34241. }
  34242. if m.id == nil || m.oldValue == nil {
  34243. return v, errors.New("OldBotID requires an ID field in the mutation")
  34244. }
  34245. oldValue, err := m.oldValue(ctx)
  34246. if err != nil {
  34247. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34248. }
  34249. return oldValue.BotID, nil
  34250. }
  34251. // ResetBotID resets all changes to the "bot_id" field.
  34252. func (m *UsageTotalMutation) ResetBotID() {
  34253. m.bot_id = nil
  34254. }
  34255. // SetTotalTokens sets the "total_tokens" field.
  34256. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  34257. m.total_tokens = &u
  34258. m.addtotal_tokens = nil
  34259. }
  34260. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34261. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  34262. v := m.total_tokens
  34263. if v == nil {
  34264. return
  34265. }
  34266. return *v, true
  34267. }
  34268. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  34269. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34271. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34272. if !m.op.Is(OpUpdateOne) {
  34273. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34274. }
  34275. if m.id == nil || m.oldValue == nil {
  34276. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34277. }
  34278. oldValue, err := m.oldValue(ctx)
  34279. if err != nil {
  34280. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34281. }
  34282. return oldValue.TotalTokens, nil
  34283. }
  34284. // AddTotalTokens adds u to the "total_tokens" field.
  34285. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  34286. if m.addtotal_tokens != nil {
  34287. *m.addtotal_tokens += u
  34288. } else {
  34289. m.addtotal_tokens = &u
  34290. }
  34291. }
  34292. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34293. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  34294. v := m.addtotal_tokens
  34295. if v == nil {
  34296. return
  34297. }
  34298. return *v, true
  34299. }
  34300. // ClearTotalTokens clears the value of the "total_tokens" field.
  34301. func (m *UsageTotalMutation) ClearTotalTokens() {
  34302. m.total_tokens = nil
  34303. m.addtotal_tokens = nil
  34304. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  34305. }
  34306. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34307. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  34308. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  34309. return ok
  34310. }
  34311. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34312. func (m *UsageTotalMutation) ResetTotalTokens() {
  34313. m.total_tokens = nil
  34314. m.addtotal_tokens = nil
  34315. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  34316. }
  34317. // SetStartIndex sets the "start_index" field.
  34318. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  34319. m.start_index = &u
  34320. m.addstart_index = nil
  34321. }
  34322. // StartIndex returns the value of the "start_index" field in the mutation.
  34323. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  34324. v := m.start_index
  34325. if v == nil {
  34326. return
  34327. }
  34328. return *v, true
  34329. }
  34330. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  34331. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34333. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  34334. if !m.op.Is(OpUpdateOne) {
  34335. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  34336. }
  34337. if m.id == nil || m.oldValue == nil {
  34338. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  34339. }
  34340. oldValue, err := m.oldValue(ctx)
  34341. if err != nil {
  34342. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  34343. }
  34344. return oldValue.StartIndex, nil
  34345. }
  34346. // AddStartIndex adds u to the "start_index" field.
  34347. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  34348. if m.addstart_index != nil {
  34349. *m.addstart_index += u
  34350. } else {
  34351. m.addstart_index = &u
  34352. }
  34353. }
  34354. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  34355. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  34356. v := m.addstart_index
  34357. if v == nil {
  34358. return
  34359. }
  34360. return *v, true
  34361. }
  34362. // ClearStartIndex clears the value of the "start_index" field.
  34363. func (m *UsageTotalMutation) ClearStartIndex() {
  34364. m.start_index = nil
  34365. m.addstart_index = nil
  34366. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  34367. }
  34368. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  34369. func (m *UsageTotalMutation) StartIndexCleared() bool {
  34370. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  34371. return ok
  34372. }
  34373. // ResetStartIndex resets all changes to the "start_index" field.
  34374. func (m *UsageTotalMutation) ResetStartIndex() {
  34375. m.start_index = nil
  34376. m.addstart_index = nil
  34377. delete(m.clearedFields, usagetotal.FieldStartIndex)
  34378. }
  34379. // SetEndIndex sets the "end_index" field.
  34380. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  34381. m.end_index = &u
  34382. m.addend_index = nil
  34383. }
  34384. // EndIndex returns the value of the "end_index" field in the mutation.
  34385. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  34386. v := m.end_index
  34387. if v == nil {
  34388. return
  34389. }
  34390. return *v, true
  34391. }
  34392. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  34393. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34395. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  34396. if !m.op.Is(OpUpdateOne) {
  34397. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  34398. }
  34399. if m.id == nil || m.oldValue == nil {
  34400. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  34401. }
  34402. oldValue, err := m.oldValue(ctx)
  34403. if err != nil {
  34404. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  34405. }
  34406. return oldValue.EndIndex, nil
  34407. }
  34408. // AddEndIndex adds u to the "end_index" field.
  34409. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  34410. if m.addend_index != nil {
  34411. *m.addend_index += u
  34412. } else {
  34413. m.addend_index = &u
  34414. }
  34415. }
  34416. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  34417. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  34418. v := m.addend_index
  34419. if v == nil {
  34420. return
  34421. }
  34422. return *v, true
  34423. }
  34424. // ClearEndIndex clears the value of the "end_index" field.
  34425. func (m *UsageTotalMutation) ClearEndIndex() {
  34426. m.end_index = nil
  34427. m.addend_index = nil
  34428. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  34429. }
  34430. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  34431. func (m *UsageTotalMutation) EndIndexCleared() bool {
  34432. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  34433. return ok
  34434. }
  34435. // ResetEndIndex resets all changes to the "end_index" field.
  34436. func (m *UsageTotalMutation) ResetEndIndex() {
  34437. m.end_index = nil
  34438. m.addend_index = nil
  34439. delete(m.clearedFields, usagetotal.FieldEndIndex)
  34440. }
  34441. // SetOrganizationID sets the "organization_id" field.
  34442. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  34443. m.organization_id = &u
  34444. m.addorganization_id = nil
  34445. }
  34446. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34447. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  34448. v := m.organization_id
  34449. if v == nil {
  34450. return
  34451. }
  34452. return *v, true
  34453. }
  34454. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  34455. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34457. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34458. if !m.op.Is(OpUpdateOne) {
  34459. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34460. }
  34461. if m.id == nil || m.oldValue == nil {
  34462. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34463. }
  34464. oldValue, err := m.oldValue(ctx)
  34465. if err != nil {
  34466. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34467. }
  34468. return oldValue.OrganizationID, nil
  34469. }
  34470. // AddOrganizationID adds u to the "organization_id" field.
  34471. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  34472. if m.addorganization_id != nil {
  34473. *m.addorganization_id += u
  34474. } else {
  34475. m.addorganization_id = &u
  34476. }
  34477. }
  34478. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34479. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  34480. v := m.addorganization_id
  34481. if v == nil {
  34482. return
  34483. }
  34484. return *v, true
  34485. }
  34486. // ClearOrganizationID clears the value of the "organization_id" field.
  34487. func (m *UsageTotalMutation) ClearOrganizationID() {
  34488. m.organization_id = nil
  34489. m.addorganization_id = nil
  34490. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  34491. }
  34492. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34493. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  34494. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  34495. return ok
  34496. }
  34497. // ResetOrganizationID resets all changes to the "organization_id" field.
  34498. func (m *UsageTotalMutation) ResetOrganizationID() {
  34499. m.organization_id = nil
  34500. m.addorganization_id = nil
  34501. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  34502. }
  34503. // Where appends a list predicates to the UsageTotalMutation builder.
  34504. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  34505. m.predicates = append(m.predicates, ps...)
  34506. }
  34507. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  34508. // users can use type-assertion to append predicates that do not depend on any generated package.
  34509. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  34510. p := make([]predicate.UsageTotal, len(ps))
  34511. for i := range ps {
  34512. p[i] = ps[i]
  34513. }
  34514. m.Where(p...)
  34515. }
  34516. // Op returns the operation name.
  34517. func (m *UsageTotalMutation) Op() Op {
  34518. return m.op
  34519. }
  34520. // SetOp allows setting the mutation operation.
  34521. func (m *UsageTotalMutation) SetOp(op Op) {
  34522. m.op = op
  34523. }
  34524. // Type returns the node type of this mutation (UsageTotal).
  34525. func (m *UsageTotalMutation) Type() string {
  34526. return m.typ
  34527. }
  34528. // Fields returns all fields that were changed during this mutation. Note that in
  34529. // order to get all numeric fields that were incremented/decremented, call
  34530. // AddedFields().
  34531. func (m *UsageTotalMutation) Fields() []string {
  34532. fields := make([]string, 0, 9)
  34533. if m.created_at != nil {
  34534. fields = append(fields, usagetotal.FieldCreatedAt)
  34535. }
  34536. if m.updated_at != nil {
  34537. fields = append(fields, usagetotal.FieldUpdatedAt)
  34538. }
  34539. if m.status != nil {
  34540. fields = append(fields, usagetotal.FieldStatus)
  34541. }
  34542. if m._type != nil {
  34543. fields = append(fields, usagetotal.FieldType)
  34544. }
  34545. if m.bot_id != nil {
  34546. fields = append(fields, usagetotal.FieldBotID)
  34547. }
  34548. if m.total_tokens != nil {
  34549. fields = append(fields, usagetotal.FieldTotalTokens)
  34550. }
  34551. if m.start_index != nil {
  34552. fields = append(fields, usagetotal.FieldStartIndex)
  34553. }
  34554. if m.end_index != nil {
  34555. fields = append(fields, usagetotal.FieldEndIndex)
  34556. }
  34557. if m.organization_id != nil {
  34558. fields = append(fields, usagetotal.FieldOrganizationID)
  34559. }
  34560. return fields
  34561. }
  34562. // Field returns the value of a field with the given name. The second boolean
  34563. // return value indicates that this field was not set, or was not defined in the
  34564. // schema.
  34565. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  34566. switch name {
  34567. case usagetotal.FieldCreatedAt:
  34568. return m.CreatedAt()
  34569. case usagetotal.FieldUpdatedAt:
  34570. return m.UpdatedAt()
  34571. case usagetotal.FieldStatus:
  34572. return m.Status()
  34573. case usagetotal.FieldType:
  34574. return m.GetType()
  34575. case usagetotal.FieldBotID:
  34576. return m.BotID()
  34577. case usagetotal.FieldTotalTokens:
  34578. return m.TotalTokens()
  34579. case usagetotal.FieldStartIndex:
  34580. return m.StartIndex()
  34581. case usagetotal.FieldEndIndex:
  34582. return m.EndIndex()
  34583. case usagetotal.FieldOrganizationID:
  34584. return m.OrganizationID()
  34585. }
  34586. return nil, false
  34587. }
  34588. // OldField returns the old value of the field from the database. An error is
  34589. // returned if the mutation operation is not UpdateOne, or the query to the
  34590. // database failed.
  34591. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34592. switch name {
  34593. case usagetotal.FieldCreatedAt:
  34594. return m.OldCreatedAt(ctx)
  34595. case usagetotal.FieldUpdatedAt:
  34596. return m.OldUpdatedAt(ctx)
  34597. case usagetotal.FieldStatus:
  34598. return m.OldStatus(ctx)
  34599. case usagetotal.FieldType:
  34600. return m.OldType(ctx)
  34601. case usagetotal.FieldBotID:
  34602. return m.OldBotID(ctx)
  34603. case usagetotal.FieldTotalTokens:
  34604. return m.OldTotalTokens(ctx)
  34605. case usagetotal.FieldStartIndex:
  34606. return m.OldStartIndex(ctx)
  34607. case usagetotal.FieldEndIndex:
  34608. return m.OldEndIndex(ctx)
  34609. case usagetotal.FieldOrganizationID:
  34610. return m.OldOrganizationID(ctx)
  34611. }
  34612. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  34613. }
  34614. // SetField sets the value of a field with the given name. It returns an error if
  34615. // the field is not defined in the schema, or if the type mismatched the field
  34616. // type.
  34617. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  34618. switch name {
  34619. case usagetotal.FieldCreatedAt:
  34620. v, ok := value.(time.Time)
  34621. if !ok {
  34622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34623. }
  34624. m.SetCreatedAt(v)
  34625. return nil
  34626. case usagetotal.FieldUpdatedAt:
  34627. v, ok := value.(time.Time)
  34628. if !ok {
  34629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34630. }
  34631. m.SetUpdatedAt(v)
  34632. return nil
  34633. case usagetotal.FieldStatus:
  34634. v, ok := value.(uint8)
  34635. if !ok {
  34636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34637. }
  34638. m.SetStatus(v)
  34639. return nil
  34640. case usagetotal.FieldType:
  34641. v, ok := value.(int)
  34642. if !ok {
  34643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34644. }
  34645. m.SetType(v)
  34646. return nil
  34647. case usagetotal.FieldBotID:
  34648. v, ok := value.(string)
  34649. if !ok {
  34650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34651. }
  34652. m.SetBotID(v)
  34653. return nil
  34654. case usagetotal.FieldTotalTokens:
  34655. v, ok := value.(uint64)
  34656. if !ok {
  34657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34658. }
  34659. m.SetTotalTokens(v)
  34660. return nil
  34661. case usagetotal.FieldStartIndex:
  34662. v, ok := value.(uint64)
  34663. if !ok {
  34664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34665. }
  34666. m.SetStartIndex(v)
  34667. return nil
  34668. case usagetotal.FieldEndIndex:
  34669. v, ok := value.(uint64)
  34670. if !ok {
  34671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34672. }
  34673. m.SetEndIndex(v)
  34674. return nil
  34675. case usagetotal.FieldOrganizationID:
  34676. v, ok := value.(uint64)
  34677. if !ok {
  34678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34679. }
  34680. m.SetOrganizationID(v)
  34681. return nil
  34682. }
  34683. return fmt.Errorf("unknown UsageTotal field %s", name)
  34684. }
  34685. // AddedFields returns all numeric fields that were incremented/decremented during
  34686. // this mutation.
  34687. func (m *UsageTotalMutation) AddedFields() []string {
  34688. var fields []string
  34689. if m.addstatus != nil {
  34690. fields = append(fields, usagetotal.FieldStatus)
  34691. }
  34692. if m.add_type != nil {
  34693. fields = append(fields, usagetotal.FieldType)
  34694. }
  34695. if m.addtotal_tokens != nil {
  34696. fields = append(fields, usagetotal.FieldTotalTokens)
  34697. }
  34698. if m.addstart_index != nil {
  34699. fields = append(fields, usagetotal.FieldStartIndex)
  34700. }
  34701. if m.addend_index != nil {
  34702. fields = append(fields, usagetotal.FieldEndIndex)
  34703. }
  34704. if m.addorganization_id != nil {
  34705. fields = append(fields, usagetotal.FieldOrganizationID)
  34706. }
  34707. return fields
  34708. }
  34709. // AddedField returns the numeric value that was incremented/decremented on a field
  34710. // with the given name. The second boolean return value indicates that this field
  34711. // was not set, or was not defined in the schema.
  34712. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  34713. switch name {
  34714. case usagetotal.FieldStatus:
  34715. return m.AddedStatus()
  34716. case usagetotal.FieldType:
  34717. return m.AddedType()
  34718. case usagetotal.FieldTotalTokens:
  34719. return m.AddedTotalTokens()
  34720. case usagetotal.FieldStartIndex:
  34721. return m.AddedStartIndex()
  34722. case usagetotal.FieldEndIndex:
  34723. return m.AddedEndIndex()
  34724. case usagetotal.FieldOrganizationID:
  34725. return m.AddedOrganizationID()
  34726. }
  34727. return nil, false
  34728. }
  34729. // AddField adds the value to the field with the given name. It returns an error if
  34730. // the field is not defined in the schema, or if the type mismatched the field
  34731. // type.
  34732. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  34733. switch name {
  34734. case usagetotal.FieldStatus:
  34735. v, ok := value.(int8)
  34736. if !ok {
  34737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34738. }
  34739. m.AddStatus(v)
  34740. return nil
  34741. case usagetotal.FieldType:
  34742. v, ok := value.(int)
  34743. if !ok {
  34744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34745. }
  34746. m.AddType(v)
  34747. return nil
  34748. case usagetotal.FieldTotalTokens:
  34749. v, ok := value.(int64)
  34750. if !ok {
  34751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34752. }
  34753. m.AddTotalTokens(v)
  34754. return nil
  34755. case usagetotal.FieldStartIndex:
  34756. v, ok := value.(int64)
  34757. if !ok {
  34758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34759. }
  34760. m.AddStartIndex(v)
  34761. return nil
  34762. case usagetotal.FieldEndIndex:
  34763. v, ok := value.(int64)
  34764. if !ok {
  34765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34766. }
  34767. m.AddEndIndex(v)
  34768. return nil
  34769. case usagetotal.FieldOrganizationID:
  34770. v, ok := value.(int64)
  34771. if !ok {
  34772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34773. }
  34774. m.AddOrganizationID(v)
  34775. return nil
  34776. }
  34777. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  34778. }
  34779. // ClearedFields returns all nullable fields that were cleared during this
  34780. // mutation.
  34781. func (m *UsageTotalMutation) ClearedFields() []string {
  34782. var fields []string
  34783. if m.FieldCleared(usagetotal.FieldStatus) {
  34784. fields = append(fields, usagetotal.FieldStatus)
  34785. }
  34786. if m.FieldCleared(usagetotal.FieldType) {
  34787. fields = append(fields, usagetotal.FieldType)
  34788. }
  34789. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  34790. fields = append(fields, usagetotal.FieldTotalTokens)
  34791. }
  34792. if m.FieldCleared(usagetotal.FieldStartIndex) {
  34793. fields = append(fields, usagetotal.FieldStartIndex)
  34794. }
  34795. if m.FieldCleared(usagetotal.FieldEndIndex) {
  34796. fields = append(fields, usagetotal.FieldEndIndex)
  34797. }
  34798. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  34799. fields = append(fields, usagetotal.FieldOrganizationID)
  34800. }
  34801. return fields
  34802. }
  34803. // FieldCleared returns a boolean indicating if a field with the given name was
  34804. // cleared in this mutation.
  34805. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  34806. _, ok := m.clearedFields[name]
  34807. return ok
  34808. }
  34809. // ClearField clears the value of the field with the given name. It returns an
  34810. // error if the field is not defined in the schema.
  34811. func (m *UsageTotalMutation) ClearField(name string) error {
  34812. switch name {
  34813. case usagetotal.FieldStatus:
  34814. m.ClearStatus()
  34815. return nil
  34816. case usagetotal.FieldType:
  34817. m.ClearType()
  34818. return nil
  34819. case usagetotal.FieldTotalTokens:
  34820. m.ClearTotalTokens()
  34821. return nil
  34822. case usagetotal.FieldStartIndex:
  34823. m.ClearStartIndex()
  34824. return nil
  34825. case usagetotal.FieldEndIndex:
  34826. m.ClearEndIndex()
  34827. return nil
  34828. case usagetotal.FieldOrganizationID:
  34829. m.ClearOrganizationID()
  34830. return nil
  34831. }
  34832. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  34833. }
  34834. // ResetField resets all changes in the mutation for the field with the given name.
  34835. // It returns an error if the field is not defined in the schema.
  34836. func (m *UsageTotalMutation) ResetField(name string) error {
  34837. switch name {
  34838. case usagetotal.FieldCreatedAt:
  34839. m.ResetCreatedAt()
  34840. return nil
  34841. case usagetotal.FieldUpdatedAt:
  34842. m.ResetUpdatedAt()
  34843. return nil
  34844. case usagetotal.FieldStatus:
  34845. m.ResetStatus()
  34846. return nil
  34847. case usagetotal.FieldType:
  34848. m.ResetType()
  34849. return nil
  34850. case usagetotal.FieldBotID:
  34851. m.ResetBotID()
  34852. return nil
  34853. case usagetotal.FieldTotalTokens:
  34854. m.ResetTotalTokens()
  34855. return nil
  34856. case usagetotal.FieldStartIndex:
  34857. m.ResetStartIndex()
  34858. return nil
  34859. case usagetotal.FieldEndIndex:
  34860. m.ResetEndIndex()
  34861. return nil
  34862. case usagetotal.FieldOrganizationID:
  34863. m.ResetOrganizationID()
  34864. return nil
  34865. }
  34866. return fmt.Errorf("unknown UsageTotal field %s", name)
  34867. }
  34868. // AddedEdges returns all edge names that were set/added in this mutation.
  34869. func (m *UsageTotalMutation) AddedEdges() []string {
  34870. edges := make([]string, 0, 0)
  34871. return edges
  34872. }
  34873. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34874. // name in this mutation.
  34875. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  34876. return nil
  34877. }
  34878. // RemovedEdges returns all edge names that were removed in this mutation.
  34879. func (m *UsageTotalMutation) RemovedEdges() []string {
  34880. edges := make([]string, 0, 0)
  34881. return edges
  34882. }
  34883. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34884. // the given name in this mutation.
  34885. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  34886. return nil
  34887. }
  34888. // ClearedEdges returns all edge names that were cleared in this mutation.
  34889. func (m *UsageTotalMutation) ClearedEdges() []string {
  34890. edges := make([]string, 0, 0)
  34891. return edges
  34892. }
  34893. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34894. // was cleared in this mutation.
  34895. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  34896. return false
  34897. }
  34898. // ClearEdge clears the value of the edge with the given name. It returns an error
  34899. // if that edge is not defined in the schema.
  34900. func (m *UsageTotalMutation) ClearEdge(name string) error {
  34901. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  34902. }
  34903. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34904. // It returns an error if the edge is not defined in the schema.
  34905. func (m *UsageTotalMutation) ResetEdge(name string) error {
  34906. return fmt.Errorf("unknown UsageTotal edge %s", name)
  34907. }
  34908. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  34909. type WhatsappMutation struct {
  34910. config
  34911. op Op
  34912. typ string
  34913. id *uint64
  34914. created_at *time.Time
  34915. updated_at *time.Time
  34916. status *uint8
  34917. addstatus *int8
  34918. deleted_at *time.Time
  34919. wa_id *string
  34920. wa_name *string
  34921. callback *string
  34922. account *string
  34923. cc *string
  34924. phone *string
  34925. cc_phone *string
  34926. phone_name *string
  34927. phone_status *int8
  34928. addphone_status *int8
  34929. organization_id *uint64
  34930. addorganization_id *int64
  34931. api_base *string
  34932. api_key *string
  34933. allow_list *[]string
  34934. appendallow_list []string
  34935. group_allow_list *[]string
  34936. appendgroup_allow_list []string
  34937. block_list *[]string
  34938. appendblock_list []string
  34939. group_block_list *[]string
  34940. appendgroup_block_list []string
  34941. clearedFields map[string]struct{}
  34942. agent *uint64
  34943. clearedagent bool
  34944. done bool
  34945. oldValue func(context.Context) (*Whatsapp, error)
  34946. predicates []predicate.Whatsapp
  34947. }
  34948. var _ ent.Mutation = (*WhatsappMutation)(nil)
  34949. // whatsappOption allows management of the mutation configuration using functional options.
  34950. type whatsappOption func(*WhatsappMutation)
  34951. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  34952. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  34953. m := &WhatsappMutation{
  34954. config: c,
  34955. op: op,
  34956. typ: TypeWhatsapp,
  34957. clearedFields: make(map[string]struct{}),
  34958. }
  34959. for _, opt := range opts {
  34960. opt(m)
  34961. }
  34962. return m
  34963. }
  34964. // withWhatsappID sets the ID field of the mutation.
  34965. func withWhatsappID(id uint64) whatsappOption {
  34966. return func(m *WhatsappMutation) {
  34967. var (
  34968. err error
  34969. once sync.Once
  34970. value *Whatsapp
  34971. )
  34972. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  34973. once.Do(func() {
  34974. if m.done {
  34975. err = errors.New("querying old values post mutation is not allowed")
  34976. } else {
  34977. value, err = m.Client().Whatsapp.Get(ctx, id)
  34978. }
  34979. })
  34980. return value, err
  34981. }
  34982. m.id = &id
  34983. }
  34984. }
  34985. // withWhatsapp sets the old Whatsapp of the mutation.
  34986. func withWhatsapp(node *Whatsapp) whatsappOption {
  34987. return func(m *WhatsappMutation) {
  34988. m.oldValue = func(context.Context) (*Whatsapp, error) {
  34989. return node, nil
  34990. }
  34991. m.id = &node.ID
  34992. }
  34993. }
  34994. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34995. // executed in a transaction (ent.Tx), a transactional client is returned.
  34996. func (m WhatsappMutation) Client() *Client {
  34997. client := &Client{config: m.config}
  34998. client.init()
  34999. return client
  35000. }
  35001. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35002. // it returns an error otherwise.
  35003. func (m WhatsappMutation) Tx() (*Tx, error) {
  35004. if _, ok := m.driver.(*txDriver); !ok {
  35005. return nil, errors.New("ent: mutation is not running in a transaction")
  35006. }
  35007. tx := &Tx{config: m.config}
  35008. tx.init()
  35009. return tx, nil
  35010. }
  35011. // SetID sets the value of the id field. Note that this
  35012. // operation is only accepted on creation of Whatsapp entities.
  35013. func (m *WhatsappMutation) SetID(id uint64) {
  35014. m.id = &id
  35015. }
  35016. // ID returns the ID value in the mutation. Note that the ID is only available
  35017. // if it was provided to the builder or after it was returned from the database.
  35018. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  35019. if m.id == nil {
  35020. return
  35021. }
  35022. return *m.id, true
  35023. }
  35024. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35025. // That means, if the mutation is applied within a transaction with an isolation level such
  35026. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35027. // or updated by the mutation.
  35028. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  35029. switch {
  35030. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35031. id, exists := m.ID()
  35032. if exists {
  35033. return []uint64{id}, nil
  35034. }
  35035. fallthrough
  35036. case m.op.Is(OpUpdate | OpDelete):
  35037. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  35038. default:
  35039. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35040. }
  35041. }
  35042. // SetCreatedAt sets the "created_at" field.
  35043. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  35044. m.created_at = &t
  35045. }
  35046. // CreatedAt returns the value of the "created_at" field in the mutation.
  35047. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  35048. v := m.created_at
  35049. if v == nil {
  35050. return
  35051. }
  35052. return *v, true
  35053. }
  35054. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  35055. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35057. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35058. if !m.op.Is(OpUpdateOne) {
  35059. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35060. }
  35061. if m.id == nil || m.oldValue == nil {
  35062. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35063. }
  35064. oldValue, err := m.oldValue(ctx)
  35065. if err != nil {
  35066. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35067. }
  35068. return oldValue.CreatedAt, nil
  35069. }
  35070. // ResetCreatedAt resets all changes to the "created_at" field.
  35071. func (m *WhatsappMutation) ResetCreatedAt() {
  35072. m.created_at = nil
  35073. }
  35074. // SetUpdatedAt sets the "updated_at" field.
  35075. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  35076. m.updated_at = &t
  35077. }
  35078. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35079. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  35080. v := m.updated_at
  35081. if v == nil {
  35082. return
  35083. }
  35084. return *v, true
  35085. }
  35086. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  35087. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35089. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35090. if !m.op.Is(OpUpdateOne) {
  35091. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35092. }
  35093. if m.id == nil || m.oldValue == nil {
  35094. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35095. }
  35096. oldValue, err := m.oldValue(ctx)
  35097. if err != nil {
  35098. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35099. }
  35100. return oldValue.UpdatedAt, nil
  35101. }
  35102. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35103. func (m *WhatsappMutation) ResetUpdatedAt() {
  35104. m.updated_at = nil
  35105. }
  35106. // SetStatus sets the "status" field.
  35107. func (m *WhatsappMutation) SetStatus(u uint8) {
  35108. m.status = &u
  35109. m.addstatus = nil
  35110. }
  35111. // Status returns the value of the "status" field in the mutation.
  35112. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  35113. v := m.status
  35114. if v == nil {
  35115. return
  35116. }
  35117. return *v, true
  35118. }
  35119. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  35120. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35122. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35123. if !m.op.Is(OpUpdateOne) {
  35124. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35125. }
  35126. if m.id == nil || m.oldValue == nil {
  35127. return v, errors.New("OldStatus requires an ID field in the mutation")
  35128. }
  35129. oldValue, err := m.oldValue(ctx)
  35130. if err != nil {
  35131. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35132. }
  35133. return oldValue.Status, nil
  35134. }
  35135. // AddStatus adds u to the "status" field.
  35136. func (m *WhatsappMutation) AddStatus(u int8) {
  35137. if m.addstatus != nil {
  35138. *m.addstatus += u
  35139. } else {
  35140. m.addstatus = &u
  35141. }
  35142. }
  35143. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35144. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  35145. v := m.addstatus
  35146. if v == nil {
  35147. return
  35148. }
  35149. return *v, true
  35150. }
  35151. // ClearStatus clears the value of the "status" field.
  35152. func (m *WhatsappMutation) ClearStatus() {
  35153. m.status = nil
  35154. m.addstatus = nil
  35155. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  35156. }
  35157. // StatusCleared returns if the "status" field was cleared in this mutation.
  35158. func (m *WhatsappMutation) StatusCleared() bool {
  35159. _, ok := m.clearedFields[whatsapp.FieldStatus]
  35160. return ok
  35161. }
  35162. // ResetStatus resets all changes to the "status" field.
  35163. func (m *WhatsappMutation) ResetStatus() {
  35164. m.status = nil
  35165. m.addstatus = nil
  35166. delete(m.clearedFields, whatsapp.FieldStatus)
  35167. }
  35168. // SetDeletedAt sets the "deleted_at" field.
  35169. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  35170. m.deleted_at = &t
  35171. }
  35172. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35173. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  35174. v := m.deleted_at
  35175. if v == nil {
  35176. return
  35177. }
  35178. return *v, true
  35179. }
  35180. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  35181. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35183. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35184. if !m.op.Is(OpUpdateOne) {
  35185. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35186. }
  35187. if m.id == nil || m.oldValue == nil {
  35188. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35189. }
  35190. oldValue, err := m.oldValue(ctx)
  35191. if err != nil {
  35192. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35193. }
  35194. return oldValue.DeletedAt, nil
  35195. }
  35196. // ClearDeletedAt clears the value of the "deleted_at" field.
  35197. func (m *WhatsappMutation) ClearDeletedAt() {
  35198. m.deleted_at = nil
  35199. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  35200. }
  35201. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35202. func (m *WhatsappMutation) DeletedAtCleared() bool {
  35203. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  35204. return ok
  35205. }
  35206. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35207. func (m *WhatsappMutation) ResetDeletedAt() {
  35208. m.deleted_at = nil
  35209. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  35210. }
  35211. // SetWaID sets the "wa_id" field.
  35212. func (m *WhatsappMutation) SetWaID(s string) {
  35213. m.wa_id = &s
  35214. }
  35215. // WaID returns the value of the "wa_id" field in the mutation.
  35216. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  35217. v := m.wa_id
  35218. if v == nil {
  35219. return
  35220. }
  35221. return *v, true
  35222. }
  35223. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  35224. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35226. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  35227. if !m.op.Is(OpUpdateOne) {
  35228. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35229. }
  35230. if m.id == nil || m.oldValue == nil {
  35231. return v, errors.New("OldWaID requires an ID field in the mutation")
  35232. }
  35233. oldValue, err := m.oldValue(ctx)
  35234. if err != nil {
  35235. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35236. }
  35237. return oldValue.WaID, nil
  35238. }
  35239. // ClearWaID clears the value of the "wa_id" field.
  35240. func (m *WhatsappMutation) ClearWaID() {
  35241. m.wa_id = nil
  35242. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  35243. }
  35244. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35245. func (m *WhatsappMutation) WaIDCleared() bool {
  35246. _, ok := m.clearedFields[whatsapp.FieldWaID]
  35247. return ok
  35248. }
  35249. // ResetWaID resets all changes to the "wa_id" field.
  35250. func (m *WhatsappMutation) ResetWaID() {
  35251. m.wa_id = nil
  35252. delete(m.clearedFields, whatsapp.FieldWaID)
  35253. }
  35254. // SetWaName sets the "wa_name" field.
  35255. func (m *WhatsappMutation) SetWaName(s string) {
  35256. m.wa_name = &s
  35257. }
  35258. // WaName returns the value of the "wa_name" field in the mutation.
  35259. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  35260. v := m.wa_name
  35261. if v == nil {
  35262. return
  35263. }
  35264. return *v, true
  35265. }
  35266. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  35267. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35269. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  35270. if !m.op.Is(OpUpdateOne) {
  35271. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35272. }
  35273. if m.id == nil || m.oldValue == nil {
  35274. return v, errors.New("OldWaName requires an ID field in the mutation")
  35275. }
  35276. oldValue, err := m.oldValue(ctx)
  35277. if err != nil {
  35278. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35279. }
  35280. return oldValue.WaName, nil
  35281. }
  35282. // ClearWaName clears the value of the "wa_name" field.
  35283. func (m *WhatsappMutation) ClearWaName() {
  35284. m.wa_name = nil
  35285. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  35286. }
  35287. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35288. func (m *WhatsappMutation) WaNameCleared() bool {
  35289. _, ok := m.clearedFields[whatsapp.FieldWaName]
  35290. return ok
  35291. }
  35292. // ResetWaName resets all changes to the "wa_name" field.
  35293. func (m *WhatsappMutation) ResetWaName() {
  35294. m.wa_name = nil
  35295. delete(m.clearedFields, whatsapp.FieldWaName)
  35296. }
  35297. // SetCallback sets the "callback" field.
  35298. func (m *WhatsappMutation) SetCallback(s string) {
  35299. m.callback = &s
  35300. }
  35301. // Callback returns the value of the "callback" field in the mutation.
  35302. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  35303. v := m.callback
  35304. if v == nil {
  35305. return
  35306. }
  35307. return *v, true
  35308. }
  35309. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  35310. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35312. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  35313. if !m.op.Is(OpUpdateOne) {
  35314. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35315. }
  35316. if m.id == nil || m.oldValue == nil {
  35317. return v, errors.New("OldCallback requires an ID field in the mutation")
  35318. }
  35319. oldValue, err := m.oldValue(ctx)
  35320. if err != nil {
  35321. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35322. }
  35323. return oldValue.Callback, nil
  35324. }
  35325. // ClearCallback clears the value of the "callback" field.
  35326. func (m *WhatsappMutation) ClearCallback() {
  35327. m.callback = nil
  35328. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  35329. }
  35330. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  35331. func (m *WhatsappMutation) CallbackCleared() bool {
  35332. _, ok := m.clearedFields[whatsapp.FieldCallback]
  35333. return ok
  35334. }
  35335. // ResetCallback resets all changes to the "callback" field.
  35336. func (m *WhatsappMutation) ResetCallback() {
  35337. m.callback = nil
  35338. delete(m.clearedFields, whatsapp.FieldCallback)
  35339. }
  35340. // SetAgentID sets the "agent_id" field.
  35341. func (m *WhatsappMutation) SetAgentID(u uint64) {
  35342. m.agent = &u
  35343. }
  35344. // AgentID returns the value of the "agent_id" field in the mutation.
  35345. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  35346. v := m.agent
  35347. if v == nil {
  35348. return
  35349. }
  35350. return *v, true
  35351. }
  35352. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  35353. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35355. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35356. if !m.op.Is(OpUpdateOne) {
  35357. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35358. }
  35359. if m.id == nil || m.oldValue == nil {
  35360. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35361. }
  35362. oldValue, err := m.oldValue(ctx)
  35363. if err != nil {
  35364. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35365. }
  35366. return oldValue.AgentID, nil
  35367. }
  35368. // ResetAgentID resets all changes to the "agent_id" field.
  35369. func (m *WhatsappMutation) ResetAgentID() {
  35370. m.agent = nil
  35371. }
  35372. // SetAccount sets the "account" field.
  35373. func (m *WhatsappMutation) SetAccount(s string) {
  35374. m.account = &s
  35375. }
  35376. // Account returns the value of the "account" field in the mutation.
  35377. func (m *WhatsappMutation) Account() (r string, exists bool) {
  35378. v := m.account
  35379. if v == nil {
  35380. return
  35381. }
  35382. return *v, true
  35383. }
  35384. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  35385. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35387. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  35388. if !m.op.Is(OpUpdateOne) {
  35389. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35390. }
  35391. if m.id == nil || m.oldValue == nil {
  35392. return v, errors.New("OldAccount requires an ID field in the mutation")
  35393. }
  35394. oldValue, err := m.oldValue(ctx)
  35395. if err != nil {
  35396. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35397. }
  35398. return oldValue.Account, nil
  35399. }
  35400. // ClearAccount clears the value of the "account" field.
  35401. func (m *WhatsappMutation) ClearAccount() {
  35402. m.account = nil
  35403. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  35404. }
  35405. // AccountCleared returns if the "account" field was cleared in this mutation.
  35406. func (m *WhatsappMutation) AccountCleared() bool {
  35407. _, ok := m.clearedFields[whatsapp.FieldAccount]
  35408. return ok
  35409. }
  35410. // ResetAccount resets all changes to the "account" field.
  35411. func (m *WhatsappMutation) ResetAccount() {
  35412. m.account = nil
  35413. delete(m.clearedFields, whatsapp.FieldAccount)
  35414. }
  35415. // SetCc sets the "cc" field.
  35416. func (m *WhatsappMutation) SetCc(s string) {
  35417. m.cc = &s
  35418. }
  35419. // Cc returns the value of the "cc" field in the mutation.
  35420. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  35421. v := m.cc
  35422. if v == nil {
  35423. return
  35424. }
  35425. return *v, true
  35426. }
  35427. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  35428. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35430. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  35431. if !m.op.Is(OpUpdateOne) {
  35432. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  35433. }
  35434. if m.id == nil || m.oldValue == nil {
  35435. return v, errors.New("OldCc requires an ID field in the mutation")
  35436. }
  35437. oldValue, err := m.oldValue(ctx)
  35438. if err != nil {
  35439. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  35440. }
  35441. return oldValue.Cc, nil
  35442. }
  35443. // ResetCc resets all changes to the "cc" field.
  35444. func (m *WhatsappMutation) ResetCc() {
  35445. m.cc = nil
  35446. }
  35447. // SetPhone sets the "phone" field.
  35448. func (m *WhatsappMutation) SetPhone(s string) {
  35449. m.phone = &s
  35450. }
  35451. // Phone returns the value of the "phone" field in the mutation.
  35452. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  35453. v := m.phone
  35454. if v == nil {
  35455. return
  35456. }
  35457. return *v, true
  35458. }
  35459. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  35460. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35462. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  35463. if !m.op.Is(OpUpdateOne) {
  35464. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35465. }
  35466. if m.id == nil || m.oldValue == nil {
  35467. return v, errors.New("OldPhone requires an ID field in the mutation")
  35468. }
  35469. oldValue, err := m.oldValue(ctx)
  35470. if err != nil {
  35471. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35472. }
  35473. return oldValue.Phone, nil
  35474. }
  35475. // ResetPhone resets all changes to the "phone" field.
  35476. func (m *WhatsappMutation) ResetPhone() {
  35477. m.phone = nil
  35478. }
  35479. // SetCcPhone sets the "cc_phone" field.
  35480. func (m *WhatsappMutation) SetCcPhone(s string) {
  35481. m.cc_phone = &s
  35482. }
  35483. // CcPhone returns the value of the "cc_phone" field in the mutation.
  35484. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  35485. v := m.cc_phone
  35486. if v == nil {
  35487. return
  35488. }
  35489. return *v, true
  35490. }
  35491. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  35492. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35494. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  35495. if !m.op.Is(OpUpdateOne) {
  35496. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  35497. }
  35498. if m.id == nil || m.oldValue == nil {
  35499. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  35500. }
  35501. oldValue, err := m.oldValue(ctx)
  35502. if err != nil {
  35503. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  35504. }
  35505. return oldValue.CcPhone, nil
  35506. }
  35507. // ResetCcPhone resets all changes to the "cc_phone" field.
  35508. func (m *WhatsappMutation) ResetCcPhone() {
  35509. m.cc_phone = nil
  35510. }
  35511. // SetPhoneName sets the "phone_name" field.
  35512. func (m *WhatsappMutation) SetPhoneName(s string) {
  35513. m.phone_name = &s
  35514. }
  35515. // PhoneName returns the value of the "phone_name" field in the mutation.
  35516. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  35517. v := m.phone_name
  35518. if v == nil {
  35519. return
  35520. }
  35521. return *v, true
  35522. }
  35523. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  35524. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35526. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  35527. if !m.op.Is(OpUpdateOne) {
  35528. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  35529. }
  35530. if m.id == nil || m.oldValue == nil {
  35531. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  35532. }
  35533. oldValue, err := m.oldValue(ctx)
  35534. if err != nil {
  35535. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  35536. }
  35537. return oldValue.PhoneName, nil
  35538. }
  35539. // ResetPhoneName resets all changes to the "phone_name" field.
  35540. func (m *WhatsappMutation) ResetPhoneName() {
  35541. m.phone_name = nil
  35542. }
  35543. // SetPhoneStatus sets the "phone_status" field.
  35544. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  35545. m.phone_status = &i
  35546. m.addphone_status = nil
  35547. }
  35548. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  35549. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  35550. v := m.phone_status
  35551. if v == nil {
  35552. return
  35553. }
  35554. return *v, true
  35555. }
  35556. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  35557. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35559. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  35560. if !m.op.Is(OpUpdateOne) {
  35561. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  35562. }
  35563. if m.id == nil || m.oldValue == nil {
  35564. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  35565. }
  35566. oldValue, err := m.oldValue(ctx)
  35567. if err != nil {
  35568. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  35569. }
  35570. return oldValue.PhoneStatus, nil
  35571. }
  35572. // AddPhoneStatus adds i to the "phone_status" field.
  35573. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  35574. if m.addphone_status != nil {
  35575. *m.addphone_status += i
  35576. } else {
  35577. m.addphone_status = &i
  35578. }
  35579. }
  35580. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  35581. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  35582. v := m.addphone_status
  35583. if v == nil {
  35584. return
  35585. }
  35586. return *v, true
  35587. }
  35588. // ResetPhoneStatus resets all changes to the "phone_status" field.
  35589. func (m *WhatsappMutation) ResetPhoneStatus() {
  35590. m.phone_status = nil
  35591. m.addphone_status = nil
  35592. }
  35593. // SetOrganizationID sets the "organization_id" field.
  35594. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  35595. m.organization_id = &u
  35596. m.addorganization_id = nil
  35597. }
  35598. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35599. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  35600. v := m.organization_id
  35601. if v == nil {
  35602. return
  35603. }
  35604. return *v, true
  35605. }
  35606. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  35607. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35609. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35610. if !m.op.Is(OpUpdateOne) {
  35611. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35612. }
  35613. if m.id == nil || m.oldValue == nil {
  35614. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35615. }
  35616. oldValue, err := m.oldValue(ctx)
  35617. if err != nil {
  35618. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35619. }
  35620. return oldValue.OrganizationID, nil
  35621. }
  35622. // AddOrganizationID adds u to the "organization_id" field.
  35623. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  35624. if m.addorganization_id != nil {
  35625. *m.addorganization_id += u
  35626. } else {
  35627. m.addorganization_id = &u
  35628. }
  35629. }
  35630. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35631. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  35632. v := m.addorganization_id
  35633. if v == nil {
  35634. return
  35635. }
  35636. return *v, true
  35637. }
  35638. // ClearOrganizationID clears the value of the "organization_id" field.
  35639. func (m *WhatsappMutation) ClearOrganizationID() {
  35640. m.organization_id = nil
  35641. m.addorganization_id = nil
  35642. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  35643. }
  35644. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35645. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  35646. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  35647. return ok
  35648. }
  35649. // ResetOrganizationID resets all changes to the "organization_id" field.
  35650. func (m *WhatsappMutation) ResetOrganizationID() {
  35651. m.organization_id = nil
  35652. m.addorganization_id = nil
  35653. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  35654. }
  35655. // SetAPIBase sets the "api_base" field.
  35656. func (m *WhatsappMutation) SetAPIBase(s string) {
  35657. m.api_base = &s
  35658. }
  35659. // APIBase returns the value of the "api_base" field in the mutation.
  35660. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  35661. v := m.api_base
  35662. if v == nil {
  35663. return
  35664. }
  35665. return *v, true
  35666. }
  35667. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  35668. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35670. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35671. if !m.op.Is(OpUpdateOne) {
  35672. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35673. }
  35674. if m.id == nil || m.oldValue == nil {
  35675. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35676. }
  35677. oldValue, err := m.oldValue(ctx)
  35678. if err != nil {
  35679. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35680. }
  35681. return oldValue.APIBase, nil
  35682. }
  35683. // ClearAPIBase clears the value of the "api_base" field.
  35684. func (m *WhatsappMutation) ClearAPIBase() {
  35685. m.api_base = nil
  35686. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  35687. }
  35688. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35689. func (m *WhatsappMutation) APIBaseCleared() bool {
  35690. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  35691. return ok
  35692. }
  35693. // ResetAPIBase resets all changes to the "api_base" field.
  35694. func (m *WhatsappMutation) ResetAPIBase() {
  35695. m.api_base = nil
  35696. delete(m.clearedFields, whatsapp.FieldAPIBase)
  35697. }
  35698. // SetAPIKey sets the "api_key" field.
  35699. func (m *WhatsappMutation) SetAPIKey(s string) {
  35700. m.api_key = &s
  35701. }
  35702. // APIKey returns the value of the "api_key" field in the mutation.
  35703. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  35704. v := m.api_key
  35705. if v == nil {
  35706. return
  35707. }
  35708. return *v, true
  35709. }
  35710. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  35711. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35713. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35714. if !m.op.Is(OpUpdateOne) {
  35715. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35716. }
  35717. if m.id == nil || m.oldValue == nil {
  35718. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35719. }
  35720. oldValue, err := m.oldValue(ctx)
  35721. if err != nil {
  35722. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35723. }
  35724. return oldValue.APIKey, nil
  35725. }
  35726. // ClearAPIKey clears the value of the "api_key" field.
  35727. func (m *WhatsappMutation) ClearAPIKey() {
  35728. m.api_key = nil
  35729. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  35730. }
  35731. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35732. func (m *WhatsappMutation) APIKeyCleared() bool {
  35733. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  35734. return ok
  35735. }
  35736. // ResetAPIKey resets all changes to the "api_key" field.
  35737. func (m *WhatsappMutation) ResetAPIKey() {
  35738. m.api_key = nil
  35739. delete(m.clearedFields, whatsapp.FieldAPIKey)
  35740. }
  35741. // SetAllowList sets the "allow_list" field.
  35742. func (m *WhatsappMutation) SetAllowList(s []string) {
  35743. m.allow_list = &s
  35744. m.appendallow_list = nil
  35745. }
  35746. // AllowList returns the value of the "allow_list" field in the mutation.
  35747. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  35748. v := m.allow_list
  35749. if v == nil {
  35750. return
  35751. }
  35752. return *v, true
  35753. }
  35754. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  35755. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35757. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35758. if !m.op.Is(OpUpdateOne) {
  35759. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35760. }
  35761. if m.id == nil || m.oldValue == nil {
  35762. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35763. }
  35764. oldValue, err := m.oldValue(ctx)
  35765. if err != nil {
  35766. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35767. }
  35768. return oldValue.AllowList, nil
  35769. }
  35770. // AppendAllowList adds s to the "allow_list" field.
  35771. func (m *WhatsappMutation) AppendAllowList(s []string) {
  35772. m.appendallow_list = append(m.appendallow_list, s...)
  35773. }
  35774. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35775. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  35776. if len(m.appendallow_list) == 0 {
  35777. return nil, false
  35778. }
  35779. return m.appendallow_list, true
  35780. }
  35781. // ClearAllowList clears the value of the "allow_list" field.
  35782. func (m *WhatsappMutation) ClearAllowList() {
  35783. m.allow_list = nil
  35784. m.appendallow_list = nil
  35785. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  35786. }
  35787. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  35788. func (m *WhatsappMutation) AllowListCleared() bool {
  35789. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  35790. return ok
  35791. }
  35792. // ResetAllowList resets all changes to the "allow_list" field.
  35793. func (m *WhatsappMutation) ResetAllowList() {
  35794. m.allow_list = nil
  35795. m.appendallow_list = nil
  35796. delete(m.clearedFields, whatsapp.FieldAllowList)
  35797. }
  35798. // SetGroupAllowList sets the "group_allow_list" field.
  35799. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  35800. m.group_allow_list = &s
  35801. m.appendgroup_allow_list = nil
  35802. }
  35803. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35804. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  35805. v := m.group_allow_list
  35806. if v == nil {
  35807. return
  35808. }
  35809. return *v, true
  35810. }
  35811. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  35812. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35814. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35815. if !m.op.Is(OpUpdateOne) {
  35816. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35817. }
  35818. if m.id == nil || m.oldValue == nil {
  35819. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35820. }
  35821. oldValue, err := m.oldValue(ctx)
  35822. if err != nil {
  35823. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35824. }
  35825. return oldValue.GroupAllowList, nil
  35826. }
  35827. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35828. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  35829. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35830. }
  35831. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35832. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  35833. if len(m.appendgroup_allow_list) == 0 {
  35834. return nil, false
  35835. }
  35836. return m.appendgroup_allow_list, true
  35837. }
  35838. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  35839. func (m *WhatsappMutation) ClearGroupAllowList() {
  35840. m.group_allow_list = nil
  35841. m.appendgroup_allow_list = nil
  35842. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  35843. }
  35844. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  35845. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  35846. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  35847. return ok
  35848. }
  35849. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35850. func (m *WhatsappMutation) ResetGroupAllowList() {
  35851. m.group_allow_list = nil
  35852. m.appendgroup_allow_list = nil
  35853. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  35854. }
  35855. // SetBlockList sets the "block_list" field.
  35856. func (m *WhatsappMutation) SetBlockList(s []string) {
  35857. m.block_list = &s
  35858. m.appendblock_list = nil
  35859. }
  35860. // BlockList returns the value of the "block_list" field in the mutation.
  35861. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  35862. v := m.block_list
  35863. if v == nil {
  35864. return
  35865. }
  35866. return *v, true
  35867. }
  35868. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  35869. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35871. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35872. if !m.op.Is(OpUpdateOne) {
  35873. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35874. }
  35875. if m.id == nil || m.oldValue == nil {
  35876. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35877. }
  35878. oldValue, err := m.oldValue(ctx)
  35879. if err != nil {
  35880. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35881. }
  35882. return oldValue.BlockList, nil
  35883. }
  35884. // AppendBlockList adds s to the "block_list" field.
  35885. func (m *WhatsappMutation) AppendBlockList(s []string) {
  35886. m.appendblock_list = append(m.appendblock_list, s...)
  35887. }
  35888. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35889. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  35890. if len(m.appendblock_list) == 0 {
  35891. return nil, false
  35892. }
  35893. return m.appendblock_list, true
  35894. }
  35895. // ClearBlockList clears the value of the "block_list" field.
  35896. func (m *WhatsappMutation) ClearBlockList() {
  35897. m.block_list = nil
  35898. m.appendblock_list = nil
  35899. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  35900. }
  35901. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  35902. func (m *WhatsappMutation) BlockListCleared() bool {
  35903. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  35904. return ok
  35905. }
  35906. // ResetBlockList resets all changes to the "block_list" field.
  35907. func (m *WhatsappMutation) ResetBlockList() {
  35908. m.block_list = nil
  35909. m.appendblock_list = nil
  35910. delete(m.clearedFields, whatsapp.FieldBlockList)
  35911. }
  35912. // SetGroupBlockList sets the "group_block_list" field.
  35913. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  35914. m.group_block_list = &s
  35915. m.appendgroup_block_list = nil
  35916. }
  35917. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  35918. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  35919. v := m.group_block_list
  35920. if v == nil {
  35921. return
  35922. }
  35923. return *v, true
  35924. }
  35925. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  35926. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35928. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  35929. if !m.op.Is(OpUpdateOne) {
  35930. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  35931. }
  35932. if m.id == nil || m.oldValue == nil {
  35933. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  35934. }
  35935. oldValue, err := m.oldValue(ctx)
  35936. if err != nil {
  35937. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  35938. }
  35939. return oldValue.GroupBlockList, nil
  35940. }
  35941. // AppendGroupBlockList adds s to the "group_block_list" field.
  35942. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  35943. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  35944. }
  35945. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  35946. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  35947. if len(m.appendgroup_block_list) == 0 {
  35948. return nil, false
  35949. }
  35950. return m.appendgroup_block_list, true
  35951. }
  35952. // ClearGroupBlockList clears the value of the "group_block_list" field.
  35953. func (m *WhatsappMutation) ClearGroupBlockList() {
  35954. m.group_block_list = nil
  35955. m.appendgroup_block_list = nil
  35956. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  35957. }
  35958. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  35959. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  35960. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  35961. return ok
  35962. }
  35963. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  35964. func (m *WhatsappMutation) ResetGroupBlockList() {
  35965. m.group_block_list = nil
  35966. m.appendgroup_block_list = nil
  35967. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  35968. }
  35969. // ClearAgent clears the "agent" edge to the Agent entity.
  35970. func (m *WhatsappMutation) ClearAgent() {
  35971. m.clearedagent = true
  35972. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  35973. }
  35974. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  35975. func (m *WhatsappMutation) AgentCleared() bool {
  35976. return m.clearedagent
  35977. }
  35978. // AgentIDs returns the "agent" edge IDs in the mutation.
  35979. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35980. // AgentID instead. It exists only for internal usage by the builders.
  35981. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  35982. if id := m.agent; id != nil {
  35983. ids = append(ids, *id)
  35984. }
  35985. return
  35986. }
  35987. // ResetAgent resets all changes to the "agent" edge.
  35988. func (m *WhatsappMutation) ResetAgent() {
  35989. m.agent = nil
  35990. m.clearedagent = false
  35991. }
  35992. // Where appends a list predicates to the WhatsappMutation builder.
  35993. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  35994. m.predicates = append(m.predicates, ps...)
  35995. }
  35996. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  35997. // users can use type-assertion to append predicates that do not depend on any generated package.
  35998. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  35999. p := make([]predicate.Whatsapp, len(ps))
  36000. for i := range ps {
  36001. p[i] = ps[i]
  36002. }
  36003. m.Where(p...)
  36004. }
  36005. // Op returns the operation name.
  36006. func (m *WhatsappMutation) Op() Op {
  36007. return m.op
  36008. }
  36009. // SetOp allows setting the mutation operation.
  36010. func (m *WhatsappMutation) SetOp(op Op) {
  36011. m.op = op
  36012. }
  36013. // Type returns the node type of this mutation (Whatsapp).
  36014. func (m *WhatsappMutation) Type() string {
  36015. return m.typ
  36016. }
  36017. // Fields returns all fields that were changed during this mutation. Note that in
  36018. // order to get all numeric fields that were incremented/decremented, call
  36019. // AddedFields().
  36020. func (m *WhatsappMutation) Fields() []string {
  36021. fields := make([]string, 0, 21)
  36022. if m.created_at != nil {
  36023. fields = append(fields, whatsapp.FieldCreatedAt)
  36024. }
  36025. if m.updated_at != nil {
  36026. fields = append(fields, whatsapp.FieldUpdatedAt)
  36027. }
  36028. if m.status != nil {
  36029. fields = append(fields, whatsapp.FieldStatus)
  36030. }
  36031. if m.deleted_at != nil {
  36032. fields = append(fields, whatsapp.FieldDeletedAt)
  36033. }
  36034. if m.wa_id != nil {
  36035. fields = append(fields, whatsapp.FieldWaID)
  36036. }
  36037. if m.wa_name != nil {
  36038. fields = append(fields, whatsapp.FieldWaName)
  36039. }
  36040. if m.callback != nil {
  36041. fields = append(fields, whatsapp.FieldCallback)
  36042. }
  36043. if m.agent != nil {
  36044. fields = append(fields, whatsapp.FieldAgentID)
  36045. }
  36046. if m.account != nil {
  36047. fields = append(fields, whatsapp.FieldAccount)
  36048. }
  36049. if m.cc != nil {
  36050. fields = append(fields, whatsapp.FieldCc)
  36051. }
  36052. if m.phone != nil {
  36053. fields = append(fields, whatsapp.FieldPhone)
  36054. }
  36055. if m.cc_phone != nil {
  36056. fields = append(fields, whatsapp.FieldCcPhone)
  36057. }
  36058. if m.phone_name != nil {
  36059. fields = append(fields, whatsapp.FieldPhoneName)
  36060. }
  36061. if m.phone_status != nil {
  36062. fields = append(fields, whatsapp.FieldPhoneStatus)
  36063. }
  36064. if m.organization_id != nil {
  36065. fields = append(fields, whatsapp.FieldOrganizationID)
  36066. }
  36067. if m.api_base != nil {
  36068. fields = append(fields, whatsapp.FieldAPIBase)
  36069. }
  36070. if m.api_key != nil {
  36071. fields = append(fields, whatsapp.FieldAPIKey)
  36072. }
  36073. if m.allow_list != nil {
  36074. fields = append(fields, whatsapp.FieldAllowList)
  36075. }
  36076. if m.group_allow_list != nil {
  36077. fields = append(fields, whatsapp.FieldGroupAllowList)
  36078. }
  36079. if m.block_list != nil {
  36080. fields = append(fields, whatsapp.FieldBlockList)
  36081. }
  36082. if m.group_block_list != nil {
  36083. fields = append(fields, whatsapp.FieldGroupBlockList)
  36084. }
  36085. return fields
  36086. }
  36087. // Field returns the value of a field with the given name. The second boolean
  36088. // return value indicates that this field was not set, or was not defined in the
  36089. // schema.
  36090. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  36091. switch name {
  36092. case whatsapp.FieldCreatedAt:
  36093. return m.CreatedAt()
  36094. case whatsapp.FieldUpdatedAt:
  36095. return m.UpdatedAt()
  36096. case whatsapp.FieldStatus:
  36097. return m.Status()
  36098. case whatsapp.FieldDeletedAt:
  36099. return m.DeletedAt()
  36100. case whatsapp.FieldWaID:
  36101. return m.WaID()
  36102. case whatsapp.FieldWaName:
  36103. return m.WaName()
  36104. case whatsapp.FieldCallback:
  36105. return m.Callback()
  36106. case whatsapp.FieldAgentID:
  36107. return m.AgentID()
  36108. case whatsapp.FieldAccount:
  36109. return m.Account()
  36110. case whatsapp.FieldCc:
  36111. return m.Cc()
  36112. case whatsapp.FieldPhone:
  36113. return m.Phone()
  36114. case whatsapp.FieldCcPhone:
  36115. return m.CcPhone()
  36116. case whatsapp.FieldPhoneName:
  36117. return m.PhoneName()
  36118. case whatsapp.FieldPhoneStatus:
  36119. return m.PhoneStatus()
  36120. case whatsapp.FieldOrganizationID:
  36121. return m.OrganizationID()
  36122. case whatsapp.FieldAPIBase:
  36123. return m.APIBase()
  36124. case whatsapp.FieldAPIKey:
  36125. return m.APIKey()
  36126. case whatsapp.FieldAllowList:
  36127. return m.AllowList()
  36128. case whatsapp.FieldGroupAllowList:
  36129. return m.GroupAllowList()
  36130. case whatsapp.FieldBlockList:
  36131. return m.BlockList()
  36132. case whatsapp.FieldGroupBlockList:
  36133. return m.GroupBlockList()
  36134. }
  36135. return nil, false
  36136. }
  36137. // OldField returns the old value of the field from the database. An error is
  36138. // returned if the mutation operation is not UpdateOne, or the query to the
  36139. // database failed.
  36140. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36141. switch name {
  36142. case whatsapp.FieldCreatedAt:
  36143. return m.OldCreatedAt(ctx)
  36144. case whatsapp.FieldUpdatedAt:
  36145. return m.OldUpdatedAt(ctx)
  36146. case whatsapp.FieldStatus:
  36147. return m.OldStatus(ctx)
  36148. case whatsapp.FieldDeletedAt:
  36149. return m.OldDeletedAt(ctx)
  36150. case whatsapp.FieldWaID:
  36151. return m.OldWaID(ctx)
  36152. case whatsapp.FieldWaName:
  36153. return m.OldWaName(ctx)
  36154. case whatsapp.FieldCallback:
  36155. return m.OldCallback(ctx)
  36156. case whatsapp.FieldAgentID:
  36157. return m.OldAgentID(ctx)
  36158. case whatsapp.FieldAccount:
  36159. return m.OldAccount(ctx)
  36160. case whatsapp.FieldCc:
  36161. return m.OldCc(ctx)
  36162. case whatsapp.FieldPhone:
  36163. return m.OldPhone(ctx)
  36164. case whatsapp.FieldCcPhone:
  36165. return m.OldCcPhone(ctx)
  36166. case whatsapp.FieldPhoneName:
  36167. return m.OldPhoneName(ctx)
  36168. case whatsapp.FieldPhoneStatus:
  36169. return m.OldPhoneStatus(ctx)
  36170. case whatsapp.FieldOrganizationID:
  36171. return m.OldOrganizationID(ctx)
  36172. case whatsapp.FieldAPIBase:
  36173. return m.OldAPIBase(ctx)
  36174. case whatsapp.FieldAPIKey:
  36175. return m.OldAPIKey(ctx)
  36176. case whatsapp.FieldAllowList:
  36177. return m.OldAllowList(ctx)
  36178. case whatsapp.FieldGroupAllowList:
  36179. return m.OldGroupAllowList(ctx)
  36180. case whatsapp.FieldBlockList:
  36181. return m.OldBlockList(ctx)
  36182. case whatsapp.FieldGroupBlockList:
  36183. return m.OldGroupBlockList(ctx)
  36184. }
  36185. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  36186. }
  36187. // SetField sets the value of a field with the given name. It returns an error if
  36188. // the field is not defined in the schema, or if the type mismatched the field
  36189. // type.
  36190. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  36191. switch name {
  36192. case whatsapp.FieldCreatedAt:
  36193. v, ok := value.(time.Time)
  36194. if !ok {
  36195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36196. }
  36197. m.SetCreatedAt(v)
  36198. return nil
  36199. case whatsapp.FieldUpdatedAt:
  36200. v, ok := value.(time.Time)
  36201. if !ok {
  36202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36203. }
  36204. m.SetUpdatedAt(v)
  36205. return nil
  36206. case whatsapp.FieldStatus:
  36207. v, ok := value.(uint8)
  36208. if !ok {
  36209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36210. }
  36211. m.SetStatus(v)
  36212. return nil
  36213. case whatsapp.FieldDeletedAt:
  36214. v, ok := value.(time.Time)
  36215. if !ok {
  36216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36217. }
  36218. m.SetDeletedAt(v)
  36219. return nil
  36220. case whatsapp.FieldWaID:
  36221. v, ok := value.(string)
  36222. if !ok {
  36223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36224. }
  36225. m.SetWaID(v)
  36226. return nil
  36227. case whatsapp.FieldWaName:
  36228. v, ok := value.(string)
  36229. if !ok {
  36230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36231. }
  36232. m.SetWaName(v)
  36233. return nil
  36234. case whatsapp.FieldCallback:
  36235. v, ok := value.(string)
  36236. if !ok {
  36237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36238. }
  36239. m.SetCallback(v)
  36240. return nil
  36241. case whatsapp.FieldAgentID:
  36242. v, ok := value.(uint64)
  36243. if !ok {
  36244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36245. }
  36246. m.SetAgentID(v)
  36247. return nil
  36248. case whatsapp.FieldAccount:
  36249. v, ok := value.(string)
  36250. if !ok {
  36251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36252. }
  36253. m.SetAccount(v)
  36254. return nil
  36255. case whatsapp.FieldCc:
  36256. v, ok := value.(string)
  36257. if !ok {
  36258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36259. }
  36260. m.SetCc(v)
  36261. return nil
  36262. case whatsapp.FieldPhone:
  36263. v, ok := value.(string)
  36264. if !ok {
  36265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36266. }
  36267. m.SetPhone(v)
  36268. return nil
  36269. case whatsapp.FieldCcPhone:
  36270. v, ok := value.(string)
  36271. if !ok {
  36272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36273. }
  36274. m.SetCcPhone(v)
  36275. return nil
  36276. case whatsapp.FieldPhoneName:
  36277. v, ok := value.(string)
  36278. if !ok {
  36279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36280. }
  36281. m.SetPhoneName(v)
  36282. return nil
  36283. case whatsapp.FieldPhoneStatus:
  36284. v, ok := value.(int8)
  36285. if !ok {
  36286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36287. }
  36288. m.SetPhoneStatus(v)
  36289. return nil
  36290. case whatsapp.FieldOrganizationID:
  36291. v, ok := value.(uint64)
  36292. if !ok {
  36293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36294. }
  36295. m.SetOrganizationID(v)
  36296. return nil
  36297. case whatsapp.FieldAPIBase:
  36298. v, ok := value.(string)
  36299. if !ok {
  36300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36301. }
  36302. m.SetAPIBase(v)
  36303. return nil
  36304. case whatsapp.FieldAPIKey:
  36305. v, ok := value.(string)
  36306. if !ok {
  36307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36308. }
  36309. m.SetAPIKey(v)
  36310. return nil
  36311. case whatsapp.FieldAllowList:
  36312. v, ok := value.([]string)
  36313. if !ok {
  36314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36315. }
  36316. m.SetAllowList(v)
  36317. return nil
  36318. case whatsapp.FieldGroupAllowList:
  36319. v, ok := value.([]string)
  36320. if !ok {
  36321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36322. }
  36323. m.SetGroupAllowList(v)
  36324. return nil
  36325. case whatsapp.FieldBlockList:
  36326. v, ok := value.([]string)
  36327. if !ok {
  36328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36329. }
  36330. m.SetBlockList(v)
  36331. return nil
  36332. case whatsapp.FieldGroupBlockList:
  36333. v, ok := value.([]string)
  36334. if !ok {
  36335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36336. }
  36337. m.SetGroupBlockList(v)
  36338. return nil
  36339. }
  36340. return fmt.Errorf("unknown Whatsapp field %s", name)
  36341. }
  36342. // AddedFields returns all numeric fields that were incremented/decremented during
  36343. // this mutation.
  36344. func (m *WhatsappMutation) AddedFields() []string {
  36345. var fields []string
  36346. if m.addstatus != nil {
  36347. fields = append(fields, whatsapp.FieldStatus)
  36348. }
  36349. if m.addphone_status != nil {
  36350. fields = append(fields, whatsapp.FieldPhoneStatus)
  36351. }
  36352. if m.addorganization_id != nil {
  36353. fields = append(fields, whatsapp.FieldOrganizationID)
  36354. }
  36355. return fields
  36356. }
  36357. // AddedField returns the numeric value that was incremented/decremented on a field
  36358. // with the given name. The second boolean return value indicates that this field
  36359. // was not set, or was not defined in the schema.
  36360. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  36361. switch name {
  36362. case whatsapp.FieldStatus:
  36363. return m.AddedStatus()
  36364. case whatsapp.FieldPhoneStatus:
  36365. return m.AddedPhoneStatus()
  36366. case whatsapp.FieldOrganizationID:
  36367. return m.AddedOrganizationID()
  36368. }
  36369. return nil, false
  36370. }
  36371. // AddField adds the value to the field with the given name. It returns an error if
  36372. // the field is not defined in the schema, or if the type mismatched the field
  36373. // type.
  36374. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  36375. switch name {
  36376. case whatsapp.FieldStatus:
  36377. v, ok := value.(int8)
  36378. if !ok {
  36379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36380. }
  36381. m.AddStatus(v)
  36382. return nil
  36383. case whatsapp.FieldPhoneStatus:
  36384. v, ok := value.(int8)
  36385. if !ok {
  36386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36387. }
  36388. m.AddPhoneStatus(v)
  36389. return nil
  36390. case whatsapp.FieldOrganizationID:
  36391. v, ok := value.(int64)
  36392. if !ok {
  36393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36394. }
  36395. m.AddOrganizationID(v)
  36396. return nil
  36397. }
  36398. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  36399. }
  36400. // ClearedFields returns all nullable fields that were cleared during this
  36401. // mutation.
  36402. func (m *WhatsappMutation) ClearedFields() []string {
  36403. var fields []string
  36404. if m.FieldCleared(whatsapp.FieldStatus) {
  36405. fields = append(fields, whatsapp.FieldStatus)
  36406. }
  36407. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  36408. fields = append(fields, whatsapp.FieldDeletedAt)
  36409. }
  36410. if m.FieldCleared(whatsapp.FieldWaID) {
  36411. fields = append(fields, whatsapp.FieldWaID)
  36412. }
  36413. if m.FieldCleared(whatsapp.FieldWaName) {
  36414. fields = append(fields, whatsapp.FieldWaName)
  36415. }
  36416. if m.FieldCleared(whatsapp.FieldCallback) {
  36417. fields = append(fields, whatsapp.FieldCallback)
  36418. }
  36419. if m.FieldCleared(whatsapp.FieldAccount) {
  36420. fields = append(fields, whatsapp.FieldAccount)
  36421. }
  36422. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  36423. fields = append(fields, whatsapp.FieldOrganizationID)
  36424. }
  36425. if m.FieldCleared(whatsapp.FieldAPIBase) {
  36426. fields = append(fields, whatsapp.FieldAPIBase)
  36427. }
  36428. if m.FieldCleared(whatsapp.FieldAPIKey) {
  36429. fields = append(fields, whatsapp.FieldAPIKey)
  36430. }
  36431. if m.FieldCleared(whatsapp.FieldAllowList) {
  36432. fields = append(fields, whatsapp.FieldAllowList)
  36433. }
  36434. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  36435. fields = append(fields, whatsapp.FieldGroupAllowList)
  36436. }
  36437. if m.FieldCleared(whatsapp.FieldBlockList) {
  36438. fields = append(fields, whatsapp.FieldBlockList)
  36439. }
  36440. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  36441. fields = append(fields, whatsapp.FieldGroupBlockList)
  36442. }
  36443. return fields
  36444. }
  36445. // FieldCleared returns a boolean indicating if a field with the given name was
  36446. // cleared in this mutation.
  36447. func (m *WhatsappMutation) FieldCleared(name string) bool {
  36448. _, ok := m.clearedFields[name]
  36449. return ok
  36450. }
  36451. // ClearField clears the value of the field with the given name. It returns an
  36452. // error if the field is not defined in the schema.
  36453. func (m *WhatsappMutation) ClearField(name string) error {
  36454. switch name {
  36455. case whatsapp.FieldStatus:
  36456. m.ClearStatus()
  36457. return nil
  36458. case whatsapp.FieldDeletedAt:
  36459. m.ClearDeletedAt()
  36460. return nil
  36461. case whatsapp.FieldWaID:
  36462. m.ClearWaID()
  36463. return nil
  36464. case whatsapp.FieldWaName:
  36465. m.ClearWaName()
  36466. return nil
  36467. case whatsapp.FieldCallback:
  36468. m.ClearCallback()
  36469. return nil
  36470. case whatsapp.FieldAccount:
  36471. m.ClearAccount()
  36472. return nil
  36473. case whatsapp.FieldOrganizationID:
  36474. m.ClearOrganizationID()
  36475. return nil
  36476. case whatsapp.FieldAPIBase:
  36477. m.ClearAPIBase()
  36478. return nil
  36479. case whatsapp.FieldAPIKey:
  36480. m.ClearAPIKey()
  36481. return nil
  36482. case whatsapp.FieldAllowList:
  36483. m.ClearAllowList()
  36484. return nil
  36485. case whatsapp.FieldGroupAllowList:
  36486. m.ClearGroupAllowList()
  36487. return nil
  36488. case whatsapp.FieldBlockList:
  36489. m.ClearBlockList()
  36490. return nil
  36491. case whatsapp.FieldGroupBlockList:
  36492. m.ClearGroupBlockList()
  36493. return nil
  36494. }
  36495. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  36496. }
  36497. // ResetField resets all changes in the mutation for the field with the given name.
  36498. // It returns an error if the field is not defined in the schema.
  36499. func (m *WhatsappMutation) ResetField(name string) error {
  36500. switch name {
  36501. case whatsapp.FieldCreatedAt:
  36502. m.ResetCreatedAt()
  36503. return nil
  36504. case whatsapp.FieldUpdatedAt:
  36505. m.ResetUpdatedAt()
  36506. return nil
  36507. case whatsapp.FieldStatus:
  36508. m.ResetStatus()
  36509. return nil
  36510. case whatsapp.FieldDeletedAt:
  36511. m.ResetDeletedAt()
  36512. return nil
  36513. case whatsapp.FieldWaID:
  36514. m.ResetWaID()
  36515. return nil
  36516. case whatsapp.FieldWaName:
  36517. m.ResetWaName()
  36518. return nil
  36519. case whatsapp.FieldCallback:
  36520. m.ResetCallback()
  36521. return nil
  36522. case whatsapp.FieldAgentID:
  36523. m.ResetAgentID()
  36524. return nil
  36525. case whatsapp.FieldAccount:
  36526. m.ResetAccount()
  36527. return nil
  36528. case whatsapp.FieldCc:
  36529. m.ResetCc()
  36530. return nil
  36531. case whatsapp.FieldPhone:
  36532. m.ResetPhone()
  36533. return nil
  36534. case whatsapp.FieldCcPhone:
  36535. m.ResetCcPhone()
  36536. return nil
  36537. case whatsapp.FieldPhoneName:
  36538. m.ResetPhoneName()
  36539. return nil
  36540. case whatsapp.FieldPhoneStatus:
  36541. m.ResetPhoneStatus()
  36542. return nil
  36543. case whatsapp.FieldOrganizationID:
  36544. m.ResetOrganizationID()
  36545. return nil
  36546. case whatsapp.FieldAPIBase:
  36547. m.ResetAPIBase()
  36548. return nil
  36549. case whatsapp.FieldAPIKey:
  36550. m.ResetAPIKey()
  36551. return nil
  36552. case whatsapp.FieldAllowList:
  36553. m.ResetAllowList()
  36554. return nil
  36555. case whatsapp.FieldGroupAllowList:
  36556. m.ResetGroupAllowList()
  36557. return nil
  36558. case whatsapp.FieldBlockList:
  36559. m.ResetBlockList()
  36560. return nil
  36561. case whatsapp.FieldGroupBlockList:
  36562. m.ResetGroupBlockList()
  36563. return nil
  36564. }
  36565. return fmt.Errorf("unknown Whatsapp field %s", name)
  36566. }
  36567. // AddedEdges returns all edge names that were set/added in this mutation.
  36568. func (m *WhatsappMutation) AddedEdges() []string {
  36569. edges := make([]string, 0, 1)
  36570. if m.agent != nil {
  36571. edges = append(edges, whatsapp.EdgeAgent)
  36572. }
  36573. return edges
  36574. }
  36575. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36576. // name in this mutation.
  36577. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  36578. switch name {
  36579. case whatsapp.EdgeAgent:
  36580. if id := m.agent; id != nil {
  36581. return []ent.Value{*id}
  36582. }
  36583. }
  36584. return nil
  36585. }
  36586. // RemovedEdges returns all edge names that were removed in this mutation.
  36587. func (m *WhatsappMutation) RemovedEdges() []string {
  36588. edges := make([]string, 0, 1)
  36589. return edges
  36590. }
  36591. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36592. // the given name in this mutation.
  36593. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  36594. return nil
  36595. }
  36596. // ClearedEdges returns all edge names that were cleared in this mutation.
  36597. func (m *WhatsappMutation) ClearedEdges() []string {
  36598. edges := make([]string, 0, 1)
  36599. if m.clearedagent {
  36600. edges = append(edges, whatsapp.EdgeAgent)
  36601. }
  36602. return edges
  36603. }
  36604. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36605. // was cleared in this mutation.
  36606. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  36607. switch name {
  36608. case whatsapp.EdgeAgent:
  36609. return m.clearedagent
  36610. }
  36611. return false
  36612. }
  36613. // ClearEdge clears the value of the edge with the given name. It returns an error
  36614. // if that edge is not defined in the schema.
  36615. func (m *WhatsappMutation) ClearEdge(name string) error {
  36616. switch name {
  36617. case whatsapp.EdgeAgent:
  36618. m.ClearAgent()
  36619. return nil
  36620. }
  36621. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  36622. }
  36623. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36624. // It returns an error if the edge is not defined in the schema.
  36625. func (m *WhatsappMutation) ResetEdge(name string) error {
  36626. switch name {
  36627. case whatsapp.EdgeAgent:
  36628. m.ResetAgent()
  36629. return nil
  36630. }
  36631. return fmt.Errorf("unknown Whatsapp edge %s", name)
  36632. }
  36633. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  36634. type WhatsappChannelMutation struct {
  36635. config
  36636. op Op
  36637. typ string
  36638. id *uint64
  36639. created_at *time.Time
  36640. updated_at *time.Time
  36641. status *uint8
  36642. addstatus *int8
  36643. deleted_at *time.Time
  36644. ak *string
  36645. sk *string
  36646. wa_id *string
  36647. wa_name *string
  36648. waba_id *uint64
  36649. addwaba_id *int64
  36650. business_id *uint64
  36651. addbusiness_id *int64
  36652. organization_id *uint64
  36653. addorganization_id *int64
  36654. verify_account *string
  36655. clearedFields map[string]struct{}
  36656. done bool
  36657. oldValue func(context.Context) (*WhatsappChannel, error)
  36658. predicates []predicate.WhatsappChannel
  36659. }
  36660. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  36661. // whatsappchannelOption allows management of the mutation configuration using functional options.
  36662. type whatsappchannelOption func(*WhatsappChannelMutation)
  36663. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  36664. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  36665. m := &WhatsappChannelMutation{
  36666. config: c,
  36667. op: op,
  36668. typ: TypeWhatsappChannel,
  36669. clearedFields: make(map[string]struct{}),
  36670. }
  36671. for _, opt := range opts {
  36672. opt(m)
  36673. }
  36674. return m
  36675. }
  36676. // withWhatsappChannelID sets the ID field of the mutation.
  36677. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  36678. return func(m *WhatsappChannelMutation) {
  36679. var (
  36680. err error
  36681. once sync.Once
  36682. value *WhatsappChannel
  36683. )
  36684. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  36685. once.Do(func() {
  36686. if m.done {
  36687. err = errors.New("querying old values post mutation is not allowed")
  36688. } else {
  36689. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  36690. }
  36691. })
  36692. return value, err
  36693. }
  36694. m.id = &id
  36695. }
  36696. }
  36697. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  36698. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  36699. return func(m *WhatsappChannelMutation) {
  36700. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  36701. return node, nil
  36702. }
  36703. m.id = &node.ID
  36704. }
  36705. }
  36706. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36707. // executed in a transaction (ent.Tx), a transactional client is returned.
  36708. func (m WhatsappChannelMutation) Client() *Client {
  36709. client := &Client{config: m.config}
  36710. client.init()
  36711. return client
  36712. }
  36713. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36714. // it returns an error otherwise.
  36715. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  36716. if _, ok := m.driver.(*txDriver); !ok {
  36717. return nil, errors.New("ent: mutation is not running in a transaction")
  36718. }
  36719. tx := &Tx{config: m.config}
  36720. tx.init()
  36721. return tx, nil
  36722. }
  36723. // SetID sets the value of the id field. Note that this
  36724. // operation is only accepted on creation of WhatsappChannel entities.
  36725. func (m *WhatsappChannelMutation) SetID(id uint64) {
  36726. m.id = &id
  36727. }
  36728. // ID returns the ID value in the mutation. Note that the ID is only available
  36729. // if it was provided to the builder or after it was returned from the database.
  36730. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  36731. if m.id == nil {
  36732. return
  36733. }
  36734. return *m.id, true
  36735. }
  36736. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36737. // That means, if the mutation is applied within a transaction with an isolation level such
  36738. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36739. // or updated by the mutation.
  36740. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  36741. switch {
  36742. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36743. id, exists := m.ID()
  36744. if exists {
  36745. return []uint64{id}, nil
  36746. }
  36747. fallthrough
  36748. case m.op.Is(OpUpdate | OpDelete):
  36749. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  36750. default:
  36751. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36752. }
  36753. }
  36754. // SetCreatedAt sets the "created_at" field.
  36755. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  36756. m.created_at = &t
  36757. }
  36758. // CreatedAt returns the value of the "created_at" field in the mutation.
  36759. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  36760. v := m.created_at
  36761. if v == nil {
  36762. return
  36763. }
  36764. return *v, true
  36765. }
  36766. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  36767. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36769. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36770. if !m.op.Is(OpUpdateOne) {
  36771. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36772. }
  36773. if m.id == nil || m.oldValue == nil {
  36774. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36775. }
  36776. oldValue, err := m.oldValue(ctx)
  36777. if err != nil {
  36778. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36779. }
  36780. return oldValue.CreatedAt, nil
  36781. }
  36782. // ResetCreatedAt resets all changes to the "created_at" field.
  36783. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  36784. m.created_at = nil
  36785. }
  36786. // SetUpdatedAt sets the "updated_at" field.
  36787. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  36788. m.updated_at = &t
  36789. }
  36790. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36791. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  36792. v := m.updated_at
  36793. if v == nil {
  36794. return
  36795. }
  36796. return *v, true
  36797. }
  36798. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  36799. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36801. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36802. if !m.op.Is(OpUpdateOne) {
  36803. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36804. }
  36805. if m.id == nil || m.oldValue == nil {
  36806. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36807. }
  36808. oldValue, err := m.oldValue(ctx)
  36809. if err != nil {
  36810. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36811. }
  36812. return oldValue.UpdatedAt, nil
  36813. }
  36814. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36815. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  36816. m.updated_at = nil
  36817. }
  36818. // SetStatus sets the "status" field.
  36819. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  36820. m.status = &u
  36821. m.addstatus = nil
  36822. }
  36823. // Status returns the value of the "status" field in the mutation.
  36824. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  36825. v := m.status
  36826. if v == nil {
  36827. return
  36828. }
  36829. return *v, true
  36830. }
  36831. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  36832. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36834. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36835. if !m.op.Is(OpUpdateOne) {
  36836. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36837. }
  36838. if m.id == nil || m.oldValue == nil {
  36839. return v, errors.New("OldStatus requires an ID field in the mutation")
  36840. }
  36841. oldValue, err := m.oldValue(ctx)
  36842. if err != nil {
  36843. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36844. }
  36845. return oldValue.Status, nil
  36846. }
  36847. // AddStatus adds u to the "status" field.
  36848. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  36849. if m.addstatus != nil {
  36850. *m.addstatus += u
  36851. } else {
  36852. m.addstatus = &u
  36853. }
  36854. }
  36855. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36856. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  36857. v := m.addstatus
  36858. if v == nil {
  36859. return
  36860. }
  36861. return *v, true
  36862. }
  36863. // ClearStatus clears the value of the "status" field.
  36864. func (m *WhatsappChannelMutation) ClearStatus() {
  36865. m.status = nil
  36866. m.addstatus = nil
  36867. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  36868. }
  36869. // StatusCleared returns if the "status" field was cleared in this mutation.
  36870. func (m *WhatsappChannelMutation) StatusCleared() bool {
  36871. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  36872. return ok
  36873. }
  36874. // ResetStatus resets all changes to the "status" field.
  36875. func (m *WhatsappChannelMutation) ResetStatus() {
  36876. m.status = nil
  36877. m.addstatus = nil
  36878. delete(m.clearedFields, whatsappchannel.FieldStatus)
  36879. }
  36880. // SetDeletedAt sets the "deleted_at" field.
  36881. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  36882. m.deleted_at = &t
  36883. }
  36884. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36885. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  36886. v := m.deleted_at
  36887. if v == nil {
  36888. return
  36889. }
  36890. return *v, true
  36891. }
  36892. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  36893. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36895. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36896. if !m.op.Is(OpUpdateOne) {
  36897. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36898. }
  36899. if m.id == nil || m.oldValue == nil {
  36900. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36901. }
  36902. oldValue, err := m.oldValue(ctx)
  36903. if err != nil {
  36904. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36905. }
  36906. return oldValue.DeletedAt, nil
  36907. }
  36908. // ClearDeletedAt clears the value of the "deleted_at" field.
  36909. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  36910. m.deleted_at = nil
  36911. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  36912. }
  36913. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36914. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  36915. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  36916. return ok
  36917. }
  36918. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36919. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  36920. m.deleted_at = nil
  36921. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  36922. }
  36923. // SetAk sets the "ak" field.
  36924. func (m *WhatsappChannelMutation) SetAk(s string) {
  36925. m.ak = &s
  36926. }
  36927. // Ak returns the value of the "ak" field in the mutation.
  36928. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  36929. v := m.ak
  36930. if v == nil {
  36931. return
  36932. }
  36933. return *v, true
  36934. }
  36935. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  36936. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36938. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  36939. if !m.op.Is(OpUpdateOne) {
  36940. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  36941. }
  36942. if m.id == nil || m.oldValue == nil {
  36943. return v, errors.New("OldAk requires an ID field in the mutation")
  36944. }
  36945. oldValue, err := m.oldValue(ctx)
  36946. if err != nil {
  36947. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  36948. }
  36949. return oldValue.Ak, nil
  36950. }
  36951. // ClearAk clears the value of the "ak" field.
  36952. func (m *WhatsappChannelMutation) ClearAk() {
  36953. m.ak = nil
  36954. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  36955. }
  36956. // AkCleared returns if the "ak" field was cleared in this mutation.
  36957. func (m *WhatsappChannelMutation) AkCleared() bool {
  36958. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  36959. return ok
  36960. }
  36961. // ResetAk resets all changes to the "ak" field.
  36962. func (m *WhatsappChannelMutation) ResetAk() {
  36963. m.ak = nil
  36964. delete(m.clearedFields, whatsappchannel.FieldAk)
  36965. }
  36966. // SetSk sets the "sk" field.
  36967. func (m *WhatsappChannelMutation) SetSk(s string) {
  36968. m.sk = &s
  36969. }
  36970. // Sk returns the value of the "sk" field in the mutation.
  36971. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  36972. v := m.sk
  36973. if v == nil {
  36974. return
  36975. }
  36976. return *v, true
  36977. }
  36978. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  36979. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36981. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  36982. if !m.op.Is(OpUpdateOne) {
  36983. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  36984. }
  36985. if m.id == nil || m.oldValue == nil {
  36986. return v, errors.New("OldSk requires an ID field in the mutation")
  36987. }
  36988. oldValue, err := m.oldValue(ctx)
  36989. if err != nil {
  36990. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  36991. }
  36992. return oldValue.Sk, nil
  36993. }
  36994. // ResetSk resets all changes to the "sk" field.
  36995. func (m *WhatsappChannelMutation) ResetSk() {
  36996. m.sk = nil
  36997. }
  36998. // SetWaID sets the "wa_id" field.
  36999. func (m *WhatsappChannelMutation) SetWaID(s string) {
  37000. m.wa_id = &s
  37001. }
  37002. // WaID returns the value of the "wa_id" field in the mutation.
  37003. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  37004. v := m.wa_id
  37005. if v == nil {
  37006. return
  37007. }
  37008. return *v, true
  37009. }
  37010. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  37011. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37013. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  37014. if !m.op.Is(OpUpdateOne) {
  37015. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  37016. }
  37017. if m.id == nil || m.oldValue == nil {
  37018. return v, errors.New("OldWaID requires an ID field in the mutation")
  37019. }
  37020. oldValue, err := m.oldValue(ctx)
  37021. if err != nil {
  37022. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  37023. }
  37024. return oldValue.WaID, nil
  37025. }
  37026. // ClearWaID clears the value of the "wa_id" field.
  37027. func (m *WhatsappChannelMutation) ClearWaID() {
  37028. m.wa_id = nil
  37029. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  37030. }
  37031. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  37032. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  37033. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  37034. return ok
  37035. }
  37036. // ResetWaID resets all changes to the "wa_id" field.
  37037. func (m *WhatsappChannelMutation) ResetWaID() {
  37038. m.wa_id = nil
  37039. delete(m.clearedFields, whatsappchannel.FieldWaID)
  37040. }
  37041. // SetWaName sets the "wa_name" field.
  37042. func (m *WhatsappChannelMutation) SetWaName(s string) {
  37043. m.wa_name = &s
  37044. }
  37045. // WaName returns the value of the "wa_name" field in the mutation.
  37046. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  37047. v := m.wa_name
  37048. if v == nil {
  37049. return
  37050. }
  37051. return *v, true
  37052. }
  37053. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  37054. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37056. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  37057. if !m.op.Is(OpUpdateOne) {
  37058. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  37059. }
  37060. if m.id == nil || m.oldValue == nil {
  37061. return v, errors.New("OldWaName requires an ID field in the mutation")
  37062. }
  37063. oldValue, err := m.oldValue(ctx)
  37064. if err != nil {
  37065. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  37066. }
  37067. return oldValue.WaName, nil
  37068. }
  37069. // ClearWaName clears the value of the "wa_name" field.
  37070. func (m *WhatsappChannelMutation) ClearWaName() {
  37071. m.wa_name = nil
  37072. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  37073. }
  37074. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  37075. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  37076. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  37077. return ok
  37078. }
  37079. // ResetWaName resets all changes to the "wa_name" field.
  37080. func (m *WhatsappChannelMutation) ResetWaName() {
  37081. m.wa_name = nil
  37082. delete(m.clearedFields, whatsappchannel.FieldWaName)
  37083. }
  37084. // SetWabaID sets the "waba_id" field.
  37085. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  37086. m.waba_id = &u
  37087. m.addwaba_id = nil
  37088. }
  37089. // WabaID returns the value of the "waba_id" field in the mutation.
  37090. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  37091. v := m.waba_id
  37092. if v == nil {
  37093. return
  37094. }
  37095. return *v, true
  37096. }
  37097. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  37098. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37100. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  37101. if !m.op.Is(OpUpdateOne) {
  37102. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  37103. }
  37104. if m.id == nil || m.oldValue == nil {
  37105. return v, errors.New("OldWabaID requires an ID field in the mutation")
  37106. }
  37107. oldValue, err := m.oldValue(ctx)
  37108. if err != nil {
  37109. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  37110. }
  37111. return oldValue.WabaID, nil
  37112. }
  37113. // AddWabaID adds u to the "waba_id" field.
  37114. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  37115. if m.addwaba_id != nil {
  37116. *m.addwaba_id += u
  37117. } else {
  37118. m.addwaba_id = &u
  37119. }
  37120. }
  37121. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  37122. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  37123. v := m.addwaba_id
  37124. if v == nil {
  37125. return
  37126. }
  37127. return *v, true
  37128. }
  37129. // ResetWabaID resets all changes to the "waba_id" field.
  37130. func (m *WhatsappChannelMutation) ResetWabaID() {
  37131. m.waba_id = nil
  37132. m.addwaba_id = nil
  37133. }
  37134. // SetBusinessID sets the "business_id" field.
  37135. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  37136. m.business_id = &u
  37137. m.addbusiness_id = nil
  37138. }
  37139. // BusinessID returns the value of the "business_id" field in the mutation.
  37140. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  37141. v := m.business_id
  37142. if v == nil {
  37143. return
  37144. }
  37145. return *v, true
  37146. }
  37147. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  37148. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37150. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  37151. if !m.op.Is(OpUpdateOne) {
  37152. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  37153. }
  37154. if m.id == nil || m.oldValue == nil {
  37155. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  37156. }
  37157. oldValue, err := m.oldValue(ctx)
  37158. if err != nil {
  37159. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  37160. }
  37161. return oldValue.BusinessID, nil
  37162. }
  37163. // AddBusinessID adds u to the "business_id" field.
  37164. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  37165. if m.addbusiness_id != nil {
  37166. *m.addbusiness_id += u
  37167. } else {
  37168. m.addbusiness_id = &u
  37169. }
  37170. }
  37171. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  37172. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  37173. v := m.addbusiness_id
  37174. if v == nil {
  37175. return
  37176. }
  37177. return *v, true
  37178. }
  37179. // ResetBusinessID resets all changes to the "business_id" field.
  37180. func (m *WhatsappChannelMutation) ResetBusinessID() {
  37181. m.business_id = nil
  37182. m.addbusiness_id = nil
  37183. }
  37184. // SetOrganizationID sets the "organization_id" field.
  37185. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  37186. m.organization_id = &u
  37187. m.addorganization_id = nil
  37188. }
  37189. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37190. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  37191. v := m.organization_id
  37192. if v == nil {
  37193. return
  37194. }
  37195. return *v, true
  37196. }
  37197. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  37198. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37200. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37201. if !m.op.Is(OpUpdateOne) {
  37202. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37203. }
  37204. if m.id == nil || m.oldValue == nil {
  37205. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37206. }
  37207. oldValue, err := m.oldValue(ctx)
  37208. if err != nil {
  37209. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37210. }
  37211. return oldValue.OrganizationID, nil
  37212. }
  37213. // AddOrganizationID adds u to the "organization_id" field.
  37214. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  37215. if m.addorganization_id != nil {
  37216. *m.addorganization_id += u
  37217. } else {
  37218. m.addorganization_id = &u
  37219. }
  37220. }
  37221. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37222. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  37223. v := m.addorganization_id
  37224. if v == nil {
  37225. return
  37226. }
  37227. return *v, true
  37228. }
  37229. // ClearOrganizationID clears the value of the "organization_id" field.
  37230. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  37231. m.organization_id = nil
  37232. m.addorganization_id = nil
  37233. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  37234. }
  37235. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37236. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  37237. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  37238. return ok
  37239. }
  37240. // ResetOrganizationID resets all changes to the "organization_id" field.
  37241. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  37242. m.organization_id = nil
  37243. m.addorganization_id = nil
  37244. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  37245. }
  37246. // SetVerifyAccount sets the "verify_account" field.
  37247. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  37248. m.verify_account = &s
  37249. }
  37250. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  37251. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  37252. v := m.verify_account
  37253. if v == nil {
  37254. return
  37255. }
  37256. return *v, true
  37257. }
  37258. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  37259. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37261. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  37262. if !m.op.Is(OpUpdateOne) {
  37263. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  37264. }
  37265. if m.id == nil || m.oldValue == nil {
  37266. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  37267. }
  37268. oldValue, err := m.oldValue(ctx)
  37269. if err != nil {
  37270. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  37271. }
  37272. return oldValue.VerifyAccount, nil
  37273. }
  37274. // ResetVerifyAccount resets all changes to the "verify_account" field.
  37275. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  37276. m.verify_account = nil
  37277. }
  37278. // Where appends a list predicates to the WhatsappChannelMutation builder.
  37279. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  37280. m.predicates = append(m.predicates, ps...)
  37281. }
  37282. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  37283. // users can use type-assertion to append predicates that do not depend on any generated package.
  37284. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  37285. p := make([]predicate.WhatsappChannel, len(ps))
  37286. for i := range ps {
  37287. p[i] = ps[i]
  37288. }
  37289. m.Where(p...)
  37290. }
  37291. // Op returns the operation name.
  37292. func (m *WhatsappChannelMutation) Op() Op {
  37293. return m.op
  37294. }
  37295. // SetOp allows setting the mutation operation.
  37296. func (m *WhatsappChannelMutation) SetOp(op Op) {
  37297. m.op = op
  37298. }
  37299. // Type returns the node type of this mutation (WhatsappChannel).
  37300. func (m *WhatsappChannelMutation) Type() string {
  37301. return m.typ
  37302. }
  37303. // Fields returns all fields that were changed during this mutation. Note that in
  37304. // order to get all numeric fields that were incremented/decremented, call
  37305. // AddedFields().
  37306. func (m *WhatsappChannelMutation) Fields() []string {
  37307. fields := make([]string, 0, 12)
  37308. if m.created_at != nil {
  37309. fields = append(fields, whatsappchannel.FieldCreatedAt)
  37310. }
  37311. if m.updated_at != nil {
  37312. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  37313. }
  37314. if m.status != nil {
  37315. fields = append(fields, whatsappchannel.FieldStatus)
  37316. }
  37317. if m.deleted_at != nil {
  37318. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37319. }
  37320. if m.ak != nil {
  37321. fields = append(fields, whatsappchannel.FieldAk)
  37322. }
  37323. if m.sk != nil {
  37324. fields = append(fields, whatsappchannel.FieldSk)
  37325. }
  37326. if m.wa_id != nil {
  37327. fields = append(fields, whatsappchannel.FieldWaID)
  37328. }
  37329. if m.wa_name != nil {
  37330. fields = append(fields, whatsappchannel.FieldWaName)
  37331. }
  37332. if m.waba_id != nil {
  37333. fields = append(fields, whatsappchannel.FieldWabaID)
  37334. }
  37335. if m.business_id != nil {
  37336. fields = append(fields, whatsappchannel.FieldBusinessID)
  37337. }
  37338. if m.organization_id != nil {
  37339. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37340. }
  37341. if m.verify_account != nil {
  37342. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  37343. }
  37344. return fields
  37345. }
  37346. // Field returns the value of a field with the given name. The second boolean
  37347. // return value indicates that this field was not set, or was not defined in the
  37348. // schema.
  37349. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  37350. switch name {
  37351. case whatsappchannel.FieldCreatedAt:
  37352. return m.CreatedAt()
  37353. case whatsappchannel.FieldUpdatedAt:
  37354. return m.UpdatedAt()
  37355. case whatsappchannel.FieldStatus:
  37356. return m.Status()
  37357. case whatsappchannel.FieldDeletedAt:
  37358. return m.DeletedAt()
  37359. case whatsappchannel.FieldAk:
  37360. return m.Ak()
  37361. case whatsappchannel.FieldSk:
  37362. return m.Sk()
  37363. case whatsappchannel.FieldWaID:
  37364. return m.WaID()
  37365. case whatsappchannel.FieldWaName:
  37366. return m.WaName()
  37367. case whatsappchannel.FieldWabaID:
  37368. return m.WabaID()
  37369. case whatsappchannel.FieldBusinessID:
  37370. return m.BusinessID()
  37371. case whatsappchannel.FieldOrganizationID:
  37372. return m.OrganizationID()
  37373. case whatsappchannel.FieldVerifyAccount:
  37374. return m.VerifyAccount()
  37375. }
  37376. return nil, false
  37377. }
  37378. // OldField returns the old value of the field from the database. An error is
  37379. // returned if the mutation operation is not UpdateOne, or the query to the
  37380. // database failed.
  37381. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37382. switch name {
  37383. case whatsappchannel.FieldCreatedAt:
  37384. return m.OldCreatedAt(ctx)
  37385. case whatsappchannel.FieldUpdatedAt:
  37386. return m.OldUpdatedAt(ctx)
  37387. case whatsappchannel.FieldStatus:
  37388. return m.OldStatus(ctx)
  37389. case whatsappchannel.FieldDeletedAt:
  37390. return m.OldDeletedAt(ctx)
  37391. case whatsappchannel.FieldAk:
  37392. return m.OldAk(ctx)
  37393. case whatsappchannel.FieldSk:
  37394. return m.OldSk(ctx)
  37395. case whatsappchannel.FieldWaID:
  37396. return m.OldWaID(ctx)
  37397. case whatsappchannel.FieldWaName:
  37398. return m.OldWaName(ctx)
  37399. case whatsappchannel.FieldWabaID:
  37400. return m.OldWabaID(ctx)
  37401. case whatsappchannel.FieldBusinessID:
  37402. return m.OldBusinessID(ctx)
  37403. case whatsappchannel.FieldOrganizationID:
  37404. return m.OldOrganizationID(ctx)
  37405. case whatsappchannel.FieldVerifyAccount:
  37406. return m.OldVerifyAccount(ctx)
  37407. }
  37408. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  37409. }
  37410. // SetField sets the value of a field with the given name. It returns an error if
  37411. // the field is not defined in the schema, or if the type mismatched the field
  37412. // type.
  37413. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  37414. switch name {
  37415. case whatsappchannel.FieldCreatedAt:
  37416. v, ok := value.(time.Time)
  37417. if !ok {
  37418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37419. }
  37420. m.SetCreatedAt(v)
  37421. return nil
  37422. case whatsappchannel.FieldUpdatedAt:
  37423. v, ok := value.(time.Time)
  37424. if !ok {
  37425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37426. }
  37427. m.SetUpdatedAt(v)
  37428. return nil
  37429. case whatsappchannel.FieldStatus:
  37430. v, ok := value.(uint8)
  37431. if !ok {
  37432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37433. }
  37434. m.SetStatus(v)
  37435. return nil
  37436. case whatsappchannel.FieldDeletedAt:
  37437. v, ok := value.(time.Time)
  37438. if !ok {
  37439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37440. }
  37441. m.SetDeletedAt(v)
  37442. return nil
  37443. case whatsappchannel.FieldAk:
  37444. v, ok := value.(string)
  37445. if !ok {
  37446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37447. }
  37448. m.SetAk(v)
  37449. return nil
  37450. case whatsappchannel.FieldSk:
  37451. v, ok := value.(string)
  37452. if !ok {
  37453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37454. }
  37455. m.SetSk(v)
  37456. return nil
  37457. case whatsappchannel.FieldWaID:
  37458. v, ok := value.(string)
  37459. if !ok {
  37460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37461. }
  37462. m.SetWaID(v)
  37463. return nil
  37464. case whatsappchannel.FieldWaName:
  37465. v, ok := value.(string)
  37466. if !ok {
  37467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37468. }
  37469. m.SetWaName(v)
  37470. return nil
  37471. case whatsappchannel.FieldWabaID:
  37472. v, ok := value.(uint64)
  37473. if !ok {
  37474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37475. }
  37476. m.SetWabaID(v)
  37477. return nil
  37478. case whatsappchannel.FieldBusinessID:
  37479. v, ok := value.(uint64)
  37480. if !ok {
  37481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37482. }
  37483. m.SetBusinessID(v)
  37484. return nil
  37485. case whatsappchannel.FieldOrganizationID:
  37486. v, ok := value.(uint64)
  37487. if !ok {
  37488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37489. }
  37490. m.SetOrganizationID(v)
  37491. return nil
  37492. case whatsappchannel.FieldVerifyAccount:
  37493. v, ok := value.(string)
  37494. if !ok {
  37495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37496. }
  37497. m.SetVerifyAccount(v)
  37498. return nil
  37499. }
  37500. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37501. }
  37502. // AddedFields returns all numeric fields that were incremented/decremented during
  37503. // this mutation.
  37504. func (m *WhatsappChannelMutation) AddedFields() []string {
  37505. var fields []string
  37506. if m.addstatus != nil {
  37507. fields = append(fields, whatsappchannel.FieldStatus)
  37508. }
  37509. if m.addwaba_id != nil {
  37510. fields = append(fields, whatsappchannel.FieldWabaID)
  37511. }
  37512. if m.addbusiness_id != nil {
  37513. fields = append(fields, whatsappchannel.FieldBusinessID)
  37514. }
  37515. if m.addorganization_id != nil {
  37516. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37517. }
  37518. return fields
  37519. }
  37520. // AddedField returns the numeric value that was incremented/decremented on a field
  37521. // with the given name. The second boolean return value indicates that this field
  37522. // was not set, or was not defined in the schema.
  37523. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  37524. switch name {
  37525. case whatsappchannel.FieldStatus:
  37526. return m.AddedStatus()
  37527. case whatsappchannel.FieldWabaID:
  37528. return m.AddedWabaID()
  37529. case whatsappchannel.FieldBusinessID:
  37530. return m.AddedBusinessID()
  37531. case whatsappchannel.FieldOrganizationID:
  37532. return m.AddedOrganizationID()
  37533. }
  37534. return nil, false
  37535. }
  37536. // AddField adds the value to the field with the given name. It returns an error if
  37537. // the field is not defined in the schema, or if the type mismatched the field
  37538. // type.
  37539. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  37540. switch name {
  37541. case whatsappchannel.FieldStatus:
  37542. v, ok := value.(int8)
  37543. if !ok {
  37544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37545. }
  37546. m.AddStatus(v)
  37547. return nil
  37548. case whatsappchannel.FieldWabaID:
  37549. v, ok := value.(int64)
  37550. if !ok {
  37551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37552. }
  37553. m.AddWabaID(v)
  37554. return nil
  37555. case whatsappchannel.FieldBusinessID:
  37556. v, ok := value.(int64)
  37557. if !ok {
  37558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37559. }
  37560. m.AddBusinessID(v)
  37561. return nil
  37562. case whatsappchannel.FieldOrganizationID:
  37563. v, ok := value.(int64)
  37564. if !ok {
  37565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37566. }
  37567. m.AddOrganizationID(v)
  37568. return nil
  37569. }
  37570. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  37571. }
  37572. // ClearedFields returns all nullable fields that were cleared during this
  37573. // mutation.
  37574. func (m *WhatsappChannelMutation) ClearedFields() []string {
  37575. var fields []string
  37576. if m.FieldCleared(whatsappchannel.FieldStatus) {
  37577. fields = append(fields, whatsappchannel.FieldStatus)
  37578. }
  37579. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  37580. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37581. }
  37582. if m.FieldCleared(whatsappchannel.FieldAk) {
  37583. fields = append(fields, whatsappchannel.FieldAk)
  37584. }
  37585. if m.FieldCleared(whatsappchannel.FieldWaID) {
  37586. fields = append(fields, whatsappchannel.FieldWaID)
  37587. }
  37588. if m.FieldCleared(whatsappchannel.FieldWaName) {
  37589. fields = append(fields, whatsappchannel.FieldWaName)
  37590. }
  37591. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  37592. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37593. }
  37594. return fields
  37595. }
  37596. // FieldCleared returns a boolean indicating if a field with the given name was
  37597. // cleared in this mutation.
  37598. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  37599. _, ok := m.clearedFields[name]
  37600. return ok
  37601. }
  37602. // ClearField clears the value of the field with the given name. It returns an
  37603. // error if the field is not defined in the schema.
  37604. func (m *WhatsappChannelMutation) ClearField(name string) error {
  37605. switch name {
  37606. case whatsappchannel.FieldStatus:
  37607. m.ClearStatus()
  37608. return nil
  37609. case whatsappchannel.FieldDeletedAt:
  37610. m.ClearDeletedAt()
  37611. return nil
  37612. case whatsappchannel.FieldAk:
  37613. m.ClearAk()
  37614. return nil
  37615. case whatsappchannel.FieldWaID:
  37616. m.ClearWaID()
  37617. return nil
  37618. case whatsappchannel.FieldWaName:
  37619. m.ClearWaName()
  37620. return nil
  37621. case whatsappchannel.FieldOrganizationID:
  37622. m.ClearOrganizationID()
  37623. return nil
  37624. }
  37625. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  37626. }
  37627. // ResetField resets all changes in the mutation for the field with the given name.
  37628. // It returns an error if the field is not defined in the schema.
  37629. func (m *WhatsappChannelMutation) ResetField(name string) error {
  37630. switch name {
  37631. case whatsappchannel.FieldCreatedAt:
  37632. m.ResetCreatedAt()
  37633. return nil
  37634. case whatsappchannel.FieldUpdatedAt:
  37635. m.ResetUpdatedAt()
  37636. return nil
  37637. case whatsappchannel.FieldStatus:
  37638. m.ResetStatus()
  37639. return nil
  37640. case whatsappchannel.FieldDeletedAt:
  37641. m.ResetDeletedAt()
  37642. return nil
  37643. case whatsappchannel.FieldAk:
  37644. m.ResetAk()
  37645. return nil
  37646. case whatsappchannel.FieldSk:
  37647. m.ResetSk()
  37648. return nil
  37649. case whatsappchannel.FieldWaID:
  37650. m.ResetWaID()
  37651. return nil
  37652. case whatsappchannel.FieldWaName:
  37653. m.ResetWaName()
  37654. return nil
  37655. case whatsappchannel.FieldWabaID:
  37656. m.ResetWabaID()
  37657. return nil
  37658. case whatsappchannel.FieldBusinessID:
  37659. m.ResetBusinessID()
  37660. return nil
  37661. case whatsappchannel.FieldOrganizationID:
  37662. m.ResetOrganizationID()
  37663. return nil
  37664. case whatsappchannel.FieldVerifyAccount:
  37665. m.ResetVerifyAccount()
  37666. return nil
  37667. }
  37668. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37669. }
  37670. // AddedEdges returns all edge names that were set/added in this mutation.
  37671. func (m *WhatsappChannelMutation) AddedEdges() []string {
  37672. edges := make([]string, 0, 0)
  37673. return edges
  37674. }
  37675. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37676. // name in this mutation.
  37677. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  37678. return nil
  37679. }
  37680. // RemovedEdges returns all edge names that were removed in this mutation.
  37681. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  37682. edges := make([]string, 0, 0)
  37683. return edges
  37684. }
  37685. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37686. // the given name in this mutation.
  37687. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  37688. return nil
  37689. }
  37690. // ClearedEdges returns all edge names that were cleared in this mutation.
  37691. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  37692. edges := make([]string, 0, 0)
  37693. return edges
  37694. }
  37695. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37696. // was cleared in this mutation.
  37697. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  37698. return false
  37699. }
  37700. // ClearEdge clears the value of the edge with the given name. It returns an error
  37701. // if that edge is not defined in the schema.
  37702. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  37703. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  37704. }
  37705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37706. // It returns an error if the edge is not defined in the schema.
  37707. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  37708. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  37709. }
  37710. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  37711. type WorkExperienceMutation struct {
  37712. config
  37713. op Op
  37714. typ string
  37715. id *uint64
  37716. created_at *time.Time
  37717. updated_at *time.Time
  37718. deleted_at *time.Time
  37719. start_date *time.Time
  37720. end_date *time.Time
  37721. company *string
  37722. experience *string
  37723. organization_id *uint64
  37724. addorganization_id *int64
  37725. clearedFields map[string]struct{}
  37726. employee *uint64
  37727. clearedemployee bool
  37728. done bool
  37729. oldValue func(context.Context) (*WorkExperience, error)
  37730. predicates []predicate.WorkExperience
  37731. }
  37732. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  37733. // workexperienceOption allows management of the mutation configuration using functional options.
  37734. type workexperienceOption func(*WorkExperienceMutation)
  37735. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  37736. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  37737. m := &WorkExperienceMutation{
  37738. config: c,
  37739. op: op,
  37740. typ: TypeWorkExperience,
  37741. clearedFields: make(map[string]struct{}),
  37742. }
  37743. for _, opt := range opts {
  37744. opt(m)
  37745. }
  37746. return m
  37747. }
  37748. // withWorkExperienceID sets the ID field of the mutation.
  37749. func withWorkExperienceID(id uint64) workexperienceOption {
  37750. return func(m *WorkExperienceMutation) {
  37751. var (
  37752. err error
  37753. once sync.Once
  37754. value *WorkExperience
  37755. )
  37756. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  37757. once.Do(func() {
  37758. if m.done {
  37759. err = errors.New("querying old values post mutation is not allowed")
  37760. } else {
  37761. value, err = m.Client().WorkExperience.Get(ctx, id)
  37762. }
  37763. })
  37764. return value, err
  37765. }
  37766. m.id = &id
  37767. }
  37768. }
  37769. // withWorkExperience sets the old WorkExperience of the mutation.
  37770. func withWorkExperience(node *WorkExperience) workexperienceOption {
  37771. return func(m *WorkExperienceMutation) {
  37772. m.oldValue = func(context.Context) (*WorkExperience, error) {
  37773. return node, nil
  37774. }
  37775. m.id = &node.ID
  37776. }
  37777. }
  37778. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37779. // executed in a transaction (ent.Tx), a transactional client is returned.
  37780. func (m WorkExperienceMutation) Client() *Client {
  37781. client := &Client{config: m.config}
  37782. client.init()
  37783. return client
  37784. }
  37785. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37786. // it returns an error otherwise.
  37787. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  37788. if _, ok := m.driver.(*txDriver); !ok {
  37789. return nil, errors.New("ent: mutation is not running in a transaction")
  37790. }
  37791. tx := &Tx{config: m.config}
  37792. tx.init()
  37793. return tx, nil
  37794. }
  37795. // SetID sets the value of the id field. Note that this
  37796. // operation is only accepted on creation of WorkExperience entities.
  37797. func (m *WorkExperienceMutation) SetID(id uint64) {
  37798. m.id = &id
  37799. }
  37800. // ID returns the ID value in the mutation. Note that the ID is only available
  37801. // if it was provided to the builder or after it was returned from the database.
  37802. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  37803. if m.id == nil {
  37804. return
  37805. }
  37806. return *m.id, true
  37807. }
  37808. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37809. // That means, if the mutation is applied within a transaction with an isolation level such
  37810. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37811. // or updated by the mutation.
  37812. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  37813. switch {
  37814. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37815. id, exists := m.ID()
  37816. if exists {
  37817. return []uint64{id}, nil
  37818. }
  37819. fallthrough
  37820. case m.op.Is(OpUpdate | OpDelete):
  37821. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  37822. default:
  37823. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37824. }
  37825. }
  37826. // SetCreatedAt sets the "created_at" field.
  37827. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  37828. m.created_at = &t
  37829. }
  37830. // CreatedAt returns the value of the "created_at" field in the mutation.
  37831. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  37832. v := m.created_at
  37833. if v == nil {
  37834. return
  37835. }
  37836. return *v, true
  37837. }
  37838. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  37839. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37841. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37842. if !m.op.Is(OpUpdateOne) {
  37843. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37844. }
  37845. if m.id == nil || m.oldValue == nil {
  37846. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37847. }
  37848. oldValue, err := m.oldValue(ctx)
  37849. if err != nil {
  37850. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37851. }
  37852. return oldValue.CreatedAt, nil
  37853. }
  37854. // ResetCreatedAt resets all changes to the "created_at" field.
  37855. func (m *WorkExperienceMutation) ResetCreatedAt() {
  37856. m.created_at = nil
  37857. }
  37858. // SetUpdatedAt sets the "updated_at" field.
  37859. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  37860. m.updated_at = &t
  37861. }
  37862. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37863. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  37864. v := m.updated_at
  37865. if v == nil {
  37866. return
  37867. }
  37868. return *v, true
  37869. }
  37870. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  37871. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37873. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37874. if !m.op.Is(OpUpdateOne) {
  37875. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37876. }
  37877. if m.id == nil || m.oldValue == nil {
  37878. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37879. }
  37880. oldValue, err := m.oldValue(ctx)
  37881. if err != nil {
  37882. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37883. }
  37884. return oldValue.UpdatedAt, nil
  37885. }
  37886. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37887. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  37888. m.updated_at = nil
  37889. }
  37890. // SetDeletedAt sets the "deleted_at" field.
  37891. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  37892. m.deleted_at = &t
  37893. }
  37894. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37895. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  37896. v := m.deleted_at
  37897. if v == nil {
  37898. return
  37899. }
  37900. return *v, true
  37901. }
  37902. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  37903. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37905. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37906. if !m.op.Is(OpUpdateOne) {
  37907. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37908. }
  37909. if m.id == nil || m.oldValue == nil {
  37910. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37911. }
  37912. oldValue, err := m.oldValue(ctx)
  37913. if err != nil {
  37914. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37915. }
  37916. return oldValue.DeletedAt, nil
  37917. }
  37918. // ClearDeletedAt clears the value of the "deleted_at" field.
  37919. func (m *WorkExperienceMutation) ClearDeletedAt() {
  37920. m.deleted_at = nil
  37921. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  37922. }
  37923. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37924. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  37925. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  37926. return ok
  37927. }
  37928. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37929. func (m *WorkExperienceMutation) ResetDeletedAt() {
  37930. m.deleted_at = nil
  37931. delete(m.clearedFields, workexperience.FieldDeletedAt)
  37932. }
  37933. // SetEmployeeID sets the "employee_id" field.
  37934. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  37935. m.employee = &u
  37936. }
  37937. // EmployeeID returns the value of the "employee_id" field in the mutation.
  37938. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  37939. v := m.employee
  37940. if v == nil {
  37941. return
  37942. }
  37943. return *v, true
  37944. }
  37945. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  37946. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37948. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  37949. if !m.op.Is(OpUpdateOne) {
  37950. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  37951. }
  37952. if m.id == nil || m.oldValue == nil {
  37953. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  37954. }
  37955. oldValue, err := m.oldValue(ctx)
  37956. if err != nil {
  37957. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  37958. }
  37959. return oldValue.EmployeeID, nil
  37960. }
  37961. // ResetEmployeeID resets all changes to the "employee_id" field.
  37962. func (m *WorkExperienceMutation) ResetEmployeeID() {
  37963. m.employee = nil
  37964. }
  37965. // SetStartDate sets the "start_date" field.
  37966. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  37967. m.start_date = &t
  37968. }
  37969. // StartDate returns the value of the "start_date" field in the mutation.
  37970. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  37971. v := m.start_date
  37972. if v == nil {
  37973. return
  37974. }
  37975. return *v, true
  37976. }
  37977. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  37978. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37980. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  37981. if !m.op.Is(OpUpdateOne) {
  37982. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  37983. }
  37984. if m.id == nil || m.oldValue == nil {
  37985. return v, errors.New("OldStartDate requires an ID field in the mutation")
  37986. }
  37987. oldValue, err := m.oldValue(ctx)
  37988. if err != nil {
  37989. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  37990. }
  37991. return oldValue.StartDate, nil
  37992. }
  37993. // ResetStartDate resets all changes to the "start_date" field.
  37994. func (m *WorkExperienceMutation) ResetStartDate() {
  37995. m.start_date = nil
  37996. }
  37997. // SetEndDate sets the "end_date" field.
  37998. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  37999. m.end_date = &t
  38000. }
  38001. // EndDate returns the value of the "end_date" field in the mutation.
  38002. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  38003. v := m.end_date
  38004. if v == nil {
  38005. return
  38006. }
  38007. return *v, true
  38008. }
  38009. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  38010. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38012. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  38013. if !m.op.Is(OpUpdateOne) {
  38014. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  38015. }
  38016. if m.id == nil || m.oldValue == nil {
  38017. return v, errors.New("OldEndDate requires an ID field in the mutation")
  38018. }
  38019. oldValue, err := m.oldValue(ctx)
  38020. if err != nil {
  38021. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  38022. }
  38023. return oldValue.EndDate, nil
  38024. }
  38025. // ResetEndDate resets all changes to the "end_date" field.
  38026. func (m *WorkExperienceMutation) ResetEndDate() {
  38027. m.end_date = nil
  38028. }
  38029. // SetCompany sets the "company" field.
  38030. func (m *WorkExperienceMutation) SetCompany(s string) {
  38031. m.company = &s
  38032. }
  38033. // Company returns the value of the "company" field in the mutation.
  38034. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  38035. v := m.company
  38036. if v == nil {
  38037. return
  38038. }
  38039. return *v, true
  38040. }
  38041. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  38042. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38044. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  38045. if !m.op.Is(OpUpdateOne) {
  38046. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  38047. }
  38048. if m.id == nil || m.oldValue == nil {
  38049. return v, errors.New("OldCompany requires an ID field in the mutation")
  38050. }
  38051. oldValue, err := m.oldValue(ctx)
  38052. if err != nil {
  38053. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  38054. }
  38055. return oldValue.Company, nil
  38056. }
  38057. // ResetCompany resets all changes to the "company" field.
  38058. func (m *WorkExperienceMutation) ResetCompany() {
  38059. m.company = nil
  38060. }
  38061. // SetExperience sets the "experience" field.
  38062. func (m *WorkExperienceMutation) SetExperience(s string) {
  38063. m.experience = &s
  38064. }
  38065. // Experience returns the value of the "experience" field in the mutation.
  38066. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  38067. v := m.experience
  38068. if v == nil {
  38069. return
  38070. }
  38071. return *v, true
  38072. }
  38073. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  38074. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38076. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  38077. if !m.op.Is(OpUpdateOne) {
  38078. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  38079. }
  38080. if m.id == nil || m.oldValue == nil {
  38081. return v, errors.New("OldExperience requires an ID field in the mutation")
  38082. }
  38083. oldValue, err := m.oldValue(ctx)
  38084. if err != nil {
  38085. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  38086. }
  38087. return oldValue.Experience, nil
  38088. }
  38089. // ResetExperience resets all changes to the "experience" field.
  38090. func (m *WorkExperienceMutation) ResetExperience() {
  38091. m.experience = nil
  38092. }
  38093. // SetOrganizationID sets the "organization_id" field.
  38094. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  38095. m.organization_id = &u
  38096. m.addorganization_id = nil
  38097. }
  38098. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38099. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  38100. v := m.organization_id
  38101. if v == nil {
  38102. return
  38103. }
  38104. return *v, true
  38105. }
  38106. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  38107. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38109. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38110. if !m.op.Is(OpUpdateOne) {
  38111. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38112. }
  38113. if m.id == nil || m.oldValue == nil {
  38114. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38115. }
  38116. oldValue, err := m.oldValue(ctx)
  38117. if err != nil {
  38118. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38119. }
  38120. return oldValue.OrganizationID, nil
  38121. }
  38122. // AddOrganizationID adds u to the "organization_id" field.
  38123. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  38124. if m.addorganization_id != nil {
  38125. *m.addorganization_id += u
  38126. } else {
  38127. m.addorganization_id = &u
  38128. }
  38129. }
  38130. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38131. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  38132. v := m.addorganization_id
  38133. if v == nil {
  38134. return
  38135. }
  38136. return *v, true
  38137. }
  38138. // ResetOrganizationID resets all changes to the "organization_id" field.
  38139. func (m *WorkExperienceMutation) ResetOrganizationID() {
  38140. m.organization_id = nil
  38141. m.addorganization_id = nil
  38142. }
  38143. // ClearEmployee clears the "employee" edge to the Employee entity.
  38144. func (m *WorkExperienceMutation) ClearEmployee() {
  38145. m.clearedemployee = true
  38146. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  38147. }
  38148. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  38149. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  38150. return m.clearedemployee
  38151. }
  38152. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  38153. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38154. // EmployeeID instead. It exists only for internal usage by the builders.
  38155. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  38156. if id := m.employee; id != nil {
  38157. ids = append(ids, *id)
  38158. }
  38159. return
  38160. }
  38161. // ResetEmployee resets all changes to the "employee" edge.
  38162. func (m *WorkExperienceMutation) ResetEmployee() {
  38163. m.employee = nil
  38164. m.clearedemployee = false
  38165. }
  38166. // Where appends a list predicates to the WorkExperienceMutation builder.
  38167. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  38168. m.predicates = append(m.predicates, ps...)
  38169. }
  38170. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  38171. // users can use type-assertion to append predicates that do not depend on any generated package.
  38172. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  38173. p := make([]predicate.WorkExperience, len(ps))
  38174. for i := range ps {
  38175. p[i] = ps[i]
  38176. }
  38177. m.Where(p...)
  38178. }
  38179. // Op returns the operation name.
  38180. func (m *WorkExperienceMutation) Op() Op {
  38181. return m.op
  38182. }
  38183. // SetOp allows setting the mutation operation.
  38184. func (m *WorkExperienceMutation) SetOp(op Op) {
  38185. m.op = op
  38186. }
  38187. // Type returns the node type of this mutation (WorkExperience).
  38188. func (m *WorkExperienceMutation) Type() string {
  38189. return m.typ
  38190. }
  38191. // Fields returns all fields that were changed during this mutation. Note that in
  38192. // order to get all numeric fields that were incremented/decremented, call
  38193. // AddedFields().
  38194. func (m *WorkExperienceMutation) Fields() []string {
  38195. fields := make([]string, 0, 9)
  38196. if m.created_at != nil {
  38197. fields = append(fields, workexperience.FieldCreatedAt)
  38198. }
  38199. if m.updated_at != nil {
  38200. fields = append(fields, workexperience.FieldUpdatedAt)
  38201. }
  38202. if m.deleted_at != nil {
  38203. fields = append(fields, workexperience.FieldDeletedAt)
  38204. }
  38205. if m.employee != nil {
  38206. fields = append(fields, workexperience.FieldEmployeeID)
  38207. }
  38208. if m.start_date != nil {
  38209. fields = append(fields, workexperience.FieldStartDate)
  38210. }
  38211. if m.end_date != nil {
  38212. fields = append(fields, workexperience.FieldEndDate)
  38213. }
  38214. if m.company != nil {
  38215. fields = append(fields, workexperience.FieldCompany)
  38216. }
  38217. if m.experience != nil {
  38218. fields = append(fields, workexperience.FieldExperience)
  38219. }
  38220. if m.organization_id != nil {
  38221. fields = append(fields, workexperience.FieldOrganizationID)
  38222. }
  38223. return fields
  38224. }
  38225. // Field returns the value of a field with the given name. The second boolean
  38226. // return value indicates that this field was not set, or was not defined in the
  38227. // schema.
  38228. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  38229. switch name {
  38230. case workexperience.FieldCreatedAt:
  38231. return m.CreatedAt()
  38232. case workexperience.FieldUpdatedAt:
  38233. return m.UpdatedAt()
  38234. case workexperience.FieldDeletedAt:
  38235. return m.DeletedAt()
  38236. case workexperience.FieldEmployeeID:
  38237. return m.EmployeeID()
  38238. case workexperience.FieldStartDate:
  38239. return m.StartDate()
  38240. case workexperience.FieldEndDate:
  38241. return m.EndDate()
  38242. case workexperience.FieldCompany:
  38243. return m.Company()
  38244. case workexperience.FieldExperience:
  38245. return m.Experience()
  38246. case workexperience.FieldOrganizationID:
  38247. return m.OrganizationID()
  38248. }
  38249. return nil, false
  38250. }
  38251. // OldField returns the old value of the field from the database. An error is
  38252. // returned if the mutation operation is not UpdateOne, or the query to the
  38253. // database failed.
  38254. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38255. switch name {
  38256. case workexperience.FieldCreatedAt:
  38257. return m.OldCreatedAt(ctx)
  38258. case workexperience.FieldUpdatedAt:
  38259. return m.OldUpdatedAt(ctx)
  38260. case workexperience.FieldDeletedAt:
  38261. return m.OldDeletedAt(ctx)
  38262. case workexperience.FieldEmployeeID:
  38263. return m.OldEmployeeID(ctx)
  38264. case workexperience.FieldStartDate:
  38265. return m.OldStartDate(ctx)
  38266. case workexperience.FieldEndDate:
  38267. return m.OldEndDate(ctx)
  38268. case workexperience.FieldCompany:
  38269. return m.OldCompany(ctx)
  38270. case workexperience.FieldExperience:
  38271. return m.OldExperience(ctx)
  38272. case workexperience.FieldOrganizationID:
  38273. return m.OldOrganizationID(ctx)
  38274. }
  38275. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  38276. }
  38277. // SetField sets the value of a field with the given name. It returns an error if
  38278. // the field is not defined in the schema, or if the type mismatched the field
  38279. // type.
  38280. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  38281. switch name {
  38282. case workexperience.FieldCreatedAt:
  38283. v, ok := value.(time.Time)
  38284. if !ok {
  38285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38286. }
  38287. m.SetCreatedAt(v)
  38288. return nil
  38289. case workexperience.FieldUpdatedAt:
  38290. v, ok := value.(time.Time)
  38291. if !ok {
  38292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38293. }
  38294. m.SetUpdatedAt(v)
  38295. return nil
  38296. case workexperience.FieldDeletedAt:
  38297. v, ok := value.(time.Time)
  38298. if !ok {
  38299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38300. }
  38301. m.SetDeletedAt(v)
  38302. return nil
  38303. case workexperience.FieldEmployeeID:
  38304. v, ok := value.(uint64)
  38305. if !ok {
  38306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38307. }
  38308. m.SetEmployeeID(v)
  38309. return nil
  38310. case workexperience.FieldStartDate:
  38311. v, ok := value.(time.Time)
  38312. if !ok {
  38313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38314. }
  38315. m.SetStartDate(v)
  38316. return nil
  38317. case workexperience.FieldEndDate:
  38318. v, ok := value.(time.Time)
  38319. if !ok {
  38320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38321. }
  38322. m.SetEndDate(v)
  38323. return nil
  38324. case workexperience.FieldCompany:
  38325. v, ok := value.(string)
  38326. if !ok {
  38327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38328. }
  38329. m.SetCompany(v)
  38330. return nil
  38331. case workexperience.FieldExperience:
  38332. v, ok := value.(string)
  38333. if !ok {
  38334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38335. }
  38336. m.SetExperience(v)
  38337. return nil
  38338. case workexperience.FieldOrganizationID:
  38339. v, ok := value.(uint64)
  38340. if !ok {
  38341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38342. }
  38343. m.SetOrganizationID(v)
  38344. return nil
  38345. }
  38346. return fmt.Errorf("unknown WorkExperience field %s", name)
  38347. }
  38348. // AddedFields returns all numeric fields that were incremented/decremented during
  38349. // this mutation.
  38350. func (m *WorkExperienceMutation) AddedFields() []string {
  38351. var fields []string
  38352. if m.addorganization_id != nil {
  38353. fields = append(fields, workexperience.FieldOrganizationID)
  38354. }
  38355. return fields
  38356. }
  38357. // AddedField returns the numeric value that was incremented/decremented on a field
  38358. // with the given name. The second boolean return value indicates that this field
  38359. // was not set, or was not defined in the schema.
  38360. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  38361. switch name {
  38362. case workexperience.FieldOrganizationID:
  38363. return m.AddedOrganizationID()
  38364. }
  38365. return nil, false
  38366. }
  38367. // AddField adds the value to the field with the given name. It returns an error if
  38368. // the field is not defined in the schema, or if the type mismatched the field
  38369. // type.
  38370. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  38371. switch name {
  38372. case workexperience.FieldOrganizationID:
  38373. v, ok := value.(int64)
  38374. if !ok {
  38375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38376. }
  38377. m.AddOrganizationID(v)
  38378. return nil
  38379. }
  38380. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  38381. }
  38382. // ClearedFields returns all nullable fields that were cleared during this
  38383. // mutation.
  38384. func (m *WorkExperienceMutation) ClearedFields() []string {
  38385. var fields []string
  38386. if m.FieldCleared(workexperience.FieldDeletedAt) {
  38387. fields = append(fields, workexperience.FieldDeletedAt)
  38388. }
  38389. return fields
  38390. }
  38391. // FieldCleared returns a boolean indicating if a field with the given name was
  38392. // cleared in this mutation.
  38393. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  38394. _, ok := m.clearedFields[name]
  38395. return ok
  38396. }
  38397. // ClearField clears the value of the field with the given name. It returns an
  38398. // error if the field is not defined in the schema.
  38399. func (m *WorkExperienceMutation) ClearField(name string) error {
  38400. switch name {
  38401. case workexperience.FieldDeletedAt:
  38402. m.ClearDeletedAt()
  38403. return nil
  38404. }
  38405. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  38406. }
  38407. // ResetField resets all changes in the mutation for the field with the given name.
  38408. // It returns an error if the field is not defined in the schema.
  38409. func (m *WorkExperienceMutation) ResetField(name string) error {
  38410. switch name {
  38411. case workexperience.FieldCreatedAt:
  38412. m.ResetCreatedAt()
  38413. return nil
  38414. case workexperience.FieldUpdatedAt:
  38415. m.ResetUpdatedAt()
  38416. return nil
  38417. case workexperience.FieldDeletedAt:
  38418. m.ResetDeletedAt()
  38419. return nil
  38420. case workexperience.FieldEmployeeID:
  38421. m.ResetEmployeeID()
  38422. return nil
  38423. case workexperience.FieldStartDate:
  38424. m.ResetStartDate()
  38425. return nil
  38426. case workexperience.FieldEndDate:
  38427. m.ResetEndDate()
  38428. return nil
  38429. case workexperience.FieldCompany:
  38430. m.ResetCompany()
  38431. return nil
  38432. case workexperience.FieldExperience:
  38433. m.ResetExperience()
  38434. return nil
  38435. case workexperience.FieldOrganizationID:
  38436. m.ResetOrganizationID()
  38437. return nil
  38438. }
  38439. return fmt.Errorf("unknown WorkExperience field %s", name)
  38440. }
  38441. // AddedEdges returns all edge names that were set/added in this mutation.
  38442. func (m *WorkExperienceMutation) AddedEdges() []string {
  38443. edges := make([]string, 0, 1)
  38444. if m.employee != nil {
  38445. edges = append(edges, workexperience.EdgeEmployee)
  38446. }
  38447. return edges
  38448. }
  38449. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38450. // name in this mutation.
  38451. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  38452. switch name {
  38453. case workexperience.EdgeEmployee:
  38454. if id := m.employee; id != nil {
  38455. return []ent.Value{*id}
  38456. }
  38457. }
  38458. return nil
  38459. }
  38460. // RemovedEdges returns all edge names that were removed in this mutation.
  38461. func (m *WorkExperienceMutation) RemovedEdges() []string {
  38462. edges := make([]string, 0, 1)
  38463. return edges
  38464. }
  38465. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38466. // the given name in this mutation.
  38467. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  38468. return nil
  38469. }
  38470. // ClearedEdges returns all edge names that were cleared in this mutation.
  38471. func (m *WorkExperienceMutation) ClearedEdges() []string {
  38472. edges := make([]string, 0, 1)
  38473. if m.clearedemployee {
  38474. edges = append(edges, workexperience.EdgeEmployee)
  38475. }
  38476. return edges
  38477. }
  38478. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38479. // was cleared in this mutation.
  38480. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  38481. switch name {
  38482. case workexperience.EdgeEmployee:
  38483. return m.clearedemployee
  38484. }
  38485. return false
  38486. }
  38487. // ClearEdge clears the value of the edge with the given name. It returns an error
  38488. // if that edge is not defined in the schema.
  38489. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  38490. switch name {
  38491. case workexperience.EdgeEmployee:
  38492. m.ClearEmployee()
  38493. return nil
  38494. }
  38495. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  38496. }
  38497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38498. // It returns an error if the edge is not defined in the schema.
  38499. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  38500. switch name {
  38501. case workexperience.EdgeEmployee:
  38502. m.ResetEmployee()
  38503. return nil
  38504. }
  38505. return fmt.Errorf("unknown WorkExperience edge %s", name)
  38506. }
  38507. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  38508. type WpChatroomMutation struct {
  38509. config
  38510. op Op
  38511. typ string
  38512. id *uint64
  38513. created_at *time.Time
  38514. updated_at *time.Time
  38515. status *uint8
  38516. addstatus *int8
  38517. wx_wxid *string
  38518. chatroom_id *string
  38519. nickname *string
  38520. owner *string
  38521. avatar *string
  38522. member_list *[]string
  38523. appendmember_list []string
  38524. clearedFields map[string]struct{}
  38525. done bool
  38526. oldValue func(context.Context) (*WpChatroom, error)
  38527. predicates []predicate.WpChatroom
  38528. }
  38529. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  38530. // wpchatroomOption allows management of the mutation configuration using functional options.
  38531. type wpchatroomOption func(*WpChatroomMutation)
  38532. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  38533. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  38534. m := &WpChatroomMutation{
  38535. config: c,
  38536. op: op,
  38537. typ: TypeWpChatroom,
  38538. clearedFields: make(map[string]struct{}),
  38539. }
  38540. for _, opt := range opts {
  38541. opt(m)
  38542. }
  38543. return m
  38544. }
  38545. // withWpChatroomID sets the ID field of the mutation.
  38546. func withWpChatroomID(id uint64) wpchatroomOption {
  38547. return func(m *WpChatroomMutation) {
  38548. var (
  38549. err error
  38550. once sync.Once
  38551. value *WpChatroom
  38552. )
  38553. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  38554. once.Do(func() {
  38555. if m.done {
  38556. err = errors.New("querying old values post mutation is not allowed")
  38557. } else {
  38558. value, err = m.Client().WpChatroom.Get(ctx, id)
  38559. }
  38560. })
  38561. return value, err
  38562. }
  38563. m.id = &id
  38564. }
  38565. }
  38566. // withWpChatroom sets the old WpChatroom of the mutation.
  38567. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  38568. return func(m *WpChatroomMutation) {
  38569. m.oldValue = func(context.Context) (*WpChatroom, error) {
  38570. return node, nil
  38571. }
  38572. m.id = &node.ID
  38573. }
  38574. }
  38575. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38576. // executed in a transaction (ent.Tx), a transactional client is returned.
  38577. func (m WpChatroomMutation) Client() *Client {
  38578. client := &Client{config: m.config}
  38579. client.init()
  38580. return client
  38581. }
  38582. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38583. // it returns an error otherwise.
  38584. func (m WpChatroomMutation) Tx() (*Tx, error) {
  38585. if _, ok := m.driver.(*txDriver); !ok {
  38586. return nil, errors.New("ent: mutation is not running in a transaction")
  38587. }
  38588. tx := &Tx{config: m.config}
  38589. tx.init()
  38590. return tx, nil
  38591. }
  38592. // SetID sets the value of the id field. Note that this
  38593. // operation is only accepted on creation of WpChatroom entities.
  38594. func (m *WpChatroomMutation) SetID(id uint64) {
  38595. m.id = &id
  38596. }
  38597. // ID returns the ID value in the mutation. Note that the ID is only available
  38598. // if it was provided to the builder or after it was returned from the database.
  38599. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  38600. if m.id == nil {
  38601. return
  38602. }
  38603. return *m.id, true
  38604. }
  38605. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38606. // That means, if the mutation is applied within a transaction with an isolation level such
  38607. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38608. // or updated by the mutation.
  38609. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  38610. switch {
  38611. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38612. id, exists := m.ID()
  38613. if exists {
  38614. return []uint64{id}, nil
  38615. }
  38616. fallthrough
  38617. case m.op.Is(OpUpdate | OpDelete):
  38618. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  38619. default:
  38620. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38621. }
  38622. }
  38623. // SetCreatedAt sets the "created_at" field.
  38624. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  38625. m.created_at = &t
  38626. }
  38627. // CreatedAt returns the value of the "created_at" field in the mutation.
  38628. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  38629. v := m.created_at
  38630. if v == nil {
  38631. return
  38632. }
  38633. return *v, true
  38634. }
  38635. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  38636. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38638. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38639. if !m.op.Is(OpUpdateOne) {
  38640. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38641. }
  38642. if m.id == nil || m.oldValue == nil {
  38643. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38644. }
  38645. oldValue, err := m.oldValue(ctx)
  38646. if err != nil {
  38647. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38648. }
  38649. return oldValue.CreatedAt, nil
  38650. }
  38651. // ResetCreatedAt resets all changes to the "created_at" field.
  38652. func (m *WpChatroomMutation) ResetCreatedAt() {
  38653. m.created_at = nil
  38654. }
  38655. // SetUpdatedAt sets the "updated_at" field.
  38656. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  38657. m.updated_at = &t
  38658. }
  38659. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38660. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  38661. v := m.updated_at
  38662. if v == nil {
  38663. return
  38664. }
  38665. return *v, true
  38666. }
  38667. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  38668. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38670. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38671. if !m.op.Is(OpUpdateOne) {
  38672. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38673. }
  38674. if m.id == nil || m.oldValue == nil {
  38675. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38676. }
  38677. oldValue, err := m.oldValue(ctx)
  38678. if err != nil {
  38679. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38680. }
  38681. return oldValue.UpdatedAt, nil
  38682. }
  38683. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38684. func (m *WpChatroomMutation) ResetUpdatedAt() {
  38685. m.updated_at = nil
  38686. }
  38687. // SetStatus sets the "status" field.
  38688. func (m *WpChatroomMutation) SetStatus(u uint8) {
  38689. m.status = &u
  38690. m.addstatus = nil
  38691. }
  38692. // Status returns the value of the "status" field in the mutation.
  38693. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  38694. v := m.status
  38695. if v == nil {
  38696. return
  38697. }
  38698. return *v, true
  38699. }
  38700. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  38701. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38703. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38704. if !m.op.Is(OpUpdateOne) {
  38705. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38706. }
  38707. if m.id == nil || m.oldValue == nil {
  38708. return v, errors.New("OldStatus requires an ID field in the mutation")
  38709. }
  38710. oldValue, err := m.oldValue(ctx)
  38711. if err != nil {
  38712. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38713. }
  38714. return oldValue.Status, nil
  38715. }
  38716. // AddStatus adds u to the "status" field.
  38717. func (m *WpChatroomMutation) AddStatus(u int8) {
  38718. if m.addstatus != nil {
  38719. *m.addstatus += u
  38720. } else {
  38721. m.addstatus = &u
  38722. }
  38723. }
  38724. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38725. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  38726. v := m.addstatus
  38727. if v == nil {
  38728. return
  38729. }
  38730. return *v, true
  38731. }
  38732. // ClearStatus clears the value of the "status" field.
  38733. func (m *WpChatroomMutation) ClearStatus() {
  38734. m.status = nil
  38735. m.addstatus = nil
  38736. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  38737. }
  38738. // StatusCleared returns if the "status" field was cleared in this mutation.
  38739. func (m *WpChatroomMutation) StatusCleared() bool {
  38740. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  38741. return ok
  38742. }
  38743. // ResetStatus resets all changes to the "status" field.
  38744. func (m *WpChatroomMutation) ResetStatus() {
  38745. m.status = nil
  38746. m.addstatus = nil
  38747. delete(m.clearedFields, wpchatroom.FieldStatus)
  38748. }
  38749. // SetWxWxid sets the "wx_wxid" field.
  38750. func (m *WpChatroomMutation) SetWxWxid(s string) {
  38751. m.wx_wxid = &s
  38752. }
  38753. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38754. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  38755. v := m.wx_wxid
  38756. if v == nil {
  38757. return
  38758. }
  38759. return *v, true
  38760. }
  38761. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  38762. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38764. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38765. if !m.op.Is(OpUpdateOne) {
  38766. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38767. }
  38768. if m.id == nil || m.oldValue == nil {
  38769. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38770. }
  38771. oldValue, err := m.oldValue(ctx)
  38772. if err != nil {
  38773. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38774. }
  38775. return oldValue.WxWxid, nil
  38776. }
  38777. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38778. func (m *WpChatroomMutation) ResetWxWxid() {
  38779. m.wx_wxid = nil
  38780. }
  38781. // SetChatroomID sets the "chatroom_id" field.
  38782. func (m *WpChatroomMutation) SetChatroomID(s string) {
  38783. m.chatroom_id = &s
  38784. }
  38785. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  38786. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  38787. v := m.chatroom_id
  38788. if v == nil {
  38789. return
  38790. }
  38791. return *v, true
  38792. }
  38793. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  38794. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38796. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  38797. if !m.op.Is(OpUpdateOne) {
  38798. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  38799. }
  38800. if m.id == nil || m.oldValue == nil {
  38801. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  38802. }
  38803. oldValue, err := m.oldValue(ctx)
  38804. if err != nil {
  38805. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  38806. }
  38807. return oldValue.ChatroomID, nil
  38808. }
  38809. // ResetChatroomID resets all changes to the "chatroom_id" field.
  38810. func (m *WpChatroomMutation) ResetChatroomID() {
  38811. m.chatroom_id = nil
  38812. }
  38813. // SetNickname sets the "nickname" field.
  38814. func (m *WpChatroomMutation) SetNickname(s string) {
  38815. m.nickname = &s
  38816. }
  38817. // Nickname returns the value of the "nickname" field in the mutation.
  38818. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  38819. v := m.nickname
  38820. if v == nil {
  38821. return
  38822. }
  38823. return *v, true
  38824. }
  38825. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  38826. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38828. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  38829. if !m.op.Is(OpUpdateOne) {
  38830. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38831. }
  38832. if m.id == nil || m.oldValue == nil {
  38833. return v, errors.New("OldNickname requires an ID field in the mutation")
  38834. }
  38835. oldValue, err := m.oldValue(ctx)
  38836. if err != nil {
  38837. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38838. }
  38839. return oldValue.Nickname, nil
  38840. }
  38841. // ResetNickname resets all changes to the "nickname" field.
  38842. func (m *WpChatroomMutation) ResetNickname() {
  38843. m.nickname = nil
  38844. }
  38845. // SetOwner sets the "owner" field.
  38846. func (m *WpChatroomMutation) SetOwner(s string) {
  38847. m.owner = &s
  38848. }
  38849. // Owner returns the value of the "owner" field in the mutation.
  38850. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  38851. v := m.owner
  38852. if v == nil {
  38853. return
  38854. }
  38855. return *v, true
  38856. }
  38857. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  38858. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38860. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  38861. if !m.op.Is(OpUpdateOne) {
  38862. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  38863. }
  38864. if m.id == nil || m.oldValue == nil {
  38865. return v, errors.New("OldOwner requires an ID field in the mutation")
  38866. }
  38867. oldValue, err := m.oldValue(ctx)
  38868. if err != nil {
  38869. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  38870. }
  38871. return oldValue.Owner, nil
  38872. }
  38873. // ResetOwner resets all changes to the "owner" field.
  38874. func (m *WpChatroomMutation) ResetOwner() {
  38875. m.owner = nil
  38876. }
  38877. // SetAvatar sets the "avatar" field.
  38878. func (m *WpChatroomMutation) SetAvatar(s string) {
  38879. m.avatar = &s
  38880. }
  38881. // Avatar returns the value of the "avatar" field in the mutation.
  38882. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  38883. v := m.avatar
  38884. if v == nil {
  38885. return
  38886. }
  38887. return *v, true
  38888. }
  38889. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  38890. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38892. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38893. if !m.op.Is(OpUpdateOne) {
  38894. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38895. }
  38896. if m.id == nil || m.oldValue == nil {
  38897. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38898. }
  38899. oldValue, err := m.oldValue(ctx)
  38900. if err != nil {
  38901. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38902. }
  38903. return oldValue.Avatar, nil
  38904. }
  38905. // ResetAvatar resets all changes to the "avatar" field.
  38906. func (m *WpChatroomMutation) ResetAvatar() {
  38907. m.avatar = nil
  38908. }
  38909. // SetMemberList sets the "member_list" field.
  38910. func (m *WpChatroomMutation) SetMemberList(s []string) {
  38911. m.member_list = &s
  38912. m.appendmember_list = nil
  38913. }
  38914. // MemberList returns the value of the "member_list" field in the mutation.
  38915. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  38916. v := m.member_list
  38917. if v == nil {
  38918. return
  38919. }
  38920. return *v, true
  38921. }
  38922. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  38923. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38925. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  38926. if !m.op.Is(OpUpdateOne) {
  38927. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  38928. }
  38929. if m.id == nil || m.oldValue == nil {
  38930. return v, errors.New("OldMemberList requires an ID field in the mutation")
  38931. }
  38932. oldValue, err := m.oldValue(ctx)
  38933. if err != nil {
  38934. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  38935. }
  38936. return oldValue.MemberList, nil
  38937. }
  38938. // AppendMemberList adds s to the "member_list" field.
  38939. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  38940. m.appendmember_list = append(m.appendmember_list, s...)
  38941. }
  38942. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  38943. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  38944. if len(m.appendmember_list) == 0 {
  38945. return nil, false
  38946. }
  38947. return m.appendmember_list, true
  38948. }
  38949. // ResetMemberList resets all changes to the "member_list" field.
  38950. func (m *WpChatroomMutation) ResetMemberList() {
  38951. m.member_list = nil
  38952. m.appendmember_list = nil
  38953. }
  38954. // Where appends a list predicates to the WpChatroomMutation builder.
  38955. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  38956. m.predicates = append(m.predicates, ps...)
  38957. }
  38958. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  38959. // users can use type-assertion to append predicates that do not depend on any generated package.
  38960. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  38961. p := make([]predicate.WpChatroom, len(ps))
  38962. for i := range ps {
  38963. p[i] = ps[i]
  38964. }
  38965. m.Where(p...)
  38966. }
  38967. // Op returns the operation name.
  38968. func (m *WpChatroomMutation) Op() Op {
  38969. return m.op
  38970. }
  38971. // SetOp allows setting the mutation operation.
  38972. func (m *WpChatroomMutation) SetOp(op Op) {
  38973. m.op = op
  38974. }
  38975. // Type returns the node type of this mutation (WpChatroom).
  38976. func (m *WpChatroomMutation) Type() string {
  38977. return m.typ
  38978. }
  38979. // Fields returns all fields that were changed during this mutation. Note that in
  38980. // order to get all numeric fields that were incremented/decremented, call
  38981. // AddedFields().
  38982. func (m *WpChatroomMutation) Fields() []string {
  38983. fields := make([]string, 0, 9)
  38984. if m.created_at != nil {
  38985. fields = append(fields, wpchatroom.FieldCreatedAt)
  38986. }
  38987. if m.updated_at != nil {
  38988. fields = append(fields, wpchatroom.FieldUpdatedAt)
  38989. }
  38990. if m.status != nil {
  38991. fields = append(fields, wpchatroom.FieldStatus)
  38992. }
  38993. if m.wx_wxid != nil {
  38994. fields = append(fields, wpchatroom.FieldWxWxid)
  38995. }
  38996. if m.chatroom_id != nil {
  38997. fields = append(fields, wpchatroom.FieldChatroomID)
  38998. }
  38999. if m.nickname != nil {
  39000. fields = append(fields, wpchatroom.FieldNickname)
  39001. }
  39002. if m.owner != nil {
  39003. fields = append(fields, wpchatroom.FieldOwner)
  39004. }
  39005. if m.avatar != nil {
  39006. fields = append(fields, wpchatroom.FieldAvatar)
  39007. }
  39008. if m.member_list != nil {
  39009. fields = append(fields, wpchatroom.FieldMemberList)
  39010. }
  39011. return fields
  39012. }
  39013. // Field returns the value of a field with the given name. The second boolean
  39014. // return value indicates that this field was not set, or was not defined in the
  39015. // schema.
  39016. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  39017. switch name {
  39018. case wpchatroom.FieldCreatedAt:
  39019. return m.CreatedAt()
  39020. case wpchatroom.FieldUpdatedAt:
  39021. return m.UpdatedAt()
  39022. case wpchatroom.FieldStatus:
  39023. return m.Status()
  39024. case wpchatroom.FieldWxWxid:
  39025. return m.WxWxid()
  39026. case wpchatroom.FieldChatroomID:
  39027. return m.ChatroomID()
  39028. case wpchatroom.FieldNickname:
  39029. return m.Nickname()
  39030. case wpchatroom.FieldOwner:
  39031. return m.Owner()
  39032. case wpchatroom.FieldAvatar:
  39033. return m.Avatar()
  39034. case wpchatroom.FieldMemberList:
  39035. return m.MemberList()
  39036. }
  39037. return nil, false
  39038. }
  39039. // OldField returns the old value of the field from the database. An error is
  39040. // returned if the mutation operation is not UpdateOne, or the query to the
  39041. // database failed.
  39042. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39043. switch name {
  39044. case wpchatroom.FieldCreatedAt:
  39045. return m.OldCreatedAt(ctx)
  39046. case wpchatroom.FieldUpdatedAt:
  39047. return m.OldUpdatedAt(ctx)
  39048. case wpchatroom.FieldStatus:
  39049. return m.OldStatus(ctx)
  39050. case wpchatroom.FieldWxWxid:
  39051. return m.OldWxWxid(ctx)
  39052. case wpchatroom.FieldChatroomID:
  39053. return m.OldChatroomID(ctx)
  39054. case wpchatroom.FieldNickname:
  39055. return m.OldNickname(ctx)
  39056. case wpchatroom.FieldOwner:
  39057. return m.OldOwner(ctx)
  39058. case wpchatroom.FieldAvatar:
  39059. return m.OldAvatar(ctx)
  39060. case wpchatroom.FieldMemberList:
  39061. return m.OldMemberList(ctx)
  39062. }
  39063. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  39064. }
  39065. // SetField sets the value of a field with the given name. It returns an error if
  39066. // the field is not defined in the schema, or if the type mismatched the field
  39067. // type.
  39068. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  39069. switch name {
  39070. case wpchatroom.FieldCreatedAt:
  39071. v, ok := value.(time.Time)
  39072. if !ok {
  39073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39074. }
  39075. m.SetCreatedAt(v)
  39076. return nil
  39077. case wpchatroom.FieldUpdatedAt:
  39078. v, ok := value.(time.Time)
  39079. if !ok {
  39080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39081. }
  39082. m.SetUpdatedAt(v)
  39083. return nil
  39084. case wpchatroom.FieldStatus:
  39085. v, ok := value.(uint8)
  39086. if !ok {
  39087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39088. }
  39089. m.SetStatus(v)
  39090. return nil
  39091. case wpchatroom.FieldWxWxid:
  39092. v, ok := value.(string)
  39093. if !ok {
  39094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39095. }
  39096. m.SetWxWxid(v)
  39097. return nil
  39098. case wpchatroom.FieldChatroomID:
  39099. v, ok := value.(string)
  39100. if !ok {
  39101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39102. }
  39103. m.SetChatroomID(v)
  39104. return nil
  39105. case wpchatroom.FieldNickname:
  39106. v, ok := value.(string)
  39107. if !ok {
  39108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39109. }
  39110. m.SetNickname(v)
  39111. return nil
  39112. case wpchatroom.FieldOwner:
  39113. v, ok := value.(string)
  39114. if !ok {
  39115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39116. }
  39117. m.SetOwner(v)
  39118. return nil
  39119. case wpchatroom.FieldAvatar:
  39120. v, ok := value.(string)
  39121. if !ok {
  39122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39123. }
  39124. m.SetAvatar(v)
  39125. return nil
  39126. case wpchatroom.FieldMemberList:
  39127. v, ok := value.([]string)
  39128. if !ok {
  39129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39130. }
  39131. m.SetMemberList(v)
  39132. return nil
  39133. }
  39134. return fmt.Errorf("unknown WpChatroom field %s", name)
  39135. }
  39136. // AddedFields returns all numeric fields that were incremented/decremented during
  39137. // this mutation.
  39138. func (m *WpChatroomMutation) AddedFields() []string {
  39139. var fields []string
  39140. if m.addstatus != nil {
  39141. fields = append(fields, wpchatroom.FieldStatus)
  39142. }
  39143. return fields
  39144. }
  39145. // AddedField returns the numeric value that was incremented/decremented on a field
  39146. // with the given name. The second boolean return value indicates that this field
  39147. // was not set, or was not defined in the schema.
  39148. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  39149. switch name {
  39150. case wpchatroom.FieldStatus:
  39151. return m.AddedStatus()
  39152. }
  39153. return nil, false
  39154. }
  39155. // AddField adds the value to the field with the given name. It returns an error if
  39156. // the field is not defined in the schema, or if the type mismatched the field
  39157. // type.
  39158. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  39159. switch name {
  39160. case wpchatroom.FieldStatus:
  39161. v, ok := value.(int8)
  39162. if !ok {
  39163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39164. }
  39165. m.AddStatus(v)
  39166. return nil
  39167. }
  39168. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  39169. }
  39170. // ClearedFields returns all nullable fields that were cleared during this
  39171. // mutation.
  39172. func (m *WpChatroomMutation) ClearedFields() []string {
  39173. var fields []string
  39174. if m.FieldCleared(wpchatroom.FieldStatus) {
  39175. fields = append(fields, wpchatroom.FieldStatus)
  39176. }
  39177. return fields
  39178. }
  39179. // FieldCleared returns a boolean indicating if a field with the given name was
  39180. // cleared in this mutation.
  39181. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  39182. _, ok := m.clearedFields[name]
  39183. return ok
  39184. }
  39185. // ClearField clears the value of the field with the given name. It returns an
  39186. // error if the field is not defined in the schema.
  39187. func (m *WpChatroomMutation) ClearField(name string) error {
  39188. switch name {
  39189. case wpchatroom.FieldStatus:
  39190. m.ClearStatus()
  39191. return nil
  39192. }
  39193. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  39194. }
  39195. // ResetField resets all changes in the mutation for the field with the given name.
  39196. // It returns an error if the field is not defined in the schema.
  39197. func (m *WpChatroomMutation) ResetField(name string) error {
  39198. switch name {
  39199. case wpchatroom.FieldCreatedAt:
  39200. m.ResetCreatedAt()
  39201. return nil
  39202. case wpchatroom.FieldUpdatedAt:
  39203. m.ResetUpdatedAt()
  39204. return nil
  39205. case wpchatroom.FieldStatus:
  39206. m.ResetStatus()
  39207. return nil
  39208. case wpchatroom.FieldWxWxid:
  39209. m.ResetWxWxid()
  39210. return nil
  39211. case wpchatroom.FieldChatroomID:
  39212. m.ResetChatroomID()
  39213. return nil
  39214. case wpchatroom.FieldNickname:
  39215. m.ResetNickname()
  39216. return nil
  39217. case wpchatroom.FieldOwner:
  39218. m.ResetOwner()
  39219. return nil
  39220. case wpchatroom.FieldAvatar:
  39221. m.ResetAvatar()
  39222. return nil
  39223. case wpchatroom.FieldMemberList:
  39224. m.ResetMemberList()
  39225. return nil
  39226. }
  39227. return fmt.Errorf("unknown WpChatroom field %s", name)
  39228. }
  39229. // AddedEdges returns all edge names that were set/added in this mutation.
  39230. func (m *WpChatroomMutation) AddedEdges() []string {
  39231. edges := make([]string, 0, 0)
  39232. return edges
  39233. }
  39234. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39235. // name in this mutation.
  39236. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  39237. return nil
  39238. }
  39239. // RemovedEdges returns all edge names that were removed in this mutation.
  39240. func (m *WpChatroomMutation) RemovedEdges() []string {
  39241. edges := make([]string, 0, 0)
  39242. return edges
  39243. }
  39244. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39245. // the given name in this mutation.
  39246. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  39247. return nil
  39248. }
  39249. // ClearedEdges returns all edge names that were cleared in this mutation.
  39250. func (m *WpChatroomMutation) ClearedEdges() []string {
  39251. edges := make([]string, 0, 0)
  39252. return edges
  39253. }
  39254. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39255. // was cleared in this mutation.
  39256. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  39257. return false
  39258. }
  39259. // ClearEdge clears the value of the edge with the given name. It returns an error
  39260. // if that edge is not defined in the schema.
  39261. func (m *WpChatroomMutation) ClearEdge(name string) error {
  39262. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  39263. }
  39264. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39265. // It returns an error if the edge is not defined in the schema.
  39266. func (m *WpChatroomMutation) ResetEdge(name string) error {
  39267. return fmt.Errorf("unknown WpChatroom edge %s", name)
  39268. }
  39269. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  39270. type WpChatroomMemberMutation struct {
  39271. config
  39272. op Op
  39273. typ string
  39274. id *uint64
  39275. created_at *time.Time
  39276. updated_at *time.Time
  39277. status *uint8
  39278. addstatus *int8
  39279. wx_wxid *string
  39280. wxid *string
  39281. nickname *string
  39282. avatar *string
  39283. clearedFields map[string]struct{}
  39284. done bool
  39285. oldValue func(context.Context) (*WpChatroomMember, error)
  39286. predicates []predicate.WpChatroomMember
  39287. }
  39288. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  39289. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  39290. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  39291. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  39292. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  39293. m := &WpChatroomMemberMutation{
  39294. config: c,
  39295. op: op,
  39296. typ: TypeWpChatroomMember,
  39297. clearedFields: make(map[string]struct{}),
  39298. }
  39299. for _, opt := range opts {
  39300. opt(m)
  39301. }
  39302. return m
  39303. }
  39304. // withWpChatroomMemberID sets the ID field of the mutation.
  39305. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  39306. return func(m *WpChatroomMemberMutation) {
  39307. var (
  39308. err error
  39309. once sync.Once
  39310. value *WpChatroomMember
  39311. )
  39312. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  39313. once.Do(func() {
  39314. if m.done {
  39315. err = errors.New("querying old values post mutation is not allowed")
  39316. } else {
  39317. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  39318. }
  39319. })
  39320. return value, err
  39321. }
  39322. m.id = &id
  39323. }
  39324. }
  39325. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  39326. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  39327. return func(m *WpChatroomMemberMutation) {
  39328. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  39329. return node, nil
  39330. }
  39331. m.id = &node.ID
  39332. }
  39333. }
  39334. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39335. // executed in a transaction (ent.Tx), a transactional client is returned.
  39336. func (m WpChatroomMemberMutation) Client() *Client {
  39337. client := &Client{config: m.config}
  39338. client.init()
  39339. return client
  39340. }
  39341. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39342. // it returns an error otherwise.
  39343. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  39344. if _, ok := m.driver.(*txDriver); !ok {
  39345. return nil, errors.New("ent: mutation is not running in a transaction")
  39346. }
  39347. tx := &Tx{config: m.config}
  39348. tx.init()
  39349. return tx, nil
  39350. }
  39351. // SetID sets the value of the id field. Note that this
  39352. // operation is only accepted on creation of WpChatroomMember entities.
  39353. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  39354. m.id = &id
  39355. }
  39356. // ID returns the ID value in the mutation. Note that the ID is only available
  39357. // if it was provided to the builder or after it was returned from the database.
  39358. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  39359. if m.id == nil {
  39360. return
  39361. }
  39362. return *m.id, true
  39363. }
  39364. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39365. // That means, if the mutation is applied within a transaction with an isolation level such
  39366. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39367. // or updated by the mutation.
  39368. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  39369. switch {
  39370. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39371. id, exists := m.ID()
  39372. if exists {
  39373. return []uint64{id}, nil
  39374. }
  39375. fallthrough
  39376. case m.op.Is(OpUpdate | OpDelete):
  39377. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  39378. default:
  39379. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39380. }
  39381. }
  39382. // SetCreatedAt sets the "created_at" field.
  39383. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  39384. m.created_at = &t
  39385. }
  39386. // CreatedAt returns the value of the "created_at" field in the mutation.
  39387. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  39388. v := m.created_at
  39389. if v == nil {
  39390. return
  39391. }
  39392. return *v, true
  39393. }
  39394. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  39395. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39397. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39398. if !m.op.Is(OpUpdateOne) {
  39399. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39400. }
  39401. if m.id == nil || m.oldValue == nil {
  39402. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39403. }
  39404. oldValue, err := m.oldValue(ctx)
  39405. if err != nil {
  39406. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39407. }
  39408. return oldValue.CreatedAt, nil
  39409. }
  39410. // ResetCreatedAt resets all changes to the "created_at" field.
  39411. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  39412. m.created_at = nil
  39413. }
  39414. // SetUpdatedAt sets the "updated_at" field.
  39415. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  39416. m.updated_at = &t
  39417. }
  39418. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39419. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  39420. v := m.updated_at
  39421. if v == nil {
  39422. return
  39423. }
  39424. return *v, true
  39425. }
  39426. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  39427. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39429. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39430. if !m.op.Is(OpUpdateOne) {
  39431. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39432. }
  39433. if m.id == nil || m.oldValue == nil {
  39434. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39435. }
  39436. oldValue, err := m.oldValue(ctx)
  39437. if err != nil {
  39438. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39439. }
  39440. return oldValue.UpdatedAt, nil
  39441. }
  39442. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39443. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  39444. m.updated_at = nil
  39445. }
  39446. // SetStatus sets the "status" field.
  39447. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  39448. m.status = &u
  39449. m.addstatus = nil
  39450. }
  39451. // Status returns the value of the "status" field in the mutation.
  39452. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  39453. v := m.status
  39454. if v == nil {
  39455. return
  39456. }
  39457. return *v, true
  39458. }
  39459. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  39460. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39462. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39463. if !m.op.Is(OpUpdateOne) {
  39464. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39465. }
  39466. if m.id == nil || m.oldValue == nil {
  39467. return v, errors.New("OldStatus requires an ID field in the mutation")
  39468. }
  39469. oldValue, err := m.oldValue(ctx)
  39470. if err != nil {
  39471. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39472. }
  39473. return oldValue.Status, nil
  39474. }
  39475. // AddStatus adds u to the "status" field.
  39476. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  39477. if m.addstatus != nil {
  39478. *m.addstatus += u
  39479. } else {
  39480. m.addstatus = &u
  39481. }
  39482. }
  39483. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39484. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  39485. v := m.addstatus
  39486. if v == nil {
  39487. return
  39488. }
  39489. return *v, true
  39490. }
  39491. // ClearStatus clears the value of the "status" field.
  39492. func (m *WpChatroomMemberMutation) ClearStatus() {
  39493. m.status = nil
  39494. m.addstatus = nil
  39495. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  39496. }
  39497. // StatusCleared returns if the "status" field was cleared in this mutation.
  39498. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  39499. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  39500. return ok
  39501. }
  39502. // ResetStatus resets all changes to the "status" field.
  39503. func (m *WpChatroomMemberMutation) ResetStatus() {
  39504. m.status = nil
  39505. m.addstatus = nil
  39506. delete(m.clearedFields, wpchatroommember.FieldStatus)
  39507. }
  39508. // SetWxWxid sets the "wx_wxid" field.
  39509. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  39510. m.wx_wxid = &s
  39511. }
  39512. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39513. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  39514. v := m.wx_wxid
  39515. if v == nil {
  39516. return
  39517. }
  39518. return *v, true
  39519. }
  39520. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  39521. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39523. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39524. if !m.op.Is(OpUpdateOne) {
  39525. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39526. }
  39527. if m.id == nil || m.oldValue == nil {
  39528. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39529. }
  39530. oldValue, err := m.oldValue(ctx)
  39531. if err != nil {
  39532. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39533. }
  39534. return oldValue.WxWxid, nil
  39535. }
  39536. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39537. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  39538. m.wx_wxid = nil
  39539. }
  39540. // SetWxid sets the "wxid" field.
  39541. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  39542. m.wxid = &s
  39543. }
  39544. // Wxid returns the value of the "wxid" field in the mutation.
  39545. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  39546. v := m.wxid
  39547. if v == nil {
  39548. return
  39549. }
  39550. return *v, true
  39551. }
  39552. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  39553. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39555. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  39556. if !m.op.Is(OpUpdateOne) {
  39557. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39558. }
  39559. if m.id == nil || m.oldValue == nil {
  39560. return v, errors.New("OldWxid requires an ID field in the mutation")
  39561. }
  39562. oldValue, err := m.oldValue(ctx)
  39563. if err != nil {
  39564. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39565. }
  39566. return oldValue.Wxid, nil
  39567. }
  39568. // ResetWxid resets all changes to the "wxid" field.
  39569. func (m *WpChatroomMemberMutation) ResetWxid() {
  39570. m.wxid = nil
  39571. }
  39572. // SetNickname sets the "nickname" field.
  39573. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  39574. m.nickname = &s
  39575. }
  39576. // Nickname returns the value of the "nickname" field in the mutation.
  39577. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  39578. v := m.nickname
  39579. if v == nil {
  39580. return
  39581. }
  39582. return *v, true
  39583. }
  39584. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  39585. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39587. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  39588. if !m.op.Is(OpUpdateOne) {
  39589. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39590. }
  39591. if m.id == nil || m.oldValue == nil {
  39592. return v, errors.New("OldNickname requires an ID field in the mutation")
  39593. }
  39594. oldValue, err := m.oldValue(ctx)
  39595. if err != nil {
  39596. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39597. }
  39598. return oldValue.Nickname, nil
  39599. }
  39600. // ResetNickname resets all changes to the "nickname" field.
  39601. func (m *WpChatroomMemberMutation) ResetNickname() {
  39602. m.nickname = nil
  39603. }
  39604. // SetAvatar sets the "avatar" field.
  39605. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  39606. m.avatar = &s
  39607. }
  39608. // Avatar returns the value of the "avatar" field in the mutation.
  39609. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  39610. v := m.avatar
  39611. if v == nil {
  39612. return
  39613. }
  39614. return *v, true
  39615. }
  39616. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  39617. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39619. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39620. if !m.op.Is(OpUpdateOne) {
  39621. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39622. }
  39623. if m.id == nil || m.oldValue == nil {
  39624. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39625. }
  39626. oldValue, err := m.oldValue(ctx)
  39627. if err != nil {
  39628. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39629. }
  39630. return oldValue.Avatar, nil
  39631. }
  39632. // ResetAvatar resets all changes to the "avatar" field.
  39633. func (m *WpChatroomMemberMutation) ResetAvatar() {
  39634. m.avatar = nil
  39635. }
  39636. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  39637. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  39638. m.predicates = append(m.predicates, ps...)
  39639. }
  39640. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  39641. // users can use type-assertion to append predicates that do not depend on any generated package.
  39642. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  39643. p := make([]predicate.WpChatroomMember, len(ps))
  39644. for i := range ps {
  39645. p[i] = ps[i]
  39646. }
  39647. m.Where(p...)
  39648. }
  39649. // Op returns the operation name.
  39650. func (m *WpChatroomMemberMutation) Op() Op {
  39651. return m.op
  39652. }
  39653. // SetOp allows setting the mutation operation.
  39654. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  39655. m.op = op
  39656. }
  39657. // Type returns the node type of this mutation (WpChatroomMember).
  39658. func (m *WpChatroomMemberMutation) Type() string {
  39659. return m.typ
  39660. }
  39661. // Fields returns all fields that were changed during this mutation. Note that in
  39662. // order to get all numeric fields that were incremented/decremented, call
  39663. // AddedFields().
  39664. func (m *WpChatroomMemberMutation) Fields() []string {
  39665. fields := make([]string, 0, 7)
  39666. if m.created_at != nil {
  39667. fields = append(fields, wpchatroommember.FieldCreatedAt)
  39668. }
  39669. if m.updated_at != nil {
  39670. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  39671. }
  39672. if m.status != nil {
  39673. fields = append(fields, wpchatroommember.FieldStatus)
  39674. }
  39675. if m.wx_wxid != nil {
  39676. fields = append(fields, wpchatroommember.FieldWxWxid)
  39677. }
  39678. if m.wxid != nil {
  39679. fields = append(fields, wpchatroommember.FieldWxid)
  39680. }
  39681. if m.nickname != nil {
  39682. fields = append(fields, wpchatroommember.FieldNickname)
  39683. }
  39684. if m.avatar != nil {
  39685. fields = append(fields, wpchatroommember.FieldAvatar)
  39686. }
  39687. return fields
  39688. }
  39689. // Field returns the value of a field with the given name. The second boolean
  39690. // return value indicates that this field was not set, or was not defined in the
  39691. // schema.
  39692. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  39693. switch name {
  39694. case wpchatroommember.FieldCreatedAt:
  39695. return m.CreatedAt()
  39696. case wpchatroommember.FieldUpdatedAt:
  39697. return m.UpdatedAt()
  39698. case wpchatroommember.FieldStatus:
  39699. return m.Status()
  39700. case wpchatroommember.FieldWxWxid:
  39701. return m.WxWxid()
  39702. case wpchatroommember.FieldWxid:
  39703. return m.Wxid()
  39704. case wpchatroommember.FieldNickname:
  39705. return m.Nickname()
  39706. case wpchatroommember.FieldAvatar:
  39707. return m.Avatar()
  39708. }
  39709. return nil, false
  39710. }
  39711. // OldField returns the old value of the field from the database. An error is
  39712. // returned if the mutation operation is not UpdateOne, or the query to the
  39713. // database failed.
  39714. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39715. switch name {
  39716. case wpchatroommember.FieldCreatedAt:
  39717. return m.OldCreatedAt(ctx)
  39718. case wpchatroommember.FieldUpdatedAt:
  39719. return m.OldUpdatedAt(ctx)
  39720. case wpchatroommember.FieldStatus:
  39721. return m.OldStatus(ctx)
  39722. case wpchatroommember.FieldWxWxid:
  39723. return m.OldWxWxid(ctx)
  39724. case wpchatroommember.FieldWxid:
  39725. return m.OldWxid(ctx)
  39726. case wpchatroommember.FieldNickname:
  39727. return m.OldNickname(ctx)
  39728. case wpchatroommember.FieldAvatar:
  39729. return m.OldAvatar(ctx)
  39730. }
  39731. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  39732. }
  39733. // SetField sets the value of a field with the given name. It returns an error if
  39734. // the field is not defined in the schema, or if the type mismatched the field
  39735. // type.
  39736. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  39737. switch name {
  39738. case wpchatroommember.FieldCreatedAt:
  39739. v, ok := value.(time.Time)
  39740. if !ok {
  39741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39742. }
  39743. m.SetCreatedAt(v)
  39744. return nil
  39745. case wpchatroommember.FieldUpdatedAt:
  39746. v, ok := value.(time.Time)
  39747. if !ok {
  39748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39749. }
  39750. m.SetUpdatedAt(v)
  39751. return nil
  39752. case wpchatroommember.FieldStatus:
  39753. v, ok := value.(uint8)
  39754. if !ok {
  39755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39756. }
  39757. m.SetStatus(v)
  39758. return nil
  39759. case wpchatroommember.FieldWxWxid:
  39760. v, ok := value.(string)
  39761. if !ok {
  39762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39763. }
  39764. m.SetWxWxid(v)
  39765. return nil
  39766. case wpchatroommember.FieldWxid:
  39767. v, ok := value.(string)
  39768. if !ok {
  39769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39770. }
  39771. m.SetWxid(v)
  39772. return nil
  39773. case wpchatroommember.FieldNickname:
  39774. v, ok := value.(string)
  39775. if !ok {
  39776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39777. }
  39778. m.SetNickname(v)
  39779. return nil
  39780. case wpchatroommember.FieldAvatar:
  39781. v, ok := value.(string)
  39782. if !ok {
  39783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39784. }
  39785. m.SetAvatar(v)
  39786. return nil
  39787. }
  39788. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39789. }
  39790. // AddedFields returns all numeric fields that were incremented/decremented during
  39791. // this mutation.
  39792. func (m *WpChatroomMemberMutation) AddedFields() []string {
  39793. var fields []string
  39794. if m.addstatus != nil {
  39795. fields = append(fields, wpchatroommember.FieldStatus)
  39796. }
  39797. return fields
  39798. }
  39799. // AddedField returns the numeric value that was incremented/decremented on a field
  39800. // with the given name. The second boolean return value indicates that this field
  39801. // was not set, or was not defined in the schema.
  39802. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  39803. switch name {
  39804. case wpchatroommember.FieldStatus:
  39805. return m.AddedStatus()
  39806. }
  39807. return nil, false
  39808. }
  39809. // AddField adds the value to the field with the given name. It returns an error if
  39810. // the field is not defined in the schema, or if the type mismatched the field
  39811. // type.
  39812. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  39813. switch name {
  39814. case wpchatroommember.FieldStatus:
  39815. v, ok := value.(int8)
  39816. if !ok {
  39817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39818. }
  39819. m.AddStatus(v)
  39820. return nil
  39821. }
  39822. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  39823. }
  39824. // ClearedFields returns all nullable fields that were cleared during this
  39825. // mutation.
  39826. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  39827. var fields []string
  39828. if m.FieldCleared(wpchatroommember.FieldStatus) {
  39829. fields = append(fields, wpchatroommember.FieldStatus)
  39830. }
  39831. return fields
  39832. }
  39833. // FieldCleared returns a boolean indicating if a field with the given name was
  39834. // cleared in this mutation.
  39835. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  39836. _, ok := m.clearedFields[name]
  39837. return ok
  39838. }
  39839. // ClearField clears the value of the field with the given name. It returns an
  39840. // error if the field is not defined in the schema.
  39841. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  39842. switch name {
  39843. case wpchatroommember.FieldStatus:
  39844. m.ClearStatus()
  39845. return nil
  39846. }
  39847. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  39848. }
  39849. // ResetField resets all changes in the mutation for the field with the given name.
  39850. // It returns an error if the field is not defined in the schema.
  39851. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  39852. switch name {
  39853. case wpchatroommember.FieldCreatedAt:
  39854. m.ResetCreatedAt()
  39855. return nil
  39856. case wpchatroommember.FieldUpdatedAt:
  39857. m.ResetUpdatedAt()
  39858. return nil
  39859. case wpchatroommember.FieldStatus:
  39860. m.ResetStatus()
  39861. return nil
  39862. case wpchatroommember.FieldWxWxid:
  39863. m.ResetWxWxid()
  39864. return nil
  39865. case wpchatroommember.FieldWxid:
  39866. m.ResetWxid()
  39867. return nil
  39868. case wpchatroommember.FieldNickname:
  39869. m.ResetNickname()
  39870. return nil
  39871. case wpchatroommember.FieldAvatar:
  39872. m.ResetAvatar()
  39873. return nil
  39874. }
  39875. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39876. }
  39877. // AddedEdges returns all edge names that were set/added in this mutation.
  39878. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  39879. edges := make([]string, 0, 0)
  39880. return edges
  39881. }
  39882. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39883. // name in this mutation.
  39884. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  39885. return nil
  39886. }
  39887. // RemovedEdges returns all edge names that were removed in this mutation.
  39888. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  39889. edges := make([]string, 0, 0)
  39890. return edges
  39891. }
  39892. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39893. // the given name in this mutation.
  39894. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  39895. return nil
  39896. }
  39897. // ClearedEdges returns all edge names that were cleared in this mutation.
  39898. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  39899. edges := make([]string, 0, 0)
  39900. return edges
  39901. }
  39902. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39903. // was cleared in this mutation.
  39904. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  39905. return false
  39906. }
  39907. // ClearEdge clears the value of the edge with the given name. It returns an error
  39908. // if that edge is not defined in the schema.
  39909. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  39910. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  39911. }
  39912. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39913. // It returns an error if the edge is not defined in the schema.
  39914. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  39915. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  39916. }
  39917. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  39918. type WxMutation struct {
  39919. config
  39920. op Op
  39921. typ string
  39922. id *uint64
  39923. created_at *time.Time
  39924. updated_at *time.Time
  39925. status *uint8
  39926. addstatus *int8
  39927. deleted_at *time.Time
  39928. port *string
  39929. process_id *string
  39930. callback *string
  39931. wxid *string
  39932. account *string
  39933. nickname *string
  39934. tel *string
  39935. head_big *string
  39936. organization_id *uint64
  39937. addorganization_id *int64
  39938. api_base *string
  39939. api_key *string
  39940. allow_list *[]string
  39941. appendallow_list []string
  39942. group_allow_list *[]string
  39943. appendgroup_allow_list []string
  39944. block_list *[]string
  39945. appendblock_list []string
  39946. group_block_list *[]string
  39947. appendgroup_block_list []string
  39948. ctype *uint64
  39949. addctype *int64
  39950. clearedFields map[string]struct{}
  39951. server *uint64
  39952. clearedserver bool
  39953. agent *uint64
  39954. clearedagent bool
  39955. done bool
  39956. oldValue func(context.Context) (*Wx, error)
  39957. predicates []predicate.Wx
  39958. }
  39959. var _ ent.Mutation = (*WxMutation)(nil)
  39960. // wxOption allows management of the mutation configuration using functional options.
  39961. type wxOption func(*WxMutation)
  39962. // newWxMutation creates new mutation for the Wx entity.
  39963. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  39964. m := &WxMutation{
  39965. config: c,
  39966. op: op,
  39967. typ: TypeWx,
  39968. clearedFields: make(map[string]struct{}),
  39969. }
  39970. for _, opt := range opts {
  39971. opt(m)
  39972. }
  39973. return m
  39974. }
  39975. // withWxID sets the ID field of the mutation.
  39976. func withWxID(id uint64) wxOption {
  39977. return func(m *WxMutation) {
  39978. var (
  39979. err error
  39980. once sync.Once
  39981. value *Wx
  39982. )
  39983. m.oldValue = func(ctx context.Context) (*Wx, error) {
  39984. once.Do(func() {
  39985. if m.done {
  39986. err = errors.New("querying old values post mutation is not allowed")
  39987. } else {
  39988. value, err = m.Client().Wx.Get(ctx, id)
  39989. }
  39990. })
  39991. return value, err
  39992. }
  39993. m.id = &id
  39994. }
  39995. }
  39996. // withWx sets the old Wx of the mutation.
  39997. func withWx(node *Wx) wxOption {
  39998. return func(m *WxMutation) {
  39999. m.oldValue = func(context.Context) (*Wx, error) {
  40000. return node, nil
  40001. }
  40002. m.id = &node.ID
  40003. }
  40004. }
  40005. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40006. // executed in a transaction (ent.Tx), a transactional client is returned.
  40007. func (m WxMutation) Client() *Client {
  40008. client := &Client{config: m.config}
  40009. client.init()
  40010. return client
  40011. }
  40012. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40013. // it returns an error otherwise.
  40014. func (m WxMutation) Tx() (*Tx, error) {
  40015. if _, ok := m.driver.(*txDriver); !ok {
  40016. return nil, errors.New("ent: mutation is not running in a transaction")
  40017. }
  40018. tx := &Tx{config: m.config}
  40019. tx.init()
  40020. return tx, nil
  40021. }
  40022. // SetID sets the value of the id field. Note that this
  40023. // operation is only accepted on creation of Wx entities.
  40024. func (m *WxMutation) SetID(id uint64) {
  40025. m.id = &id
  40026. }
  40027. // ID returns the ID value in the mutation. Note that the ID is only available
  40028. // if it was provided to the builder or after it was returned from the database.
  40029. func (m *WxMutation) ID() (id uint64, exists bool) {
  40030. if m.id == nil {
  40031. return
  40032. }
  40033. return *m.id, true
  40034. }
  40035. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40036. // That means, if the mutation is applied within a transaction with an isolation level such
  40037. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40038. // or updated by the mutation.
  40039. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  40040. switch {
  40041. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40042. id, exists := m.ID()
  40043. if exists {
  40044. return []uint64{id}, nil
  40045. }
  40046. fallthrough
  40047. case m.op.Is(OpUpdate | OpDelete):
  40048. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  40049. default:
  40050. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40051. }
  40052. }
  40053. // SetCreatedAt sets the "created_at" field.
  40054. func (m *WxMutation) SetCreatedAt(t time.Time) {
  40055. m.created_at = &t
  40056. }
  40057. // CreatedAt returns the value of the "created_at" field in the mutation.
  40058. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  40059. v := m.created_at
  40060. if v == nil {
  40061. return
  40062. }
  40063. return *v, true
  40064. }
  40065. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  40066. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40068. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40069. if !m.op.Is(OpUpdateOne) {
  40070. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40071. }
  40072. if m.id == nil || m.oldValue == nil {
  40073. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40074. }
  40075. oldValue, err := m.oldValue(ctx)
  40076. if err != nil {
  40077. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40078. }
  40079. return oldValue.CreatedAt, nil
  40080. }
  40081. // ResetCreatedAt resets all changes to the "created_at" field.
  40082. func (m *WxMutation) ResetCreatedAt() {
  40083. m.created_at = nil
  40084. }
  40085. // SetUpdatedAt sets the "updated_at" field.
  40086. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  40087. m.updated_at = &t
  40088. }
  40089. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40090. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  40091. v := m.updated_at
  40092. if v == nil {
  40093. return
  40094. }
  40095. return *v, true
  40096. }
  40097. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  40098. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40100. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40101. if !m.op.Is(OpUpdateOne) {
  40102. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40103. }
  40104. if m.id == nil || m.oldValue == nil {
  40105. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40106. }
  40107. oldValue, err := m.oldValue(ctx)
  40108. if err != nil {
  40109. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40110. }
  40111. return oldValue.UpdatedAt, nil
  40112. }
  40113. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40114. func (m *WxMutation) ResetUpdatedAt() {
  40115. m.updated_at = nil
  40116. }
  40117. // SetStatus sets the "status" field.
  40118. func (m *WxMutation) SetStatus(u uint8) {
  40119. m.status = &u
  40120. m.addstatus = nil
  40121. }
  40122. // Status returns the value of the "status" field in the mutation.
  40123. func (m *WxMutation) Status() (r uint8, exists bool) {
  40124. v := m.status
  40125. if v == nil {
  40126. return
  40127. }
  40128. return *v, true
  40129. }
  40130. // OldStatus returns the old "status" field's value of the Wx entity.
  40131. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40133. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40134. if !m.op.Is(OpUpdateOne) {
  40135. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40136. }
  40137. if m.id == nil || m.oldValue == nil {
  40138. return v, errors.New("OldStatus requires an ID field in the mutation")
  40139. }
  40140. oldValue, err := m.oldValue(ctx)
  40141. if err != nil {
  40142. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40143. }
  40144. return oldValue.Status, nil
  40145. }
  40146. // AddStatus adds u to the "status" field.
  40147. func (m *WxMutation) AddStatus(u int8) {
  40148. if m.addstatus != nil {
  40149. *m.addstatus += u
  40150. } else {
  40151. m.addstatus = &u
  40152. }
  40153. }
  40154. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40155. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  40156. v := m.addstatus
  40157. if v == nil {
  40158. return
  40159. }
  40160. return *v, true
  40161. }
  40162. // ClearStatus clears the value of the "status" field.
  40163. func (m *WxMutation) ClearStatus() {
  40164. m.status = nil
  40165. m.addstatus = nil
  40166. m.clearedFields[wx.FieldStatus] = struct{}{}
  40167. }
  40168. // StatusCleared returns if the "status" field was cleared in this mutation.
  40169. func (m *WxMutation) StatusCleared() bool {
  40170. _, ok := m.clearedFields[wx.FieldStatus]
  40171. return ok
  40172. }
  40173. // ResetStatus resets all changes to the "status" field.
  40174. func (m *WxMutation) ResetStatus() {
  40175. m.status = nil
  40176. m.addstatus = nil
  40177. delete(m.clearedFields, wx.FieldStatus)
  40178. }
  40179. // SetDeletedAt sets the "deleted_at" field.
  40180. func (m *WxMutation) SetDeletedAt(t time.Time) {
  40181. m.deleted_at = &t
  40182. }
  40183. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40184. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  40185. v := m.deleted_at
  40186. if v == nil {
  40187. return
  40188. }
  40189. return *v, true
  40190. }
  40191. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  40192. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40194. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40195. if !m.op.Is(OpUpdateOne) {
  40196. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40197. }
  40198. if m.id == nil || m.oldValue == nil {
  40199. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40200. }
  40201. oldValue, err := m.oldValue(ctx)
  40202. if err != nil {
  40203. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40204. }
  40205. return oldValue.DeletedAt, nil
  40206. }
  40207. // ClearDeletedAt clears the value of the "deleted_at" field.
  40208. func (m *WxMutation) ClearDeletedAt() {
  40209. m.deleted_at = nil
  40210. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  40211. }
  40212. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40213. func (m *WxMutation) DeletedAtCleared() bool {
  40214. _, ok := m.clearedFields[wx.FieldDeletedAt]
  40215. return ok
  40216. }
  40217. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40218. func (m *WxMutation) ResetDeletedAt() {
  40219. m.deleted_at = nil
  40220. delete(m.clearedFields, wx.FieldDeletedAt)
  40221. }
  40222. // SetServerID sets the "server_id" field.
  40223. func (m *WxMutation) SetServerID(u uint64) {
  40224. m.server = &u
  40225. }
  40226. // ServerID returns the value of the "server_id" field in the mutation.
  40227. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  40228. v := m.server
  40229. if v == nil {
  40230. return
  40231. }
  40232. return *v, true
  40233. }
  40234. // OldServerID returns the old "server_id" field's value of the Wx entity.
  40235. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40237. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  40238. if !m.op.Is(OpUpdateOne) {
  40239. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  40240. }
  40241. if m.id == nil || m.oldValue == nil {
  40242. return v, errors.New("OldServerID requires an ID field in the mutation")
  40243. }
  40244. oldValue, err := m.oldValue(ctx)
  40245. if err != nil {
  40246. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  40247. }
  40248. return oldValue.ServerID, nil
  40249. }
  40250. // ClearServerID clears the value of the "server_id" field.
  40251. func (m *WxMutation) ClearServerID() {
  40252. m.server = nil
  40253. m.clearedFields[wx.FieldServerID] = struct{}{}
  40254. }
  40255. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  40256. func (m *WxMutation) ServerIDCleared() bool {
  40257. _, ok := m.clearedFields[wx.FieldServerID]
  40258. return ok
  40259. }
  40260. // ResetServerID resets all changes to the "server_id" field.
  40261. func (m *WxMutation) ResetServerID() {
  40262. m.server = nil
  40263. delete(m.clearedFields, wx.FieldServerID)
  40264. }
  40265. // SetPort sets the "port" field.
  40266. func (m *WxMutation) SetPort(s string) {
  40267. m.port = &s
  40268. }
  40269. // Port returns the value of the "port" field in the mutation.
  40270. func (m *WxMutation) Port() (r string, exists bool) {
  40271. v := m.port
  40272. if v == nil {
  40273. return
  40274. }
  40275. return *v, true
  40276. }
  40277. // OldPort returns the old "port" field's value of the Wx entity.
  40278. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40280. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  40281. if !m.op.Is(OpUpdateOne) {
  40282. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  40283. }
  40284. if m.id == nil || m.oldValue == nil {
  40285. return v, errors.New("OldPort requires an ID field in the mutation")
  40286. }
  40287. oldValue, err := m.oldValue(ctx)
  40288. if err != nil {
  40289. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  40290. }
  40291. return oldValue.Port, nil
  40292. }
  40293. // ResetPort resets all changes to the "port" field.
  40294. func (m *WxMutation) ResetPort() {
  40295. m.port = nil
  40296. }
  40297. // SetProcessID sets the "process_id" field.
  40298. func (m *WxMutation) SetProcessID(s string) {
  40299. m.process_id = &s
  40300. }
  40301. // ProcessID returns the value of the "process_id" field in the mutation.
  40302. func (m *WxMutation) ProcessID() (r string, exists bool) {
  40303. v := m.process_id
  40304. if v == nil {
  40305. return
  40306. }
  40307. return *v, true
  40308. }
  40309. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  40310. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40312. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  40313. if !m.op.Is(OpUpdateOne) {
  40314. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  40315. }
  40316. if m.id == nil || m.oldValue == nil {
  40317. return v, errors.New("OldProcessID requires an ID field in the mutation")
  40318. }
  40319. oldValue, err := m.oldValue(ctx)
  40320. if err != nil {
  40321. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  40322. }
  40323. return oldValue.ProcessID, nil
  40324. }
  40325. // ResetProcessID resets all changes to the "process_id" field.
  40326. func (m *WxMutation) ResetProcessID() {
  40327. m.process_id = nil
  40328. }
  40329. // SetCallback sets the "callback" field.
  40330. func (m *WxMutation) SetCallback(s string) {
  40331. m.callback = &s
  40332. }
  40333. // Callback returns the value of the "callback" field in the mutation.
  40334. func (m *WxMutation) Callback() (r string, exists bool) {
  40335. v := m.callback
  40336. if v == nil {
  40337. return
  40338. }
  40339. return *v, true
  40340. }
  40341. // OldCallback returns the old "callback" field's value of the Wx entity.
  40342. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40344. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  40345. if !m.op.Is(OpUpdateOne) {
  40346. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40347. }
  40348. if m.id == nil || m.oldValue == nil {
  40349. return v, errors.New("OldCallback requires an ID field in the mutation")
  40350. }
  40351. oldValue, err := m.oldValue(ctx)
  40352. if err != nil {
  40353. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40354. }
  40355. return oldValue.Callback, nil
  40356. }
  40357. // ResetCallback resets all changes to the "callback" field.
  40358. func (m *WxMutation) ResetCallback() {
  40359. m.callback = nil
  40360. }
  40361. // SetWxid sets the "wxid" field.
  40362. func (m *WxMutation) SetWxid(s string) {
  40363. m.wxid = &s
  40364. }
  40365. // Wxid returns the value of the "wxid" field in the mutation.
  40366. func (m *WxMutation) Wxid() (r string, exists bool) {
  40367. v := m.wxid
  40368. if v == nil {
  40369. return
  40370. }
  40371. return *v, true
  40372. }
  40373. // OldWxid returns the old "wxid" field's value of the Wx entity.
  40374. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40376. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  40377. if !m.op.Is(OpUpdateOne) {
  40378. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40379. }
  40380. if m.id == nil || m.oldValue == nil {
  40381. return v, errors.New("OldWxid requires an ID field in the mutation")
  40382. }
  40383. oldValue, err := m.oldValue(ctx)
  40384. if err != nil {
  40385. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40386. }
  40387. return oldValue.Wxid, nil
  40388. }
  40389. // ResetWxid resets all changes to the "wxid" field.
  40390. func (m *WxMutation) ResetWxid() {
  40391. m.wxid = nil
  40392. }
  40393. // SetAccount sets the "account" field.
  40394. func (m *WxMutation) SetAccount(s string) {
  40395. m.account = &s
  40396. }
  40397. // Account returns the value of the "account" field in the mutation.
  40398. func (m *WxMutation) Account() (r string, exists bool) {
  40399. v := m.account
  40400. if v == nil {
  40401. return
  40402. }
  40403. return *v, true
  40404. }
  40405. // OldAccount returns the old "account" field's value of the Wx entity.
  40406. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40408. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  40409. if !m.op.Is(OpUpdateOne) {
  40410. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40411. }
  40412. if m.id == nil || m.oldValue == nil {
  40413. return v, errors.New("OldAccount requires an ID field in the mutation")
  40414. }
  40415. oldValue, err := m.oldValue(ctx)
  40416. if err != nil {
  40417. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40418. }
  40419. return oldValue.Account, nil
  40420. }
  40421. // ResetAccount resets all changes to the "account" field.
  40422. func (m *WxMutation) ResetAccount() {
  40423. m.account = nil
  40424. }
  40425. // SetNickname sets the "nickname" field.
  40426. func (m *WxMutation) SetNickname(s string) {
  40427. m.nickname = &s
  40428. }
  40429. // Nickname returns the value of the "nickname" field in the mutation.
  40430. func (m *WxMutation) Nickname() (r string, exists bool) {
  40431. v := m.nickname
  40432. if v == nil {
  40433. return
  40434. }
  40435. return *v, true
  40436. }
  40437. // OldNickname returns the old "nickname" field's value of the Wx entity.
  40438. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40440. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  40441. if !m.op.Is(OpUpdateOne) {
  40442. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40443. }
  40444. if m.id == nil || m.oldValue == nil {
  40445. return v, errors.New("OldNickname requires an ID field in the mutation")
  40446. }
  40447. oldValue, err := m.oldValue(ctx)
  40448. if err != nil {
  40449. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40450. }
  40451. return oldValue.Nickname, nil
  40452. }
  40453. // ResetNickname resets all changes to the "nickname" field.
  40454. func (m *WxMutation) ResetNickname() {
  40455. m.nickname = nil
  40456. }
  40457. // SetTel sets the "tel" field.
  40458. func (m *WxMutation) SetTel(s string) {
  40459. m.tel = &s
  40460. }
  40461. // Tel returns the value of the "tel" field in the mutation.
  40462. func (m *WxMutation) Tel() (r string, exists bool) {
  40463. v := m.tel
  40464. if v == nil {
  40465. return
  40466. }
  40467. return *v, true
  40468. }
  40469. // OldTel returns the old "tel" field's value of the Wx entity.
  40470. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40472. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  40473. if !m.op.Is(OpUpdateOne) {
  40474. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  40475. }
  40476. if m.id == nil || m.oldValue == nil {
  40477. return v, errors.New("OldTel requires an ID field in the mutation")
  40478. }
  40479. oldValue, err := m.oldValue(ctx)
  40480. if err != nil {
  40481. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  40482. }
  40483. return oldValue.Tel, nil
  40484. }
  40485. // ResetTel resets all changes to the "tel" field.
  40486. func (m *WxMutation) ResetTel() {
  40487. m.tel = nil
  40488. }
  40489. // SetHeadBig sets the "head_big" field.
  40490. func (m *WxMutation) SetHeadBig(s string) {
  40491. m.head_big = &s
  40492. }
  40493. // HeadBig returns the value of the "head_big" field in the mutation.
  40494. func (m *WxMutation) HeadBig() (r string, exists bool) {
  40495. v := m.head_big
  40496. if v == nil {
  40497. return
  40498. }
  40499. return *v, true
  40500. }
  40501. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  40502. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40504. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  40505. if !m.op.Is(OpUpdateOne) {
  40506. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  40507. }
  40508. if m.id == nil || m.oldValue == nil {
  40509. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  40510. }
  40511. oldValue, err := m.oldValue(ctx)
  40512. if err != nil {
  40513. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  40514. }
  40515. return oldValue.HeadBig, nil
  40516. }
  40517. // ResetHeadBig resets all changes to the "head_big" field.
  40518. func (m *WxMutation) ResetHeadBig() {
  40519. m.head_big = nil
  40520. }
  40521. // SetOrganizationID sets the "organization_id" field.
  40522. func (m *WxMutation) SetOrganizationID(u uint64) {
  40523. m.organization_id = &u
  40524. m.addorganization_id = nil
  40525. }
  40526. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40527. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  40528. v := m.organization_id
  40529. if v == nil {
  40530. return
  40531. }
  40532. return *v, true
  40533. }
  40534. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  40535. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40537. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40538. if !m.op.Is(OpUpdateOne) {
  40539. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40540. }
  40541. if m.id == nil || m.oldValue == nil {
  40542. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40543. }
  40544. oldValue, err := m.oldValue(ctx)
  40545. if err != nil {
  40546. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40547. }
  40548. return oldValue.OrganizationID, nil
  40549. }
  40550. // AddOrganizationID adds u to the "organization_id" field.
  40551. func (m *WxMutation) AddOrganizationID(u int64) {
  40552. if m.addorganization_id != nil {
  40553. *m.addorganization_id += u
  40554. } else {
  40555. m.addorganization_id = &u
  40556. }
  40557. }
  40558. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40559. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  40560. v := m.addorganization_id
  40561. if v == nil {
  40562. return
  40563. }
  40564. return *v, true
  40565. }
  40566. // ClearOrganizationID clears the value of the "organization_id" field.
  40567. func (m *WxMutation) ClearOrganizationID() {
  40568. m.organization_id = nil
  40569. m.addorganization_id = nil
  40570. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  40571. }
  40572. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40573. func (m *WxMutation) OrganizationIDCleared() bool {
  40574. _, ok := m.clearedFields[wx.FieldOrganizationID]
  40575. return ok
  40576. }
  40577. // ResetOrganizationID resets all changes to the "organization_id" field.
  40578. func (m *WxMutation) ResetOrganizationID() {
  40579. m.organization_id = nil
  40580. m.addorganization_id = nil
  40581. delete(m.clearedFields, wx.FieldOrganizationID)
  40582. }
  40583. // SetAgentID sets the "agent_id" field.
  40584. func (m *WxMutation) SetAgentID(u uint64) {
  40585. m.agent = &u
  40586. }
  40587. // AgentID returns the value of the "agent_id" field in the mutation.
  40588. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  40589. v := m.agent
  40590. if v == nil {
  40591. return
  40592. }
  40593. return *v, true
  40594. }
  40595. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  40596. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40598. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40599. if !m.op.Is(OpUpdateOne) {
  40600. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40601. }
  40602. if m.id == nil || m.oldValue == nil {
  40603. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40604. }
  40605. oldValue, err := m.oldValue(ctx)
  40606. if err != nil {
  40607. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40608. }
  40609. return oldValue.AgentID, nil
  40610. }
  40611. // ResetAgentID resets all changes to the "agent_id" field.
  40612. func (m *WxMutation) ResetAgentID() {
  40613. m.agent = nil
  40614. }
  40615. // SetAPIBase sets the "api_base" field.
  40616. func (m *WxMutation) SetAPIBase(s string) {
  40617. m.api_base = &s
  40618. }
  40619. // APIBase returns the value of the "api_base" field in the mutation.
  40620. func (m *WxMutation) APIBase() (r string, exists bool) {
  40621. v := m.api_base
  40622. if v == nil {
  40623. return
  40624. }
  40625. return *v, true
  40626. }
  40627. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  40628. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40630. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40631. if !m.op.Is(OpUpdateOne) {
  40632. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40633. }
  40634. if m.id == nil || m.oldValue == nil {
  40635. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40636. }
  40637. oldValue, err := m.oldValue(ctx)
  40638. if err != nil {
  40639. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40640. }
  40641. return oldValue.APIBase, nil
  40642. }
  40643. // ClearAPIBase clears the value of the "api_base" field.
  40644. func (m *WxMutation) ClearAPIBase() {
  40645. m.api_base = nil
  40646. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  40647. }
  40648. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40649. func (m *WxMutation) APIBaseCleared() bool {
  40650. _, ok := m.clearedFields[wx.FieldAPIBase]
  40651. return ok
  40652. }
  40653. // ResetAPIBase resets all changes to the "api_base" field.
  40654. func (m *WxMutation) ResetAPIBase() {
  40655. m.api_base = nil
  40656. delete(m.clearedFields, wx.FieldAPIBase)
  40657. }
  40658. // SetAPIKey sets the "api_key" field.
  40659. func (m *WxMutation) SetAPIKey(s string) {
  40660. m.api_key = &s
  40661. }
  40662. // APIKey returns the value of the "api_key" field in the mutation.
  40663. func (m *WxMutation) APIKey() (r string, exists bool) {
  40664. v := m.api_key
  40665. if v == nil {
  40666. return
  40667. }
  40668. return *v, true
  40669. }
  40670. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  40671. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40673. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40674. if !m.op.Is(OpUpdateOne) {
  40675. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40676. }
  40677. if m.id == nil || m.oldValue == nil {
  40678. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40679. }
  40680. oldValue, err := m.oldValue(ctx)
  40681. if err != nil {
  40682. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40683. }
  40684. return oldValue.APIKey, nil
  40685. }
  40686. // ClearAPIKey clears the value of the "api_key" field.
  40687. func (m *WxMutation) ClearAPIKey() {
  40688. m.api_key = nil
  40689. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  40690. }
  40691. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40692. func (m *WxMutation) APIKeyCleared() bool {
  40693. _, ok := m.clearedFields[wx.FieldAPIKey]
  40694. return ok
  40695. }
  40696. // ResetAPIKey resets all changes to the "api_key" field.
  40697. func (m *WxMutation) ResetAPIKey() {
  40698. m.api_key = nil
  40699. delete(m.clearedFields, wx.FieldAPIKey)
  40700. }
  40701. // SetAllowList sets the "allow_list" field.
  40702. func (m *WxMutation) SetAllowList(s []string) {
  40703. m.allow_list = &s
  40704. m.appendallow_list = nil
  40705. }
  40706. // AllowList returns the value of the "allow_list" field in the mutation.
  40707. func (m *WxMutation) AllowList() (r []string, exists bool) {
  40708. v := m.allow_list
  40709. if v == nil {
  40710. return
  40711. }
  40712. return *v, true
  40713. }
  40714. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  40715. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40717. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40718. if !m.op.Is(OpUpdateOne) {
  40719. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40720. }
  40721. if m.id == nil || m.oldValue == nil {
  40722. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40723. }
  40724. oldValue, err := m.oldValue(ctx)
  40725. if err != nil {
  40726. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40727. }
  40728. return oldValue.AllowList, nil
  40729. }
  40730. // AppendAllowList adds s to the "allow_list" field.
  40731. func (m *WxMutation) AppendAllowList(s []string) {
  40732. m.appendallow_list = append(m.appendallow_list, s...)
  40733. }
  40734. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40735. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  40736. if len(m.appendallow_list) == 0 {
  40737. return nil, false
  40738. }
  40739. return m.appendallow_list, true
  40740. }
  40741. // ResetAllowList resets all changes to the "allow_list" field.
  40742. func (m *WxMutation) ResetAllowList() {
  40743. m.allow_list = nil
  40744. m.appendallow_list = nil
  40745. }
  40746. // SetGroupAllowList sets the "group_allow_list" field.
  40747. func (m *WxMutation) SetGroupAllowList(s []string) {
  40748. m.group_allow_list = &s
  40749. m.appendgroup_allow_list = nil
  40750. }
  40751. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40752. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  40753. v := m.group_allow_list
  40754. if v == nil {
  40755. return
  40756. }
  40757. return *v, true
  40758. }
  40759. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  40760. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40762. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40763. if !m.op.Is(OpUpdateOne) {
  40764. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40765. }
  40766. if m.id == nil || m.oldValue == nil {
  40767. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40768. }
  40769. oldValue, err := m.oldValue(ctx)
  40770. if err != nil {
  40771. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40772. }
  40773. return oldValue.GroupAllowList, nil
  40774. }
  40775. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40776. func (m *WxMutation) AppendGroupAllowList(s []string) {
  40777. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40778. }
  40779. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40780. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  40781. if len(m.appendgroup_allow_list) == 0 {
  40782. return nil, false
  40783. }
  40784. return m.appendgroup_allow_list, true
  40785. }
  40786. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40787. func (m *WxMutation) ResetGroupAllowList() {
  40788. m.group_allow_list = nil
  40789. m.appendgroup_allow_list = nil
  40790. }
  40791. // SetBlockList sets the "block_list" field.
  40792. func (m *WxMutation) SetBlockList(s []string) {
  40793. m.block_list = &s
  40794. m.appendblock_list = nil
  40795. }
  40796. // BlockList returns the value of the "block_list" field in the mutation.
  40797. func (m *WxMutation) BlockList() (r []string, exists bool) {
  40798. v := m.block_list
  40799. if v == nil {
  40800. return
  40801. }
  40802. return *v, true
  40803. }
  40804. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  40805. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40807. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40808. if !m.op.Is(OpUpdateOne) {
  40809. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40810. }
  40811. if m.id == nil || m.oldValue == nil {
  40812. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40813. }
  40814. oldValue, err := m.oldValue(ctx)
  40815. if err != nil {
  40816. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40817. }
  40818. return oldValue.BlockList, nil
  40819. }
  40820. // AppendBlockList adds s to the "block_list" field.
  40821. func (m *WxMutation) AppendBlockList(s []string) {
  40822. m.appendblock_list = append(m.appendblock_list, s...)
  40823. }
  40824. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40825. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  40826. if len(m.appendblock_list) == 0 {
  40827. return nil, false
  40828. }
  40829. return m.appendblock_list, true
  40830. }
  40831. // ResetBlockList resets all changes to the "block_list" field.
  40832. func (m *WxMutation) ResetBlockList() {
  40833. m.block_list = nil
  40834. m.appendblock_list = nil
  40835. }
  40836. // SetGroupBlockList sets the "group_block_list" field.
  40837. func (m *WxMutation) SetGroupBlockList(s []string) {
  40838. m.group_block_list = &s
  40839. m.appendgroup_block_list = nil
  40840. }
  40841. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40842. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  40843. v := m.group_block_list
  40844. if v == nil {
  40845. return
  40846. }
  40847. return *v, true
  40848. }
  40849. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  40850. // If the Wx 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 *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40853. if !m.op.Is(OpUpdateOne) {
  40854. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40855. }
  40856. if m.id == nil || m.oldValue == nil {
  40857. return v, errors.New("OldGroupBlockList 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 OldGroupBlockList: %w", err)
  40862. }
  40863. return oldValue.GroupBlockList, nil
  40864. }
  40865. // AppendGroupBlockList adds s to the "group_block_list" field.
  40866. func (m *WxMutation) AppendGroupBlockList(s []string) {
  40867. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40868. }
  40869. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40870. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  40871. if len(m.appendgroup_block_list) == 0 {
  40872. return nil, false
  40873. }
  40874. return m.appendgroup_block_list, true
  40875. }
  40876. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40877. func (m *WxMutation) ResetGroupBlockList() {
  40878. m.group_block_list = nil
  40879. m.appendgroup_block_list = nil
  40880. }
  40881. // SetCtype sets the "ctype" field.
  40882. func (m *WxMutation) SetCtype(u uint64) {
  40883. m.ctype = &u
  40884. m.addctype = nil
  40885. }
  40886. // Ctype returns the value of the "ctype" field in the mutation.
  40887. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  40888. v := m.ctype
  40889. if v == nil {
  40890. return
  40891. }
  40892. return *v, true
  40893. }
  40894. // OldCtype returns the old "ctype" field's value of the Wx entity.
  40895. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40897. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  40898. if !m.op.Is(OpUpdateOne) {
  40899. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  40900. }
  40901. if m.id == nil || m.oldValue == nil {
  40902. return v, errors.New("OldCtype requires an ID field in the mutation")
  40903. }
  40904. oldValue, err := m.oldValue(ctx)
  40905. if err != nil {
  40906. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  40907. }
  40908. return oldValue.Ctype, nil
  40909. }
  40910. // AddCtype adds u to the "ctype" field.
  40911. func (m *WxMutation) AddCtype(u int64) {
  40912. if m.addctype != nil {
  40913. *m.addctype += u
  40914. } else {
  40915. m.addctype = &u
  40916. }
  40917. }
  40918. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  40919. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  40920. v := m.addctype
  40921. if v == nil {
  40922. return
  40923. }
  40924. return *v, true
  40925. }
  40926. // ClearCtype clears the value of the "ctype" field.
  40927. func (m *WxMutation) ClearCtype() {
  40928. m.ctype = nil
  40929. m.addctype = nil
  40930. m.clearedFields[wx.FieldCtype] = struct{}{}
  40931. }
  40932. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  40933. func (m *WxMutation) CtypeCleared() bool {
  40934. _, ok := m.clearedFields[wx.FieldCtype]
  40935. return ok
  40936. }
  40937. // ResetCtype resets all changes to the "ctype" field.
  40938. func (m *WxMutation) ResetCtype() {
  40939. m.ctype = nil
  40940. m.addctype = nil
  40941. delete(m.clearedFields, wx.FieldCtype)
  40942. }
  40943. // ClearServer clears the "server" edge to the Server entity.
  40944. func (m *WxMutation) ClearServer() {
  40945. m.clearedserver = true
  40946. m.clearedFields[wx.FieldServerID] = struct{}{}
  40947. }
  40948. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  40949. func (m *WxMutation) ServerCleared() bool {
  40950. return m.ServerIDCleared() || m.clearedserver
  40951. }
  40952. // ServerIDs returns the "server" edge IDs in the mutation.
  40953. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40954. // ServerID instead. It exists only for internal usage by the builders.
  40955. func (m *WxMutation) ServerIDs() (ids []uint64) {
  40956. if id := m.server; id != nil {
  40957. ids = append(ids, *id)
  40958. }
  40959. return
  40960. }
  40961. // ResetServer resets all changes to the "server" edge.
  40962. func (m *WxMutation) ResetServer() {
  40963. m.server = nil
  40964. m.clearedserver = false
  40965. }
  40966. // ClearAgent clears the "agent" edge to the Agent entity.
  40967. func (m *WxMutation) ClearAgent() {
  40968. m.clearedagent = true
  40969. m.clearedFields[wx.FieldAgentID] = struct{}{}
  40970. }
  40971. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40972. func (m *WxMutation) AgentCleared() bool {
  40973. return m.clearedagent
  40974. }
  40975. // AgentIDs returns the "agent" edge IDs in the mutation.
  40976. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40977. // AgentID instead. It exists only for internal usage by the builders.
  40978. func (m *WxMutation) AgentIDs() (ids []uint64) {
  40979. if id := m.agent; id != nil {
  40980. ids = append(ids, *id)
  40981. }
  40982. return
  40983. }
  40984. // ResetAgent resets all changes to the "agent" edge.
  40985. func (m *WxMutation) ResetAgent() {
  40986. m.agent = nil
  40987. m.clearedagent = false
  40988. }
  40989. // Where appends a list predicates to the WxMutation builder.
  40990. func (m *WxMutation) Where(ps ...predicate.Wx) {
  40991. m.predicates = append(m.predicates, ps...)
  40992. }
  40993. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  40994. // users can use type-assertion to append predicates that do not depend on any generated package.
  40995. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  40996. p := make([]predicate.Wx, len(ps))
  40997. for i := range ps {
  40998. p[i] = ps[i]
  40999. }
  41000. m.Where(p...)
  41001. }
  41002. // Op returns the operation name.
  41003. func (m *WxMutation) Op() Op {
  41004. return m.op
  41005. }
  41006. // SetOp allows setting the mutation operation.
  41007. func (m *WxMutation) SetOp(op Op) {
  41008. m.op = op
  41009. }
  41010. // Type returns the node type of this mutation (Wx).
  41011. func (m *WxMutation) Type() string {
  41012. return m.typ
  41013. }
  41014. // Fields returns all fields that were changed during this mutation. Note that in
  41015. // order to get all numeric fields that were incremented/decremented, call
  41016. // AddedFields().
  41017. func (m *WxMutation) Fields() []string {
  41018. fields := make([]string, 0, 22)
  41019. if m.created_at != nil {
  41020. fields = append(fields, wx.FieldCreatedAt)
  41021. }
  41022. if m.updated_at != nil {
  41023. fields = append(fields, wx.FieldUpdatedAt)
  41024. }
  41025. if m.status != nil {
  41026. fields = append(fields, wx.FieldStatus)
  41027. }
  41028. if m.deleted_at != nil {
  41029. fields = append(fields, wx.FieldDeletedAt)
  41030. }
  41031. if m.server != nil {
  41032. fields = append(fields, wx.FieldServerID)
  41033. }
  41034. if m.port != nil {
  41035. fields = append(fields, wx.FieldPort)
  41036. }
  41037. if m.process_id != nil {
  41038. fields = append(fields, wx.FieldProcessID)
  41039. }
  41040. if m.callback != nil {
  41041. fields = append(fields, wx.FieldCallback)
  41042. }
  41043. if m.wxid != nil {
  41044. fields = append(fields, wx.FieldWxid)
  41045. }
  41046. if m.account != nil {
  41047. fields = append(fields, wx.FieldAccount)
  41048. }
  41049. if m.nickname != nil {
  41050. fields = append(fields, wx.FieldNickname)
  41051. }
  41052. if m.tel != nil {
  41053. fields = append(fields, wx.FieldTel)
  41054. }
  41055. if m.head_big != nil {
  41056. fields = append(fields, wx.FieldHeadBig)
  41057. }
  41058. if m.organization_id != nil {
  41059. fields = append(fields, wx.FieldOrganizationID)
  41060. }
  41061. if m.agent != nil {
  41062. fields = append(fields, wx.FieldAgentID)
  41063. }
  41064. if m.api_base != nil {
  41065. fields = append(fields, wx.FieldAPIBase)
  41066. }
  41067. if m.api_key != nil {
  41068. fields = append(fields, wx.FieldAPIKey)
  41069. }
  41070. if m.allow_list != nil {
  41071. fields = append(fields, wx.FieldAllowList)
  41072. }
  41073. if m.group_allow_list != nil {
  41074. fields = append(fields, wx.FieldGroupAllowList)
  41075. }
  41076. if m.block_list != nil {
  41077. fields = append(fields, wx.FieldBlockList)
  41078. }
  41079. if m.group_block_list != nil {
  41080. fields = append(fields, wx.FieldGroupBlockList)
  41081. }
  41082. if m.ctype != nil {
  41083. fields = append(fields, wx.FieldCtype)
  41084. }
  41085. return fields
  41086. }
  41087. // Field returns the value of a field with the given name. The second boolean
  41088. // return value indicates that this field was not set, or was not defined in the
  41089. // schema.
  41090. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  41091. switch name {
  41092. case wx.FieldCreatedAt:
  41093. return m.CreatedAt()
  41094. case wx.FieldUpdatedAt:
  41095. return m.UpdatedAt()
  41096. case wx.FieldStatus:
  41097. return m.Status()
  41098. case wx.FieldDeletedAt:
  41099. return m.DeletedAt()
  41100. case wx.FieldServerID:
  41101. return m.ServerID()
  41102. case wx.FieldPort:
  41103. return m.Port()
  41104. case wx.FieldProcessID:
  41105. return m.ProcessID()
  41106. case wx.FieldCallback:
  41107. return m.Callback()
  41108. case wx.FieldWxid:
  41109. return m.Wxid()
  41110. case wx.FieldAccount:
  41111. return m.Account()
  41112. case wx.FieldNickname:
  41113. return m.Nickname()
  41114. case wx.FieldTel:
  41115. return m.Tel()
  41116. case wx.FieldHeadBig:
  41117. return m.HeadBig()
  41118. case wx.FieldOrganizationID:
  41119. return m.OrganizationID()
  41120. case wx.FieldAgentID:
  41121. return m.AgentID()
  41122. case wx.FieldAPIBase:
  41123. return m.APIBase()
  41124. case wx.FieldAPIKey:
  41125. return m.APIKey()
  41126. case wx.FieldAllowList:
  41127. return m.AllowList()
  41128. case wx.FieldGroupAllowList:
  41129. return m.GroupAllowList()
  41130. case wx.FieldBlockList:
  41131. return m.BlockList()
  41132. case wx.FieldGroupBlockList:
  41133. return m.GroupBlockList()
  41134. case wx.FieldCtype:
  41135. return m.Ctype()
  41136. }
  41137. return nil, false
  41138. }
  41139. // OldField returns the old value of the field from the database. An error is
  41140. // returned if the mutation operation is not UpdateOne, or the query to the
  41141. // database failed.
  41142. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41143. switch name {
  41144. case wx.FieldCreatedAt:
  41145. return m.OldCreatedAt(ctx)
  41146. case wx.FieldUpdatedAt:
  41147. return m.OldUpdatedAt(ctx)
  41148. case wx.FieldStatus:
  41149. return m.OldStatus(ctx)
  41150. case wx.FieldDeletedAt:
  41151. return m.OldDeletedAt(ctx)
  41152. case wx.FieldServerID:
  41153. return m.OldServerID(ctx)
  41154. case wx.FieldPort:
  41155. return m.OldPort(ctx)
  41156. case wx.FieldProcessID:
  41157. return m.OldProcessID(ctx)
  41158. case wx.FieldCallback:
  41159. return m.OldCallback(ctx)
  41160. case wx.FieldWxid:
  41161. return m.OldWxid(ctx)
  41162. case wx.FieldAccount:
  41163. return m.OldAccount(ctx)
  41164. case wx.FieldNickname:
  41165. return m.OldNickname(ctx)
  41166. case wx.FieldTel:
  41167. return m.OldTel(ctx)
  41168. case wx.FieldHeadBig:
  41169. return m.OldHeadBig(ctx)
  41170. case wx.FieldOrganizationID:
  41171. return m.OldOrganizationID(ctx)
  41172. case wx.FieldAgentID:
  41173. return m.OldAgentID(ctx)
  41174. case wx.FieldAPIBase:
  41175. return m.OldAPIBase(ctx)
  41176. case wx.FieldAPIKey:
  41177. return m.OldAPIKey(ctx)
  41178. case wx.FieldAllowList:
  41179. return m.OldAllowList(ctx)
  41180. case wx.FieldGroupAllowList:
  41181. return m.OldGroupAllowList(ctx)
  41182. case wx.FieldBlockList:
  41183. return m.OldBlockList(ctx)
  41184. case wx.FieldGroupBlockList:
  41185. return m.OldGroupBlockList(ctx)
  41186. case wx.FieldCtype:
  41187. return m.OldCtype(ctx)
  41188. }
  41189. return nil, fmt.Errorf("unknown Wx field %s", name)
  41190. }
  41191. // SetField sets the value of a field with the given name. It returns an error if
  41192. // the field is not defined in the schema, or if the type mismatched the field
  41193. // type.
  41194. func (m *WxMutation) SetField(name string, value ent.Value) error {
  41195. switch name {
  41196. case wx.FieldCreatedAt:
  41197. v, ok := value.(time.Time)
  41198. if !ok {
  41199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41200. }
  41201. m.SetCreatedAt(v)
  41202. return nil
  41203. case wx.FieldUpdatedAt:
  41204. v, ok := value.(time.Time)
  41205. if !ok {
  41206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41207. }
  41208. m.SetUpdatedAt(v)
  41209. return nil
  41210. case wx.FieldStatus:
  41211. v, ok := value.(uint8)
  41212. if !ok {
  41213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41214. }
  41215. m.SetStatus(v)
  41216. return nil
  41217. case wx.FieldDeletedAt:
  41218. v, ok := value.(time.Time)
  41219. if !ok {
  41220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41221. }
  41222. m.SetDeletedAt(v)
  41223. return nil
  41224. case wx.FieldServerID:
  41225. v, ok := value.(uint64)
  41226. if !ok {
  41227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41228. }
  41229. m.SetServerID(v)
  41230. return nil
  41231. case wx.FieldPort:
  41232. v, ok := value.(string)
  41233. if !ok {
  41234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41235. }
  41236. m.SetPort(v)
  41237. return nil
  41238. case wx.FieldProcessID:
  41239. v, ok := value.(string)
  41240. if !ok {
  41241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41242. }
  41243. m.SetProcessID(v)
  41244. return nil
  41245. case wx.FieldCallback:
  41246. v, ok := value.(string)
  41247. if !ok {
  41248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41249. }
  41250. m.SetCallback(v)
  41251. return nil
  41252. case wx.FieldWxid:
  41253. v, ok := value.(string)
  41254. if !ok {
  41255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41256. }
  41257. m.SetWxid(v)
  41258. return nil
  41259. case wx.FieldAccount:
  41260. v, ok := value.(string)
  41261. if !ok {
  41262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41263. }
  41264. m.SetAccount(v)
  41265. return nil
  41266. case wx.FieldNickname:
  41267. v, ok := value.(string)
  41268. if !ok {
  41269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41270. }
  41271. m.SetNickname(v)
  41272. return nil
  41273. case wx.FieldTel:
  41274. v, ok := value.(string)
  41275. if !ok {
  41276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41277. }
  41278. m.SetTel(v)
  41279. return nil
  41280. case wx.FieldHeadBig:
  41281. v, ok := value.(string)
  41282. if !ok {
  41283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41284. }
  41285. m.SetHeadBig(v)
  41286. return nil
  41287. case wx.FieldOrganizationID:
  41288. v, ok := value.(uint64)
  41289. if !ok {
  41290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41291. }
  41292. m.SetOrganizationID(v)
  41293. return nil
  41294. case wx.FieldAgentID:
  41295. v, ok := value.(uint64)
  41296. if !ok {
  41297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41298. }
  41299. m.SetAgentID(v)
  41300. return nil
  41301. case wx.FieldAPIBase:
  41302. v, ok := value.(string)
  41303. if !ok {
  41304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41305. }
  41306. m.SetAPIBase(v)
  41307. return nil
  41308. case wx.FieldAPIKey:
  41309. v, ok := value.(string)
  41310. if !ok {
  41311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41312. }
  41313. m.SetAPIKey(v)
  41314. return nil
  41315. case wx.FieldAllowList:
  41316. v, ok := value.([]string)
  41317. if !ok {
  41318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41319. }
  41320. m.SetAllowList(v)
  41321. return nil
  41322. case wx.FieldGroupAllowList:
  41323. v, ok := value.([]string)
  41324. if !ok {
  41325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41326. }
  41327. m.SetGroupAllowList(v)
  41328. return nil
  41329. case wx.FieldBlockList:
  41330. v, ok := value.([]string)
  41331. if !ok {
  41332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41333. }
  41334. m.SetBlockList(v)
  41335. return nil
  41336. case wx.FieldGroupBlockList:
  41337. v, ok := value.([]string)
  41338. if !ok {
  41339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41340. }
  41341. m.SetGroupBlockList(v)
  41342. return nil
  41343. case wx.FieldCtype:
  41344. v, ok := value.(uint64)
  41345. if !ok {
  41346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41347. }
  41348. m.SetCtype(v)
  41349. return nil
  41350. }
  41351. return fmt.Errorf("unknown Wx field %s", name)
  41352. }
  41353. // AddedFields returns all numeric fields that were incremented/decremented during
  41354. // this mutation.
  41355. func (m *WxMutation) AddedFields() []string {
  41356. var fields []string
  41357. if m.addstatus != nil {
  41358. fields = append(fields, wx.FieldStatus)
  41359. }
  41360. if m.addorganization_id != nil {
  41361. fields = append(fields, wx.FieldOrganizationID)
  41362. }
  41363. if m.addctype != nil {
  41364. fields = append(fields, wx.FieldCtype)
  41365. }
  41366. return fields
  41367. }
  41368. // AddedField returns the numeric value that was incremented/decremented on a field
  41369. // with the given name. The second boolean return value indicates that this field
  41370. // was not set, or was not defined in the schema.
  41371. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  41372. switch name {
  41373. case wx.FieldStatus:
  41374. return m.AddedStatus()
  41375. case wx.FieldOrganizationID:
  41376. return m.AddedOrganizationID()
  41377. case wx.FieldCtype:
  41378. return m.AddedCtype()
  41379. }
  41380. return nil, false
  41381. }
  41382. // AddField adds the value to the field with the given name. It returns an error if
  41383. // the field is not defined in the schema, or if the type mismatched the field
  41384. // type.
  41385. func (m *WxMutation) AddField(name string, value ent.Value) error {
  41386. switch name {
  41387. case wx.FieldStatus:
  41388. v, ok := value.(int8)
  41389. if !ok {
  41390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41391. }
  41392. m.AddStatus(v)
  41393. return nil
  41394. case wx.FieldOrganizationID:
  41395. v, ok := value.(int64)
  41396. if !ok {
  41397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41398. }
  41399. m.AddOrganizationID(v)
  41400. return nil
  41401. case wx.FieldCtype:
  41402. v, ok := value.(int64)
  41403. if !ok {
  41404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41405. }
  41406. m.AddCtype(v)
  41407. return nil
  41408. }
  41409. return fmt.Errorf("unknown Wx numeric field %s", name)
  41410. }
  41411. // ClearedFields returns all nullable fields that were cleared during this
  41412. // mutation.
  41413. func (m *WxMutation) ClearedFields() []string {
  41414. var fields []string
  41415. if m.FieldCleared(wx.FieldStatus) {
  41416. fields = append(fields, wx.FieldStatus)
  41417. }
  41418. if m.FieldCleared(wx.FieldDeletedAt) {
  41419. fields = append(fields, wx.FieldDeletedAt)
  41420. }
  41421. if m.FieldCleared(wx.FieldServerID) {
  41422. fields = append(fields, wx.FieldServerID)
  41423. }
  41424. if m.FieldCleared(wx.FieldOrganizationID) {
  41425. fields = append(fields, wx.FieldOrganizationID)
  41426. }
  41427. if m.FieldCleared(wx.FieldAPIBase) {
  41428. fields = append(fields, wx.FieldAPIBase)
  41429. }
  41430. if m.FieldCleared(wx.FieldAPIKey) {
  41431. fields = append(fields, wx.FieldAPIKey)
  41432. }
  41433. if m.FieldCleared(wx.FieldCtype) {
  41434. fields = append(fields, wx.FieldCtype)
  41435. }
  41436. return fields
  41437. }
  41438. // FieldCleared returns a boolean indicating if a field with the given name was
  41439. // cleared in this mutation.
  41440. func (m *WxMutation) FieldCleared(name string) bool {
  41441. _, ok := m.clearedFields[name]
  41442. return ok
  41443. }
  41444. // ClearField clears the value of the field with the given name. It returns an
  41445. // error if the field is not defined in the schema.
  41446. func (m *WxMutation) ClearField(name string) error {
  41447. switch name {
  41448. case wx.FieldStatus:
  41449. m.ClearStatus()
  41450. return nil
  41451. case wx.FieldDeletedAt:
  41452. m.ClearDeletedAt()
  41453. return nil
  41454. case wx.FieldServerID:
  41455. m.ClearServerID()
  41456. return nil
  41457. case wx.FieldOrganizationID:
  41458. m.ClearOrganizationID()
  41459. return nil
  41460. case wx.FieldAPIBase:
  41461. m.ClearAPIBase()
  41462. return nil
  41463. case wx.FieldAPIKey:
  41464. m.ClearAPIKey()
  41465. return nil
  41466. case wx.FieldCtype:
  41467. m.ClearCtype()
  41468. return nil
  41469. }
  41470. return fmt.Errorf("unknown Wx nullable field %s", name)
  41471. }
  41472. // ResetField resets all changes in the mutation for the field with the given name.
  41473. // It returns an error if the field is not defined in the schema.
  41474. func (m *WxMutation) ResetField(name string) error {
  41475. switch name {
  41476. case wx.FieldCreatedAt:
  41477. m.ResetCreatedAt()
  41478. return nil
  41479. case wx.FieldUpdatedAt:
  41480. m.ResetUpdatedAt()
  41481. return nil
  41482. case wx.FieldStatus:
  41483. m.ResetStatus()
  41484. return nil
  41485. case wx.FieldDeletedAt:
  41486. m.ResetDeletedAt()
  41487. return nil
  41488. case wx.FieldServerID:
  41489. m.ResetServerID()
  41490. return nil
  41491. case wx.FieldPort:
  41492. m.ResetPort()
  41493. return nil
  41494. case wx.FieldProcessID:
  41495. m.ResetProcessID()
  41496. return nil
  41497. case wx.FieldCallback:
  41498. m.ResetCallback()
  41499. return nil
  41500. case wx.FieldWxid:
  41501. m.ResetWxid()
  41502. return nil
  41503. case wx.FieldAccount:
  41504. m.ResetAccount()
  41505. return nil
  41506. case wx.FieldNickname:
  41507. m.ResetNickname()
  41508. return nil
  41509. case wx.FieldTel:
  41510. m.ResetTel()
  41511. return nil
  41512. case wx.FieldHeadBig:
  41513. m.ResetHeadBig()
  41514. return nil
  41515. case wx.FieldOrganizationID:
  41516. m.ResetOrganizationID()
  41517. return nil
  41518. case wx.FieldAgentID:
  41519. m.ResetAgentID()
  41520. return nil
  41521. case wx.FieldAPIBase:
  41522. m.ResetAPIBase()
  41523. return nil
  41524. case wx.FieldAPIKey:
  41525. m.ResetAPIKey()
  41526. return nil
  41527. case wx.FieldAllowList:
  41528. m.ResetAllowList()
  41529. return nil
  41530. case wx.FieldGroupAllowList:
  41531. m.ResetGroupAllowList()
  41532. return nil
  41533. case wx.FieldBlockList:
  41534. m.ResetBlockList()
  41535. return nil
  41536. case wx.FieldGroupBlockList:
  41537. m.ResetGroupBlockList()
  41538. return nil
  41539. case wx.FieldCtype:
  41540. m.ResetCtype()
  41541. return nil
  41542. }
  41543. return fmt.Errorf("unknown Wx field %s", name)
  41544. }
  41545. // AddedEdges returns all edge names that were set/added in this mutation.
  41546. func (m *WxMutation) AddedEdges() []string {
  41547. edges := make([]string, 0, 2)
  41548. if m.server != nil {
  41549. edges = append(edges, wx.EdgeServer)
  41550. }
  41551. if m.agent != nil {
  41552. edges = append(edges, wx.EdgeAgent)
  41553. }
  41554. return edges
  41555. }
  41556. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41557. // name in this mutation.
  41558. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  41559. switch name {
  41560. case wx.EdgeServer:
  41561. if id := m.server; id != nil {
  41562. return []ent.Value{*id}
  41563. }
  41564. case wx.EdgeAgent:
  41565. if id := m.agent; id != nil {
  41566. return []ent.Value{*id}
  41567. }
  41568. }
  41569. return nil
  41570. }
  41571. // RemovedEdges returns all edge names that were removed in this mutation.
  41572. func (m *WxMutation) RemovedEdges() []string {
  41573. edges := make([]string, 0, 2)
  41574. return edges
  41575. }
  41576. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41577. // the given name in this mutation.
  41578. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  41579. return nil
  41580. }
  41581. // ClearedEdges returns all edge names that were cleared in this mutation.
  41582. func (m *WxMutation) ClearedEdges() []string {
  41583. edges := make([]string, 0, 2)
  41584. if m.clearedserver {
  41585. edges = append(edges, wx.EdgeServer)
  41586. }
  41587. if m.clearedagent {
  41588. edges = append(edges, wx.EdgeAgent)
  41589. }
  41590. return edges
  41591. }
  41592. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41593. // was cleared in this mutation.
  41594. func (m *WxMutation) EdgeCleared(name string) bool {
  41595. switch name {
  41596. case wx.EdgeServer:
  41597. return m.clearedserver
  41598. case wx.EdgeAgent:
  41599. return m.clearedagent
  41600. }
  41601. return false
  41602. }
  41603. // ClearEdge clears the value of the edge with the given name. It returns an error
  41604. // if that edge is not defined in the schema.
  41605. func (m *WxMutation) ClearEdge(name string) error {
  41606. switch name {
  41607. case wx.EdgeServer:
  41608. m.ClearServer()
  41609. return nil
  41610. case wx.EdgeAgent:
  41611. m.ClearAgent()
  41612. return nil
  41613. }
  41614. return fmt.Errorf("unknown Wx unique edge %s", name)
  41615. }
  41616. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41617. // It returns an error if the edge is not defined in the schema.
  41618. func (m *WxMutation) ResetEdge(name string) error {
  41619. switch name {
  41620. case wx.EdgeServer:
  41621. m.ResetServer()
  41622. return nil
  41623. case wx.EdgeAgent:
  41624. m.ResetAgent()
  41625. return nil
  41626. }
  41627. return fmt.Errorf("unknown Wx edge %s", name)
  41628. }
  41629. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  41630. type WxCardMutation struct {
  41631. config
  41632. op Op
  41633. typ string
  41634. id *uint64
  41635. created_at *time.Time
  41636. updated_at *time.Time
  41637. deleted_at *time.Time
  41638. user_id *uint64
  41639. adduser_id *int64
  41640. wx_user_id *uint64
  41641. addwx_user_id *int64
  41642. avatar *string
  41643. logo *string
  41644. name *string
  41645. company *string
  41646. address *string
  41647. phone *string
  41648. official_account *string
  41649. wechat_account *string
  41650. email *string
  41651. api_base *string
  41652. api_key *string
  41653. ai_info *string
  41654. intro *string
  41655. clearedFields map[string]struct{}
  41656. done bool
  41657. oldValue func(context.Context) (*WxCard, error)
  41658. predicates []predicate.WxCard
  41659. }
  41660. var _ ent.Mutation = (*WxCardMutation)(nil)
  41661. // wxcardOption allows management of the mutation configuration using functional options.
  41662. type wxcardOption func(*WxCardMutation)
  41663. // newWxCardMutation creates new mutation for the WxCard entity.
  41664. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  41665. m := &WxCardMutation{
  41666. config: c,
  41667. op: op,
  41668. typ: TypeWxCard,
  41669. clearedFields: make(map[string]struct{}),
  41670. }
  41671. for _, opt := range opts {
  41672. opt(m)
  41673. }
  41674. return m
  41675. }
  41676. // withWxCardID sets the ID field of the mutation.
  41677. func withWxCardID(id uint64) wxcardOption {
  41678. return func(m *WxCardMutation) {
  41679. var (
  41680. err error
  41681. once sync.Once
  41682. value *WxCard
  41683. )
  41684. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  41685. once.Do(func() {
  41686. if m.done {
  41687. err = errors.New("querying old values post mutation is not allowed")
  41688. } else {
  41689. value, err = m.Client().WxCard.Get(ctx, id)
  41690. }
  41691. })
  41692. return value, err
  41693. }
  41694. m.id = &id
  41695. }
  41696. }
  41697. // withWxCard sets the old WxCard of the mutation.
  41698. func withWxCard(node *WxCard) wxcardOption {
  41699. return func(m *WxCardMutation) {
  41700. m.oldValue = func(context.Context) (*WxCard, error) {
  41701. return node, nil
  41702. }
  41703. m.id = &node.ID
  41704. }
  41705. }
  41706. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41707. // executed in a transaction (ent.Tx), a transactional client is returned.
  41708. func (m WxCardMutation) Client() *Client {
  41709. client := &Client{config: m.config}
  41710. client.init()
  41711. return client
  41712. }
  41713. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41714. // it returns an error otherwise.
  41715. func (m WxCardMutation) Tx() (*Tx, error) {
  41716. if _, ok := m.driver.(*txDriver); !ok {
  41717. return nil, errors.New("ent: mutation is not running in a transaction")
  41718. }
  41719. tx := &Tx{config: m.config}
  41720. tx.init()
  41721. return tx, nil
  41722. }
  41723. // SetID sets the value of the id field. Note that this
  41724. // operation is only accepted on creation of WxCard entities.
  41725. func (m *WxCardMutation) SetID(id uint64) {
  41726. m.id = &id
  41727. }
  41728. // ID returns the ID value in the mutation. Note that the ID is only available
  41729. // if it was provided to the builder or after it was returned from the database.
  41730. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  41731. if m.id == nil {
  41732. return
  41733. }
  41734. return *m.id, true
  41735. }
  41736. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41737. // That means, if the mutation is applied within a transaction with an isolation level such
  41738. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41739. // or updated by the mutation.
  41740. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  41741. switch {
  41742. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41743. id, exists := m.ID()
  41744. if exists {
  41745. return []uint64{id}, nil
  41746. }
  41747. fallthrough
  41748. case m.op.Is(OpUpdate | OpDelete):
  41749. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  41750. default:
  41751. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41752. }
  41753. }
  41754. // SetCreatedAt sets the "created_at" field.
  41755. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  41756. m.created_at = &t
  41757. }
  41758. // CreatedAt returns the value of the "created_at" field in the mutation.
  41759. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  41760. v := m.created_at
  41761. if v == nil {
  41762. return
  41763. }
  41764. return *v, true
  41765. }
  41766. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  41767. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41769. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41770. if !m.op.Is(OpUpdateOne) {
  41771. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41772. }
  41773. if m.id == nil || m.oldValue == nil {
  41774. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41775. }
  41776. oldValue, err := m.oldValue(ctx)
  41777. if err != nil {
  41778. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41779. }
  41780. return oldValue.CreatedAt, nil
  41781. }
  41782. // ResetCreatedAt resets all changes to the "created_at" field.
  41783. func (m *WxCardMutation) ResetCreatedAt() {
  41784. m.created_at = nil
  41785. }
  41786. // SetUpdatedAt sets the "updated_at" field.
  41787. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  41788. m.updated_at = &t
  41789. }
  41790. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41791. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  41792. v := m.updated_at
  41793. if v == nil {
  41794. return
  41795. }
  41796. return *v, true
  41797. }
  41798. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  41799. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41801. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41802. if !m.op.Is(OpUpdateOne) {
  41803. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41804. }
  41805. if m.id == nil || m.oldValue == nil {
  41806. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41807. }
  41808. oldValue, err := m.oldValue(ctx)
  41809. if err != nil {
  41810. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41811. }
  41812. return oldValue.UpdatedAt, nil
  41813. }
  41814. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41815. func (m *WxCardMutation) ResetUpdatedAt() {
  41816. m.updated_at = nil
  41817. }
  41818. // SetDeletedAt sets the "deleted_at" field.
  41819. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  41820. m.deleted_at = &t
  41821. }
  41822. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41823. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  41824. v := m.deleted_at
  41825. if v == nil {
  41826. return
  41827. }
  41828. return *v, true
  41829. }
  41830. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  41831. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41833. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41834. if !m.op.Is(OpUpdateOne) {
  41835. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41836. }
  41837. if m.id == nil || m.oldValue == nil {
  41838. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41839. }
  41840. oldValue, err := m.oldValue(ctx)
  41841. if err != nil {
  41842. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41843. }
  41844. return oldValue.DeletedAt, nil
  41845. }
  41846. // ClearDeletedAt clears the value of the "deleted_at" field.
  41847. func (m *WxCardMutation) ClearDeletedAt() {
  41848. m.deleted_at = nil
  41849. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  41850. }
  41851. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41852. func (m *WxCardMutation) DeletedAtCleared() bool {
  41853. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  41854. return ok
  41855. }
  41856. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41857. func (m *WxCardMutation) ResetDeletedAt() {
  41858. m.deleted_at = nil
  41859. delete(m.clearedFields, wxcard.FieldDeletedAt)
  41860. }
  41861. // SetUserID sets the "user_id" field.
  41862. func (m *WxCardMutation) SetUserID(u uint64) {
  41863. m.user_id = &u
  41864. m.adduser_id = nil
  41865. }
  41866. // UserID returns the value of the "user_id" field in the mutation.
  41867. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  41868. v := m.user_id
  41869. if v == nil {
  41870. return
  41871. }
  41872. return *v, true
  41873. }
  41874. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  41875. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41877. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41878. if !m.op.Is(OpUpdateOne) {
  41879. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41880. }
  41881. if m.id == nil || m.oldValue == nil {
  41882. return v, errors.New("OldUserID requires an ID field in the mutation")
  41883. }
  41884. oldValue, err := m.oldValue(ctx)
  41885. if err != nil {
  41886. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41887. }
  41888. return oldValue.UserID, nil
  41889. }
  41890. // AddUserID adds u to the "user_id" field.
  41891. func (m *WxCardMutation) AddUserID(u int64) {
  41892. if m.adduser_id != nil {
  41893. *m.adduser_id += u
  41894. } else {
  41895. m.adduser_id = &u
  41896. }
  41897. }
  41898. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41899. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  41900. v := m.adduser_id
  41901. if v == nil {
  41902. return
  41903. }
  41904. return *v, true
  41905. }
  41906. // ClearUserID clears the value of the "user_id" field.
  41907. func (m *WxCardMutation) ClearUserID() {
  41908. m.user_id = nil
  41909. m.adduser_id = nil
  41910. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  41911. }
  41912. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41913. func (m *WxCardMutation) UserIDCleared() bool {
  41914. _, ok := m.clearedFields[wxcard.FieldUserID]
  41915. return ok
  41916. }
  41917. // ResetUserID resets all changes to the "user_id" field.
  41918. func (m *WxCardMutation) ResetUserID() {
  41919. m.user_id = nil
  41920. m.adduser_id = nil
  41921. delete(m.clearedFields, wxcard.FieldUserID)
  41922. }
  41923. // SetWxUserID sets the "wx_user_id" field.
  41924. func (m *WxCardMutation) SetWxUserID(u uint64) {
  41925. m.wx_user_id = &u
  41926. m.addwx_user_id = nil
  41927. }
  41928. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  41929. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  41930. v := m.wx_user_id
  41931. if v == nil {
  41932. return
  41933. }
  41934. return *v, true
  41935. }
  41936. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  41937. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41939. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  41940. if !m.op.Is(OpUpdateOne) {
  41941. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  41942. }
  41943. if m.id == nil || m.oldValue == nil {
  41944. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  41945. }
  41946. oldValue, err := m.oldValue(ctx)
  41947. if err != nil {
  41948. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  41949. }
  41950. return oldValue.WxUserID, nil
  41951. }
  41952. // AddWxUserID adds u to the "wx_user_id" field.
  41953. func (m *WxCardMutation) AddWxUserID(u int64) {
  41954. if m.addwx_user_id != nil {
  41955. *m.addwx_user_id += u
  41956. } else {
  41957. m.addwx_user_id = &u
  41958. }
  41959. }
  41960. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  41961. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  41962. v := m.addwx_user_id
  41963. if v == nil {
  41964. return
  41965. }
  41966. return *v, true
  41967. }
  41968. // ClearWxUserID clears the value of the "wx_user_id" field.
  41969. func (m *WxCardMutation) ClearWxUserID() {
  41970. m.wx_user_id = nil
  41971. m.addwx_user_id = nil
  41972. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  41973. }
  41974. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  41975. func (m *WxCardMutation) WxUserIDCleared() bool {
  41976. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  41977. return ok
  41978. }
  41979. // ResetWxUserID resets all changes to the "wx_user_id" field.
  41980. func (m *WxCardMutation) ResetWxUserID() {
  41981. m.wx_user_id = nil
  41982. m.addwx_user_id = nil
  41983. delete(m.clearedFields, wxcard.FieldWxUserID)
  41984. }
  41985. // SetAvatar sets the "avatar" field.
  41986. func (m *WxCardMutation) SetAvatar(s string) {
  41987. m.avatar = &s
  41988. }
  41989. // Avatar returns the value of the "avatar" field in the mutation.
  41990. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  41991. v := m.avatar
  41992. if v == nil {
  41993. return
  41994. }
  41995. return *v, true
  41996. }
  41997. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  41998. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42000. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42001. if !m.op.Is(OpUpdateOne) {
  42002. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42003. }
  42004. if m.id == nil || m.oldValue == nil {
  42005. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42006. }
  42007. oldValue, err := m.oldValue(ctx)
  42008. if err != nil {
  42009. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42010. }
  42011. return oldValue.Avatar, nil
  42012. }
  42013. // ResetAvatar resets all changes to the "avatar" field.
  42014. func (m *WxCardMutation) ResetAvatar() {
  42015. m.avatar = nil
  42016. }
  42017. // SetLogo sets the "logo" field.
  42018. func (m *WxCardMutation) SetLogo(s string) {
  42019. m.logo = &s
  42020. }
  42021. // Logo returns the value of the "logo" field in the mutation.
  42022. func (m *WxCardMutation) Logo() (r string, exists bool) {
  42023. v := m.logo
  42024. if v == nil {
  42025. return
  42026. }
  42027. return *v, true
  42028. }
  42029. // OldLogo returns the old "logo" field's value of the WxCard entity.
  42030. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42032. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  42033. if !m.op.Is(OpUpdateOne) {
  42034. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  42035. }
  42036. if m.id == nil || m.oldValue == nil {
  42037. return v, errors.New("OldLogo requires an ID field in the mutation")
  42038. }
  42039. oldValue, err := m.oldValue(ctx)
  42040. if err != nil {
  42041. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  42042. }
  42043. return oldValue.Logo, nil
  42044. }
  42045. // ResetLogo resets all changes to the "logo" field.
  42046. func (m *WxCardMutation) ResetLogo() {
  42047. m.logo = nil
  42048. }
  42049. // SetName sets the "name" field.
  42050. func (m *WxCardMutation) SetName(s string) {
  42051. m.name = &s
  42052. }
  42053. // Name returns the value of the "name" field in the mutation.
  42054. func (m *WxCardMutation) Name() (r string, exists bool) {
  42055. v := m.name
  42056. if v == nil {
  42057. return
  42058. }
  42059. return *v, true
  42060. }
  42061. // OldName returns the old "name" field's value of the WxCard entity.
  42062. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42064. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  42065. if !m.op.Is(OpUpdateOne) {
  42066. return v, errors.New("OldName is only allowed on UpdateOne operations")
  42067. }
  42068. if m.id == nil || m.oldValue == nil {
  42069. return v, errors.New("OldName requires an ID field in the mutation")
  42070. }
  42071. oldValue, err := m.oldValue(ctx)
  42072. if err != nil {
  42073. return v, fmt.Errorf("querying old value for OldName: %w", err)
  42074. }
  42075. return oldValue.Name, nil
  42076. }
  42077. // ResetName resets all changes to the "name" field.
  42078. func (m *WxCardMutation) ResetName() {
  42079. m.name = nil
  42080. }
  42081. // SetCompany sets the "company" field.
  42082. func (m *WxCardMutation) SetCompany(s string) {
  42083. m.company = &s
  42084. }
  42085. // Company returns the value of the "company" field in the mutation.
  42086. func (m *WxCardMutation) Company() (r string, exists bool) {
  42087. v := m.company
  42088. if v == nil {
  42089. return
  42090. }
  42091. return *v, true
  42092. }
  42093. // OldCompany returns the old "company" field's value of the WxCard entity.
  42094. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42096. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  42097. if !m.op.Is(OpUpdateOne) {
  42098. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  42099. }
  42100. if m.id == nil || m.oldValue == nil {
  42101. return v, errors.New("OldCompany requires an ID field in the mutation")
  42102. }
  42103. oldValue, err := m.oldValue(ctx)
  42104. if err != nil {
  42105. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  42106. }
  42107. return oldValue.Company, nil
  42108. }
  42109. // ResetCompany resets all changes to the "company" field.
  42110. func (m *WxCardMutation) ResetCompany() {
  42111. m.company = nil
  42112. }
  42113. // SetAddress sets the "address" field.
  42114. func (m *WxCardMutation) SetAddress(s string) {
  42115. m.address = &s
  42116. }
  42117. // Address returns the value of the "address" field in the mutation.
  42118. func (m *WxCardMutation) Address() (r string, exists bool) {
  42119. v := m.address
  42120. if v == nil {
  42121. return
  42122. }
  42123. return *v, true
  42124. }
  42125. // OldAddress returns the old "address" field's value of the WxCard entity.
  42126. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42128. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  42129. if !m.op.Is(OpUpdateOne) {
  42130. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  42131. }
  42132. if m.id == nil || m.oldValue == nil {
  42133. return v, errors.New("OldAddress requires an ID field in the mutation")
  42134. }
  42135. oldValue, err := m.oldValue(ctx)
  42136. if err != nil {
  42137. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  42138. }
  42139. return oldValue.Address, nil
  42140. }
  42141. // ResetAddress resets all changes to the "address" field.
  42142. func (m *WxCardMutation) ResetAddress() {
  42143. m.address = nil
  42144. }
  42145. // SetPhone sets the "phone" field.
  42146. func (m *WxCardMutation) SetPhone(s string) {
  42147. m.phone = &s
  42148. }
  42149. // Phone returns the value of the "phone" field in the mutation.
  42150. func (m *WxCardMutation) Phone() (r string, exists bool) {
  42151. v := m.phone
  42152. if v == nil {
  42153. return
  42154. }
  42155. return *v, true
  42156. }
  42157. // OldPhone returns the old "phone" field's value of the WxCard entity.
  42158. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42160. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  42161. if !m.op.Is(OpUpdateOne) {
  42162. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42163. }
  42164. if m.id == nil || m.oldValue == nil {
  42165. return v, errors.New("OldPhone requires an ID field in the mutation")
  42166. }
  42167. oldValue, err := m.oldValue(ctx)
  42168. if err != nil {
  42169. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42170. }
  42171. return oldValue.Phone, nil
  42172. }
  42173. // ResetPhone resets all changes to the "phone" field.
  42174. func (m *WxCardMutation) ResetPhone() {
  42175. m.phone = nil
  42176. }
  42177. // SetOfficialAccount sets the "official_account" field.
  42178. func (m *WxCardMutation) SetOfficialAccount(s string) {
  42179. m.official_account = &s
  42180. }
  42181. // OfficialAccount returns the value of the "official_account" field in the mutation.
  42182. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  42183. v := m.official_account
  42184. if v == nil {
  42185. return
  42186. }
  42187. return *v, true
  42188. }
  42189. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  42190. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42192. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  42193. if !m.op.Is(OpUpdateOne) {
  42194. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  42195. }
  42196. if m.id == nil || m.oldValue == nil {
  42197. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  42198. }
  42199. oldValue, err := m.oldValue(ctx)
  42200. if err != nil {
  42201. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  42202. }
  42203. return oldValue.OfficialAccount, nil
  42204. }
  42205. // ResetOfficialAccount resets all changes to the "official_account" field.
  42206. func (m *WxCardMutation) ResetOfficialAccount() {
  42207. m.official_account = nil
  42208. }
  42209. // SetWechatAccount sets the "wechat_account" field.
  42210. func (m *WxCardMutation) SetWechatAccount(s string) {
  42211. m.wechat_account = &s
  42212. }
  42213. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  42214. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  42215. v := m.wechat_account
  42216. if v == nil {
  42217. return
  42218. }
  42219. return *v, true
  42220. }
  42221. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  42222. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42224. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  42225. if !m.op.Is(OpUpdateOne) {
  42226. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  42227. }
  42228. if m.id == nil || m.oldValue == nil {
  42229. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  42230. }
  42231. oldValue, err := m.oldValue(ctx)
  42232. if err != nil {
  42233. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  42234. }
  42235. return oldValue.WechatAccount, nil
  42236. }
  42237. // ResetWechatAccount resets all changes to the "wechat_account" field.
  42238. func (m *WxCardMutation) ResetWechatAccount() {
  42239. m.wechat_account = nil
  42240. }
  42241. // SetEmail sets the "email" field.
  42242. func (m *WxCardMutation) SetEmail(s string) {
  42243. m.email = &s
  42244. }
  42245. // Email returns the value of the "email" field in the mutation.
  42246. func (m *WxCardMutation) Email() (r string, exists bool) {
  42247. v := m.email
  42248. if v == nil {
  42249. return
  42250. }
  42251. return *v, true
  42252. }
  42253. // OldEmail returns the old "email" field's value of the WxCard entity.
  42254. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42256. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  42257. if !m.op.Is(OpUpdateOne) {
  42258. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  42259. }
  42260. if m.id == nil || m.oldValue == nil {
  42261. return v, errors.New("OldEmail requires an ID field in the mutation")
  42262. }
  42263. oldValue, err := m.oldValue(ctx)
  42264. if err != nil {
  42265. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  42266. }
  42267. return oldValue.Email, nil
  42268. }
  42269. // ClearEmail clears the value of the "email" field.
  42270. func (m *WxCardMutation) ClearEmail() {
  42271. m.email = nil
  42272. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  42273. }
  42274. // EmailCleared returns if the "email" field was cleared in this mutation.
  42275. func (m *WxCardMutation) EmailCleared() bool {
  42276. _, ok := m.clearedFields[wxcard.FieldEmail]
  42277. return ok
  42278. }
  42279. // ResetEmail resets all changes to the "email" field.
  42280. func (m *WxCardMutation) ResetEmail() {
  42281. m.email = nil
  42282. delete(m.clearedFields, wxcard.FieldEmail)
  42283. }
  42284. // SetAPIBase sets the "api_base" field.
  42285. func (m *WxCardMutation) SetAPIBase(s string) {
  42286. m.api_base = &s
  42287. }
  42288. // APIBase returns the value of the "api_base" field in the mutation.
  42289. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  42290. v := m.api_base
  42291. if v == nil {
  42292. return
  42293. }
  42294. return *v, true
  42295. }
  42296. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  42297. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42299. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42300. if !m.op.Is(OpUpdateOne) {
  42301. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42302. }
  42303. if m.id == nil || m.oldValue == nil {
  42304. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42305. }
  42306. oldValue, err := m.oldValue(ctx)
  42307. if err != nil {
  42308. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42309. }
  42310. return oldValue.APIBase, nil
  42311. }
  42312. // ClearAPIBase clears the value of the "api_base" field.
  42313. func (m *WxCardMutation) ClearAPIBase() {
  42314. m.api_base = nil
  42315. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  42316. }
  42317. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42318. func (m *WxCardMutation) APIBaseCleared() bool {
  42319. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  42320. return ok
  42321. }
  42322. // ResetAPIBase resets all changes to the "api_base" field.
  42323. func (m *WxCardMutation) ResetAPIBase() {
  42324. m.api_base = nil
  42325. delete(m.clearedFields, wxcard.FieldAPIBase)
  42326. }
  42327. // SetAPIKey sets the "api_key" field.
  42328. func (m *WxCardMutation) SetAPIKey(s string) {
  42329. m.api_key = &s
  42330. }
  42331. // APIKey returns the value of the "api_key" field in the mutation.
  42332. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  42333. v := m.api_key
  42334. if v == nil {
  42335. return
  42336. }
  42337. return *v, true
  42338. }
  42339. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  42340. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42342. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42343. if !m.op.Is(OpUpdateOne) {
  42344. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42345. }
  42346. if m.id == nil || m.oldValue == nil {
  42347. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42348. }
  42349. oldValue, err := m.oldValue(ctx)
  42350. if err != nil {
  42351. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42352. }
  42353. return oldValue.APIKey, nil
  42354. }
  42355. // ClearAPIKey clears the value of the "api_key" field.
  42356. func (m *WxCardMutation) ClearAPIKey() {
  42357. m.api_key = nil
  42358. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  42359. }
  42360. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42361. func (m *WxCardMutation) APIKeyCleared() bool {
  42362. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  42363. return ok
  42364. }
  42365. // ResetAPIKey resets all changes to the "api_key" field.
  42366. func (m *WxCardMutation) ResetAPIKey() {
  42367. m.api_key = nil
  42368. delete(m.clearedFields, wxcard.FieldAPIKey)
  42369. }
  42370. // SetAiInfo sets the "ai_info" field.
  42371. func (m *WxCardMutation) SetAiInfo(s string) {
  42372. m.ai_info = &s
  42373. }
  42374. // AiInfo returns the value of the "ai_info" field in the mutation.
  42375. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  42376. v := m.ai_info
  42377. if v == nil {
  42378. return
  42379. }
  42380. return *v, true
  42381. }
  42382. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  42383. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42385. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  42386. if !m.op.Is(OpUpdateOne) {
  42387. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  42388. }
  42389. if m.id == nil || m.oldValue == nil {
  42390. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  42391. }
  42392. oldValue, err := m.oldValue(ctx)
  42393. if err != nil {
  42394. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  42395. }
  42396. return oldValue.AiInfo, nil
  42397. }
  42398. // ClearAiInfo clears the value of the "ai_info" field.
  42399. func (m *WxCardMutation) ClearAiInfo() {
  42400. m.ai_info = nil
  42401. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  42402. }
  42403. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  42404. func (m *WxCardMutation) AiInfoCleared() bool {
  42405. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  42406. return ok
  42407. }
  42408. // ResetAiInfo resets all changes to the "ai_info" field.
  42409. func (m *WxCardMutation) ResetAiInfo() {
  42410. m.ai_info = nil
  42411. delete(m.clearedFields, wxcard.FieldAiInfo)
  42412. }
  42413. // SetIntro sets the "intro" field.
  42414. func (m *WxCardMutation) SetIntro(s string) {
  42415. m.intro = &s
  42416. }
  42417. // Intro returns the value of the "intro" field in the mutation.
  42418. func (m *WxCardMutation) Intro() (r string, exists bool) {
  42419. v := m.intro
  42420. if v == nil {
  42421. return
  42422. }
  42423. return *v, true
  42424. }
  42425. // OldIntro returns the old "intro" field's value of the WxCard entity.
  42426. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42428. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  42429. if !m.op.Is(OpUpdateOne) {
  42430. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  42431. }
  42432. if m.id == nil || m.oldValue == nil {
  42433. return v, errors.New("OldIntro requires an ID field in the mutation")
  42434. }
  42435. oldValue, err := m.oldValue(ctx)
  42436. if err != nil {
  42437. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  42438. }
  42439. return oldValue.Intro, nil
  42440. }
  42441. // ClearIntro clears the value of the "intro" field.
  42442. func (m *WxCardMutation) ClearIntro() {
  42443. m.intro = nil
  42444. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  42445. }
  42446. // IntroCleared returns if the "intro" field was cleared in this mutation.
  42447. func (m *WxCardMutation) IntroCleared() bool {
  42448. _, ok := m.clearedFields[wxcard.FieldIntro]
  42449. return ok
  42450. }
  42451. // ResetIntro resets all changes to the "intro" field.
  42452. func (m *WxCardMutation) ResetIntro() {
  42453. m.intro = nil
  42454. delete(m.clearedFields, wxcard.FieldIntro)
  42455. }
  42456. // Where appends a list predicates to the WxCardMutation builder.
  42457. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  42458. m.predicates = append(m.predicates, ps...)
  42459. }
  42460. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  42461. // users can use type-assertion to append predicates that do not depend on any generated package.
  42462. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  42463. p := make([]predicate.WxCard, len(ps))
  42464. for i := range ps {
  42465. p[i] = ps[i]
  42466. }
  42467. m.Where(p...)
  42468. }
  42469. // Op returns the operation name.
  42470. func (m *WxCardMutation) Op() Op {
  42471. return m.op
  42472. }
  42473. // SetOp allows setting the mutation operation.
  42474. func (m *WxCardMutation) SetOp(op Op) {
  42475. m.op = op
  42476. }
  42477. // Type returns the node type of this mutation (WxCard).
  42478. func (m *WxCardMutation) Type() string {
  42479. return m.typ
  42480. }
  42481. // Fields returns all fields that were changed during this mutation. Note that in
  42482. // order to get all numeric fields that were incremented/decremented, call
  42483. // AddedFields().
  42484. func (m *WxCardMutation) Fields() []string {
  42485. fields := make([]string, 0, 18)
  42486. if m.created_at != nil {
  42487. fields = append(fields, wxcard.FieldCreatedAt)
  42488. }
  42489. if m.updated_at != nil {
  42490. fields = append(fields, wxcard.FieldUpdatedAt)
  42491. }
  42492. if m.deleted_at != nil {
  42493. fields = append(fields, wxcard.FieldDeletedAt)
  42494. }
  42495. if m.user_id != nil {
  42496. fields = append(fields, wxcard.FieldUserID)
  42497. }
  42498. if m.wx_user_id != nil {
  42499. fields = append(fields, wxcard.FieldWxUserID)
  42500. }
  42501. if m.avatar != nil {
  42502. fields = append(fields, wxcard.FieldAvatar)
  42503. }
  42504. if m.logo != nil {
  42505. fields = append(fields, wxcard.FieldLogo)
  42506. }
  42507. if m.name != nil {
  42508. fields = append(fields, wxcard.FieldName)
  42509. }
  42510. if m.company != nil {
  42511. fields = append(fields, wxcard.FieldCompany)
  42512. }
  42513. if m.address != nil {
  42514. fields = append(fields, wxcard.FieldAddress)
  42515. }
  42516. if m.phone != nil {
  42517. fields = append(fields, wxcard.FieldPhone)
  42518. }
  42519. if m.official_account != nil {
  42520. fields = append(fields, wxcard.FieldOfficialAccount)
  42521. }
  42522. if m.wechat_account != nil {
  42523. fields = append(fields, wxcard.FieldWechatAccount)
  42524. }
  42525. if m.email != nil {
  42526. fields = append(fields, wxcard.FieldEmail)
  42527. }
  42528. if m.api_base != nil {
  42529. fields = append(fields, wxcard.FieldAPIBase)
  42530. }
  42531. if m.api_key != nil {
  42532. fields = append(fields, wxcard.FieldAPIKey)
  42533. }
  42534. if m.ai_info != nil {
  42535. fields = append(fields, wxcard.FieldAiInfo)
  42536. }
  42537. if m.intro != nil {
  42538. fields = append(fields, wxcard.FieldIntro)
  42539. }
  42540. return fields
  42541. }
  42542. // Field returns the value of a field with the given name. The second boolean
  42543. // return value indicates that this field was not set, or was not defined in the
  42544. // schema.
  42545. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  42546. switch name {
  42547. case wxcard.FieldCreatedAt:
  42548. return m.CreatedAt()
  42549. case wxcard.FieldUpdatedAt:
  42550. return m.UpdatedAt()
  42551. case wxcard.FieldDeletedAt:
  42552. return m.DeletedAt()
  42553. case wxcard.FieldUserID:
  42554. return m.UserID()
  42555. case wxcard.FieldWxUserID:
  42556. return m.WxUserID()
  42557. case wxcard.FieldAvatar:
  42558. return m.Avatar()
  42559. case wxcard.FieldLogo:
  42560. return m.Logo()
  42561. case wxcard.FieldName:
  42562. return m.Name()
  42563. case wxcard.FieldCompany:
  42564. return m.Company()
  42565. case wxcard.FieldAddress:
  42566. return m.Address()
  42567. case wxcard.FieldPhone:
  42568. return m.Phone()
  42569. case wxcard.FieldOfficialAccount:
  42570. return m.OfficialAccount()
  42571. case wxcard.FieldWechatAccount:
  42572. return m.WechatAccount()
  42573. case wxcard.FieldEmail:
  42574. return m.Email()
  42575. case wxcard.FieldAPIBase:
  42576. return m.APIBase()
  42577. case wxcard.FieldAPIKey:
  42578. return m.APIKey()
  42579. case wxcard.FieldAiInfo:
  42580. return m.AiInfo()
  42581. case wxcard.FieldIntro:
  42582. return m.Intro()
  42583. }
  42584. return nil, false
  42585. }
  42586. // OldField returns the old value of the field from the database. An error is
  42587. // returned if the mutation operation is not UpdateOne, or the query to the
  42588. // database failed.
  42589. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42590. switch name {
  42591. case wxcard.FieldCreatedAt:
  42592. return m.OldCreatedAt(ctx)
  42593. case wxcard.FieldUpdatedAt:
  42594. return m.OldUpdatedAt(ctx)
  42595. case wxcard.FieldDeletedAt:
  42596. return m.OldDeletedAt(ctx)
  42597. case wxcard.FieldUserID:
  42598. return m.OldUserID(ctx)
  42599. case wxcard.FieldWxUserID:
  42600. return m.OldWxUserID(ctx)
  42601. case wxcard.FieldAvatar:
  42602. return m.OldAvatar(ctx)
  42603. case wxcard.FieldLogo:
  42604. return m.OldLogo(ctx)
  42605. case wxcard.FieldName:
  42606. return m.OldName(ctx)
  42607. case wxcard.FieldCompany:
  42608. return m.OldCompany(ctx)
  42609. case wxcard.FieldAddress:
  42610. return m.OldAddress(ctx)
  42611. case wxcard.FieldPhone:
  42612. return m.OldPhone(ctx)
  42613. case wxcard.FieldOfficialAccount:
  42614. return m.OldOfficialAccount(ctx)
  42615. case wxcard.FieldWechatAccount:
  42616. return m.OldWechatAccount(ctx)
  42617. case wxcard.FieldEmail:
  42618. return m.OldEmail(ctx)
  42619. case wxcard.FieldAPIBase:
  42620. return m.OldAPIBase(ctx)
  42621. case wxcard.FieldAPIKey:
  42622. return m.OldAPIKey(ctx)
  42623. case wxcard.FieldAiInfo:
  42624. return m.OldAiInfo(ctx)
  42625. case wxcard.FieldIntro:
  42626. return m.OldIntro(ctx)
  42627. }
  42628. return nil, fmt.Errorf("unknown WxCard field %s", name)
  42629. }
  42630. // SetField sets the value of a field with the given name. It returns an error if
  42631. // the field is not defined in the schema, or if the type mismatched the field
  42632. // type.
  42633. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  42634. switch name {
  42635. case wxcard.FieldCreatedAt:
  42636. v, ok := value.(time.Time)
  42637. if !ok {
  42638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42639. }
  42640. m.SetCreatedAt(v)
  42641. return nil
  42642. case wxcard.FieldUpdatedAt:
  42643. v, ok := value.(time.Time)
  42644. if !ok {
  42645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42646. }
  42647. m.SetUpdatedAt(v)
  42648. return nil
  42649. case wxcard.FieldDeletedAt:
  42650. v, ok := value.(time.Time)
  42651. if !ok {
  42652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42653. }
  42654. m.SetDeletedAt(v)
  42655. return nil
  42656. case wxcard.FieldUserID:
  42657. v, ok := value.(uint64)
  42658. if !ok {
  42659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42660. }
  42661. m.SetUserID(v)
  42662. return nil
  42663. case wxcard.FieldWxUserID:
  42664. v, ok := value.(uint64)
  42665. if !ok {
  42666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42667. }
  42668. m.SetWxUserID(v)
  42669. return nil
  42670. case wxcard.FieldAvatar:
  42671. v, ok := value.(string)
  42672. if !ok {
  42673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42674. }
  42675. m.SetAvatar(v)
  42676. return nil
  42677. case wxcard.FieldLogo:
  42678. v, ok := value.(string)
  42679. if !ok {
  42680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42681. }
  42682. m.SetLogo(v)
  42683. return nil
  42684. case wxcard.FieldName:
  42685. v, ok := value.(string)
  42686. if !ok {
  42687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42688. }
  42689. m.SetName(v)
  42690. return nil
  42691. case wxcard.FieldCompany:
  42692. v, ok := value.(string)
  42693. if !ok {
  42694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42695. }
  42696. m.SetCompany(v)
  42697. return nil
  42698. case wxcard.FieldAddress:
  42699. v, ok := value.(string)
  42700. if !ok {
  42701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42702. }
  42703. m.SetAddress(v)
  42704. return nil
  42705. case wxcard.FieldPhone:
  42706. v, ok := value.(string)
  42707. if !ok {
  42708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42709. }
  42710. m.SetPhone(v)
  42711. return nil
  42712. case wxcard.FieldOfficialAccount:
  42713. v, ok := value.(string)
  42714. if !ok {
  42715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42716. }
  42717. m.SetOfficialAccount(v)
  42718. return nil
  42719. case wxcard.FieldWechatAccount:
  42720. v, ok := value.(string)
  42721. if !ok {
  42722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42723. }
  42724. m.SetWechatAccount(v)
  42725. return nil
  42726. case wxcard.FieldEmail:
  42727. v, ok := value.(string)
  42728. if !ok {
  42729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42730. }
  42731. m.SetEmail(v)
  42732. return nil
  42733. case wxcard.FieldAPIBase:
  42734. v, ok := value.(string)
  42735. if !ok {
  42736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42737. }
  42738. m.SetAPIBase(v)
  42739. return nil
  42740. case wxcard.FieldAPIKey:
  42741. v, ok := value.(string)
  42742. if !ok {
  42743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42744. }
  42745. m.SetAPIKey(v)
  42746. return nil
  42747. case wxcard.FieldAiInfo:
  42748. v, ok := value.(string)
  42749. if !ok {
  42750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42751. }
  42752. m.SetAiInfo(v)
  42753. return nil
  42754. case wxcard.FieldIntro:
  42755. v, ok := value.(string)
  42756. if !ok {
  42757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42758. }
  42759. m.SetIntro(v)
  42760. return nil
  42761. }
  42762. return fmt.Errorf("unknown WxCard field %s", name)
  42763. }
  42764. // AddedFields returns all numeric fields that were incremented/decremented during
  42765. // this mutation.
  42766. func (m *WxCardMutation) AddedFields() []string {
  42767. var fields []string
  42768. if m.adduser_id != nil {
  42769. fields = append(fields, wxcard.FieldUserID)
  42770. }
  42771. if m.addwx_user_id != nil {
  42772. fields = append(fields, wxcard.FieldWxUserID)
  42773. }
  42774. return fields
  42775. }
  42776. // AddedField returns the numeric value that was incremented/decremented on a field
  42777. // with the given name. The second boolean return value indicates that this field
  42778. // was not set, or was not defined in the schema.
  42779. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  42780. switch name {
  42781. case wxcard.FieldUserID:
  42782. return m.AddedUserID()
  42783. case wxcard.FieldWxUserID:
  42784. return m.AddedWxUserID()
  42785. }
  42786. return nil, false
  42787. }
  42788. // AddField adds the value to the field with the given name. It returns an error if
  42789. // the field is not defined in the schema, or if the type mismatched the field
  42790. // type.
  42791. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  42792. switch name {
  42793. case wxcard.FieldUserID:
  42794. v, ok := value.(int64)
  42795. if !ok {
  42796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42797. }
  42798. m.AddUserID(v)
  42799. return nil
  42800. case wxcard.FieldWxUserID:
  42801. v, ok := value.(int64)
  42802. if !ok {
  42803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42804. }
  42805. m.AddWxUserID(v)
  42806. return nil
  42807. }
  42808. return fmt.Errorf("unknown WxCard numeric field %s", name)
  42809. }
  42810. // ClearedFields returns all nullable fields that were cleared during this
  42811. // mutation.
  42812. func (m *WxCardMutation) ClearedFields() []string {
  42813. var fields []string
  42814. if m.FieldCleared(wxcard.FieldDeletedAt) {
  42815. fields = append(fields, wxcard.FieldDeletedAt)
  42816. }
  42817. if m.FieldCleared(wxcard.FieldUserID) {
  42818. fields = append(fields, wxcard.FieldUserID)
  42819. }
  42820. if m.FieldCleared(wxcard.FieldWxUserID) {
  42821. fields = append(fields, wxcard.FieldWxUserID)
  42822. }
  42823. if m.FieldCleared(wxcard.FieldEmail) {
  42824. fields = append(fields, wxcard.FieldEmail)
  42825. }
  42826. if m.FieldCleared(wxcard.FieldAPIBase) {
  42827. fields = append(fields, wxcard.FieldAPIBase)
  42828. }
  42829. if m.FieldCleared(wxcard.FieldAPIKey) {
  42830. fields = append(fields, wxcard.FieldAPIKey)
  42831. }
  42832. if m.FieldCleared(wxcard.FieldAiInfo) {
  42833. fields = append(fields, wxcard.FieldAiInfo)
  42834. }
  42835. if m.FieldCleared(wxcard.FieldIntro) {
  42836. fields = append(fields, wxcard.FieldIntro)
  42837. }
  42838. return fields
  42839. }
  42840. // FieldCleared returns a boolean indicating if a field with the given name was
  42841. // cleared in this mutation.
  42842. func (m *WxCardMutation) FieldCleared(name string) bool {
  42843. _, ok := m.clearedFields[name]
  42844. return ok
  42845. }
  42846. // ClearField clears the value of the field with the given name. It returns an
  42847. // error if the field is not defined in the schema.
  42848. func (m *WxCardMutation) ClearField(name string) error {
  42849. switch name {
  42850. case wxcard.FieldDeletedAt:
  42851. m.ClearDeletedAt()
  42852. return nil
  42853. case wxcard.FieldUserID:
  42854. m.ClearUserID()
  42855. return nil
  42856. case wxcard.FieldWxUserID:
  42857. m.ClearWxUserID()
  42858. return nil
  42859. case wxcard.FieldEmail:
  42860. m.ClearEmail()
  42861. return nil
  42862. case wxcard.FieldAPIBase:
  42863. m.ClearAPIBase()
  42864. return nil
  42865. case wxcard.FieldAPIKey:
  42866. m.ClearAPIKey()
  42867. return nil
  42868. case wxcard.FieldAiInfo:
  42869. m.ClearAiInfo()
  42870. return nil
  42871. case wxcard.FieldIntro:
  42872. m.ClearIntro()
  42873. return nil
  42874. }
  42875. return fmt.Errorf("unknown WxCard nullable field %s", name)
  42876. }
  42877. // ResetField resets all changes in the mutation for the field with the given name.
  42878. // It returns an error if the field is not defined in the schema.
  42879. func (m *WxCardMutation) ResetField(name string) error {
  42880. switch name {
  42881. case wxcard.FieldCreatedAt:
  42882. m.ResetCreatedAt()
  42883. return nil
  42884. case wxcard.FieldUpdatedAt:
  42885. m.ResetUpdatedAt()
  42886. return nil
  42887. case wxcard.FieldDeletedAt:
  42888. m.ResetDeletedAt()
  42889. return nil
  42890. case wxcard.FieldUserID:
  42891. m.ResetUserID()
  42892. return nil
  42893. case wxcard.FieldWxUserID:
  42894. m.ResetWxUserID()
  42895. return nil
  42896. case wxcard.FieldAvatar:
  42897. m.ResetAvatar()
  42898. return nil
  42899. case wxcard.FieldLogo:
  42900. m.ResetLogo()
  42901. return nil
  42902. case wxcard.FieldName:
  42903. m.ResetName()
  42904. return nil
  42905. case wxcard.FieldCompany:
  42906. m.ResetCompany()
  42907. return nil
  42908. case wxcard.FieldAddress:
  42909. m.ResetAddress()
  42910. return nil
  42911. case wxcard.FieldPhone:
  42912. m.ResetPhone()
  42913. return nil
  42914. case wxcard.FieldOfficialAccount:
  42915. m.ResetOfficialAccount()
  42916. return nil
  42917. case wxcard.FieldWechatAccount:
  42918. m.ResetWechatAccount()
  42919. return nil
  42920. case wxcard.FieldEmail:
  42921. m.ResetEmail()
  42922. return nil
  42923. case wxcard.FieldAPIBase:
  42924. m.ResetAPIBase()
  42925. return nil
  42926. case wxcard.FieldAPIKey:
  42927. m.ResetAPIKey()
  42928. return nil
  42929. case wxcard.FieldAiInfo:
  42930. m.ResetAiInfo()
  42931. return nil
  42932. case wxcard.FieldIntro:
  42933. m.ResetIntro()
  42934. return nil
  42935. }
  42936. return fmt.Errorf("unknown WxCard field %s", name)
  42937. }
  42938. // AddedEdges returns all edge names that were set/added in this mutation.
  42939. func (m *WxCardMutation) AddedEdges() []string {
  42940. edges := make([]string, 0, 0)
  42941. return edges
  42942. }
  42943. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42944. // name in this mutation.
  42945. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  42946. return nil
  42947. }
  42948. // RemovedEdges returns all edge names that were removed in this mutation.
  42949. func (m *WxCardMutation) RemovedEdges() []string {
  42950. edges := make([]string, 0, 0)
  42951. return edges
  42952. }
  42953. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42954. // the given name in this mutation.
  42955. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  42956. return nil
  42957. }
  42958. // ClearedEdges returns all edge names that were cleared in this mutation.
  42959. func (m *WxCardMutation) ClearedEdges() []string {
  42960. edges := make([]string, 0, 0)
  42961. return edges
  42962. }
  42963. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42964. // was cleared in this mutation.
  42965. func (m *WxCardMutation) EdgeCleared(name string) bool {
  42966. return false
  42967. }
  42968. // ClearEdge clears the value of the edge with the given name. It returns an error
  42969. // if that edge is not defined in the schema.
  42970. func (m *WxCardMutation) ClearEdge(name string) error {
  42971. return fmt.Errorf("unknown WxCard unique edge %s", name)
  42972. }
  42973. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42974. // It returns an error if the edge is not defined in the schema.
  42975. func (m *WxCardMutation) ResetEdge(name string) error {
  42976. return fmt.Errorf("unknown WxCard edge %s", name)
  42977. }
  42978. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  42979. type WxCardUserMutation struct {
  42980. config
  42981. op Op
  42982. typ string
  42983. id *uint64
  42984. created_at *time.Time
  42985. updated_at *time.Time
  42986. deleted_at *time.Time
  42987. wxid *string
  42988. account *string
  42989. avatar *string
  42990. nickname *string
  42991. remark *string
  42992. phone *string
  42993. open_id *string
  42994. union_id *string
  42995. session_key *string
  42996. is_vip *int
  42997. addis_vip *int
  42998. clearedFields map[string]struct{}
  42999. done bool
  43000. oldValue func(context.Context) (*WxCardUser, error)
  43001. predicates []predicate.WxCardUser
  43002. }
  43003. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  43004. // wxcarduserOption allows management of the mutation configuration using functional options.
  43005. type wxcarduserOption func(*WxCardUserMutation)
  43006. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  43007. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  43008. m := &WxCardUserMutation{
  43009. config: c,
  43010. op: op,
  43011. typ: TypeWxCardUser,
  43012. clearedFields: make(map[string]struct{}),
  43013. }
  43014. for _, opt := range opts {
  43015. opt(m)
  43016. }
  43017. return m
  43018. }
  43019. // withWxCardUserID sets the ID field of the mutation.
  43020. func withWxCardUserID(id uint64) wxcarduserOption {
  43021. return func(m *WxCardUserMutation) {
  43022. var (
  43023. err error
  43024. once sync.Once
  43025. value *WxCardUser
  43026. )
  43027. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  43028. once.Do(func() {
  43029. if m.done {
  43030. err = errors.New("querying old values post mutation is not allowed")
  43031. } else {
  43032. value, err = m.Client().WxCardUser.Get(ctx, id)
  43033. }
  43034. })
  43035. return value, err
  43036. }
  43037. m.id = &id
  43038. }
  43039. }
  43040. // withWxCardUser sets the old WxCardUser of the mutation.
  43041. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  43042. return func(m *WxCardUserMutation) {
  43043. m.oldValue = func(context.Context) (*WxCardUser, error) {
  43044. return node, nil
  43045. }
  43046. m.id = &node.ID
  43047. }
  43048. }
  43049. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43050. // executed in a transaction (ent.Tx), a transactional client is returned.
  43051. func (m WxCardUserMutation) Client() *Client {
  43052. client := &Client{config: m.config}
  43053. client.init()
  43054. return client
  43055. }
  43056. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43057. // it returns an error otherwise.
  43058. func (m WxCardUserMutation) Tx() (*Tx, error) {
  43059. if _, ok := m.driver.(*txDriver); !ok {
  43060. return nil, errors.New("ent: mutation is not running in a transaction")
  43061. }
  43062. tx := &Tx{config: m.config}
  43063. tx.init()
  43064. return tx, nil
  43065. }
  43066. // SetID sets the value of the id field. Note that this
  43067. // operation is only accepted on creation of WxCardUser entities.
  43068. func (m *WxCardUserMutation) SetID(id uint64) {
  43069. m.id = &id
  43070. }
  43071. // ID returns the ID value in the mutation. Note that the ID is only available
  43072. // if it was provided to the builder or after it was returned from the database.
  43073. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  43074. if m.id == nil {
  43075. return
  43076. }
  43077. return *m.id, true
  43078. }
  43079. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43080. // That means, if the mutation is applied within a transaction with an isolation level such
  43081. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43082. // or updated by the mutation.
  43083. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  43084. switch {
  43085. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43086. id, exists := m.ID()
  43087. if exists {
  43088. return []uint64{id}, nil
  43089. }
  43090. fallthrough
  43091. case m.op.Is(OpUpdate | OpDelete):
  43092. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  43093. default:
  43094. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43095. }
  43096. }
  43097. // SetCreatedAt sets the "created_at" field.
  43098. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  43099. m.created_at = &t
  43100. }
  43101. // CreatedAt returns the value of the "created_at" field in the mutation.
  43102. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  43103. v := m.created_at
  43104. if v == nil {
  43105. return
  43106. }
  43107. return *v, true
  43108. }
  43109. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  43110. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43112. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43113. if !m.op.Is(OpUpdateOne) {
  43114. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43115. }
  43116. if m.id == nil || m.oldValue == nil {
  43117. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43118. }
  43119. oldValue, err := m.oldValue(ctx)
  43120. if err != nil {
  43121. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43122. }
  43123. return oldValue.CreatedAt, nil
  43124. }
  43125. // ResetCreatedAt resets all changes to the "created_at" field.
  43126. func (m *WxCardUserMutation) ResetCreatedAt() {
  43127. m.created_at = nil
  43128. }
  43129. // SetUpdatedAt sets the "updated_at" field.
  43130. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  43131. m.updated_at = &t
  43132. }
  43133. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43134. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  43135. v := m.updated_at
  43136. if v == nil {
  43137. return
  43138. }
  43139. return *v, true
  43140. }
  43141. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  43142. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43144. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43145. if !m.op.Is(OpUpdateOne) {
  43146. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43147. }
  43148. if m.id == nil || m.oldValue == nil {
  43149. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43150. }
  43151. oldValue, err := m.oldValue(ctx)
  43152. if err != nil {
  43153. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43154. }
  43155. return oldValue.UpdatedAt, nil
  43156. }
  43157. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43158. func (m *WxCardUserMutation) ResetUpdatedAt() {
  43159. m.updated_at = nil
  43160. }
  43161. // SetDeletedAt sets the "deleted_at" field.
  43162. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  43163. m.deleted_at = &t
  43164. }
  43165. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43166. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  43167. v := m.deleted_at
  43168. if v == nil {
  43169. return
  43170. }
  43171. return *v, true
  43172. }
  43173. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  43174. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43176. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43177. if !m.op.Is(OpUpdateOne) {
  43178. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43179. }
  43180. if m.id == nil || m.oldValue == nil {
  43181. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43182. }
  43183. oldValue, err := m.oldValue(ctx)
  43184. if err != nil {
  43185. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43186. }
  43187. return oldValue.DeletedAt, nil
  43188. }
  43189. // ClearDeletedAt clears the value of the "deleted_at" field.
  43190. func (m *WxCardUserMutation) ClearDeletedAt() {
  43191. m.deleted_at = nil
  43192. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  43193. }
  43194. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43195. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  43196. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  43197. return ok
  43198. }
  43199. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43200. func (m *WxCardUserMutation) ResetDeletedAt() {
  43201. m.deleted_at = nil
  43202. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  43203. }
  43204. // SetWxid sets the "wxid" field.
  43205. func (m *WxCardUserMutation) SetWxid(s string) {
  43206. m.wxid = &s
  43207. }
  43208. // Wxid returns the value of the "wxid" field in the mutation.
  43209. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  43210. v := m.wxid
  43211. if v == nil {
  43212. return
  43213. }
  43214. return *v, true
  43215. }
  43216. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  43217. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43219. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  43220. if !m.op.Is(OpUpdateOne) {
  43221. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43222. }
  43223. if m.id == nil || m.oldValue == nil {
  43224. return v, errors.New("OldWxid requires an ID field in the mutation")
  43225. }
  43226. oldValue, err := m.oldValue(ctx)
  43227. if err != nil {
  43228. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43229. }
  43230. return oldValue.Wxid, nil
  43231. }
  43232. // ResetWxid resets all changes to the "wxid" field.
  43233. func (m *WxCardUserMutation) ResetWxid() {
  43234. m.wxid = nil
  43235. }
  43236. // SetAccount sets the "account" field.
  43237. func (m *WxCardUserMutation) SetAccount(s string) {
  43238. m.account = &s
  43239. }
  43240. // Account returns the value of the "account" field in the mutation.
  43241. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  43242. v := m.account
  43243. if v == nil {
  43244. return
  43245. }
  43246. return *v, true
  43247. }
  43248. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  43249. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43251. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  43252. if !m.op.Is(OpUpdateOne) {
  43253. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43254. }
  43255. if m.id == nil || m.oldValue == nil {
  43256. return v, errors.New("OldAccount requires an ID field in the mutation")
  43257. }
  43258. oldValue, err := m.oldValue(ctx)
  43259. if err != nil {
  43260. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43261. }
  43262. return oldValue.Account, nil
  43263. }
  43264. // ResetAccount resets all changes to the "account" field.
  43265. func (m *WxCardUserMutation) ResetAccount() {
  43266. m.account = nil
  43267. }
  43268. // SetAvatar sets the "avatar" field.
  43269. func (m *WxCardUserMutation) SetAvatar(s string) {
  43270. m.avatar = &s
  43271. }
  43272. // Avatar returns the value of the "avatar" field in the mutation.
  43273. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  43274. v := m.avatar
  43275. if v == nil {
  43276. return
  43277. }
  43278. return *v, true
  43279. }
  43280. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  43281. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43283. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43284. if !m.op.Is(OpUpdateOne) {
  43285. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43286. }
  43287. if m.id == nil || m.oldValue == nil {
  43288. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43289. }
  43290. oldValue, err := m.oldValue(ctx)
  43291. if err != nil {
  43292. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43293. }
  43294. return oldValue.Avatar, nil
  43295. }
  43296. // ResetAvatar resets all changes to the "avatar" field.
  43297. func (m *WxCardUserMutation) ResetAvatar() {
  43298. m.avatar = nil
  43299. }
  43300. // SetNickname sets the "nickname" field.
  43301. func (m *WxCardUserMutation) SetNickname(s string) {
  43302. m.nickname = &s
  43303. }
  43304. // Nickname returns the value of the "nickname" field in the mutation.
  43305. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  43306. v := m.nickname
  43307. if v == nil {
  43308. return
  43309. }
  43310. return *v, true
  43311. }
  43312. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  43313. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43315. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  43316. if !m.op.Is(OpUpdateOne) {
  43317. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43318. }
  43319. if m.id == nil || m.oldValue == nil {
  43320. return v, errors.New("OldNickname requires an ID field in the mutation")
  43321. }
  43322. oldValue, err := m.oldValue(ctx)
  43323. if err != nil {
  43324. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43325. }
  43326. return oldValue.Nickname, nil
  43327. }
  43328. // ResetNickname resets all changes to the "nickname" field.
  43329. func (m *WxCardUserMutation) ResetNickname() {
  43330. m.nickname = nil
  43331. }
  43332. // SetRemark sets the "remark" field.
  43333. func (m *WxCardUserMutation) SetRemark(s string) {
  43334. m.remark = &s
  43335. }
  43336. // Remark returns the value of the "remark" field in the mutation.
  43337. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  43338. v := m.remark
  43339. if v == nil {
  43340. return
  43341. }
  43342. return *v, true
  43343. }
  43344. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  43345. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43347. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  43348. if !m.op.Is(OpUpdateOne) {
  43349. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  43350. }
  43351. if m.id == nil || m.oldValue == nil {
  43352. return v, errors.New("OldRemark requires an ID field in the mutation")
  43353. }
  43354. oldValue, err := m.oldValue(ctx)
  43355. if err != nil {
  43356. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  43357. }
  43358. return oldValue.Remark, nil
  43359. }
  43360. // ResetRemark resets all changes to the "remark" field.
  43361. func (m *WxCardUserMutation) ResetRemark() {
  43362. m.remark = nil
  43363. }
  43364. // SetPhone sets the "phone" field.
  43365. func (m *WxCardUserMutation) SetPhone(s string) {
  43366. m.phone = &s
  43367. }
  43368. // Phone returns the value of the "phone" field in the mutation.
  43369. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  43370. v := m.phone
  43371. if v == nil {
  43372. return
  43373. }
  43374. return *v, true
  43375. }
  43376. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  43377. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43379. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  43380. if !m.op.Is(OpUpdateOne) {
  43381. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43382. }
  43383. if m.id == nil || m.oldValue == nil {
  43384. return v, errors.New("OldPhone requires an ID field in the mutation")
  43385. }
  43386. oldValue, err := m.oldValue(ctx)
  43387. if err != nil {
  43388. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43389. }
  43390. return oldValue.Phone, nil
  43391. }
  43392. // ResetPhone resets all changes to the "phone" field.
  43393. func (m *WxCardUserMutation) ResetPhone() {
  43394. m.phone = nil
  43395. }
  43396. // SetOpenID sets the "open_id" field.
  43397. func (m *WxCardUserMutation) SetOpenID(s string) {
  43398. m.open_id = &s
  43399. }
  43400. // OpenID returns the value of the "open_id" field in the mutation.
  43401. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  43402. v := m.open_id
  43403. if v == nil {
  43404. return
  43405. }
  43406. return *v, true
  43407. }
  43408. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  43409. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43411. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  43412. if !m.op.Is(OpUpdateOne) {
  43413. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  43414. }
  43415. if m.id == nil || m.oldValue == nil {
  43416. return v, errors.New("OldOpenID requires an ID field in the mutation")
  43417. }
  43418. oldValue, err := m.oldValue(ctx)
  43419. if err != nil {
  43420. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  43421. }
  43422. return oldValue.OpenID, nil
  43423. }
  43424. // ResetOpenID resets all changes to the "open_id" field.
  43425. func (m *WxCardUserMutation) ResetOpenID() {
  43426. m.open_id = nil
  43427. }
  43428. // SetUnionID sets the "union_id" field.
  43429. func (m *WxCardUserMutation) SetUnionID(s string) {
  43430. m.union_id = &s
  43431. }
  43432. // UnionID returns the value of the "union_id" field in the mutation.
  43433. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  43434. v := m.union_id
  43435. if v == nil {
  43436. return
  43437. }
  43438. return *v, true
  43439. }
  43440. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  43441. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43443. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  43444. if !m.op.Is(OpUpdateOne) {
  43445. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  43446. }
  43447. if m.id == nil || m.oldValue == nil {
  43448. return v, errors.New("OldUnionID requires an ID field in the mutation")
  43449. }
  43450. oldValue, err := m.oldValue(ctx)
  43451. if err != nil {
  43452. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  43453. }
  43454. return oldValue.UnionID, nil
  43455. }
  43456. // ResetUnionID resets all changes to the "union_id" field.
  43457. func (m *WxCardUserMutation) ResetUnionID() {
  43458. m.union_id = nil
  43459. }
  43460. // SetSessionKey sets the "session_key" field.
  43461. func (m *WxCardUserMutation) SetSessionKey(s string) {
  43462. m.session_key = &s
  43463. }
  43464. // SessionKey returns the value of the "session_key" field in the mutation.
  43465. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  43466. v := m.session_key
  43467. if v == nil {
  43468. return
  43469. }
  43470. return *v, true
  43471. }
  43472. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  43473. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43475. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  43476. if !m.op.Is(OpUpdateOne) {
  43477. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  43478. }
  43479. if m.id == nil || m.oldValue == nil {
  43480. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  43481. }
  43482. oldValue, err := m.oldValue(ctx)
  43483. if err != nil {
  43484. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  43485. }
  43486. return oldValue.SessionKey, nil
  43487. }
  43488. // ResetSessionKey resets all changes to the "session_key" field.
  43489. func (m *WxCardUserMutation) ResetSessionKey() {
  43490. m.session_key = nil
  43491. }
  43492. // SetIsVip sets the "is_vip" field.
  43493. func (m *WxCardUserMutation) SetIsVip(i int) {
  43494. m.is_vip = &i
  43495. m.addis_vip = nil
  43496. }
  43497. // IsVip returns the value of the "is_vip" field in the mutation.
  43498. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  43499. v := m.is_vip
  43500. if v == nil {
  43501. return
  43502. }
  43503. return *v, true
  43504. }
  43505. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  43506. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43508. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  43509. if !m.op.Is(OpUpdateOne) {
  43510. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  43511. }
  43512. if m.id == nil || m.oldValue == nil {
  43513. return v, errors.New("OldIsVip requires an ID field in the mutation")
  43514. }
  43515. oldValue, err := m.oldValue(ctx)
  43516. if err != nil {
  43517. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  43518. }
  43519. return oldValue.IsVip, nil
  43520. }
  43521. // AddIsVip adds i to the "is_vip" field.
  43522. func (m *WxCardUserMutation) AddIsVip(i int) {
  43523. if m.addis_vip != nil {
  43524. *m.addis_vip += i
  43525. } else {
  43526. m.addis_vip = &i
  43527. }
  43528. }
  43529. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  43530. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  43531. v := m.addis_vip
  43532. if v == nil {
  43533. return
  43534. }
  43535. return *v, true
  43536. }
  43537. // ResetIsVip resets all changes to the "is_vip" field.
  43538. func (m *WxCardUserMutation) ResetIsVip() {
  43539. m.is_vip = nil
  43540. m.addis_vip = nil
  43541. }
  43542. // Where appends a list predicates to the WxCardUserMutation builder.
  43543. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  43544. m.predicates = append(m.predicates, ps...)
  43545. }
  43546. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  43547. // users can use type-assertion to append predicates that do not depend on any generated package.
  43548. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  43549. p := make([]predicate.WxCardUser, len(ps))
  43550. for i := range ps {
  43551. p[i] = ps[i]
  43552. }
  43553. m.Where(p...)
  43554. }
  43555. // Op returns the operation name.
  43556. func (m *WxCardUserMutation) Op() Op {
  43557. return m.op
  43558. }
  43559. // SetOp allows setting the mutation operation.
  43560. func (m *WxCardUserMutation) SetOp(op Op) {
  43561. m.op = op
  43562. }
  43563. // Type returns the node type of this mutation (WxCardUser).
  43564. func (m *WxCardUserMutation) Type() string {
  43565. return m.typ
  43566. }
  43567. // Fields returns all fields that were changed during this mutation. Note that in
  43568. // order to get all numeric fields that were incremented/decremented, call
  43569. // AddedFields().
  43570. func (m *WxCardUserMutation) Fields() []string {
  43571. fields := make([]string, 0, 13)
  43572. if m.created_at != nil {
  43573. fields = append(fields, wxcarduser.FieldCreatedAt)
  43574. }
  43575. if m.updated_at != nil {
  43576. fields = append(fields, wxcarduser.FieldUpdatedAt)
  43577. }
  43578. if m.deleted_at != nil {
  43579. fields = append(fields, wxcarduser.FieldDeletedAt)
  43580. }
  43581. if m.wxid != nil {
  43582. fields = append(fields, wxcarduser.FieldWxid)
  43583. }
  43584. if m.account != nil {
  43585. fields = append(fields, wxcarduser.FieldAccount)
  43586. }
  43587. if m.avatar != nil {
  43588. fields = append(fields, wxcarduser.FieldAvatar)
  43589. }
  43590. if m.nickname != nil {
  43591. fields = append(fields, wxcarduser.FieldNickname)
  43592. }
  43593. if m.remark != nil {
  43594. fields = append(fields, wxcarduser.FieldRemark)
  43595. }
  43596. if m.phone != nil {
  43597. fields = append(fields, wxcarduser.FieldPhone)
  43598. }
  43599. if m.open_id != nil {
  43600. fields = append(fields, wxcarduser.FieldOpenID)
  43601. }
  43602. if m.union_id != nil {
  43603. fields = append(fields, wxcarduser.FieldUnionID)
  43604. }
  43605. if m.session_key != nil {
  43606. fields = append(fields, wxcarduser.FieldSessionKey)
  43607. }
  43608. if m.is_vip != nil {
  43609. fields = append(fields, wxcarduser.FieldIsVip)
  43610. }
  43611. return fields
  43612. }
  43613. // Field returns the value of a field with the given name. The second boolean
  43614. // return value indicates that this field was not set, or was not defined in the
  43615. // schema.
  43616. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  43617. switch name {
  43618. case wxcarduser.FieldCreatedAt:
  43619. return m.CreatedAt()
  43620. case wxcarduser.FieldUpdatedAt:
  43621. return m.UpdatedAt()
  43622. case wxcarduser.FieldDeletedAt:
  43623. return m.DeletedAt()
  43624. case wxcarduser.FieldWxid:
  43625. return m.Wxid()
  43626. case wxcarduser.FieldAccount:
  43627. return m.Account()
  43628. case wxcarduser.FieldAvatar:
  43629. return m.Avatar()
  43630. case wxcarduser.FieldNickname:
  43631. return m.Nickname()
  43632. case wxcarduser.FieldRemark:
  43633. return m.Remark()
  43634. case wxcarduser.FieldPhone:
  43635. return m.Phone()
  43636. case wxcarduser.FieldOpenID:
  43637. return m.OpenID()
  43638. case wxcarduser.FieldUnionID:
  43639. return m.UnionID()
  43640. case wxcarduser.FieldSessionKey:
  43641. return m.SessionKey()
  43642. case wxcarduser.FieldIsVip:
  43643. return m.IsVip()
  43644. }
  43645. return nil, false
  43646. }
  43647. // OldField returns the old value of the field from the database. An error is
  43648. // returned if the mutation operation is not UpdateOne, or the query to the
  43649. // database failed.
  43650. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43651. switch name {
  43652. case wxcarduser.FieldCreatedAt:
  43653. return m.OldCreatedAt(ctx)
  43654. case wxcarduser.FieldUpdatedAt:
  43655. return m.OldUpdatedAt(ctx)
  43656. case wxcarduser.FieldDeletedAt:
  43657. return m.OldDeletedAt(ctx)
  43658. case wxcarduser.FieldWxid:
  43659. return m.OldWxid(ctx)
  43660. case wxcarduser.FieldAccount:
  43661. return m.OldAccount(ctx)
  43662. case wxcarduser.FieldAvatar:
  43663. return m.OldAvatar(ctx)
  43664. case wxcarduser.FieldNickname:
  43665. return m.OldNickname(ctx)
  43666. case wxcarduser.FieldRemark:
  43667. return m.OldRemark(ctx)
  43668. case wxcarduser.FieldPhone:
  43669. return m.OldPhone(ctx)
  43670. case wxcarduser.FieldOpenID:
  43671. return m.OldOpenID(ctx)
  43672. case wxcarduser.FieldUnionID:
  43673. return m.OldUnionID(ctx)
  43674. case wxcarduser.FieldSessionKey:
  43675. return m.OldSessionKey(ctx)
  43676. case wxcarduser.FieldIsVip:
  43677. return m.OldIsVip(ctx)
  43678. }
  43679. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  43680. }
  43681. // SetField sets the value of a field with the given name. It returns an error if
  43682. // the field is not defined in the schema, or if the type mismatched the field
  43683. // type.
  43684. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  43685. switch name {
  43686. case wxcarduser.FieldCreatedAt:
  43687. v, ok := value.(time.Time)
  43688. if !ok {
  43689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43690. }
  43691. m.SetCreatedAt(v)
  43692. return nil
  43693. case wxcarduser.FieldUpdatedAt:
  43694. v, ok := value.(time.Time)
  43695. if !ok {
  43696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43697. }
  43698. m.SetUpdatedAt(v)
  43699. return nil
  43700. case wxcarduser.FieldDeletedAt:
  43701. v, ok := value.(time.Time)
  43702. if !ok {
  43703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43704. }
  43705. m.SetDeletedAt(v)
  43706. return nil
  43707. case wxcarduser.FieldWxid:
  43708. v, ok := value.(string)
  43709. if !ok {
  43710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43711. }
  43712. m.SetWxid(v)
  43713. return nil
  43714. case wxcarduser.FieldAccount:
  43715. v, ok := value.(string)
  43716. if !ok {
  43717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43718. }
  43719. m.SetAccount(v)
  43720. return nil
  43721. case wxcarduser.FieldAvatar:
  43722. v, ok := value.(string)
  43723. if !ok {
  43724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43725. }
  43726. m.SetAvatar(v)
  43727. return nil
  43728. case wxcarduser.FieldNickname:
  43729. v, ok := value.(string)
  43730. if !ok {
  43731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43732. }
  43733. m.SetNickname(v)
  43734. return nil
  43735. case wxcarduser.FieldRemark:
  43736. v, ok := value.(string)
  43737. if !ok {
  43738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43739. }
  43740. m.SetRemark(v)
  43741. return nil
  43742. case wxcarduser.FieldPhone:
  43743. v, ok := value.(string)
  43744. if !ok {
  43745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43746. }
  43747. m.SetPhone(v)
  43748. return nil
  43749. case wxcarduser.FieldOpenID:
  43750. v, ok := value.(string)
  43751. if !ok {
  43752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43753. }
  43754. m.SetOpenID(v)
  43755. return nil
  43756. case wxcarduser.FieldUnionID:
  43757. v, ok := value.(string)
  43758. if !ok {
  43759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43760. }
  43761. m.SetUnionID(v)
  43762. return nil
  43763. case wxcarduser.FieldSessionKey:
  43764. v, ok := value.(string)
  43765. if !ok {
  43766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43767. }
  43768. m.SetSessionKey(v)
  43769. return nil
  43770. case wxcarduser.FieldIsVip:
  43771. v, ok := value.(int)
  43772. if !ok {
  43773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43774. }
  43775. m.SetIsVip(v)
  43776. return nil
  43777. }
  43778. return fmt.Errorf("unknown WxCardUser field %s", name)
  43779. }
  43780. // AddedFields returns all numeric fields that were incremented/decremented during
  43781. // this mutation.
  43782. func (m *WxCardUserMutation) AddedFields() []string {
  43783. var fields []string
  43784. if m.addis_vip != nil {
  43785. fields = append(fields, wxcarduser.FieldIsVip)
  43786. }
  43787. return fields
  43788. }
  43789. // AddedField returns the numeric value that was incremented/decremented on a field
  43790. // with the given name. The second boolean return value indicates that this field
  43791. // was not set, or was not defined in the schema.
  43792. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  43793. switch name {
  43794. case wxcarduser.FieldIsVip:
  43795. return m.AddedIsVip()
  43796. }
  43797. return nil, false
  43798. }
  43799. // AddField adds the value to the field with the given name. It returns an error if
  43800. // the field is not defined in the schema, or if the type mismatched the field
  43801. // type.
  43802. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  43803. switch name {
  43804. case wxcarduser.FieldIsVip:
  43805. v, ok := value.(int)
  43806. if !ok {
  43807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43808. }
  43809. m.AddIsVip(v)
  43810. return nil
  43811. }
  43812. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  43813. }
  43814. // ClearedFields returns all nullable fields that were cleared during this
  43815. // mutation.
  43816. func (m *WxCardUserMutation) ClearedFields() []string {
  43817. var fields []string
  43818. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  43819. fields = append(fields, wxcarduser.FieldDeletedAt)
  43820. }
  43821. return fields
  43822. }
  43823. // FieldCleared returns a boolean indicating if a field with the given name was
  43824. // cleared in this mutation.
  43825. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  43826. _, ok := m.clearedFields[name]
  43827. return ok
  43828. }
  43829. // ClearField clears the value of the field with the given name. It returns an
  43830. // error if the field is not defined in the schema.
  43831. func (m *WxCardUserMutation) ClearField(name string) error {
  43832. switch name {
  43833. case wxcarduser.FieldDeletedAt:
  43834. m.ClearDeletedAt()
  43835. return nil
  43836. }
  43837. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  43838. }
  43839. // ResetField resets all changes in the mutation for the field with the given name.
  43840. // It returns an error if the field is not defined in the schema.
  43841. func (m *WxCardUserMutation) ResetField(name string) error {
  43842. switch name {
  43843. case wxcarduser.FieldCreatedAt:
  43844. m.ResetCreatedAt()
  43845. return nil
  43846. case wxcarduser.FieldUpdatedAt:
  43847. m.ResetUpdatedAt()
  43848. return nil
  43849. case wxcarduser.FieldDeletedAt:
  43850. m.ResetDeletedAt()
  43851. return nil
  43852. case wxcarduser.FieldWxid:
  43853. m.ResetWxid()
  43854. return nil
  43855. case wxcarduser.FieldAccount:
  43856. m.ResetAccount()
  43857. return nil
  43858. case wxcarduser.FieldAvatar:
  43859. m.ResetAvatar()
  43860. return nil
  43861. case wxcarduser.FieldNickname:
  43862. m.ResetNickname()
  43863. return nil
  43864. case wxcarduser.FieldRemark:
  43865. m.ResetRemark()
  43866. return nil
  43867. case wxcarduser.FieldPhone:
  43868. m.ResetPhone()
  43869. return nil
  43870. case wxcarduser.FieldOpenID:
  43871. m.ResetOpenID()
  43872. return nil
  43873. case wxcarduser.FieldUnionID:
  43874. m.ResetUnionID()
  43875. return nil
  43876. case wxcarduser.FieldSessionKey:
  43877. m.ResetSessionKey()
  43878. return nil
  43879. case wxcarduser.FieldIsVip:
  43880. m.ResetIsVip()
  43881. return nil
  43882. }
  43883. return fmt.Errorf("unknown WxCardUser field %s", name)
  43884. }
  43885. // AddedEdges returns all edge names that were set/added in this mutation.
  43886. func (m *WxCardUserMutation) AddedEdges() []string {
  43887. edges := make([]string, 0, 0)
  43888. return edges
  43889. }
  43890. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43891. // name in this mutation.
  43892. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  43893. return nil
  43894. }
  43895. // RemovedEdges returns all edge names that were removed in this mutation.
  43896. func (m *WxCardUserMutation) RemovedEdges() []string {
  43897. edges := make([]string, 0, 0)
  43898. return edges
  43899. }
  43900. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43901. // the given name in this mutation.
  43902. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  43903. return nil
  43904. }
  43905. // ClearedEdges returns all edge names that were cleared in this mutation.
  43906. func (m *WxCardUserMutation) ClearedEdges() []string {
  43907. edges := make([]string, 0, 0)
  43908. return edges
  43909. }
  43910. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43911. // was cleared in this mutation.
  43912. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  43913. return false
  43914. }
  43915. // ClearEdge clears the value of the edge with the given name. It returns an error
  43916. // if that edge is not defined in the schema.
  43917. func (m *WxCardUserMutation) ClearEdge(name string) error {
  43918. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  43919. }
  43920. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43921. // It returns an error if the edge is not defined in the schema.
  43922. func (m *WxCardUserMutation) ResetEdge(name string) error {
  43923. return fmt.Errorf("unknown WxCardUser edge %s", name)
  43924. }
  43925. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  43926. type WxCardVisitMutation struct {
  43927. config
  43928. op Op
  43929. typ string
  43930. id *uint64
  43931. created_at *time.Time
  43932. updated_at *time.Time
  43933. deleted_at *time.Time
  43934. user_id *uint64
  43935. adduser_id *int64
  43936. bot_id *uint64
  43937. addbot_id *int64
  43938. bot_type *uint8
  43939. addbot_type *int8
  43940. clearedFields map[string]struct{}
  43941. done bool
  43942. oldValue func(context.Context) (*WxCardVisit, error)
  43943. predicates []predicate.WxCardVisit
  43944. }
  43945. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  43946. // wxcardvisitOption allows management of the mutation configuration using functional options.
  43947. type wxcardvisitOption func(*WxCardVisitMutation)
  43948. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  43949. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  43950. m := &WxCardVisitMutation{
  43951. config: c,
  43952. op: op,
  43953. typ: TypeWxCardVisit,
  43954. clearedFields: make(map[string]struct{}),
  43955. }
  43956. for _, opt := range opts {
  43957. opt(m)
  43958. }
  43959. return m
  43960. }
  43961. // withWxCardVisitID sets the ID field of the mutation.
  43962. func withWxCardVisitID(id uint64) wxcardvisitOption {
  43963. return func(m *WxCardVisitMutation) {
  43964. var (
  43965. err error
  43966. once sync.Once
  43967. value *WxCardVisit
  43968. )
  43969. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  43970. once.Do(func() {
  43971. if m.done {
  43972. err = errors.New("querying old values post mutation is not allowed")
  43973. } else {
  43974. value, err = m.Client().WxCardVisit.Get(ctx, id)
  43975. }
  43976. })
  43977. return value, err
  43978. }
  43979. m.id = &id
  43980. }
  43981. }
  43982. // withWxCardVisit sets the old WxCardVisit of the mutation.
  43983. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  43984. return func(m *WxCardVisitMutation) {
  43985. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  43986. return node, nil
  43987. }
  43988. m.id = &node.ID
  43989. }
  43990. }
  43991. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43992. // executed in a transaction (ent.Tx), a transactional client is returned.
  43993. func (m WxCardVisitMutation) Client() *Client {
  43994. client := &Client{config: m.config}
  43995. client.init()
  43996. return client
  43997. }
  43998. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43999. // it returns an error otherwise.
  44000. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  44001. if _, ok := m.driver.(*txDriver); !ok {
  44002. return nil, errors.New("ent: mutation is not running in a transaction")
  44003. }
  44004. tx := &Tx{config: m.config}
  44005. tx.init()
  44006. return tx, nil
  44007. }
  44008. // SetID sets the value of the id field. Note that this
  44009. // operation is only accepted on creation of WxCardVisit entities.
  44010. func (m *WxCardVisitMutation) SetID(id uint64) {
  44011. m.id = &id
  44012. }
  44013. // ID returns the ID value in the mutation. Note that the ID is only available
  44014. // if it was provided to the builder or after it was returned from the database.
  44015. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  44016. if m.id == nil {
  44017. return
  44018. }
  44019. return *m.id, true
  44020. }
  44021. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44022. // That means, if the mutation is applied within a transaction with an isolation level such
  44023. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44024. // or updated by the mutation.
  44025. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  44026. switch {
  44027. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44028. id, exists := m.ID()
  44029. if exists {
  44030. return []uint64{id}, nil
  44031. }
  44032. fallthrough
  44033. case m.op.Is(OpUpdate | OpDelete):
  44034. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  44035. default:
  44036. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44037. }
  44038. }
  44039. // SetCreatedAt sets the "created_at" field.
  44040. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  44041. m.created_at = &t
  44042. }
  44043. // CreatedAt returns the value of the "created_at" field in the mutation.
  44044. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  44045. v := m.created_at
  44046. if v == nil {
  44047. return
  44048. }
  44049. return *v, true
  44050. }
  44051. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  44052. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44054. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44055. if !m.op.Is(OpUpdateOne) {
  44056. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44057. }
  44058. if m.id == nil || m.oldValue == nil {
  44059. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44060. }
  44061. oldValue, err := m.oldValue(ctx)
  44062. if err != nil {
  44063. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44064. }
  44065. return oldValue.CreatedAt, nil
  44066. }
  44067. // ResetCreatedAt resets all changes to the "created_at" field.
  44068. func (m *WxCardVisitMutation) ResetCreatedAt() {
  44069. m.created_at = nil
  44070. }
  44071. // SetUpdatedAt sets the "updated_at" field.
  44072. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  44073. m.updated_at = &t
  44074. }
  44075. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44076. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  44077. v := m.updated_at
  44078. if v == nil {
  44079. return
  44080. }
  44081. return *v, true
  44082. }
  44083. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  44084. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44086. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44087. if !m.op.Is(OpUpdateOne) {
  44088. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44089. }
  44090. if m.id == nil || m.oldValue == nil {
  44091. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44092. }
  44093. oldValue, err := m.oldValue(ctx)
  44094. if err != nil {
  44095. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44096. }
  44097. return oldValue.UpdatedAt, nil
  44098. }
  44099. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44100. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  44101. m.updated_at = nil
  44102. }
  44103. // SetDeletedAt sets the "deleted_at" field.
  44104. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  44105. m.deleted_at = &t
  44106. }
  44107. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44108. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  44109. v := m.deleted_at
  44110. if v == nil {
  44111. return
  44112. }
  44113. return *v, true
  44114. }
  44115. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  44116. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44118. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44119. if !m.op.Is(OpUpdateOne) {
  44120. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44121. }
  44122. if m.id == nil || m.oldValue == nil {
  44123. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44124. }
  44125. oldValue, err := m.oldValue(ctx)
  44126. if err != nil {
  44127. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44128. }
  44129. return oldValue.DeletedAt, nil
  44130. }
  44131. // ClearDeletedAt clears the value of the "deleted_at" field.
  44132. func (m *WxCardVisitMutation) ClearDeletedAt() {
  44133. m.deleted_at = nil
  44134. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  44135. }
  44136. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44137. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  44138. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  44139. return ok
  44140. }
  44141. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44142. func (m *WxCardVisitMutation) ResetDeletedAt() {
  44143. m.deleted_at = nil
  44144. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  44145. }
  44146. // SetUserID sets the "user_id" field.
  44147. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  44148. m.user_id = &u
  44149. m.adduser_id = nil
  44150. }
  44151. // UserID returns the value of the "user_id" field in the mutation.
  44152. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  44153. v := m.user_id
  44154. if v == nil {
  44155. return
  44156. }
  44157. return *v, true
  44158. }
  44159. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  44160. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44162. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44163. if !m.op.Is(OpUpdateOne) {
  44164. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44165. }
  44166. if m.id == nil || m.oldValue == nil {
  44167. return v, errors.New("OldUserID requires an ID field in the mutation")
  44168. }
  44169. oldValue, err := m.oldValue(ctx)
  44170. if err != nil {
  44171. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44172. }
  44173. return oldValue.UserID, nil
  44174. }
  44175. // AddUserID adds u to the "user_id" field.
  44176. func (m *WxCardVisitMutation) AddUserID(u int64) {
  44177. if m.adduser_id != nil {
  44178. *m.adduser_id += u
  44179. } else {
  44180. m.adduser_id = &u
  44181. }
  44182. }
  44183. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44184. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  44185. v := m.adduser_id
  44186. if v == nil {
  44187. return
  44188. }
  44189. return *v, true
  44190. }
  44191. // ClearUserID clears the value of the "user_id" field.
  44192. func (m *WxCardVisitMutation) ClearUserID() {
  44193. m.user_id = nil
  44194. m.adduser_id = nil
  44195. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  44196. }
  44197. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44198. func (m *WxCardVisitMutation) UserIDCleared() bool {
  44199. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  44200. return ok
  44201. }
  44202. // ResetUserID resets all changes to the "user_id" field.
  44203. func (m *WxCardVisitMutation) ResetUserID() {
  44204. m.user_id = nil
  44205. m.adduser_id = nil
  44206. delete(m.clearedFields, wxcardvisit.FieldUserID)
  44207. }
  44208. // SetBotID sets the "bot_id" field.
  44209. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  44210. m.bot_id = &u
  44211. m.addbot_id = nil
  44212. }
  44213. // BotID returns the value of the "bot_id" field in the mutation.
  44214. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  44215. v := m.bot_id
  44216. if v == nil {
  44217. return
  44218. }
  44219. return *v, true
  44220. }
  44221. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  44222. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44224. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  44225. if !m.op.Is(OpUpdateOne) {
  44226. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  44227. }
  44228. if m.id == nil || m.oldValue == nil {
  44229. return v, errors.New("OldBotID requires an ID field in the mutation")
  44230. }
  44231. oldValue, err := m.oldValue(ctx)
  44232. if err != nil {
  44233. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  44234. }
  44235. return oldValue.BotID, nil
  44236. }
  44237. // AddBotID adds u to the "bot_id" field.
  44238. func (m *WxCardVisitMutation) AddBotID(u int64) {
  44239. if m.addbot_id != nil {
  44240. *m.addbot_id += u
  44241. } else {
  44242. m.addbot_id = &u
  44243. }
  44244. }
  44245. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  44246. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  44247. v := m.addbot_id
  44248. if v == nil {
  44249. return
  44250. }
  44251. return *v, true
  44252. }
  44253. // ResetBotID resets all changes to the "bot_id" field.
  44254. func (m *WxCardVisitMutation) ResetBotID() {
  44255. m.bot_id = nil
  44256. m.addbot_id = nil
  44257. }
  44258. // SetBotType sets the "bot_type" field.
  44259. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  44260. m.bot_type = &u
  44261. m.addbot_type = nil
  44262. }
  44263. // BotType returns the value of the "bot_type" field in the mutation.
  44264. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  44265. v := m.bot_type
  44266. if v == nil {
  44267. return
  44268. }
  44269. return *v, true
  44270. }
  44271. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  44272. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44274. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  44275. if !m.op.Is(OpUpdateOne) {
  44276. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  44277. }
  44278. if m.id == nil || m.oldValue == nil {
  44279. return v, errors.New("OldBotType requires an ID field in the mutation")
  44280. }
  44281. oldValue, err := m.oldValue(ctx)
  44282. if err != nil {
  44283. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  44284. }
  44285. return oldValue.BotType, nil
  44286. }
  44287. // AddBotType adds u to the "bot_type" field.
  44288. func (m *WxCardVisitMutation) AddBotType(u int8) {
  44289. if m.addbot_type != nil {
  44290. *m.addbot_type += u
  44291. } else {
  44292. m.addbot_type = &u
  44293. }
  44294. }
  44295. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  44296. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  44297. v := m.addbot_type
  44298. if v == nil {
  44299. return
  44300. }
  44301. return *v, true
  44302. }
  44303. // ResetBotType resets all changes to the "bot_type" field.
  44304. func (m *WxCardVisitMutation) ResetBotType() {
  44305. m.bot_type = nil
  44306. m.addbot_type = nil
  44307. }
  44308. // Where appends a list predicates to the WxCardVisitMutation builder.
  44309. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  44310. m.predicates = append(m.predicates, ps...)
  44311. }
  44312. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  44313. // users can use type-assertion to append predicates that do not depend on any generated package.
  44314. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  44315. p := make([]predicate.WxCardVisit, len(ps))
  44316. for i := range ps {
  44317. p[i] = ps[i]
  44318. }
  44319. m.Where(p...)
  44320. }
  44321. // Op returns the operation name.
  44322. func (m *WxCardVisitMutation) Op() Op {
  44323. return m.op
  44324. }
  44325. // SetOp allows setting the mutation operation.
  44326. func (m *WxCardVisitMutation) SetOp(op Op) {
  44327. m.op = op
  44328. }
  44329. // Type returns the node type of this mutation (WxCardVisit).
  44330. func (m *WxCardVisitMutation) Type() string {
  44331. return m.typ
  44332. }
  44333. // Fields returns all fields that were changed during this mutation. Note that in
  44334. // order to get all numeric fields that were incremented/decremented, call
  44335. // AddedFields().
  44336. func (m *WxCardVisitMutation) Fields() []string {
  44337. fields := make([]string, 0, 6)
  44338. if m.created_at != nil {
  44339. fields = append(fields, wxcardvisit.FieldCreatedAt)
  44340. }
  44341. if m.updated_at != nil {
  44342. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  44343. }
  44344. if m.deleted_at != nil {
  44345. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44346. }
  44347. if m.user_id != nil {
  44348. fields = append(fields, wxcardvisit.FieldUserID)
  44349. }
  44350. if m.bot_id != nil {
  44351. fields = append(fields, wxcardvisit.FieldBotID)
  44352. }
  44353. if m.bot_type != nil {
  44354. fields = append(fields, wxcardvisit.FieldBotType)
  44355. }
  44356. return fields
  44357. }
  44358. // Field returns the value of a field with the given name. The second boolean
  44359. // return value indicates that this field was not set, or was not defined in the
  44360. // schema.
  44361. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  44362. switch name {
  44363. case wxcardvisit.FieldCreatedAt:
  44364. return m.CreatedAt()
  44365. case wxcardvisit.FieldUpdatedAt:
  44366. return m.UpdatedAt()
  44367. case wxcardvisit.FieldDeletedAt:
  44368. return m.DeletedAt()
  44369. case wxcardvisit.FieldUserID:
  44370. return m.UserID()
  44371. case wxcardvisit.FieldBotID:
  44372. return m.BotID()
  44373. case wxcardvisit.FieldBotType:
  44374. return m.BotType()
  44375. }
  44376. return nil, false
  44377. }
  44378. // OldField returns the old value of the field from the database. An error is
  44379. // returned if the mutation operation is not UpdateOne, or the query to the
  44380. // database failed.
  44381. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44382. switch name {
  44383. case wxcardvisit.FieldCreatedAt:
  44384. return m.OldCreatedAt(ctx)
  44385. case wxcardvisit.FieldUpdatedAt:
  44386. return m.OldUpdatedAt(ctx)
  44387. case wxcardvisit.FieldDeletedAt:
  44388. return m.OldDeletedAt(ctx)
  44389. case wxcardvisit.FieldUserID:
  44390. return m.OldUserID(ctx)
  44391. case wxcardvisit.FieldBotID:
  44392. return m.OldBotID(ctx)
  44393. case wxcardvisit.FieldBotType:
  44394. return m.OldBotType(ctx)
  44395. }
  44396. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  44397. }
  44398. // SetField sets the value of a field with the given name. It returns an error if
  44399. // the field is not defined in the schema, or if the type mismatched the field
  44400. // type.
  44401. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  44402. switch name {
  44403. case wxcardvisit.FieldCreatedAt:
  44404. v, ok := value.(time.Time)
  44405. if !ok {
  44406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44407. }
  44408. m.SetCreatedAt(v)
  44409. return nil
  44410. case wxcardvisit.FieldUpdatedAt:
  44411. v, ok := value.(time.Time)
  44412. if !ok {
  44413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44414. }
  44415. m.SetUpdatedAt(v)
  44416. return nil
  44417. case wxcardvisit.FieldDeletedAt:
  44418. v, ok := value.(time.Time)
  44419. if !ok {
  44420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44421. }
  44422. m.SetDeletedAt(v)
  44423. return nil
  44424. case wxcardvisit.FieldUserID:
  44425. v, ok := value.(uint64)
  44426. if !ok {
  44427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44428. }
  44429. m.SetUserID(v)
  44430. return nil
  44431. case wxcardvisit.FieldBotID:
  44432. v, ok := value.(uint64)
  44433. if !ok {
  44434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44435. }
  44436. m.SetBotID(v)
  44437. return nil
  44438. case wxcardvisit.FieldBotType:
  44439. v, ok := value.(uint8)
  44440. if !ok {
  44441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44442. }
  44443. m.SetBotType(v)
  44444. return nil
  44445. }
  44446. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44447. }
  44448. // AddedFields returns all numeric fields that were incremented/decremented during
  44449. // this mutation.
  44450. func (m *WxCardVisitMutation) AddedFields() []string {
  44451. var fields []string
  44452. if m.adduser_id != nil {
  44453. fields = append(fields, wxcardvisit.FieldUserID)
  44454. }
  44455. if m.addbot_id != nil {
  44456. fields = append(fields, wxcardvisit.FieldBotID)
  44457. }
  44458. if m.addbot_type != nil {
  44459. fields = append(fields, wxcardvisit.FieldBotType)
  44460. }
  44461. return fields
  44462. }
  44463. // AddedField returns the numeric value that was incremented/decremented on a field
  44464. // with the given name. The second boolean return value indicates that this field
  44465. // was not set, or was not defined in the schema.
  44466. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  44467. switch name {
  44468. case wxcardvisit.FieldUserID:
  44469. return m.AddedUserID()
  44470. case wxcardvisit.FieldBotID:
  44471. return m.AddedBotID()
  44472. case wxcardvisit.FieldBotType:
  44473. return m.AddedBotType()
  44474. }
  44475. return nil, false
  44476. }
  44477. // AddField adds the value to the field with the given name. It returns an error if
  44478. // the field is not defined in the schema, or if the type mismatched the field
  44479. // type.
  44480. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  44481. switch name {
  44482. case wxcardvisit.FieldUserID:
  44483. v, ok := value.(int64)
  44484. if !ok {
  44485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44486. }
  44487. m.AddUserID(v)
  44488. return nil
  44489. case wxcardvisit.FieldBotID:
  44490. v, ok := value.(int64)
  44491. if !ok {
  44492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44493. }
  44494. m.AddBotID(v)
  44495. return nil
  44496. case wxcardvisit.FieldBotType:
  44497. v, ok := value.(int8)
  44498. if !ok {
  44499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44500. }
  44501. m.AddBotType(v)
  44502. return nil
  44503. }
  44504. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  44505. }
  44506. // ClearedFields returns all nullable fields that were cleared during this
  44507. // mutation.
  44508. func (m *WxCardVisitMutation) ClearedFields() []string {
  44509. var fields []string
  44510. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  44511. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44512. }
  44513. if m.FieldCleared(wxcardvisit.FieldUserID) {
  44514. fields = append(fields, wxcardvisit.FieldUserID)
  44515. }
  44516. return fields
  44517. }
  44518. // FieldCleared returns a boolean indicating if a field with the given name was
  44519. // cleared in this mutation.
  44520. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  44521. _, ok := m.clearedFields[name]
  44522. return ok
  44523. }
  44524. // ClearField clears the value of the field with the given name. It returns an
  44525. // error if the field is not defined in the schema.
  44526. func (m *WxCardVisitMutation) ClearField(name string) error {
  44527. switch name {
  44528. case wxcardvisit.FieldDeletedAt:
  44529. m.ClearDeletedAt()
  44530. return nil
  44531. case wxcardvisit.FieldUserID:
  44532. m.ClearUserID()
  44533. return nil
  44534. }
  44535. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  44536. }
  44537. // ResetField resets all changes in the mutation for the field with the given name.
  44538. // It returns an error if the field is not defined in the schema.
  44539. func (m *WxCardVisitMutation) ResetField(name string) error {
  44540. switch name {
  44541. case wxcardvisit.FieldCreatedAt:
  44542. m.ResetCreatedAt()
  44543. return nil
  44544. case wxcardvisit.FieldUpdatedAt:
  44545. m.ResetUpdatedAt()
  44546. return nil
  44547. case wxcardvisit.FieldDeletedAt:
  44548. m.ResetDeletedAt()
  44549. return nil
  44550. case wxcardvisit.FieldUserID:
  44551. m.ResetUserID()
  44552. return nil
  44553. case wxcardvisit.FieldBotID:
  44554. m.ResetBotID()
  44555. return nil
  44556. case wxcardvisit.FieldBotType:
  44557. m.ResetBotType()
  44558. return nil
  44559. }
  44560. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44561. }
  44562. // AddedEdges returns all edge names that were set/added in this mutation.
  44563. func (m *WxCardVisitMutation) AddedEdges() []string {
  44564. edges := make([]string, 0, 0)
  44565. return edges
  44566. }
  44567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44568. // name in this mutation.
  44569. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  44570. return nil
  44571. }
  44572. // RemovedEdges returns all edge names that were removed in this mutation.
  44573. func (m *WxCardVisitMutation) RemovedEdges() []string {
  44574. edges := make([]string, 0, 0)
  44575. return edges
  44576. }
  44577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44578. // the given name in this mutation.
  44579. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  44580. return nil
  44581. }
  44582. // ClearedEdges returns all edge names that were cleared in this mutation.
  44583. func (m *WxCardVisitMutation) ClearedEdges() []string {
  44584. edges := make([]string, 0, 0)
  44585. return edges
  44586. }
  44587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44588. // was cleared in this mutation.
  44589. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  44590. return false
  44591. }
  44592. // ClearEdge clears the value of the edge with the given name. It returns an error
  44593. // if that edge is not defined in the schema.
  44594. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  44595. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  44596. }
  44597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44598. // It returns an error if the edge is not defined in the schema.
  44599. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  44600. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  44601. }
  44602. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  44603. type XunjiMutation struct {
  44604. config
  44605. op Op
  44606. typ string
  44607. id *uint64
  44608. created_at *time.Time
  44609. updated_at *time.Time
  44610. status *uint8
  44611. addstatus *int8
  44612. deleted_at *time.Time
  44613. app_key *string
  44614. app_secret *string
  44615. token *string
  44616. encoding_key *string
  44617. agent_id *uint64
  44618. addagent_id *int64
  44619. organization_id *uint64
  44620. addorganization_id *int64
  44621. clearedFields map[string]struct{}
  44622. done bool
  44623. oldValue func(context.Context) (*Xunji, error)
  44624. predicates []predicate.Xunji
  44625. }
  44626. var _ ent.Mutation = (*XunjiMutation)(nil)
  44627. // xunjiOption allows management of the mutation configuration using functional options.
  44628. type xunjiOption func(*XunjiMutation)
  44629. // newXunjiMutation creates new mutation for the Xunji entity.
  44630. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  44631. m := &XunjiMutation{
  44632. config: c,
  44633. op: op,
  44634. typ: TypeXunji,
  44635. clearedFields: make(map[string]struct{}),
  44636. }
  44637. for _, opt := range opts {
  44638. opt(m)
  44639. }
  44640. return m
  44641. }
  44642. // withXunjiID sets the ID field of the mutation.
  44643. func withXunjiID(id uint64) xunjiOption {
  44644. return func(m *XunjiMutation) {
  44645. var (
  44646. err error
  44647. once sync.Once
  44648. value *Xunji
  44649. )
  44650. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  44651. once.Do(func() {
  44652. if m.done {
  44653. err = errors.New("querying old values post mutation is not allowed")
  44654. } else {
  44655. value, err = m.Client().Xunji.Get(ctx, id)
  44656. }
  44657. })
  44658. return value, err
  44659. }
  44660. m.id = &id
  44661. }
  44662. }
  44663. // withXunji sets the old Xunji of the mutation.
  44664. func withXunji(node *Xunji) xunjiOption {
  44665. return func(m *XunjiMutation) {
  44666. m.oldValue = func(context.Context) (*Xunji, error) {
  44667. return node, nil
  44668. }
  44669. m.id = &node.ID
  44670. }
  44671. }
  44672. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44673. // executed in a transaction (ent.Tx), a transactional client is returned.
  44674. func (m XunjiMutation) Client() *Client {
  44675. client := &Client{config: m.config}
  44676. client.init()
  44677. return client
  44678. }
  44679. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44680. // it returns an error otherwise.
  44681. func (m XunjiMutation) Tx() (*Tx, error) {
  44682. if _, ok := m.driver.(*txDriver); !ok {
  44683. return nil, errors.New("ent: mutation is not running in a transaction")
  44684. }
  44685. tx := &Tx{config: m.config}
  44686. tx.init()
  44687. return tx, nil
  44688. }
  44689. // SetID sets the value of the id field. Note that this
  44690. // operation is only accepted on creation of Xunji entities.
  44691. func (m *XunjiMutation) SetID(id uint64) {
  44692. m.id = &id
  44693. }
  44694. // ID returns the ID value in the mutation. Note that the ID is only available
  44695. // if it was provided to the builder or after it was returned from the database.
  44696. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  44697. if m.id == nil {
  44698. return
  44699. }
  44700. return *m.id, true
  44701. }
  44702. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44703. // That means, if the mutation is applied within a transaction with an isolation level such
  44704. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44705. // or updated by the mutation.
  44706. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  44707. switch {
  44708. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44709. id, exists := m.ID()
  44710. if exists {
  44711. return []uint64{id}, nil
  44712. }
  44713. fallthrough
  44714. case m.op.Is(OpUpdate | OpDelete):
  44715. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  44716. default:
  44717. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44718. }
  44719. }
  44720. // SetCreatedAt sets the "created_at" field.
  44721. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  44722. m.created_at = &t
  44723. }
  44724. // CreatedAt returns the value of the "created_at" field in the mutation.
  44725. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  44726. v := m.created_at
  44727. if v == nil {
  44728. return
  44729. }
  44730. return *v, true
  44731. }
  44732. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  44733. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44735. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44736. if !m.op.Is(OpUpdateOne) {
  44737. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44738. }
  44739. if m.id == nil || m.oldValue == nil {
  44740. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44741. }
  44742. oldValue, err := m.oldValue(ctx)
  44743. if err != nil {
  44744. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44745. }
  44746. return oldValue.CreatedAt, nil
  44747. }
  44748. // ResetCreatedAt resets all changes to the "created_at" field.
  44749. func (m *XunjiMutation) ResetCreatedAt() {
  44750. m.created_at = nil
  44751. }
  44752. // SetUpdatedAt sets the "updated_at" field.
  44753. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  44754. m.updated_at = &t
  44755. }
  44756. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44757. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  44758. v := m.updated_at
  44759. if v == nil {
  44760. return
  44761. }
  44762. return *v, true
  44763. }
  44764. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  44765. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44767. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44768. if !m.op.Is(OpUpdateOne) {
  44769. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44770. }
  44771. if m.id == nil || m.oldValue == nil {
  44772. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44773. }
  44774. oldValue, err := m.oldValue(ctx)
  44775. if err != nil {
  44776. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44777. }
  44778. return oldValue.UpdatedAt, nil
  44779. }
  44780. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44781. func (m *XunjiMutation) ResetUpdatedAt() {
  44782. m.updated_at = nil
  44783. }
  44784. // SetStatus sets the "status" field.
  44785. func (m *XunjiMutation) SetStatus(u uint8) {
  44786. m.status = &u
  44787. m.addstatus = nil
  44788. }
  44789. // Status returns the value of the "status" field in the mutation.
  44790. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  44791. v := m.status
  44792. if v == nil {
  44793. return
  44794. }
  44795. return *v, true
  44796. }
  44797. // OldStatus returns the old "status" field's value of the Xunji entity.
  44798. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44800. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44801. if !m.op.Is(OpUpdateOne) {
  44802. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44803. }
  44804. if m.id == nil || m.oldValue == nil {
  44805. return v, errors.New("OldStatus requires an ID field in the mutation")
  44806. }
  44807. oldValue, err := m.oldValue(ctx)
  44808. if err != nil {
  44809. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44810. }
  44811. return oldValue.Status, nil
  44812. }
  44813. // AddStatus adds u to the "status" field.
  44814. func (m *XunjiMutation) AddStatus(u int8) {
  44815. if m.addstatus != nil {
  44816. *m.addstatus += u
  44817. } else {
  44818. m.addstatus = &u
  44819. }
  44820. }
  44821. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44822. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  44823. v := m.addstatus
  44824. if v == nil {
  44825. return
  44826. }
  44827. return *v, true
  44828. }
  44829. // ClearStatus clears the value of the "status" field.
  44830. func (m *XunjiMutation) ClearStatus() {
  44831. m.status = nil
  44832. m.addstatus = nil
  44833. m.clearedFields[xunji.FieldStatus] = struct{}{}
  44834. }
  44835. // StatusCleared returns if the "status" field was cleared in this mutation.
  44836. func (m *XunjiMutation) StatusCleared() bool {
  44837. _, ok := m.clearedFields[xunji.FieldStatus]
  44838. return ok
  44839. }
  44840. // ResetStatus resets all changes to the "status" field.
  44841. func (m *XunjiMutation) ResetStatus() {
  44842. m.status = nil
  44843. m.addstatus = nil
  44844. delete(m.clearedFields, xunji.FieldStatus)
  44845. }
  44846. // SetDeletedAt sets the "deleted_at" field.
  44847. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  44848. m.deleted_at = &t
  44849. }
  44850. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44851. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  44852. v := m.deleted_at
  44853. if v == nil {
  44854. return
  44855. }
  44856. return *v, true
  44857. }
  44858. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  44859. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44861. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44862. if !m.op.Is(OpUpdateOne) {
  44863. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44864. }
  44865. if m.id == nil || m.oldValue == nil {
  44866. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44867. }
  44868. oldValue, err := m.oldValue(ctx)
  44869. if err != nil {
  44870. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44871. }
  44872. return oldValue.DeletedAt, nil
  44873. }
  44874. // ClearDeletedAt clears the value of the "deleted_at" field.
  44875. func (m *XunjiMutation) ClearDeletedAt() {
  44876. m.deleted_at = nil
  44877. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  44878. }
  44879. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44880. func (m *XunjiMutation) DeletedAtCleared() bool {
  44881. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  44882. return ok
  44883. }
  44884. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44885. func (m *XunjiMutation) ResetDeletedAt() {
  44886. m.deleted_at = nil
  44887. delete(m.clearedFields, xunji.FieldDeletedAt)
  44888. }
  44889. // SetAppKey sets the "app_key" field.
  44890. func (m *XunjiMutation) SetAppKey(s string) {
  44891. m.app_key = &s
  44892. }
  44893. // AppKey returns the value of the "app_key" field in the mutation.
  44894. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  44895. v := m.app_key
  44896. if v == nil {
  44897. return
  44898. }
  44899. return *v, true
  44900. }
  44901. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  44902. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44904. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  44905. if !m.op.Is(OpUpdateOne) {
  44906. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  44907. }
  44908. if m.id == nil || m.oldValue == nil {
  44909. return v, errors.New("OldAppKey requires an ID field in the mutation")
  44910. }
  44911. oldValue, err := m.oldValue(ctx)
  44912. if err != nil {
  44913. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  44914. }
  44915. return oldValue.AppKey, nil
  44916. }
  44917. // ResetAppKey resets all changes to the "app_key" field.
  44918. func (m *XunjiMutation) ResetAppKey() {
  44919. m.app_key = nil
  44920. }
  44921. // SetAppSecret sets the "app_secret" field.
  44922. func (m *XunjiMutation) SetAppSecret(s string) {
  44923. m.app_secret = &s
  44924. }
  44925. // AppSecret returns the value of the "app_secret" field in the mutation.
  44926. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  44927. v := m.app_secret
  44928. if v == nil {
  44929. return
  44930. }
  44931. return *v, true
  44932. }
  44933. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  44934. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44936. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  44937. if !m.op.Is(OpUpdateOne) {
  44938. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  44939. }
  44940. if m.id == nil || m.oldValue == nil {
  44941. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  44942. }
  44943. oldValue, err := m.oldValue(ctx)
  44944. if err != nil {
  44945. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  44946. }
  44947. return oldValue.AppSecret, nil
  44948. }
  44949. // ResetAppSecret resets all changes to the "app_secret" field.
  44950. func (m *XunjiMutation) ResetAppSecret() {
  44951. m.app_secret = nil
  44952. }
  44953. // SetToken sets the "token" field.
  44954. func (m *XunjiMutation) SetToken(s string) {
  44955. m.token = &s
  44956. }
  44957. // Token returns the value of the "token" field in the mutation.
  44958. func (m *XunjiMutation) Token() (r string, exists bool) {
  44959. v := m.token
  44960. if v == nil {
  44961. return
  44962. }
  44963. return *v, true
  44964. }
  44965. // OldToken returns the old "token" field's value of the Xunji entity.
  44966. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44968. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  44969. if !m.op.Is(OpUpdateOne) {
  44970. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  44971. }
  44972. if m.id == nil || m.oldValue == nil {
  44973. return v, errors.New("OldToken requires an ID field in the mutation")
  44974. }
  44975. oldValue, err := m.oldValue(ctx)
  44976. if err != nil {
  44977. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  44978. }
  44979. return oldValue.Token, nil
  44980. }
  44981. // ResetToken resets all changes to the "token" field.
  44982. func (m *XunjiMutation) ResetToken() {
  44983. m.token = nil
  44984. }
  44985. // SetEncodingKey sets the "encoding_key" field.
  44986. func (m *XunjiMutation) SetEncodingKey(s string) {
  44987. m.encoding_key = &s
  44988. }
  44989. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  44990. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  44991. v := m.encoding_key
  44992. if v == nil {
  44993. return
  44994. }
  44995. return *v, true
  44996. }
  44997. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  44998. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  44999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45000. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  45001. if !m.op.Is(OpUpdateOne) {
  45002. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  45003. }
  45004. if m.id == nil || m.oldValue == nil {
  45005. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  45006. }
  45007. oldValue, err := m.oldValue(ctx)
  45008. if err != nil {
  45009. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  45010. }
  45011. return oldValue.EncodingKey, nil
  45012. }
  45013. // ResetEncodingKey resets all changes to the "encoding_key" field.
  45014. func (m *XunjiMutation) ResetEncodingKey() {
  45015. m.encoding_key = nil
  45016. }
  45017. // SetAgentID sets the "agent_id" field.
  45018. func (m *XunjiMutation) SetAgentID(u uint64) {
  45019. m.agent_id = &u
  45020. m.addagent_id = nil
  45021. }
  45022. // AgentID returns the value of the "agent_id" field in the mutation.
  45023. func (m *XunjiMutation) AgentID() (r uint64, exists bool) {
  45024. v := m.agent_id
  45025. if v == nil {
  45026. return
  45027. }
  45028. return *v, true
  45029. }
  45030. // OldAgentID returns the old "agent_id" field's value of the Xunji entity.
  45031. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45033. func (m *XunjiMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  45034. if !m.op.Is(OpUpdateOne) {
  45035. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  45036. }
  45037. if m.id == nil || m.oldValue == nil {
  45038. return v, errors.New("OldAgentID requires an ID field in the mutation")
  45039. }
  45040. oldValue, err := m.oldValue(ctx)
  45041. if err != nil {
  45042. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  45043. }
  45044. return oldValue.AgentID, nil
  45045. }
  45046. // AddAgentID adds u to the "agent_id" field.
  45047. func (m *XunjiMutation) AddAgentID(u int64) {
  45048. if m.addagent_id != nil {
  45049. *m.addagent_id += u
  45050. } else {
  45051. m.addagent_id = &u
  45052. }
  45053. }
  45054. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  45055. func (m *XunjiMutation) AddedAgentID() (r int64, exists bool) {
  45056. v := m.addagent_id
  45057. if v == nil {
  45058. return
  45059. }
  45060. return *v, true
  45061. }
  45062. // ResetAgentID resets all changes to the "agent_id" field.
  45063. func (m *XunjiMutation) ResetAgentID() {
  45064. m.agent_id = nil
  45065. m.addagent_id = nil
  45066. }
  45067. // SetOrganizationID sets the "organization_id" field.
  45068. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  45069. m.organization_id = &u
  45070. m.addorganization_id = nil
  45071. }
  45072. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45073. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  45074. v := m.organization_id
  45075. if v == nil {
  45076. return
  45077. }
  45078. return *v, true
  45079. }
  45080. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  45081. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45083. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45084. if !m.op.Is(OpUpdateOne) {
  45085. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45086. }
  45087. if m.id == nil || m.oldValue == nil {
  45088. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45089. }
  45090. oldValue, err := m.oldValue(ctx)
  45091. if err != nil {
  45092. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45093. }
  45094. return oldValue.OrganizationID, nil
  45095. }
  45096. // AddOrganizationID adds u to the "organization_id" field.
  45097. func (m *XunjiMutation) AddOrganizationID(u int64) {
  45098. if m.addorganization_id != nil {
  45099. *m.addorganization_id += u
  45100. } else {
  45101. m.addorganization_id = &u
  45102. }
  45103. }
  45104. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45105. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  45106. v := m.addorganization_id
  45107. if v == nil {
  45108. return
  45109. }
  45110. return *v, true
  45111. }
  45112. // ResetOrganizationID resets all changes to the "organization_id" field.
  45113. func (m *XunjiMutation) ResetOrganizationID() {
  45114. m.organization_id = nil
  45115. m.addorganization_id = nil
  45116. }
  45117. // Where appends a list predicates to the XunjiMutation builder.
  45118. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  45119. m.predicates = append(m.predicates, ps...)
  45120. }
  45121. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  45122. // users can use type-assertion to append predicates that do not depend on any generated package.
  45123. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  45124. p := make([]predicate.Xunji, len(ps))
  45125. for i := range ps {
  45126. p[i] = ps[i]
  45127. }
  45128. m.Where(p...)
  45129. }
  45130. // Op returns the operation name.
  45131. func (m *XunjiMutation) Op() Op {
  45132. return m.op
  45133. }
  45134. // SetOp allows setting the mutation operation.
  45135. func (m *XunjiMutation) SetOp(op Op) {
  45136. m.op = op
  45137. }
  45138. // Type returns the node type of this mutation (Xunji).
  45139. func (m *XunjiMutation) Type() string {
  45140. return m.typ
  45141. }
  45142. // Fields returns all fields that were changed during this mutation. Note that in
  45143. // order to get all numeric fields that were incremented/decremented, call
  45144. // AddedFields().
  45145. func (m *XunjiMutation) Fields() []string {
  45146. fields := make([]string, 0, 10)
  45147. if m.created_at != nil {
  45148. fields = append(fields, xunji.FieldCreatedAt)
  45149. }
  45150. if m.updated_at != nil {
  45151. fields = append(fields, xunji.FieldUpdatedAt)
  45152. }
  45153. if m.status != nil {
  45154. fields = append(fields, xunji.FieldStatus)
  45155. }
  45156. if m.deleted_at != nil {
  45157. fields = append(fields, xunji.FieldDeletedAt)
  45158. }
  45159. if m.app_key != nil {
  45160. fields = append(fields, xunji.FieldAppKey)
  45161. }
  45162. if m.app_secret != nil {
  45163. fields = append(fields, xunji.FieldAppSecret)
  45164. }
  45165. if m.token != nil {
  45166. fields = append(fields, xunji.FieldToken)
  45167. }
  45168. if m.encoding_key != nil {
  45169. fields = append(fields, xunji.FieldEncodingKey)
  45170. }
  45171. if m.agent_id != nil {
  45172. fields = append(fields, xunji.FieldAgentID)
  45173. }
  45174. if m.organization_id != nil {
  45175. fields = append(fields, xunji.FieldOrganizationID)
  45176. }
  45177. return fields
  45178. }
  45179. // Field returns the value of a field with the given name. The second boolean
  45180. // return value indicates that this field was not set, or was not defined in the
  45181. // schema.
  45182. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  45183. switch name {
  45184. case xunji.FieldCreatedAt:
  45185. return m.CreatedAt()
  45186. case xunji.FieldUpdatedAt:
  45187. return m.UpdatedAt()
  45188. case xunji.FieldStatus:
  45189. return m.Status()
  45190. case xunji.FieldDeletedAt:
  45191. return m.DeletedAt()
  45192. case xunji.FieldAppKey:
  45193. return m.AppKey()
  45194. case xunji.FieldAppSecret:
  45195. return m.AppSecret()
  45196. case xunji.FieldToken:
  45197. return m.Token()
  45198. case xunji.FieldEncodingKey:
  45199. return m.EncodingKey()
  45200. case xunji.FieldAgentID:
  45201. return m.AgentID()
  45202. case xunji.FieldOrganizationID:
  45203. return m.OrganizationID()
  45204. }
  45205. return nil, false
  45206. }
  45207. // OldField returns the old value of the field from the database. An error is
  45208. // returned if the mutation operation is not UpdateOne, or the query to the
  45209. // database failed.
  45210. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45211. switch name {
  45212. case xunji.FieldCreatedAt:
  45213. return m.OldCreatedAt(ctx)
  45214. case xunji.FieldUpdatedAt:
  45215. return m.OldUpdatedAt(ctx)
  45216. case xunji.FieldStatus:
  45217. return m.OldStatus(ctx)
  45218. case xunji.FieldDeletedAt:
  45219. return m.OldDeletedAt(ctx)
  45220. case xunji.FieldAppKey:
  45221. return m.OldAppKey(ctx)
  45222. case xunji.FieldAppSecret:
  45223. return m.OldAppSecret(ctx)
  45224. case xunji.FieldToken:
  45225. return m.OldToken(ctx)
  45226. case xunji.FieldEncodingKey:
  45227. return m.OldEncodingKey(ctx)
  45228. case xunji.FieldAgentID:
  45229. return m.OldAgentID(ctx)
  45230. case xunji.FieldOrganizationID:
  45231. return m.OldOrganizationID(ctx)
  45232. }
  45233. return nil, fmt.Errorf("unknown Xunji field %s", name)
  45234. }
  45235. // SetField sets the value of a field with the given name. It returns an error if
  45236. // the field is not defined in the schema, or if the type mismatched the field
  45237. // type.
  45238. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  45239. switch name {
  45240. case xunji.FieldCreatedAt:
  45241. v, ok := value.(time.Time)
  45242. if !ok {
  45243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45244. }
  45245. m.SetCreatedAt(v)
  45246. return nil
  45247. case xunji.FieldUpdatedAt:
  45248. v, ok := value.(time.Time)
  45249. if !ok {
  45250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45251. }
  45252. m.SetUpdatedAt(v)
  45253. return nil
  45254. case xunji.FieldStatus:
  45255. v, ok := value.(uint8)
  45256. if !ok {
  45257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45258. }
  45259. m.SetStatus(v)
  45260. return nil
  45261. case xunji.FieldDeletedAt:
  45262. v, ok := value.(time.Time)
  45263. if !ok {
  45264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45265. }
  45266. m.SetDeletedAt(v)
  45267. return nil
  45268. case xunji.FieldAppKey:
  45269. v, ok := value.(string)
  45270. if !ok {
  45271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45272. }
  45273. m.SetAppKey(v)
  45274. return nil
  45275. case xunji.FieldAppSecret:
  45276. v, ok := value.(string)
  45277. if !ok {
  45278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45279. }
  45280. m.SetAppSecret(v)
  45281. return nil
  45282. case xunji.FieldToken:
  45283. v, ok := value.(string)
  45284. if !ok {
  45285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45286. }
  45287. m.SetToken(v)
  45288. return nil
  45289. case xunji.FieldEncodingKey:
  45290. v, ok := value.(string)
  45291. if !ok {
  45292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45293. }
  45294. m.SetEncodingKey(v)
  45295. return nil
  45296. case xunji.FieldAgentID:
  45297. v, ok := value.(uint64)
  45298. if !ok {
  45299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45300. }
  45301. m.SetAgentID(v)
  45302. return nil
  45303. case xunji.FieldOrganizationID:
  45304. v, ok := value.(uint64)
  45305. if !ok {
  45306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45307. }
  45308. m.SetOrganizationID(v)
  45309. return nil
  45310. }
  45311. return fmt.Errorf("unknown Xunji field %s", name)
  45312. }
  45313. // AddedFields returns all numeric fields that were incremented/decremented during
  45314. // this mutation.
  45315. func (m *XunjiMutation) AddedFields() []string {
  45316. var fields []string
  45317. if m.addstatus != nil {
  45318. fields = append(fields, xunji.FieldStatus)
  45319. }
  45320. if m.addagent_id != nil {
  45321. fields = append(fields, xunji.FieldAgentID)
  45322. }
  45323. if m.addorganization_id != nil {
  45324. fields = append(fields, xunji.FieldOrganizationID)
  45325. }
  45326. return fields
  45327. }
  45328. // AddedField returns the numeric value that was incremented/decremented on a field
  45329. // with the given name. The second boolean return value indicates that this field
  45330. // was not set, or was not defined in the schema.
  45331. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  45332. switch name {
  45333. case xunji.FieldStatus:
  45334. return m.AddedStatus()
  45335. case xunji.FieldAgentID:
  45336. return m.AddedAgentID()
  45337. case xunji.FieldOrganizationID:
  45338. return m.AddedOrganizationID()
  45339. }
  45340. return nil, false
  45341. }
  45342. // AddField adds the value to the field with the given name. It returns an error if
  45343. // the field is not defined in the schema, or if the type mismatched the field
  45344. // type.
  45345. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  45346. switch name {
  45347. case xunji.FieldStatus:
  45348. v, ok := value.(int8)
  45349. if !ok {
  45350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45351. }
  45352. m.AddStatus(v)
  45353. return nil
  45354. case xunji.FieldAgentID:
  45355. v, ok := value.(int64)
  45356. if !ok {
  45357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45358. }
  45359. m.AddAgentID(v)
  45360. return nil
  45361. case xunji.FieldOrganizationID:
  45362. v, ok := value.(int64)
  45363. if !ok {
  45364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45365. }
  45366. m.AddOrganizationID(v)
  45367. return nil
  45368. }
  45369. return fmt.Errorf("unknown Xunji numeric field %s", name)
  45370. }
  45371. // ClearedFields returns all nullable fields that were cleared during this
  45372. // mutation.
  45373. func (m *XunjiMutation) ClearedFields() []string {
  45374. var fields []string
  45375. if m.FieldCleared(xunji.FieldStatus) {
  45376. fields = append(fields, xunji.FieldStatus)
  45377. }
  45378. if m.FieldCleared(xunji.FieldDeletedAt) {
  45379. fields = append(fields, xunji.FieldDeletedAt)
  45380. }
  45381. return fields
  45382. }
  45383. // FieldCleared returns a boolean indicating if a field with the given name was
  45384. // cleared in this mutation.
  45385. func (m *XunjiMutation) FieldCleared(name string) bool {
  45386. _, ok := m.clearedFields[name]
  45387. return ok
  45388. }
  45389. // ClearField clears the value of the field with the given name. It returns an
  45390. // error if the field is not defined in the schema.
  45391. func (m *XunjiMutation) ClearField(name string) error {
  45392. switch name {
  45393. case xunji.FieldStatus:
  45394. m.ClearStatus()
  45395. return nil
  45396. case xunji.FieldDeletedAt:
  45397. m.ClearDeletedAt()
  45398. return nil
  45399. }
  45400. return fmt.Errorf("unknown Xunji nullable field %s", name)
  45401. }
  45402. // ResetField resets all changes in the mutation for the field with the given name.
  45403. // It returns an error if the field is not defined in the schema.
  45404. func (m *XunjiMutation) ResetField(name string) error {
  45405. switch name {
  45406. case xunji.FieldCreatedAt:
  45407. m.ResetCreatedAt()
  45408. return nil
  45409. case xunji.FieldUpdatedAt:
  45410. m.ResetUpdatedAt()
  45411. return nil
  45412. case xunji.FieldStatus:
  45413. m.ResetStatus()
  45414. return nil
  45415. case xunji.FieldDeletedAt:
  45416. m.ResetDeletedAt()
  45417. return nil
  45418. case xunji.FieldAppKey:
  45419. m.ResetAppKey()
  45420. return nil
  45421. case xunji.FieldAppSecret:
  45422. m.ResetAppSecret()
  45423. return nil
  45424. case xunji.FieldToken:
  45425. m.ResetToken()
  45426. return nil
  45427. case xunji.FieldEncodingKey:
  45428. m.ResetEncodingKey()
  45429. return nil
  45430. case xunji.FieldAgentID:
  45431. m.ResetAgentID()
  45432. return nil
  45433. case xunji.FieldOrganizationID:
  45434. m.ResetOrganizationID()
  45435. return nil
  45436. }
  45437. return fmt.Errorf("unknown Xunji field %s", name)
  45438. }
  45439. // AddedEdges returns all edge names that were set/added in this mutation.
  45440. func (m *XunjiMutation) AddedEdges() []string {
  45441. edges := make([]string, 0, 0)
  45442. return edges
  45443. }
  45444. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45445. // name in this mutation.
  45446. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  45447. return nil
  45448. }
  45449. // RemovedEdges returns all edge names that were removed in this mutation.
  45450. func (m *XunjiMutation) RemovedEdges() []string {
  45451. edges := make([]string, 0, 0)
  45452. return edges
  45453. }
  45454. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45455. // the given name in this mutation.
  45456. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  45457. return nil
  45458. }
  45459. // ClearedEdges returns all edge names that were cleared in this mutation.
  45460. func (m *XunjiMutation) ClearedEdges() []string {
  45461. edges := make([]string, 0, 0)
  45462. return edges
  45463. }
  45464. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45465. // was cleared in this mutation.
  45466. func (m *XunjiMutation) EdgeCleared(name string) bool {
  45467. return false
  45468. }
  45469. // ClearEdge clears the value of the edge with the given name. It returns an error
  45470. // if that edge is not defined in the schema.
  45471. func (m *XunjiMutation) ClearEdge(name string) error {
  45472. return fmt.Errorf("unknown Xunji unique edge %s", name)
  45473. }
  45474. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45475. // It returns an error if the edge is not defined in the schema.
  45476. func (m *XunjiMutation) ResetEdge(name string) error {
  45477. return fmt.Errorf("unknown Xunji edge %s", name)
  45478. }
  45479. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  45480. type XunjiServiceMutation struct {
  45481. config
  45482. op Op
  45483. typ string
  45484. id *uint64
  45485. created_at *time.Time
  45486. updated_at *time.Time
  45487. status *uint8
  45488. addstatus *int8
  45489. deleted_at *time.Time
  45490. xunji_id *uint64
  45491. addxunji_id *int64
  45492. organization_id *uint64
  45493. addorganization_id *int64
  45494. wxid *string
  45495. api_base *string
  45496. api_key *string
  45497. clearedFields map[string]struct{}
  45498. agent *uint64
  45499. clearedagent bool
  45500. done bool
  45501. oldValue func(context.Context) (*XunjiService, error)
  45502. predicates []predicate.XunjiService
  45503. }
  45504. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  45505. // xunjiserviceOption allows management of the mutation configuration using functional options.
  45506. type xunjiserviceOption func(*XunjiServiceMutation)
  45507. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  45508. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  45509. m := &XunjiServiceMutation{
  45510. config: c,
  45511. op: op,
  45512. typ: TypeXunjiService,
  45513. clearedFields: make(map[string]struct{}),
  45514. }
  45515. for _, opt := range opts {
  45516. opt(m)
  45517. }
  45518. return m
  45519. }
  45520. // withXunjiServiceID sets the ID field of the mutation.
  45521. func withXunjiServiceID(id uint64) xunjiserviceOption {
  45522. return func(m *XunjiServiceMutation) {
  45523. var (
  45524. err error
  45525. once sync.Once
  45526. value *XunjiService
  45527. )
  45528. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  45529. once.Do(func() {
  45530. if m.done {
  45531. err = errors.New("querying old values post mutation is not allowed")
  45532. } else {
  45533. value, err = m.Client().XunjiService.Get(ctx, id)
  45534. }
  45535. })
  45536. return value, err
  45537. }
  45538. m.id = &id
  45539. }
  45540. }
  45541. // withXunjiService sets the old XunjiService of the mutation.
  45542. func withXunjiService(node *XunjiService) xunjiserviceOption {
  45543. return func(m *XunjiServiceMutation) {
  45544. m.oldValue = func(context.Context) (*XunjiService, error) {
  45545. return node, nil
  45546. }
  45547. m.id = &node.ID
  45548. }
  45549. }
  45550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45551. // executed in a transaction (ent.Tx), a transactional client is returned.
  45552. func (m XunjiServiceMutation) Client() *Client {
  45553. client := &Client{config: m.config}
  45554. client.init()
  45555. return client
  45556. }
  45557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45558. // it returns an error otherwise.
  45559. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  45560. if _, ok := m.driver.(*txDriver); !ok {
  45561. return nil, errors.New("ent: mutation is not running in a transaction")
  45562. }
  45563. tx := &Tx{config: m.config}
  45564. tx.init()
  45565. return tx, nil
  45566. }
  45567. // SetID sets the value of the id field. Note that this
  45568. // operation is only accepted on creation of XunjiService entities.
  45569. func (m *XunjiServiceMutation) SetID(id uint64) {
  45570. m.id = &id
  45571. }
  45572. // ID returns the ID value in the mutation. Note that the ID is only available
  45573. // if it was provided to the builder or after it was returned from the database.
  45574. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  45575. if m.id == nil {
  45576. return
  45577. }
  45578. return *m.id, true
  45579. }
  45580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45581. // That means, if the mutation is applied within a transaction with an isolation level such
  45582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45583. // or updated by the mutation.
  45584. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  45585. switch {
  45586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45587. id, exists := m.ID()
  45588. if exists {
  45589. return []uint64{id}, nil
  45590. }
  45591. fallthrough
  45592. case m.op.Is(OpUpdate | OpDelete):
  45593. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  45594. default:
  45595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45596. }
  45597. }
  45598. // SetCreatedAt sets the "created_at" field.
  45599. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  45600. m.created_at = &t
  45601. }
  45602. // CreatedAt returns the value of the "created_at" field in the mutation.
  45603. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  45604. v := m.created_at
  45605. if v == nil {
  45606. return
  45607. }
  45608. return *v, true
  45609. }
  45610. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  45611. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45613. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45614. if !m.op.Is(OpUpdateOne) {
  45615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45616. }
  45617. if m.id == nil || m.oldValue == nil {
  45618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45619. }
  45620. oldValue, err := m.oldValue(ctx)
  45621. if err != nil {
  45622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45623. }
  45624. return oldValue.CreatedAt, nil
  45625. }
  45626. // ResetCreatedAt resets all changes to the "created_at" field.
  45627. func (m *XunjiServiceMutation) ResetCreatedAt() {
  45628. m.created_at = nil
  45629. }
  45630. // SetUpdatedAt sets the "updated_at" field.
  45631. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  45632. m.updated_at = &t
  45633. }
  45634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45635. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  45636. v := m.updated_at
  45637. if v == nil {
  45638. return
  45639. }
  45640. return *v, true
  45641. }
  45642. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  45643. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45645. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45646. if !m.op.Is(OpUpdateOne) {
  45647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45648. }
  45649. if m.id == nil || m.oldValue == nil {
  45650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45651. }
  45652. oldValue, err := m.oldValue(ctx)
  45653. if err != nil {
  45654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45655. }
  45656. return oldValue.UpdatedAt, nil
  45657. }
  45658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45659. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  45660. m.updated_at = nil
  45661. }
  45662. // SetStatus sets the "status" field.
  45663. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  45664. m.status = &u
  45665. m.addstatus = nil
  45666. }
  45667. // Status returns the value of the "status" field in the mutation.
  45668. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  45669. v := m.status
  45670. if v == nil {
  45671. return
  45672. }
  45673. return *v, true
  45674. }
  45675. // OldStatus returns the old "status" field's value of the XunjiService entity.
  45676. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45678. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45679. if !m.op.Is(OpUpdateOne) {
  45680. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45681. }
  45682. if m.id == nil || m.oldValue == nil {
  45683. return v, errors.New("OldStatus requires an ID field in the mutation")
  45684. }
  45685. oldValue, err := m.oldValue(ctx)
  45686. if err != nil {
  45687. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45688. }
  45689. return oldValue.Status, nil
  45690. }
  45691. // AddStatus adds u to the "status" field.
  45692. func (m *XunjiServiceMutation) AddStatus(u int8) {
  45693. if m.addstatus != nil {
  45694. *m.addstatus += u
  45695. } else {
  45696. m.addstatus = &u
  45697. }
  45698. }
  45699. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45700. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  45701. v := m.addstatus
  45702. if v == nil {
  45703. return
  45704. }
  45705. return *v, true
  45706. }
  45707. // ClearStatus clears the value of the "status" field.
  45708. func (m *XunjiServiceMutation) ClearStatus() {
  45709. m.status = nil
  45710. m.addstatus = nil
  45711. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  45712. }
  45713. // StatusCleared returns if the "status" field was cleared in this mutation.
  45714. func (m *XunjiServiceMutation) StatusCleared() bool {
  45715. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  45716. return ok
  45717. }
  45718. // ResetStatus resets all changes to the "status" field.
  45719. func (m *XunjiServiceMutation) ResetStatus() {
  45720. m.status = nil
  45721. m.addstatus = nil
  45722. delete(m.clearedFields, xunjiservice.FieldStatus)
  45723. }
  45724. // SetDeletedAt sets the "deleted_at" field.
  45725. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  45726. m.deleted_at = &t
  45727. }
  45728. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45729. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  45730. v := m.deleted_at
  45731. if v == nil {
  45732. return
  45733. }
  45734. return *v, true
  45735. }
  45736. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  45737. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45739. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45740. if !m.op.Is(OpUpdateOne) {
  45741. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45742. }
  45743. if m.id == nil || m.oldValue == nil {
  45744. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45745. }
  45746. oldValue, err := m.oldValue(ctx)
  45747. if err != nil {
  45748. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45749. }
  45750. return oldValue.DeletedAt, nil
  45751. }
  45752. // ClearDeletedAt clears the value of the "deleted_at" field.
  45753. func (m *XunjiServiceMutation) ClearDeletedAt() {
  45754. m.deleted_at = nil
  45755. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  45756. }
  45757. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45758. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  45759. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  45760. return ok
  45761. }
  45762. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45763. func (m *XunjiServiceMutation) ResetDeletedAt() {
  45764. m.deleted_at = nil
  45765. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  45766. }
  45767. // SetXunjiID sets the "xunji_id" field.
  45768. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  45769. m.xunji_id = &u
  45770. m.addxunji_id = nil
  45771. }
  45772. // XunjiID returns the value of the "xunji_id" field in the mutation.
  45773. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  45774. v := m.xunji_id
  45775. if v == nil {
  45776. return
  45777. }
  45778. return *v, true
  45779. }
  45780. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  45781. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45783. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  45784. if !m.op.Is(OpUpdateOne) {
  45785. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  45786. }
  45787. if m.id == nil || m.oldValue == nil {
  45788. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  45789. }
  45790. oldValue, err := m.oldValue(ctx)
  45791. if err != nil {
  45792. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  45793. }
  45794. return oldValue.XunjiID, nil
  45795. }
  45796. // AddXunjiID adds u to the "xunji_id" field.
  45797. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  45798. if m.addxunji_id != nil {
  45799. *m.addxunji_id += u
  45800. } else {
  45801. m.addxunji_id = &u
  45802. }
  45803. }
  45804. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  45805. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  45806. v := m.addxunji_id
  45807. if v == nil {
  45808. return
  45809. }
  45810. return *v, true
  45811. }
  45812. // ResetXunjiID resets all changes to the "xunji_id" field.
  45813. func (m *XunjiServiceMutation) ResetXunjiID() {
  45814. m.xunji_id = nil
  45815. m.addxunji_id = nil
  45816. }
  45817. // SetAgentID sets the "agent_id" field.
  45818. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  45819. m.agent = &u
  45820. }
  45821. // AgentID returns the value of the "agent_id" field in the mutation.
  45822. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  45823. v := m.agent
  45824. if v == nil {
  45825. return
  45826. }
  45827. return *v, true
  45828. }
  45829. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  45830. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45832. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  45833. if !m.op.Is(OpUpdateOne) {
  45834. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  45835. }
  45836. if m.id == nil || m.oldValue == nil {
  45837. return v, errors.New("OldAgentID requires an ID field in the mutation")
  45838. }
  45839. oldValue, err := m.oldValue(ctx)
  45840. if err != nil {
  45841. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  45842. }
  45843. return oldValue.AgentID, nil
  45844. }
  45845. // ResetAgentID resets all changes to the "agent_id" field.
  45846. func (m *XunjiServiceMutation) ResetAgentID() {
  45847. m.agent = nil
  45848. }
  45849. // SetOrganizationID sets the "organization_id" field.
  45850. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  45851. m.organization_id = &u
  45852. m.addorganization_id = nil
  45853. }
  45854. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45855. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  45856. v := m.organization_id
  45857. if v == nil {
  45858. return
  45859. }
  45860. return *v, true
  45861. }
  45862. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  45863. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45865. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45866. if !m.op.Is(OpUpdateOne) {
  45867. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45868. }
  45869. if m.id == nil || m.oldValue == nil {
  45870. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45871. }
  45872. oldValue, err := m.oldValue(ctx)
  45873. if err != nil {
  45874. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45875. }
  45876. return oldValue.OrganizationID, nil
  45877. }
  45878. // AddOrganizationID adds u to the "organization_id" field.
  45879. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  45880. if m.addorganization_id != nil {
  45881. *m.addorganization_id += u
  45882. } else {
  45883. m.addorganization_id = &u
  45884. }
  45885. }
  45886. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45887. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  45888. v := m.addorganization_id
  45889. if v == nil {
  45890. return
  45891. }
  45892. return *v, true
  45893. }
  45894. // ResetOrganizationID resets all changes to the "organization_id" field.
  45895. func (m *XunjiServiceMutation) ResetOrganizationID() {
  45896. m.organization_id = nil
  45897. m.addorganization_id = nil
  45898. }
  45899. // SetWxid sets the "wxid" field.
  45900. func (m *XunjiServiceMutation) SetWxid(s string) {
  45901. m.wxid = &s
  45902. }
  45903. // Wxid returns the value of the "wxid" field in the mutation.
  45904. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  45905. v := m.wxid
  45906. if v == nil {
  45907. return
  45908. }
  45909. return *v, true
  45910. }
  45911. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  45912. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45914. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  45915. if !m.op.Is(OpUpdateOne) {
  45916. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45917. }
  45918. if m.id == nil || m.oldValue == nil {
  45919. return v, errors.New("OldWxid requires an ID field in the mutation")
  45920. }
  45921. oldValue, err := m.oldValue(ctx)
  45922. if err != nil {
  45923. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45924. }
  45925. return oldValue.Wxid, nil
  45926. }
  45927. // ResetWxid resets all changes to the "wxid" field.
  45928. func (m *XunjiServiceMutation) ResetWxid() {
  45929. m.wxid = nil
  45930. }
  45931. // SetAPIBase sets the "api_base" field.
  45932. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  45933. m.api_base = &s
  45934. }
  45935. // APIBase returns the value of the "api_base" field in the mutation.
  45936. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  45937. v := m.api_base
  45938. if v == nil {
  45939. return
  45940. }
  45941. return *v, true
  45942. }
  45943. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  45944. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45946. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45947. if !m.op.Is(OpUpdateOne) {
  45948. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45949. }
  45950. if m.id == nil || m.oldValue == nil {
  45951. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45952. }
  45953. oldValue, err := m.oldValue(ctx)
  45954. if err != nil {
  45955. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45956. }
  45957. return oldValue.APIBase, nil
  45958. }
  45959. // ClearAPIBase clears the value of the "api_base" field.
  45960. func (m *XunjiServiceMutation) ClearAPIBase() {
  45961. m.api_base = nil
  45962. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  45963. }
  45964. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45965. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  45966. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  45967. return ok
  45968. }
  45969. // ResetAPIBase resets all changes to the "api_base" field.
  45970. func (m *XunjiServiceMutation) ResetAPIBase() {
  45971. m.api_base = nil
  45972. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  45973. }
  45974. // SetAPIKey sets the "api_key" field.
  45975. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  45976. m.api_key = &s
  45977. }
  45978. // APIKey returns the value of the "api_key" field in the mutation.
  45979. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  45980. v := m.api_key
  45981. if v == nil {
  45982. return
  45983. }
  45984. return *v, true
  45985. }
  45986. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  45987. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  45988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45989. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45990. if !m.op.Is(OpUpdateOne) {
  45991. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45992. }
  45993. if m.id == nil || m.oldValue == nil {
  45994. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45995. }
  45996. oldValue, err := m.oldValue(ctx)
  45997. if err != nil {
  45998. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45999. }
  46000. return oldValue.APIKey, nil
  46001. }
  46002. // ClearAPIKey clears the value of the "api_key" field.
  46003. func (m *XunjiServiceMutation) ClearAPIKey() {
  46004. m.api_key = nil
  46005. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  46006. }
  46007. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  46008. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  46009. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  46010. return ok
  46011. }
  46012. // ResetAPIKey resets all changes to the "api_key" field.
  46013. func (m *XunjiServiceMutation) ResetAPIKey() {
  46014. m.api_key = nil
  46015. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  46016. }
  46017. // ClearAgent clears the "agent" edge to the Agent entity.
  46018. func (m *XunjiServiceMutation) ClearAgent() {
  46019. m.clearedagent = true
  46020. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  46021. }
  46022. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  46023. func (m *XunjiServiceMutation) AgentCleared() bool {
  46024. return m.clearedagent
  46025. }
  46026. // AgentIDs returns the "agent" edge IDs in the mutation.
  46027. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  46028. // AgentID instead. It exists only for internal usage by the builders.
  46029. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  46030. if id := m.agent; id != nil {
  46031. ids = append(ids, *id)
  46032. }
  46033. return
  46034. }
  46035. // ResetAgent resets all changes to the "agent" edge.
  46036. func (m *XunjiServiceMutation) ResetAgent() {
  46037. m.agent = nil
  46038. m.clearedagent = false
  46039. }
  46040. // Where appends a list predicates to the XunjiServiceMutation builder.
  46041. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  46042. m.predicates = append(m.predicates, ps...)
  46043. }
  46044. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  46045. // users can use type-assertion to append predicates that do not depend on any generated package.
  46046. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  46047. p := make([]predicate.XunjiService, len(ps))
  46048. for i := range ps {
  46049. p[i] = ps[i]
  46050. }
  46051. m.Where(p...)
  46052. }
  46053. // Op returns the operation name.
  46054. func (m *XunjiServiceMutation) Op() Op {
  46055. return m.op
  46056. }
  46057. // SetOp allows setting the mutation operation.
  46058. func (m *XunjiServiceMutation) SetOp(op Op) {
  46059. m.op = op
  46060. }
  46061. // Type returns the node type of this mutation (XunjiService).
  46062. func (m *XunjiServiceMutation) Type() string {
  46063. return m.typ
  46064. }
  46065. // Fields returns all fields that were changed during this mutation. Note that in
  46066. // order to get all numeric fields that were incremented/decremented, call
  46067. // AddedFields().
  46068. func (m *XunjiServiceMutation) Fields() []string {
  46069. fields := make([]string, 0, 10)
  46070. if m.created_at != nil {
  46071. fields = append(fields, xunjiservice.FieldCreatedAt)
  46072. }
  46073. if m.updated_at != nil {
  46074. fields = append(fields, xunjiservice.FieldUpdatedAt)
  46075. }
  46076. if m.status != nil {
  46077. fields = append(fields, xunjiservice.FieldStatus)
  46078. }
  46079. if m.deleted_at != nil {
  46080. fields = append(fields, xunjiservice.FieldDeletedAt)
  46081. }
  46082. if m.xunji_id != nil {
  46083. fields = append(fields, xunjiservice.FieldXunjiID)
  46084. }
  46085. if m.agent != nil {
  46086. fields = append(fields, xunjiservice.FieldAgentID)
  46087. }
  46088. if m.organization_id != nil {
  46089. fields = append(fields, xunjiservice.FieldOrganizationID)
  46090. }
  46091. if m.wxid != nil {
  46092. fields = append(fields, xunjiservice.FieldWxid)
  46093. }
  46094. if m.api_base != nil {
  46095. fields = append(fields, xunjiservice.FieldAPIBase)
  46096. }
  46097. if m.api_key != nil {
  46098. fields = append(fields, xunjiservice.FieldAPIKey)
  46099. }
  46100. return fields
  46101. }
  46102. // Field returns the value of a field with the given name. The second boolean
  46103. // return value indicates that this field was not set, or was not defined in the
  46104. // schema.
  46105. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  46106. switch name {
  46107. case xunjiservice.FieldCreatedAt:
  46108. return m.CreatedAt()
  46109. case xunjiservice.FieldUpdatedAt:
  46110. return m.UpdatedAt()
  46111. case xunjiservice.FieldStatus:
  46112. return m.Status()
  46113. case xunjiservice.FieldDeletedAt:
  46114. return m.DeletedAt()
  46115. case xunjiservice.FieldXunjiID:
  46116. return m.XunjiID()
  46117. case xunjiservice.FieldAgentID:
  46118. return m.AgentID()
  46119. case xunjiservice.FieldOrganizationID:
  46120. return m.OrganizationID()
  46121. case xunjiservice.FieldWxid:
  46122. return m.Wxid()
  46123. case xunjiservice.FieldAPIBase:
  46124. return m.APIBase()
  46125. case xunjiservice.FieldAPIKey:
  46126. return m.APIKey()
  46127. }
  46128. return nil, false
  46129. }
  46130. // OldField returns the old value of the field from the database. An error is
  46131. // returned if the mutation operation is not UpdateOne, or the query to the
  46132. // database failed.
  46133. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46134. switch name {
  46135. case xunjiservice.FieldCreatedAt:
  46136. return m.OldCreatedAt(ctx)
  46137. case xunjiservice.FieldUpdatedAt:
  46138. return m.OldUpdatedAt(ctx)
  46139. case xunjiservice.FieldStatus:
  46140. return m.OldStatus(ctx)
  46141. case xunjiservice.FieldDeletedAt:
  46142. return m.OldDeletedAt(ctx)
  46143. case xunjiservice.FieldXunjiID:
  46144. return m.OldXunjiID(ctx)
  46145. case xunjiservice.FieldAgentID:
  46146. return m.OldAgentID(ctx)
  46147. case xunjiservice.FieldOrganizationID:
  46148. return m.OldOrganizationID(ctx)
  46149. case xunjiservice.FieldWxid:
  46150. return m.OldWxid(ctx)
  46151. case xunjiservice.FieldAPIBase:
  46152. return m.OldAPIBase(ctx)
  46153. case xunjiservice.FieldAPIKey:
  46154. return m.OldAPIKey(ctx)
  46155. }
  46156. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  46157. }
  46158. // SetField sets the value of a field with the given name. It returns an error if
  46159. // the field is not defined in the schema, or if the type mismatched the field
  46160. // type.
  46161. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  46162. switch name {
  46163. case xunjiservice.FieldCreatedAt:
  46164. v, ok := value.(time.Time)
  46165. if !ok {
  46166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46167. }
  46168. m.SetCreatedAt(v)
  46169. return nil
  46170. case xunjiservice.FieldUpdatedAt:
  46171. v, ok := value.(time.Time)
  46172. if !ok {
  46173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46174. }
  46175. m.SetUpdatedAt(v)
  46176. return nil
  46177. case xunjiservice.FieldStatus:
  46178. v, ok := value.(uint8)
  46179. if !ok {
  46180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46181. }
  46182. m.SetStatus(v)
  46183. return nil
  46184. case xunjiservice.FieldDeletedAt:
  46185. v, ok := value.(time.Time)
  46186. if !ok {
  46187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46188. }
  46189. m.SetDeletedAt(v)
  46190. return nil
  46191. case xunjiservice.FieldXunjiID:
  46192. v, ok := value.(uint64)
  46193. if !ok {
  46194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46195. }
  46196. m.SetXunjiID(v)
  46197. return nil
  46198. case xunjiservice.FieldAgentID:
  46199. v, ok := value.(uint64)
  46200. if !ok {
  46201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46202. }
  46203. m.SetAgentID(v)
  46204. return nil
  46205. case xunjiservice.FieldOrganizationID:
  46206. v, ok := value.(uint64)
  46207. if !ok {
  46208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46209. }
  46210. m.SetOrganizationID(v)
  46211. return nil
  46212. case xunjiservice.FieldWxid:
  46213. v, ok := value.(string)
  46214. if !ok {
  46215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46216. }
  46217. m.SetWxid(v)
  46218. return nil
  46219. case xunjiservice.FieldAPIBase:
  46220. v, ok := value.(string)
  46221. if !ok {
  46222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46223. }
  46224. m.SetAPIBase(v)
  46225. return nil
  46226. case xunjiservice.FieldAPIKey:
  46227. v, ok := value.(string)
  46228. if !ok {
  46229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46230. }
  46231. m.SetAPIKey(v)
  46232. return nil
  46233. }
  46234. return fmt.Errorf("unknown XunjiService field %s", name)
  46235. }
  46236. // AddedFields returns all numeric fields that were incremented/decremented during
  46237. // this mutation.
  46238. func (m *XunjiServiceMutation) AddedFields() []string {
  46239. var fields []string
  46240. if m.addstatus != nil {
  46241. fields = append(fields, xunjiservice.FieldStatus)
  46242. }
  46243. if m.addxunji_id != nil {
  46244. fields = append(fields, xunjiservice.FieldXunjiID)
  46245. }
  46246. if m.addorganization_id != nil {
  46247. fields = append(fields, xunjiservice.FieldOrganizationID)
  46248. }
  46249. return fields
  46250. }
  46251. // AddedField returns the numeric value that was incremented/decremented on a field
  46252. // with the given name. The second boolean return value indicates that this field
  46253. // was not set, or was not defined in the schema.
  46254. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  46255. switch name {
  46256. case xunjiservice.FieldStatus:
  46257. return m.AddedStatus()
  46258. case xunjiservice.FieldXunjiID:
  46259. return m.AddedXunjiID()
  46260. case xunjiservice.FieldOrganizationID:
  46261. return m.AddedOrganizationID()
  46262. }
  46263. return nil, false
  46264. }
  46265. // AddField adds the value to the field with the given name. It returns an error if
  46266. // the field is not defined in the schema, or if the type mismatched the field
  46267. // type.
  46268. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  46269. switch name {
  46270. case xunjiservice.FieldStatus:
  46271. v, ok := value.(int8)
  46272. if !ok {
  46273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46274. }
  46275. m.AddStatus(v)
  46276. return nil
  46277. case xunjiservice.FieldXunjiID:
  46278. v, ok := value.(int64)
  46279. if !ok {
  46280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46281. }
  46282. m.AddXunjiID(v)
  46283. return nil
  46284. case xunjiservice.FieldOrganizationID:
  46285. v, ok := value.(int64)
  46286. if !ok {
  46287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46288. }
  46289. m.AddOrganizationID(v)
  46290. return nil
  46291. }
  46292. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  46293. }
  46294. // ClearedFields returns all nullable fields that were cleared during this
  46295. // mutation.
  46296. func (m *XunjiServiceMutation) ClearedFields() []string {
  46297. var fields []string
  46298. if m.FieldCleared(xunjiservice.FieldStatus) {
  46299. fields = append(fields, xunjiservice.FieldStatus)
  46300. }
  46301. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  46302. fields = append(fields, xunjiservice.FieldDeletedAt)
  46303. }
  46304. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  46305. fields = append(fields, xunjiservice.FieldAPIBase)
  46306. }
  46307. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  46308. fields = append(fields, xunjiservice.FieldAPIKey)
  46309. }
  46310. return fields
  46311. }
  46312. // FieldCleared returns a boolean indicating if a field with the given name was
  46313. // cleared in this mutation.
  46314. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  46315. _, ok := m.clearedFields[name]
  46316. return ok
  46317. }
  46318. // ClearField clears the value of the field with the given name. It returns an
  46319. // error if the field is not defined in the schema.
  46320. func (m *XunjiServiceMutation) ClearField(name string) error {
  46321. switch name {
  46322. case xunjiservice.FieldStatus:
  46323. m.ClearStatus()
  46324. return nil
  46325. case xunjiservice.FieldDeletedAt:
  46326. m.ClearDeletedAt()
  46327. return nil
  46328. case xunjiservice.FieldAPIBase:
  46329. m.ClearAPIBase()
  46330. return nil
  46331. case xunjiservice.FieldAPIKey:
  46332. m.ClearAPIKey()
  46333. return nil
  46334. }
  46335. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  46336. }
  46337. // ResetField resets all changes in the mutation for the field with the given name.
  46338. // It returns an error if the field is not defined in the schema.
  46339. func (m *XunjiServiceMutation) ResetField(name string) error {
  46340. switch name {
  46341. case xunjiservice.FieldCreatedAt:
  46342. m.ResetCreatedAt()
  46343. return nil
  46344. case xunjiservice.FieldUpdatedAt:
  46345. m.ResetUpdatedAt()
  46346. return nil
  46347. case xunjiservice.FieldStatus:
  46348. m.ResetStatus()
  46349. return nil
  46350. case xunjiservice.FieldDeletedAt:
  46351. m.ResetDeletedAt()
  46352. return nil
  46353. case xunjiservice.FieldXunjiID:
  46354. m.ResetXunjiID()
  46355. return nil
  46356. case xunjiservice.FieldAgentID:
  46357. m.ResetAgentID()
  46358. return nil
  46359. case xunjiservice.FieldOrganizationID:
  46360. m.ResetOrganizationID()
  46361. return nil
  46362. case xunjiservice.FieldWxid:
  46363. m.ResetWxid()
  46364. return nil
  46365. case xunjiservice.FieldAPIBase:
  46366. m.ResetAPIBase()
  46367. return nil
  46368. case xunjiservice.FieldAPIKey:
  46369. m.ResetAPIKey()
  46370. return nil
  46371. }
  46372. return fmt.Errorf("unknown XunjiService field %s", name)
  46373. }
  46374. // AddedEdges returns all edge names that were set/added in this mutation.
  46375. func (m *XunjiServiceMutation) AddedEdges() []string {
  46376. edges := make([]string, 0, 1)
  46377. if m.agent != nil {
  46378. edges = append(edges, xunjiservice.EdgeAgent)
  46379. }
  46380. return edges
  46381. }
  46382. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46383. // name in this mutation.
  46384. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  46385. switch name {
  46386. case xunjiservice.EdgeAgent:
  46387. if id := m.agent; id != nil {
  46388. return []ent.Value{*id}
  46389. }
  46390. }
  46391. return nil
  46392. }
  46393. // RemovedEdges returns all edge names that were removed in this mutation.
  46394. func (m *XunjiServiceMutation) RemovedEdges() []string {
  46395. edges := make([]string, 0, 1)
  46396. return edges
  46397. }
  46398. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46399. // the given name in this mutation.
  46400. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  46401. return nil
  46402. }
  46403. // ClearedEdges returns all edge names that were cleared in this mutation.
  46404. func (m *XunjiServiceMutation) ClearedEdges() []string {
  46405. edges := make([]string, 0, 1)
  46406. if m.clearedagent {
  46407. edges = append(edges, xunjiservice.EdgeAgent)
  46408. }
  46409. return edges
  46410. }
  46411. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46412. // was cleared in this mutation.
  46413. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  46414. switch name {
  46415. case xunjiservice.EdgeAgent:
  46416. return m.clearedagent
  46417. }
  46418. return false
  46419. }
  46420. // ClearEdge clears the value of the edge with the given name. It returns an error
  46421. // if that edge is not defined in the schema.
  46422. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  46423. switch name {
  46424. case xunjiservice.EdgeAgent:
  46425. m.ClearAgent()
  46426. return nil
  46427. }
  46428. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  46429. }
  46430. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46431. // It returns an error if the edge is not defined in the schema.
  46432. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  46433. switch name {
  46434. case xunjiservice.EdgeAgent:
  46435. m.ResetAgent()
  46436. return nil
  46437. }
  46438. return fmt.Errorf("unknown XunjiService edge %s", name)
  46439. }