mutation.go 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381
  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/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/compapiasynctask"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/contactfield"
  21. "wechat-api/ent/contactfieldtemplate"
  22. "wechat-api/ent/creditbalance"
  23. "wechat-api/ent/creditusage"
  24. "wechat-api/ent/custom_types"
  25. "wechat-api/ent/employee"
  26. "wechat-api/ent/employeeconfig"
  27. "wechat-api/ent/label"
  28. "wechat-api/ent/labelrelationship"
  29. "wechat-api/ent/labeltagging"
  30. "wechat-api/ent/message"
  31. "wechat-api/ent/messagerecords"
  32. "wechat-api/ent/msg"
  33. "wechat-api/ent/payrecharge"
  34. "wechat-api/ent/predicate"
  35. "wechat-api/ent/server"
  36. "wechat-api/ent/sopnode"
  37. "wechat-api/ent/sopstage"
  38. "wechat-api/ent/soptask"
  39. "wechat-api/ent/token"
  40. "wechat-api/ent/tutorial"
  41. "wechat-api/ent/usagedetail"
  42. "wechat-api/ent/usagestatisticday"
  43. "wechat-api/ent/usagestatistichour"
  44. "wechat-api/ent/usagestatisticmonth"
  45. "wechat-api/ent/usagetotal"
  46. "wechat-api/ent/whatsapp"
  47. "wechat-api/ent/whatsappchannel"
  48. "wechat-api/ent/workexperience"
  49. "wechat-api/ent/wpchatroom"
  50. "wechat-api/ent/wpchatroommember"
  51. "wechat-api/ent/wx"
  52. "wechat-api/ent/wxcard"
  53. "wechat-api/ent/wxcarduser"
  54. "wechat-api/ent/wxcardvisit"
  55. "entgo.io/ent"
  56. "entgo.io/ent/dialect/sql"
  57. )
  58. const (
  59. // Operation types.
  60. OpCreate = ent.OpCreate
  61. OpDelete = ent.OpDelete
  62. OpDeleteOne = ent.OpDeleteOne
  63. OpUpdate = ent.OpUpdate
  64. OpUpdateOne = ent.OpUpdateOne
  65. // Node types.
  66. TypeAgent = "Agent"
  67. TypeAgentBase = "AgentBase"
  68. TypeAliyunAvatar = "AliyunAvatar"
  69. TypeAllocAgent = "AllocAgent"
  70. TypeApiKey = "ApiKey"
  71. TypeBatchMsg = "BatchMsg"
  72. TypeCategory = "Category"
  73. TypeChatRecords = "ChatRecords"
  74. TypeChatSession = "ChatSession"
  75. TypeCompapiAsynctask = "CompapiAsynctask"
  76. TypeContact = "Contact"
  77. TypeContactField = "ContactField"
  78. TypeContactFieldTemplate = "ContactFieldTemplate"
  79. TypeCreditBalance = "CreditBalance"
  80. TypeCreditUsage = "CreditUsage"
  81. TypeEmployee = "Employee"
  82. TypeEmployeeConfig = "EmployeeConfig"
  83. TypeLabel = "Label"
  84. TypeLabelRelationship = "LabelRelationship"
  85. TypeLabelTagging = "LabelTagging"
  86. TypeMessage = "Message"
  87. TypeMessageRecords = "MessageRecords"
  88. TypeMsg = "Msg"
  89. TypePayRecharge = "PayRecharge"
  90. TypeServer = "Server"
  91. TypeSopNode = "SopNode"
  92. TypeSopStage = "SopStage"
  93. TypeSopTask = "SopTask"
  94. TypeToken = "Token"
  95. TypeTutorial = "Tutorial"
  96. TypeUsageDetail = "UsageDetail"
  97. TypeUsageStatisticDay = "UsageStatisticDay"
  98. TypeUsageStatisticHour = "UsageStatisticHour"
  99. TypeUsageStatisticMonth = "UsageStatisticMonth"
  100. TypeUsageTotal = "UsageTotal"
  101. TypeWhatsapp = "Whatsapp"
  102. TypeWhatsappChannel = "WhatsappChannel"
  103. TypeWorkExperience = "WorkExperience"
  104. TypeWpChatroom = "WpChatroom"
  105. TypeWpChatroomMember = "WpChatroomMember"
  106. TypeWx = "Wx"
  107. TypeWxCard = "WxCard"
  108. TypeWxCardUser = "WxCardUser"
  109. TypeWxCardVisit = "WxCardVisit"
  110. )
  111. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  112. type AgentMutation struct {
  113. config
  114. op Op
  115. typ string
  116. id *uint64
  117. created_at *time.Time
  118. updated_at *time.Time
  119. deleted_at *time.Time
  120. name *string
  121. role *string
  122. status *int
  123. addstatus *int
  124. background *string
  125. examples *string
  126. organization_id *uint64
  127. addorganization_id *int64
  128. dataset_id *string
  129. collection_id *string
  130. model *string
  131. api_base *string
  132. api_key *string
  133. _type *int
  134. add_type *int
  135. clearedFields map[string]struct{}
  136. wx_agent map[uint64]struct{}
  137. removedwx_agent map[uint64]struct{}
  138. clearedwx_agent bool
  139. token_agent map[uint64]struct{}
  140. removedtoken_agent map[uint64]struct{}
  141. clearedtoken_agent bool
  142. wa_agent map[uint64]struct{}
  143. removedwa_agent map[uint64]struct{}
  144. clearedwa_agent bool
  145. key_agent map[uint64]struct{}
  146. removedkey_agent map[uint64]struct{}
  147. clearedkey_agent bool
  148. done bool
  149. oldValue func(context.Context) (*Agent, error)
  150. predicates []predicate.Agent
  151. }
  152. var _ ent.Mutation = (*AgentMutation)(nil)
  153. // agentOption allows management of the mutation configuration using functional options.
  154. type agentOption func(*AgentMutation)
  155. // newAgentMutation creates new mutation for the Agent entity.
  156. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  157. m := &AgentMutation{
  158. config: c,
  159. op: op,
  160. typ: TypeAgent,
  161. clearedFields: make(map[string]struct{}),
  162. }
  163. for _, opt := range opts {
  164. opt(m)
  165. }
  166. return m
  167. }
  168. // withAgentID sets the ID field of the mutation.
  169. func withAgentID(id uint64) agentOption {
  170. return func(m *AgentMutation) {
  171. var (
  172. err error
  173. once sync.Once
  174. value *Agent
  175. )
  176. m.oldValue = func(ctx context.Context) (*Agent, error) {
  177. once.Do(func() {
  178. if m.done {
  179. err = errors.New("querying old values post mutation is not allowed")
  180. } else {
  181. value, err = m.Client().Agent.Get(ctx, id)
  182. }
  183. })
  184. return value, err
  185. }
  186. m.id = &id
  187. }
  188. }
  189. // withAgent sets the old Agent of the mutation.
  190. func withAgent(node *Agent) agentOption {
  191. return func(m *AgentMutation) {
  192. m.oldValue = func(context.Context) (*Agent, error) {
  193. return node, nil
  194. }
  195. m.id = &node.ID
  196. }
  197. }
  198. // Client returns a new `ent.Client` from the mutation. If the mutation was
  199. // executed in a transaction (ent.Tx), a transactional client is returned.
  200. func (m AgentMutation) Client() *Client {
  201. client := &Client{config: m.config}
  202. client.init()
  203. return client
  204. }
  205. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  206. // it returns an error otherwise.
  207. func (m AgentMutation) Tx() (*Tx, error) {
  208. if _, ok := m.driver.(*txDriver); !ok {
  209. return nil, errors.New("ent: mutation is not running in a transaction")
  210. }
  211. tx := &Tx{config: m.config}
  212. tx.init()
  213. return tx, nil
  214. }
  215. // SetID sets the value of the id field. Note that this
  216. // operation is only accepted on creation of Agent entities.
  217. func (m *AgentMutation) SetID(id uint64) {
  218. m.id = &id
  219. }
  220. // ID returns the ID value in the mutation. Note that the ID is only available
  221. // if it was provided to the builder or after it was returned from the database.
  222. func (m *AgentMutation) ID() (id uint64, exists bool) {
  223. if m.id == nil {
  224. return
  225. }
  226. return *m.id, true
  227. }
  228. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  229. // That means, if the mutation is applied within a transaction with an isolation level such
  230. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  231. // or updated by the mutation.
  232. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  233. switch {
  234. case m.op.Is(OpUpdateOne | OpDeleteOne):
  235. id, exists := m.ID()
  236. if exists {
  237. return []uint64{id}, nil
  238. }
  239. fallthrough
  240. case m.op.Is(OpUpdate | OpDelete):
  241. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  242. default:
  243. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  244. }
  245. }
  246. // SetCreatedAt sets the "created_at" field.
  247. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  248. m.created_at = &t
  249. }
  250. // CreatedAt returns the value of the "created_at" field in the mutation.
  251. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  252. v := m.created_at
  253. if v == nil {
  254. return
  255. }
  256. return *v, true
  257. }
  258. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  259. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  261. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  262. if !m.op.Is(OpUpdateOne) {
  263. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  264. }
  265. if m.id == nil || m.oldValue == nil {
  266. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  267. }
  268. oldValue, err := m.oldValue(ctx)
  269. if err != nil {
  270. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  271. }
  272. return oldValue.CreatedAt, nil
  273. }
  274. // ResetCreatedAt resets all changes to the "created_at" field.
  275. func (m *AgentMutation) ResetCreatedAt() {
  276. m.created_at = nil
  277. }
  278. // SetUpdatedAt sets the "updated_at" field.
  279. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  280. m.updated_at = &t
  281. }
  282. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  283. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  284. v := m.updated_at
  285. if v == nil {
  286. return
  287. }
  288. return *v, true
  289. }
  290. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  291. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  293. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  294. if !m.op.Is(OpUpdateOne) {
  295. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  296. }
  297. if m.id == nil || m.oldValue == nil {
  298. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  299. }
  300. oldValue, err := m.oldValue(ctx)
  301. if err != nil {
  302. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  303. }
  304. return oldValue.UpdatedAt, nil
  305. }
  306. // ResetUpdatedAt resets all changes to the "updated_at" field.
  307. func (m *AgentMutation) ResetUpdatedAt() {
  308. m.updated_at = nil
  309. }
  310. // SetDeletedAt sets the "deleted_at" field.
  311. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  312. m.deleted_at = &t
  313. }
  314. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  315. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  316. v := m.deleted_at
  317. if v == nil {
  318. return
  319. }
  320. return *v, true
  321. }
  322. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  323. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  325. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  326. if !m.op.Is(OpUpdateOne) {
  327. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  328. }
  329. if m.id == nil || m.oldValue == nil {
  330. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  331. }
  332. oldValue, err := m.oldValue(ctx)
  333. if err != nil {
  334. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  335. }
  336. return oldValue.DeletedAt, nil
  337. }
  338. // ClearDeletedAt clears the value of the "deleted_at" field.
  339. func (m *AgentMutation) ClearDeletedAt() {
  340. m.deleted_at = nil
  341. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  342. }
  343. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  344. func (m *AgentMutation) DeletedAtCleared() bool {
  345. _, ok := m.clearedFields[agent.FieldDeletedAt]
  346. return ok
  347. }
  348. // ResetDeletedAt resets all changes to the "deleted_at" field.
  349. func (m *AgentMutation) ResetDeletedAt() {
  350. m.deleted_at = nil
  351. delete(m.clearedFields, agent.FieldDeletedAt)
  352. }
  353. // SetName sets the "name" field.
  354. func (m *AgentMutation) SetName(s string) {
  355. m.name = &s
  356. }
  357. // Name returns the value of the "name" field in the mutation.
  358. func (m *AgentMutation) Name() (r string, exists bool) {
  359. v := m.name
  360. if v == nil {
  361. return
  362. }
  363. return *v, true
  364. }
  365. // OldName returns the old "name" field's value of the Agent entity.
  366. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  368. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  369. if !m.op.Is(OpUpdateOne) {
  370. return v, errors.New("OldName is only allowed on UpdateOne operations")
  371. }
  372. if m.id == nil || m.oldValue == nil {
  373. return v, errors.New("OldName requires an ID field in the mutation")
  374. }
  375. oldValue, err := m.oldValue(ctx)
  376. if err != nil {
  377. return v, fmt.Errorf("querying old value for OldName: %w", err)
  378. }
  379. return oldValue.Name, nil
  380. }
  381. // ResetName resets all changes to the "name" field.
  382. func (m *AgentMutation) ResetName() {
  383. m.name = nil
  384. }
  385. // SetRole sets the "role" field.
  386. func (m *AgentMutation) SetRole(s string) {
  387. m.role = &s
  388. }
  389. // Role returns the value of the "role" field in the mutation.
  390. func (m *AgentMutation) Role() (r string, exists bool) {
  391. v := m.role
  392. if v == nil {
  393. return
  394. }
  395. return *v, true
  396. }
  397. // OldRole returns the old "role" field's value of the Agent entity.
  398. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  400. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  401. if !m.op.Is(OpUpdateOne) {
  402. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  403. }
  404. if m.id == nil || m.oldValue == nil {
  405. return v, errors.New("OldRole requires an ID field in the mutation")
  406. }
  407. oldValue, err := m.oldValue(ctx)
  408. if err != nil {
  409. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  410. }
  411. return oldValue.Role, nil
  412. }
  413. // ClearRole clears the value of the "role" field.
  414. func (m *AgentMutation) ClearRole() {
  415. m.role = nil
  416. m.clearedFields[agent.FieldRole] = struct{}{}
  417. }
  418. // RoleCleared returns if the "role" field was cleared in this mutation.
  419. func (m *AgentMutation) RoleCleared() bool {
  420. _, ok := m.clearedFields[agent.FieldRole]
  421. return ok
  422. }
  423. // ResetRole resets all changes to the "role" field.
  424. func (m *AgentMutation) ResetRole() {
  425. m.role = nil
  426. delete(m.clearedFields, agent.FieldRole)
  427. }
  428. // SetStatus sets the "status" field.
  429. func (m *AgentMutation) SetStatus(i int) {
  430. m.status = &i
  431. m.addstatus = nil
  432. }
  433. // Status returns the value of the "status" field in the mutation.
  434. func (m *AgentMutation) Status() (r int, exists bool) {
  435. v := m.status
  436. if v == nil {
  437. return
  438. }
  439. return *v, true
  440. }
  441. // OldStatus returns the old "status" field's value of the Agent entity.
  442. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  444. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  445. if !m.op.Is(OpUpdateOne) {
  446. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  447. }
  448. if m.id == nil || m.oldValue == nil {
  449. return v, errors.New("OldStatus requires an ID field in the mutation")
  450. }
  451. oldValue, err := m.oldValue(ctx)
  452. if err != nil {
  453. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  454. }
  455. return oldValue.Status, nil
  456. }
  457. // AddStatus adds i to the "status" field.
  458. func (m *AgentMutation) AddStatus(i int) {
  459. if m.addstatus != nil {
  460. *m.addstatus += i
  461. } else {
  462. m.addstatus = &i
  463. }
  464. }
  465. // AddedStatus returns the value that was added to the "status" field in this mutation.
  466. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  467. v := m.addstatus
  468. if v == nil {
  469. return
  470. }
  471. return *v, true
  472. }
  473. // ClearStatus clears the value of the "status" field.
  474. func (m *AgentMutation) ClearStatus() {
  475. m.status = nil
  476. m.addstatus = nil
  477. m.clearedFields[agent.FieldStatus] = struct{}{}
  478. }
  479. // StatusCleared returns if the "status" field was cleared in this mutation.
  480. func (m *AgentMutation) StatusCleared() bool {
  481. _, ok := m.clearedFields[agent.FieldStatus]
  482. return ok
  483. }
  484. // ResetStatus resets all changes to the "status" field.
  485. func (m *AgentMutation) ResetStatus() {
  486. m.status = nil
  487. m.addstatus = nil
  488. delete(m.clearedFields, agent.FieldStatus)
  489. }
  490. // SetBackground sets the "background" field.
  491. func (m *AgentMutation) SetBackground(s string) {
  492. m.background = &s
  493. }
  494. // Background returns the value of the "background" field in the mutation.
  495. func (m *AgentMutation) Background() (r string, exists bool) {
  496. v := m.background
  497. if v == nil {
  498. return
  499. }
  500. return *v, true
  501. }
  502. // OldBackground returns the old "background" field's value of the Agent entity.
  503. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  505. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  506. if !m.op.Is(OpUpdateOne) {
  507. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  508. }
  509. if m.id == nil || m.oldValue == nil {
  510. return v, errors.New("OldBackground requires an ID field in the mutation")
  511. }
  512. oldValue, err := m.oldValue(ctx)
  513. if err != nil {
  514. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  515. }
  516. return oldValue.Background, nil
  517. }
  518. // ClearBackground clears the value of the "background" field.
  519. func (m *AgentMutation) ClearBackground() {
  520. m.background = nil
  521. m.clearedFields[agent.FieldBackground] = struct{}{}
  522. }
  523. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  524. func (m *AgentMutation) BackgroundCleared() bool {
  525. _, ok := m.clearedFields[agent.FieldBackground]
  526. return ok
  527. }
  528. // ResetBackground resets all changes to the "background" field.
  529. func (m *AgentMutation) ResetBackground() {
  530. m.background = nil
  531. delete(m.clearedFields, agent.FieldBackground)
  532. }
  533. // SetExamples sets the "examples" field.
  534. func (m *AgentMutation) SetExamples(s string) {
  535. m.examples = &s
  536. }
  537. // Examples returns the value of the "examples" field in the mutation.
  538. func (m *AgentMutation) Examples() (r string, exists bool) {
  539. v := m.examples
  540. if v == nil {
  541. return
  542. }
  543. return *v, true
  544. }
  545. // OldExamples returns the old "examples" field's value of the Agent entity.
  546. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  548. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  549. if !m.op.Is(OpUpdateOne) {
  550. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  551. }
  552. if m.id == nil || m.oldValue == nil {
  553. return v, errors.New("OldExamples requires an ID field in the mutation")
  554. }
  555. oldValue, err := m.oldValue(ctx)
  556. if err != nil {
  557. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  558. }
  559. return oldValue.Examples, nil
  560. }
  561. // ClearExamples clears the value of the "examples" field.
  562. func (m *AgentMutation) ClearExamples() {
  563. m.examples = nil
  564. m.clearedFields[agent.FieldExamples] = struct{}{}
  565. }
  566. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  567. func (m *AgentMutation) ExamplesCleared() bool {
  568. _, ok := m.clearedFields[agent.FieldExamples]
  569. return ok
  570. }
  571. // ResetExamples resets all changes to the "examples" field.
  572. func (m *AgentMutation) ResetExamples() {
  573. m.examples = nil
  574. delete(m.clearedFields, agent.FieldExamples)
  575. }
  576. // SetOrganizationID sets the "organization_id" field.
  577. func (m *AgentMutation) SetOrganizationID(u uint64) {
  578. m.organization_id = &u
  579. m.addorganization_id = nil
  580. }
  581. // OrganizationID returns the value of the "organization_id" field in the mutation.
  582. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  583. v := m.organization_id
  584. if v == nil {
  585. return
  586. }
  587. return *v, true
  588. }
  589. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  590. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  592. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  593. if !m.op.Is(OpUpdateOne) {
  594. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  595. }
  596. if m.id == nil || m.oldValue == nil {
  597. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  598. }
  599. oldValue, err := m.oldValue(ctx)
  600. if err != nil {
  601. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  602. }
  603. return oldValue.OrganizationID, nil
  604. }
  605. // AddOrganizationID adds u to the "organization_id" field.
  606. func (m *AgentMutation) AddOrganizationID(u int64) {
  607. if m.addorganization_id != nil {
  608. *m.addorganization_id += u
  609. } else {
  610. m.addorganization_id = &u
  611. }
  612. }
  613. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  614. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  615. v := m.addorganization_id
  616. if v == nil {
  617. return
  618. }
  619. return *v, true
  620. }
  621. // ResetOrganizationID resets all changes to the "organization_id" field.
  622. func (m *AgentMutation) ResetOrganizationID() {
  623. m.organization_id = nil
  624. m.addorganization_id = nil
  625. }
  626. // SetDatasetID sets the "dataset_id" field.
  627. func (m *AgentMutation) SetDatasetID(s string) {
  628. m.dataset_id = &s
  629. }
  630. // DatasetID returns the value of the "dataset_id" field in the mutation.
  631. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  632. v := m.dataset_id
  633. if v == nil {
  634. return
  635. }
  636. return *v, true
  637. }
  638. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  639. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  641. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  642. if !m.op.Is(OpUpdateOne) {
  643. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  644. }
  645. if m.id == nil || m.oldValue == nil {
  646. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  647. }
  648. oldValue, err := m.oldValue(ctx)
  649. if err != nil {
  650. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  651. }
  652. return oldValue.DatasetID, nil
  653. }
  654. // ResetDatasetID resets all changes to the "dataset_id" field.
  655. func (m *AgentMutation) ResetDatasetID() {
  656. m.dataset_id = nil
  657. }
  658. // SetCollectionID sets the "collection_id" field.
  659. func (m *AgentMutation) SetCollectionID(s string) {
  660. m.collection_id = &s
  661. }
  662. // CollectionID returns the value of the "collection_id" field in the mutation.
  663. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  664. v := m.collection_id
  665. if v == nil {
  666. return
  667. }
  668. return *v, true
  669. }
  670. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  671. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  673. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  674. if !m.op.Is(OpUpdateOne) {
  675. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  676. }
  677. if m.id == nil || m.oldValue == nil {
  678. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  679. }
  680. oldValue, err := m.oldValue(ctx)
  681. if err != nil {
  682. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  683. }
  684. return oldValue.CollectionID, nil
  685. }
  686. // ResetCollectionID resets all changes to the "collection_id" field.
  687. func (m *AgentMutation) ResetCollectionID() {
  688. m.collection_id = nil
  689. }
  690. // SetModel sets the "model" field.
  691. func (m *AgentMutation) SetModel(s string) {
  692. m.model = &s
  693. }
  694. // Model returns the value of the "model" field in the mutation.
  695. func (m *AgentMutation) Model() (r string, exists bool) {
  696. v := m.model
  697. if v == nil {
  698. return
  699. }
  700. return *v, true
  701. }
  702. // OldModel returns the old "model" field's value of the Agent entity.
  703. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  705. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  706. if !m.op.Is(OpUpdateOne) {
  707. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  708. }
  709. if m.id == nil || m.oldValue == nil {
  710. return v, errors.New("OldModel requires an ID field in the mutation")
  711. }
  712. oldValue, err := m.oldValue(ctx)
  713. if err != nil {
  714. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  715. }
  716. return oldValue.Model, nil
  717. }
  718. // ClearModel clears the value of the "model" field.
  719. func (m *AgentMutation) ClearModel() {
  720. m.model = nil
  721. m.clearedFields[agent.FieldModel] = struct{}{}
  722. }
  723. // ModelCleared returns if the "model" field was cleared in this mutation.
  724. func (m *AgentMutation) ModelCleared() bool {
  725. _, ok := m.clearedFields[agent.FieldModel]
  726. return ok
  727. }
  728. // ResetModel resets all changes to the "model" field.
  729. func (m *AgentMutation) ResetModel() {
  730. m.model = nil
  731. delete(m.clearedFields, agent.FieldModel)
  732. }
  733. // SetAPIBase sets the "api_base" field.
  734. func (m *AgentMutation) SetAPIBase(s string) {
  735. m.api_base = &s
  736. }
  737. // APIBase returns the value of the "api_base" field in the mutation.
  738. func (m *AgentMutation) APIBase() (r string, exists bool) {
  739. v := m.api_base
  740. if v == nil {
  741. return
  742. }
  743. return *v, true
  744. }
  745. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  746. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  748. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  749. if !m.op.Is(OpUpdateOne) {
  750. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  751. }
  752. if m.id == nil || m.oldValue == nil {
  753. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  754. }
  755. oldValue, err := m.oldValue(ctx)
  756. if err != nil {
  757. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  758. }
  759. return oldValue.APIBase, nil
  760. }
  761. // ClearAPIBase clears the value of the "api_base" field.
  762. func (m *AgentMutation) ClearAPIBase() {
  763. m.api_base = nil
  764. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  765. }
  766. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  767. func (m *AgentMutation) APIBaseCleared() bool {
  768. _, ok := m.clearedFields[agent.FieldAPIBase]
  769. return ok
  770. }
  771. // ResetAPIBase resets all changes to the "api_base" field.
  772. func (m *AgentMutation) ResetAPIBase() {
  773. m.api_base = nil
  774. delete(m.clearedFields, agent.FieldAPIBase)
  775. }
  776. // SetAPIKey sets the "api_key" field.
  777. func (m *AgentMutation) SetAPIKey(s string) {
  778. m.api_key = &s
  779. }
  780. // APIKey returns the value of the "api_key" field in the mutation.
  781. func (m *AgentMutation) APIKey() (r string, exists bool) {
  782. v := m.api_key
  783. if v == nil {
  784. return
  785. }
  786. return *v, true
  787. }
  788. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  789. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  791. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  792. if !m.op.Is(OpUpdateOne) {
  793. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  794. }
  795. if m.id == nil || m.oldValue == nil {
  796. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  797. }
  798. oldValue, err := m.oldValue(ctx)
  799. if err != nil {
  800. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  801. }
  802. return oldValue.APIKey, nil
  803. }
  804. // ClearAPIKey clears the value of the "api_key" field.
  805. func (m *AgentMutation) ClearAPIKey() {
  806. m.api_key = nil
  807. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  808. }
  809. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  810. func (m *AgentMutation) APIKeyCleared() bool {
  811. _, ok := m.clearedFields[agent.FieldAPIKey]
  812. return ok
  813. }
  814. // ResetAPIKey resets all changes to the "api_key" field.
  815. func (m *AgentMutation) ResetAPIKey() {
  816. m.api_key = nil
  817. delete(m.clearedFields, agent.FieldAPIKey)
  818. }
  819. // SetType sets the "type" field.
  820. func (m *AgentMutation) SetType(i int) {
  821. m._type = &i
  822. m.add_type = nil
  823. }
  824. // GetType returns the value of the "type" field in the mutation.
  825. func (m *AgentMutation) GetType() (r int, exists bool) {
  826. v := m._type
  827. if v == nil {
  828. return
  829. }
  830. return *v, true
  831. }
  832. // OldType returns the old "type" field's value of the Agent entity.
  833. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  835. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  836. if !m.op.Is(OpUpdateOne) {
  837. return v, errors.New("OldType is only allowed on UpdateOne operations")
  838. }
  839. if m.id == nil || m.oldValue == nil {
  840. return v, errors.New("OldType requires an ID field in the mutation")
  841. }
  842. oldValue, err := m.oldValue(ctx)
  843. if err != nil {
  844. return v, fmt.Errorf("querying old value for OldType: %w", err)
  845. }
  846. return oldValue.Type, nil
  847. }
  848. // AddType adds i to the "type" field.
  849. func (m *AgentMutation) AddType(i int) {
  850. if m.add_type != nil {
  851. *m.add_type += i
  852. } else {
  853. m.add_type = &i
  854. }
  855. }
  856. // AddedType returns the value that was added to the "type" field in this mutation.
  857. func (m *AgentMutation) AddedType() (r int, exists bool) {
  858. v := m.add_type
  859. if v == nil {
  860. return
  861. }
  862. return *v, true
  863. }
  864. // ClearType clears the value of the "type" field.
  865. func (m *AgentMutation) ClearType() {
  866. m._type = nil
  867. m.add_type = nil
  868. m.clearedFields[agent.FieldType] = struct{}{}
  869. }
  870. // TypeCleared returns if the "type" field was cleared in this mutation.
  871. func (m *AgentMutation) TypeCleared() bool {
  872. _, ok := m.clearedFields[agent.FieldType]
  873. return ok
  874. }
  875. // ResetType resets all changes to the "type" field.
  876. func (m *AgentMutation) ResetType() {
  877. m._type = nil
  878. m.add_type = nil
  879. delete(m.clearedFields, agent.FieldType)
  880. }
  881. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  882. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  883. if m.wx_agent == nil {
  884. m.wx_agent = make(map[uint64]struct{})
  885. }
  886. for i := range ids {
  887. m.wx_agent[ids[i]] = struct{}{}
  888. }
  889. }
  890. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  891. func (m *AgentMutation) ClearWxAgent() {
  892. m.clearedwx_agent = true
  893. }
  894. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  895. func (m *AgentMutation) WxAgentCleared() bool {
  896. return m.clearedwx_agent
  897. }
  898. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  899. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  900. if m.removedwx_agent == nil {
  901. m.removedwx_agent = make(map[uint64]struct{})
  902. }
  903. for i := range ids {
  904. delete(m.wx_agent, ids[i])
  905. m.removedwx_agent[ids[i]] = struct{}{}
  906. }
  907. }
  908. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  909. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  910. for id := range m.removedwx_agent {
  911. ids = append(ids, id)
  912. }
  913. return
  914. }
  915. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  916. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  917. for id := range m.wx_agent {
  918. ids = append(ids, id)
  919. }
  920. return
  921. }
  922. // ResetWxAgent resets all changes to the "wx_agent" edge.
  923. func (m *AgentMutation) ResetWxAgent() {
  924. m.wx_agent = nil
  925. m.clearedwx_agent = false
  926. m.removedwx_agent = nil
  927. }
  928. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  929. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  930. if m.token_agent == nil {
  931. m.token_agent = make(map[uint64]struct{})
  932. }
  933. for i := range ids {
  934. m.token_agent[ids[i]] = struct{}{}
  935. }
  936. }
  937. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  938. func (m *AgentMutation) ClearTokenAgent() {
  939. m.clearedtoken_agent = true
  940. }
  941. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  942. func (m *AgentMutation) TokenAgentCleared() bool {
  943. return m.clearedtoken_agent
  944. }
  945. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  946. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  947. if m.removedtoken_agent == nil {
  948. m.removedtoken_agent = make(map[uint64]struct{})
  949. }
  950. for i := range ids {
  951. delete(m.token_agent, ids[i])
  952. m.removedtoken_agent[ids[i]] = struct{}{}
  953. }
  954. }
  955. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  956. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  957. for id := range m.removedtoken_agent {
  958. ids = append(ids, id)
  959. }
  960. return
  961. }
  962. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  963. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  964. for id := range m.token_agent {
  965. ids = append(ids, id)
  966. }
  967. return
  968. }
  969. // ResetTokenAgent resets all changes to the "token_agent" edge.
  970. func (m *AgentMutation) ResetTokenAgent() {
  971. m.token_agent = nil
  972. m.clearedtoken_agent = false
  973. m.removedtoken_agent = nil
  974. }
  975. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  976. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  977. if m.wa_agent == nil {
  978. m.wa_agent = make(map[uint64]struct{})
  979. }
  980. for i := range ids {
  981. m.wa_agent[ids[i]] = struct{}{}
  982. }
  983. }
  984. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  985. func (m *AgentMutation) ClearWaAgent() {
  986. m.clearedwa_agent = true
  987. }
  988. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  989. func (m *AgentMutation) WaAgentCleared() bool {
  990. return m.clearedwa_agent
  991. }
  992. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  993. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  994. if m.removedwa_agent == nil {
  995. m.removedwa_agent = make(map[uint64]struct{})
  996. }
  997. for i := range ids {
  998. delete(m.wa_agent, ids[i])
  999. m.removedwa_agent[ids[i]] = struct{}{}
  1000. }
  1001. }
  1002. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1003. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1004. for id := range m.removedwa_agent {
  1005. ids = append(ids, id)
  1006. }
  1007. return
  1008. }
  1009. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1010. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1011. for id := range m.wa_agent {
  1012. ids = append(ids, id)
  1013. }
  1014. return
  1015. }
  1016. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1017. func (m *AgentMutation) ResetWaAgent() {
  1018. m.wa_agent = nil
  1019. m.clearedwa_agent = false
  1020. m.removedwa_agent = nil
  1021. }
  1022. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1023. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1024. if m.key_agent == nil {
  1025. m.key_agent = make(map[uint64]struct{})
  1026. }
  1027. for i := range ids {
  1028. m.key_agent[ids[i]] = struct{}{}
  1029. }
  1030. }
  1031. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1032. func (m *AgentMutation) ClearKeyAgent() {
  1033. m.clearedkey_agent = true
  1034. }
  1035. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1036. func (m *AgentMutation) KeyAgentCleared() bool {
  1037. return m.clearedkey_agent
  1038. }
  1039. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1040. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1041. if m.removedkey_agent == nil {
  1042. m.removedkey_agent = make(map[uint64]struct{})
  1043. }
  1044. for i := range ids {
  1045. delete(m.key_agent, ids[i])
  1046. m.removedkey_agent[ids[i]] = struct{}{}
  1047. }
  1048. }
  1049. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1050. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1051. for id := range m.removedkey_agent {
  1052. ids = append(ids, id)
  1053. }
  1054. return
  1055. }
  1056. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1057. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1058. for id := range m.key_agent {
  1059. ids = append(ids, id)
  1060. }
  1061. return
  1062. }
  1063. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1064. func (m *AgentMutation) ResetKeyAgent() {
  1065. m.key_agent = nil
  1066. m.clearedkey_agent = false
  1067. m.removedkey_agent = nil
  1068. }
  1069. // Where appends a list predicates to the AgentMutation builder.
  1070. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1071. m.predicates = append(m.predicates, ps...)
  1072. }
  1073. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1074. // users can use type-assertion to append predicates that do not depend on any generated package.
  1075. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1076. p := make([]predicate.Agent, len(ps))
  1077. for i := range ps {
  1078. p[i] = ps[i]
  1079. }
  1080. m.Where(p...)
  1081. }
  1082. // Op returns the operation name.
  1083. func (m *AgentMutation) Op() Op {
  1084. return m.op
  1085. }
  1086. // SetOp allows setting the mutation operation.
  1087. func (m *AgentMutation) SetOp(op Op) {
  1088. m.op = op
  1089. }
  1090. // Type returns the node type of this mutation (Agent).
  1091. func (m *AgentMutation) Type() string {
  1092. return m.typ
  1093. }
  1094. // Fields returns all fields that were changed during this mutation. Note that in
  1095. // order to get all numeric fields that were incremented/decremented, call
  1096. // AddedFields().
  1097. func (m *AgentMutation) Fields() []string {
  1098. fields := make([]string, 0, 15)
  1099. if m.created_at != nil {
  1100. fields = append(fields, agent.FieldCreatedAt)
  1101. }
  1102. if m.updated_at != nil {
  1103. fields = append(fields, agent.FieldUpdatedAt)
  1104. }
  1105. if m.deleted_at != nil {
  1106. fields = append(fields, agent.FieldDeletedAt)
  1107. }
  1108. if m.name != nil {
  1109. fields = append(fields, agent.FieldName)
  1110. }
  1111. if m.role != nil {
  1112. fields = append(fields, agent.FieldRole)
  1113. }
  1114. if m.status != nil {
  1115. fields = append(fields, agent.FieldStatus)
  1116. }
  1117. if m.background != nil {
  1118. fields = append(fields, agent.FieldBackground)
  1119. }
  1120. if m.examples != nil {
  1121. fields = append(fields, agent.FieldExamples)
  1122. }
  1123. if m.organization_id != nil {
  1124. fields = append(fields, agent.FieldOrganizationID)
  1125. }
  1126. if m.dataset_id != nil {
  1127. fields = append(fields, agent.FieldDatasetID)
  1128. }
  1129. if m.collection_id != nil {
  1130. fields = append(fields, agent.FieldCollectionID)
  1131. }
  1132. if m.model != nil {
  1133. fields = append(fields, agent.FieldModel)
  1134. }
  1135. if m.api_base != nil {
  1136. fields = append(fields, agent.FieldAPIBase)
  1137. }
  1138. if m.api_key != nil {
  1139. fields = append(fields, agent.FieldAPIKey)
  1140. }
  1141. if m._type != nil {
  1142. fields = append(fields, agent.FieldType)
  1143. }
  1144. return fields
  1145. }
  1146. // Field returns the value of a field with the given name. The second boolean
  1147. // return value indicates that this field was not set, or was not defined in the
  1148. // schema.
  1149. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1150. switch name {
  1151. case agent.FieldCreatedAt:
  1152. return m.CreatedAt()
  1153. case agent.FieldUpdatedAt:
  1154. return m.UpdatedAt()
  1155. case agent.FieldDeletedAt:
  1156. return m.DeletedAt()
  1157. case agent.FieldName:
  1158. return m.Name()
  1159. case agent.FieldRole:
  1160. return m.Role()
  1161. case agent.FieldStatus:
  1162. return m.Status()
  1163. case agent.FieldBackground:
  1164. return m.Background()
  1165. case agent.FieldExamples:
  1166. return m.Examples()
  1167. case agent.FieldOrganizationID:
  1168. return m.OrganizationID()
  1169. case agent.FieldDatasetID:
  1170. return m.DatasetID()
  1171. case agent.FieldCollectionID:
  1172. return m.CollectionID()
  1173. case agent.FieldModel:
  1174. return m.Model()
  1175. case agent.FieldAPIBase:
  1176. return m.APIBase()
  1177. case agent.FieldAPIKey:
  1178. return m.APIKey()
  1179. case agent.FieldType:
  1180. return m.GetType()
  1181. }
  1182. return nil, false
  1183. }
  1184. // OldField returns the old value of the field from the database. An error is
  1185. // returned if the mutation operation is not UpdateOne, or the query to the
  1186. // database failed.
  1187. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1188. switch name {
  1189. case agent.FieldCreatedAt:
  1190. return m.OldCreatedAt(ctx)
  1191. case agent.FieldUpdatedAt:
  1192. return m.OldUpdatedAt(ctx)
  1193. case agent.FieldDeletedAt:
  1194. return m.OldDeletedAt(ctx)
  1195. case agent.FieldName:
  1196. return m.OldName(ctx)
  1197. case agent.FieldRole:
  1198. return m.OldRole(ctx)
  1199. case agent.FieldStatus:
  1200. return m.OldStatus(ctx)
  1201. case agent.FieldBackground:
  1202. return m.OldBackground(ctx)
  1203. case agent.FieldExamples:
  1204. return m.OldExamples(ctx)
  1205. case agent.FieldOrganizationID:
  1206. return m.OldOrganizationID(ctx)
  1207. case agent.FieldDatasetID:
  1208. return m.OldDatasetID(ctx)
  1209. case agent.FieldCollectionID:
  1210. return m.OldCollectionID(ctx)
  1211. case agent.FieldModel:
  1212. return m.OldModel(ctx)
  1213. case agent.FieldAPIBase:
  1214. return m.OldAPIBase(ctx)
  1215. case agent.FieldAPIKey:
  1216. return m.OldAPIKey(ctx)
  1217. case agent.FieldType:
  1218. return m.OldType(ctx)
  1219. }
  1220. return nil, fmt.Errorf("unknown Agent field %s", name)
  1221. }
  1222. // SetField sets the value of a field with the given name. It returns an error if
  1223. // the field is not defined in the schema, or if the type mismatched the field
  1224. // type.
  1225. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1226. switch name {
  1227. case agent.FieldCreatedAt:
  1228. v, ok := value.(time.Time)
  1229. if !ok {
  1230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1231. }
  1232. m.SetCreatedAt(v)
  1233. return nil
  1234. case agent.FieldUpdatedAt:
  1235. v, ok := value.(time.Time)
  1236. if !ok {
  1237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1238. }
  1239. m.SetUpdatedAt(v)
  1240. return nil
  1241. case agent.FieldDeletedAt:
  1242. v, ok := value.(time.Time)
  1243. if !ok {
  1244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1245. }
  1246. m.SetDeletedAt(v)
  1247. return nil
  1248. case agent.FieldName:
  1249. v, ok := value.(string)
  1250. if !ok {
  1251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1252. }
  1253. m.SetName(v)
  1254. return nil
  1255. case agent.FieldRole:
  1256. v, ok := value.(string)
  1257. if !ok {
  1258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1259. }
  1260. m.SetRole(v)
  1261. return nil
  1262. case agent.FieldStatus:
  1263. v, ok := value.(int)
  1264. if !ok {
  1265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1266. }
  1267. m.SetStatus(v)
  1268. return nil
  1269. case agent.FieldBackground:
  1270. v, ok := value.(string)
  1271. if !ok {
  1272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1273. }
  1274. m.SetBackground(v)
  1275. return nil
  1276. case agent.FieldExamples:
  1277. v, ok := value.(string)
  1278. if !ok {
  1279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1280. }
  1281. m.SetExamples(v)
  1282. return nil
  1283. case agent.FieldOrganizationID:
  1284. v, ok := value.(uint64)
  1285. if !ok {
  1286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1287. }
  1288. m.SetOrganizationID(v)
  1289. return nil
  1290. case agent.FieldDatasetID:
  1291. v, ok := value.(string)
  1292. if !ok {
  1293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1294. }
  1295. m.SetDatasetID(v)
  1296. return nil
  1297. case agent.FieldCollectionID:
  1298. v, ok := value.(string)
  1299. if !ok {
  1300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1301. }
  1302. m.SetCollectionID(v)
  1303. return nil
  1304. case agent.FieldModel:
  1305. v, ok := value.(string)
  1306. if !ok {
  1307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1308. }
  1309. m.SetModel(v)
  1310. return nil
  1311. case agent.FieldAPIBase:
  1312. v, ok := value.(string)
  1313. if !ok {
  1314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1315. }
  1316. m.SetAPIBase(v)
  1317. return nil
  1318. case agent.FieldAPIKey:
  1319. v, ok := value.(string)
  1320. if !ok {
  1321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1322. }
  1323. m.SetAPIKey(v)
  1324. return nil
  1325. case agent.FieldType:
  1326. v, ok := value.(int)
  1327. if !ok {
  1328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1329. }
  1330. m.SetType(v)
  1331. return nil
  1332. }
  1333. return fmt.Errorf("unknown Agent field %s", name)
  1334. }
  1335. // AddedFields returns all numeric fields that were incremented/decremented during
  1336. // this mutation.
  1337. func (m *AgentMutation) AddedFields() []string {
  1338. var fields []string
  1339. if m.addstatus != nil {
  1340. fields = append(fields, agent.FieldStatus)
  1341. }
  1342. if m.addorganization_id != nil {
  1343. fields = append(fields, agent.FieldOrganizationID)
  1344. }
  1345. if m.add_type != nil {
  1346. fields = append(fields, agent.FieldType)
  1347. }
  1348. return fields
  1349. }
  1350. // AddedField returns the numeric value that was incremented/decremented on a field
  1351. // with the given name. The second boolean return value indicates that this field
  1352. // was not set, or was not defined in the schema.
  1353. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1354. switch name {
  1355. case agent.FieldStatus:
  1356. return m.AddedStatus()
  1357. case agent.FieldOrganizationID:
  1358. return m.AddedOrganizationID()
  1359. case agent.FieldType:
  1360. return m.AddedType()
  1361. }
  1362. return nil, false
  1363. }
  1364. // AddField adds the value to the field with the given name. It returns an error if
  1365. // the field is not defined in the schema, or if the type mismatched the field
  1366. // type.
  1367. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1368. switch name {
  1369. case agent.FieldStatus:
  1370. v, ok := value.(int)
  1371. if !ok {
  1372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1373. }
  1374. m.AddStatus(v)
  1375. return nil
  1376. case agent.FieldOrganizationID:
  1377. v, ok := value.(int64)
  1378. if !ok {
  1379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1380. }
  1381. m.AddOrganizationID(v)
  1382. return nil
  1383. case agent.FieldType:
  1384. v, ok := value.(int)
  1385. if !ok {
  1386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1387. }
  1388. m.AddType(v)
  1389. return nil
  1390. }
  1391. return fmt.Errorf("unknown Agent numeric field %s", name)
  1392. }
  1393. // ClearedFields returns all nullable fields that were cleared during this
  1394. // mutation.
  1395. func (m *AgentMutation) ClearedFields() []string {
  1396. var fields []string
  1397. if m.FieldCleared(agent.FieldDeletedAt) {
  1398. fields = append(fields, agent.FieldDeletedAt)
  1399. }
  1400. if m.FieldCleared(agent.FieldRole) {
  1401. fields = append(fields, agent.FieldRole)
  1402. }
  1403. if m.FieldCleared(agent.FieldStatus) {
  1404. fields = append(fields, agent.FieldStatus)
  1405. }
  1406. if m.FieldCleared(agent.FieldBackground) {
  1407. fields = append(fields, agent.FieldBackground)
  1408. }
  1409. if m.FieldCleared(agent.FieldExamples) {
  1410. fields = append(fields, agent.FieldExamples)
  1411. }
  1412. if m.FieldCleared(agent.FieldModel) {
  1413. fields = append(fields, agent.FieldModel)
  1414. }
  1415. if m.FieldCleared(agent.FieldAPIBase) {
  1416. fields = append(fields, agent.FieldAPIBase)
  1417. }
  1418. if m.FieldCleared(agent.FieldAPIKey) {
  1419. fields = append(fields, agent.FieldAPIKey)
  1420. }
  1421. if m.FieldCleared(agent.FieldType) {
  1422. fields = append(fields, agent.FieldType)
  1423. }
  1424. return fields
  1425. }
  1426. // FieldCleared returns a boolean indicating if a field with the given name was
  1427. // cleared in this mutation.
  1428. func (m *AgentMutation) FieldCleared(name string) bool {
  1429. _, ok := m.clearedFields[name]
  1430. return ok
  1431. }
  1432. // ClearField clears the value of the field with the given name. It returns an
  1433. // error if the field is not defined in the schema.
  1434. func (m *AgentMutation) ClearField(name string) error {
  1435. switch name {
  1436. case agent.FieldDeletedAt:
  1437. m.ClearDeletedAt()
  1438. return nil
  1439. case agent.FieldRole:
  1440. m.ClearRole()
  1441. return nil
  1442. case agent.FieldStatus:
  1443. m.ClearStatus()
  1444. return nil
  1445. case agent.FieldBackground:
  1446. m.ClearBackground()
  1447. return nil
  1448. case agent.FieldExamples:
  1449. m.ClearExamples()
  1450. return nil
  1451. case agent.FieldModel:
  1452. m.ClearModel()
  1453. return nil
  1454. case agent.FieldAPIBase:
  1455. m.ClearAPIBase()
  1456. return nil
  1457. case agent.FieldAPIKey:
  1458. m.ClearAPIKey()
  1459. return nil
  1460. case agent.FieldType:
  1461. m.ClearType()
  1462. return nil
  1463. }
  1464. return fmt.Errorf("unknown Agent nullable field %s", name)
  1465. }
  1466. // ResetField resets all changes in the mutation for the field with the given name.
  1467. // It returns an error if the field is not defined in the schema.
  1468. func (m *AgentMutation) ResetField(name string) error {
  1469. switch name {
  1470. case agent.FieldCreatedAt:
  1471. m.ResetCreatedAt()
  1472. return nil
  1473. case agent.FieldUpdatedAt:
  1474. m.ResetUpdatedAt()
  1475. return nil
  1476. case agent.FieldDeletedAt:
  1477. m.ResetDeletedAt()
  1478. return nil
  1479. case agent.FieldName:
  1480. m.ResetName()
  1481. return nil
  1482. case agent.FieldRole:
  1483. m.ResetRole()
  1484. return nil
  1485. case agent.FieldStatus:
  1486. m.ResetStatus()
  1487. return nil
  1488. case agent.FieldBackground:
  1489. m.ResetBackground()
  1490. return nil
  1491. case agent.FieldExamples:
  1492. m.ResetExamples()
  1493. return nil
  1494. case agent.FieldOrganizationID:
  1495. m.ResetOrganizationID()
  1496. return nil
  1497. case agent.FieldDatasetID:
  1498. m.ResetDatasetID()
  1499. return nil
  1500. case agent.FieldCollectionID:
  1501. m.ResetCollectionID()
  1502. return nil
  1503. case agent.FieldModel:
  1504. m.ResetModel()
  1505. return nil
  1506. case agent.FieldAPIBase:
  1507. m.ResetAPIBase()
  1508. return nil
  1509. case agent.FieldAPIKey:
  1510. m.ResetAPIKey()
  1511. return nil
  1512. case agent.FieldType:
  1513. m.ResetType()
  1514. return nil
  1515. }
  1516. return fmt.Errorf("unknown Agent field %s", name)
  1517. }
  1518. // AddedEdges returns all edge names that were set/added in this mutation.
  1519. func (m *AgentMutation) AddedEdges() []string {
  1520. edges := make([]string, 0, 4)
  1521. if m.wx_agent != nil {
  1522. edges = append(edges, agent.EdgeWxAgent)
  1523. }
  1524. if m.token_agent != nil {
  1525. edges = append(edges, agent.EdgeTokenAgent)
  1526. }
  1527. if m.wa_agent != nil {
  1528. edges = append(edges, agent.EdgeWaAgent)
  1529. }
  1530. if m.key_agent != nil {
  1531. edges = append(edges, agent.EdgeKeyAgent)
  1532. }
  1533. return edges
  1534. }
  1535. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1536. // name in this mutation.
  1537. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1538. switch name {
  1539. case agent.EdgeWxAgent:
  1540. ids := make([]ent.Value, 0, len(m.wx_agent))
  1541. for id := range m.wx_agent {
  1542. ids = append(ids, id)
  1543. }
  1544. return ids
  1545. case agent.EdgeTokenAgent:
  1546. ids := make([]ent.Value, 0, len(m.token_agent))
  1547. for id := range m.token_agent {
  1548. ids = append(ids, id)
  1549. }
  1550. return ids
  1551. case agent.EdgeWaAgent:
  1552. ids := make([]ent.Value, 0, len(m.wa_agent))
  1553. for id := range m.wa_agent {
  1554. ids = append(ids, id)
  1555. }
  1556. return ids
  1557. case agent.EdgeKeyAgent:
  1558. ids := make([]ent.Value, 0, len(m.key_agent))
  1559. for id := range m.key_agent {
  1560. ids = append(ids, id)
  1561. }
  1562. return ids
  1563. }
  1564. return nil
  1565. }
  1566. // RemovedEdges returns all edge names that were removed in this mutation.
  1567. func (m *AgentMutation) RemovedEdges() []string {
  1568. edges := make([]string, 0, 4)
  1569. if m.removedwx_agent != nil {
  1570. edges = append(edges, agent.EdgeWxAgent)
  1571. }
  1572. if m.removedtoken_agent != nil {
  1573. edges = append(edges, agent.EdgeTokenAgent)
  1574. }
  1575. if m.removedwa_agent != nil {
  1576. edges = append(edges, agent.EdgeWaAgent)
  1577. }
  1578. if m.removedkey_agent != nil {
  1579. edges = append(edges, agent.EdgeKeyAgent)
  1580. }
  1581. return edges
  1582. }
  1583. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1584. // the given name in this mutation.
  1585. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1586. switch name {
  1587. case agent.EdgeWxAgent:
  1588. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1589. for id := range m.removedwx_agent {
  1590. ids = append(ids, id)
  1591. }
  1592. return ids
  1593. case agent.EdgeTokenAgent:
  1594. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1595. for id := range m.removedtoken_agent {
  1596. ids = append(ids, id)
  1597. }
  1598. return ids
  1599. case agent.EdgeWaAgent:
  1600. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1601. for id := range m.removedwa_agent {
  1602. ids = append(ids, id)
  1603. }
  1604. return ids
  1605. case agent.EdgeKeyAgent:
  1606. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1607. for id := range m.removedkey_agent {
  1608. ids = append(ids, id)
  1609. }
  1610. return ids
  1611. }
  1612. return nil
  1613. }
  1614. // ClearedEdges returns all edge names that were cleared in this mutation.
  1615. func (m *AgentMutation) ClearedEdges() []string {
  1616. edges := make([]string, 0, 4)
  1617. if m.clearedwx_agent {
  1618. edges = append(edges, agent.EdgeWxAgent)
  1619. }
  1620. if m.clearedtoken_agent {
  1621. edges = append(edges, agent.EdgeTokenAgent)
  1622. }
  1623. if m.clearedwa_agent {
  1624. edges = append(edges, agent.EdgeWaAgent)
  1625. }
  1626. if m.clearedkey_agent {
  1627. edges = append(edges, agent.EdgeKeyAgent)
  1628. }
  1629. return edges
  1630. }
  1631. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1632. // was cleared in this mutation.
  1633. func (m *AgentMutation) EdgeCleared(name string) bool {
  1634. switch name {
  1635. case agent.EdgeWxAgent:
  1636. return m.clearedwx_agent
  1637. case agent.EdgeTokenAgent:
  1638. return m.clearedtoken_agent
  1639. case agent.EdgeWaAgent:
  1640. return m.clearedwa_agent
  1641. case agent.EdgeKeyAgent:
  1642. return m.clearedkey_agent
  1643. }
  1644. return false
  1645. }
  1646. // ClearEdge clears the value of the edge with the given name. It returns an error
  1647. // if that edge is not defined in the schema.
  1648. func (m *AgentMutation) ClearEdge(name string) error {
  1649. switch name {
  1650. }
  1651. return fmt.Errorf("unknown Agent unique edge %s", name)
  1652. }
  1653. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1654. // It returns an error if the edge is not defined in the schema.
  1655. func (m *AgentMutation) ResetEdge(name string) error {
  1656. switch name {
  1657. case agent.EdgeWxAgent:
  1658. m.ResetWxAgent()
  1659. return nil
  1660. case agent.EdgeTokenAgent:
  1661. m.ResetTokenAgent()
  1662. return nil
  1663. case agent.EdgeWaAgent:
  1664. m.ResetWaAgent()
  1665. return nil
  1666. case agent.EdgeKeyAgent:
  1667. m.ResetKeyAgent()
  1668. return nil
  1669. }
  1670. return fmt.Errorf("unknown Agent edge %s", name)
  1671. }
  1672. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1673. type AgentBaseMutation struct {
  1674. config
  1675. op Op
  1676. typ string
  1677. id *string
  1678. q *string
  1679. a *string
  1680. chunk_index *uint64
  1681. addchunk_index *int64
  1682. indexes *[]string
  1683. appendindexes []string
  1684. dataset_id *string
  1685. collection_id *string
  1686. source_name *string
  1687. can_write *[]bool
  1688. appendcan_write []bool
  1689. is_owner *[]bool
  1690. appendis_owner []bool
  1691. clearedFields map[string]struct{}
  1692. wx_agent map[uint64]struct{}
  1693. removedwx_agent map[uint64]struct{}
  1694. clearedwx_agent bool
  1695. done bool
  1696. oldValue func(context.Context) (*AgentBase, error)
  1697. predicates []predicate.AgentBase
  1698. }
  1699. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1700. // agentbaseOption allows management of the mutation configuration using functional options.
  1701. type agentbaseOption func(*AgentBaseMutation)
  1702. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1703. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1704. m := &AgentBaseMutation{
  1705. config: c,
  1706. op: op,
  1707. typ: TypeAgentBase,
  1708. clearedFields: make(map[string]struct{}),
  1709. }
  1710. for _, opt := range opts {
  1711. opt(m)
  1712. }
  1713. return m
  1714. }
  1715. // withAgentBaseID sets the ID field of the mutation.
  1716. func withAgentBaseID(id string) agentbaseOption {
  1717. return func(m *AgentBaseMutation) {
  1718. var (
  1719. err error
  1720. once sync.Once
  1721. value *AgentBase
  1722. )
  1723. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1724. once.Do(func() {
  1725. if m.done {
  1726. err = errors.New("querying old values post mutation is not allowed")
  1727. } else {
  1728. value, err = m.Client().AgentBase.Get(ctx, id)
  1729. }
  1730. })
  1731. return value, err
  1732. }
  1733. m.id = &id
  1734. }
  1735. }
  1736. // withAgentBase sets the old AgentBase of the mutation.
  1737. func withAgentBase(node *AgentBase) agentbaseOption {
  1738. return func(m *AgentBaseMutation) {
  1739. m.oldValue = func(context.Context) (*AgentBase, error) {
  1740. return node, nil
  1741. }
  1742. m.id = &node.ID
  1743. }
  1744. }
  1745. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1746. // executed in a transaction (ent.Tx), a transactional client is returned.
  1747. func (m AgentBaseMutation) Client() *Client {
  1748. client := &Client{config: m.config}
  1749. client.init()
  1750. return client
  1751. }
  1752. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1753. // it returns an error otherwise.
  1754. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1755. if _, ok := m.driver.(*txDriver); !ok {
  1756. return nil, errors.New("ent: mutation is not running in a transaction")
  1757. }
  1758. tx := &Tx{config: m.config}
  1759. tx.init()
  1760. return tx, nil
  1761. }
  1762. // SetID sets the value of the id field. Note that this
  1763. // operation is only accepted on creation of AgentBase entities.
  1764. func (m *AgentBaseMutation) SetID(id string) {
  1765. m.id = &id
  1766. }
  1767. // ID returns the ID value in the mutation. Note that the ID is only available
  1768. // if it was provided to the builder or after it was returned from the database.
  1769. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1770. if m.id == nil {
  1771. return
  1772. }
  1773. return *m.id, true
  1774. }
  1775. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1776. // That means, if the mutation is applied within a transaction with an isolation level such
  1777. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1778. // or updated by the mutation.
  1779. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1780. switch {
  1781. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1782. id, exists := m.ID()
  1783. if exists {
  1784. return []string{id}, nil
  1785. }
  1786. fallthrough
  1787. case m.op.Is(OpUpdate | OpDelete):
  1788. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1789. default:
  1790. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1791. }
  1792. }
  1793. // SetQ sets the "q" field.
  1794. func (m *AgentBaseMutation) SetQ(s string) {
  1795. m.q = &s
  1796. }
  1797. // Q returns the value of the "q" field in the mutation.
  1798. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1799. v := m.q
  1800. if v == nil {
  1801. return
  1802. }
  1803. return *v, true
  1804. }
  1805. // OldQ returns the old "q" field's value of the AgentBase entity.
  1806. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1808. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1809. if !m.op.Is(OpUpdateOne) {
  1810. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1811. }
  1812. if m.id == nil || m.oldValue == nil {
  1813. return v, errors.New("OldQ requires an ID field in the mutation")
  1814. }
  1815. oldValue, err := m.oldValue(ctx)
  1816. if err != nil {
  1817. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1818. }
  1819. return oldValue.Q, nil
  1820. }
  1821. // ClearQ clears the value of the "q" field.
  1822. func (m *AgentBaseMutation) ClearQ() {
  1823. m.q = nil
  1824. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1825. }
  1826. // QCleared returns if the "q" field was cleared in this mutation.
  1827. func (m *AgentBaseMutation) QCleared() bool {
  1828. _, ok := m.clearedFields[agentbase.FieldQ]
  1829. return ok
  1830. }
  1831. // ResetQ resets all changes to the "q" field.
  1832. func (m *AgentBaseMutation) ResetQ() {
  1833. m.q = nil
  1834. delete(m.clearedFields, agentbase.FieldQ)
  1835. }
  1836. // SetA sets the "a" field.
  1837. func (m *AgentBaseMutation) SetA(s string) {
  1838. m.a = &s
  1839. }
  1840. // A returns the value of the "a" field in the mutation.
  1841. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1842. v := m.a
  1843. if v == nil {
  1844. return
  1845. }
  1846. return *v, true
  1847. }
  1848. // OldA returns the old "a" field's value of the AgentBase entity.
  1849. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1851. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1852. if !m.op.Is(OpUpdateOne) {
  1853. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1854. }
  1855. if m.id == nil || m.oldValue == nil {
  1856. return v, errors.New("OldA requires an ID field in the mutation")
  1857. }
  1858. oldValue, err := m.oldValue(ctx)
  1859. if err != nil {
  1860. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1861. }
  1862. return oldValue.A, nil
  1863. }
  1864. // ClearA clears the value of the "a" field.
  1865. func (m *AgentBaseMutation) ClearA() {
  1866. m.a = nil
  1867. m.clearedFields[agentbase.FieldA] = struct{}{}
  1868. }
  1869. // ACleared returns if the "a" field was cleared in this mutation.
  1870. func (m *AgentBaseMutation) ACleared() bool {
  1871. _, ok := m.clearedFields[agentbase.FieldA]
  1872. return ok
  1873. }
  1874. // ResetA resets all changes to the "a" field.
  1875. func (m *AgentBaseMutation) ResetA() {
  1876. m.a = nil
  1877. delete(m.clearedFields, agentbase.FieldA)
  1878. }
  1879. // SetChunkIndex sets the "chunk_index" field.
  1880. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1881. m.chunk_index = &u
  1882. m.addchunk_index = nil
  1883. }
  1884. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1885. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1886. v := m.chunk_index
  1887. if v == nil {
  1888. return
  1889. }
  1890. return *v, true
  1891. }
  1892. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1893. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1895. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1896. if !m.op.Is(OpUpdateOne) {
  1897. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1898. }
  1899. if m.id == nil || m.oldValue == nil {
  1900. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1901. }
  1902. oldValue, err := m.oldValue(ctx)
  1903. if err != nil {
  1904. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1905. }
  1906. return oldValue.ChunkIndex, nil
  1907. }
  1908. // AddChunkIndex adds u to the "chunk_index" field.
  1909. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1910. if m.addchunk_index != nil {
  1911. *m.addchunk_index += u
  1912. } else {
  1913. m.addchunk_index = &u
  1914. }
  1915. }
  1916. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1917. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1918. v := m.addchunk_index
  1919. if v == nil {
  1920. return
  1921. }
  1922. return *v, true
  1923. }
  1924. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1925. func (m *AgentBaseMutation) ResetChunkIndex() {
  1926. m.chunk_index = nil
  1927. m.addchunk_index = nil
  1928. }
  1929. // SetIndexes sets the "indexes" field.
  1930. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1931. m.indexes = &s
  1932. m.appendindexes = nil
  1933. }
  1934. // Indexes returns the value of the "indexes" field in the mutation.
  1935. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1936. v := m.indexes
  1937. if v == nil {
  1938. return
  1939. }
  1940. return *v, true
  1941. }
  1942. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1943. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1945. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1946. if !m.op.Is(OpUpdateOne) {
  1947. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1948. }
  1949. if m.id == nil || m.oldValue == nil {
  1950. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1951. }
  1952. oldValue, err := m.oldValue(ctx)
  1953. if err != nil {
  1954. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1955. }
  1956. return oldValue.Indexes, nil
  1957. }
  1958. // AppendIndexes adds s to the "indexes" field.
  1959. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1960. m.appendindexes = append(m.appendindexes, s...)
  1961. }
  1962. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1963. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1964. if len(m.appendindexes) == 0 {
  1965. return nil, false
  1966. }
  1967. return m.appendindexes, true
  1968. }
  1969. // ClearIndexes clears the value of the "indexes" field.
  1970. func (m *AgentBaseMutation) ClearIndexes() {
  1971. m.indexes = nil
  1972. m.appendindexes = nil
  1973. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1974. }
  1975. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1976. func (m *AgentBaseMutation) IndexesCleared() bool {
  1977. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1978. return ok
  1979. }
  1980. // ResetIndexes resets all changes to the "indexes" field.
  1981. func (m *AgentBaseMutation) ResetIndexes() {
  1982. m.indexes = nil
  1983. m.appendindexes = nil
  1984. delete(m.clearedFields, agentbase.FieldIndexes)
  1985. }
  1986. // SetDatasetID sets the "dataset_id" field.
  1987. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1988. m.dataset_id = &s
  1989. }
  1990. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1991. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1992. v := m.dataset_id
  1993. if v == nil {
  1994. return
  1995. }
  1996. return *v, true
  1997. }
  1998. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1999. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2001. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2002. if !m.op.Is(OpUpdateOne) {
  2003. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2004. }
  2005. if m.id == nil || m.oldValue == nil {
  2006. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2007. }
  2008. oldValue, err := m.oldValue(ctx)
  2009. if err != nil {
  2010. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2011. }
  2012. return oldValue.DatasetID, nil
  2013. }
  2014. // ClearDatasetID clears the value of the "dataset_id" field.
  2015. func (m *AgentBaseMutation) ClearDatasetID() {
  2016. m.dataset_id = nil
  2017. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2018. }
  2019. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2020. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2021. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2022. return ok
  2023. }
  2024. // ResetDatasetID resets all changes to the "dataset_id" field.
  2025. func (m *AgentBaseMutation) ResetDatasetID() {
  2026. m.dataset_id = nil
  2027. delete(m.clearedFields, agentbase.FieldDatasetID)
  2028. }
  2029. // SetCollectionID sets the "collection_id" field.
  2030. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2031. m.collection_id = &s
  2032. }
  2033. // CollectionID returns the value of the "collection_id" field in the mutation.
  2034. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2035. v := m.collection_id
  2036. if v == nil {
  2037. return
  2038. }
  2039. return *v, true
  2040. }
  2041. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2042. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2044. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2045. if !m.op.Is(OpUpdateOne) {
  2046. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2047. }
  2048. if m.id == nil || m.oldValue == nil {
  2049. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2050. }
  2051. oldValue, err := m.oldValue(ctx)
  2052. if err != nil {
  2053. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2054. }
  2055. return oldValue.CollectionID, nil
  2056. }
  2057. // ClearCollectionID clears the value of the "collection_id" field.
  2058. func (m *AgentBaseMutation) ClearCollectionID() {
  2059. m.collection_id = nil
  2060. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2061. }
  2062. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2063. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2064. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2065. return ok
  2066. }
  2067. // ResetCollectionID resets all changes to the "collection_id" field.
  2068. func (m *AgentBaseMutation) ResetCollectionID() {
  2069. m.collection_id = nil
  2070. delete(m.clearedFields, agentbase.FieldCollectionID)
  2071. }
  2072. // SetSourceName sets the "source_name" field.
  2073. func (m *AgentBaseMutation) SetSourceName(s string) {
  2074. m.source_name = &s
  2075. }
  2076. // SourceName returns the value of the "source_name" field in the mutation.
  2077. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2078. v := m.source_name
  2079. if v == nil {
  2080. return
  2081. }
  2082. return *v, true
  2083. }
  2084. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2085. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2087. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2088. if !m.op.Is(OpUpdateOne) {
  2089. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2090. }
  2091. if m.id == nil || m.oldValue == nil {
  2092. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2093. }
  2094. oldValue, err := m.oldValue(ctx)
  2095. if err != nil {
  2096. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2097. }
  2098. return oldValue.SourceName, nil
  2099. }
  2100. // ClearSourceName clears the value of the "source_name" field.
  2101. func (m *AgentBaseMutation) ClearSourceName() {
  2102. m.source_name = nil
  2103. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2104. }
  2105. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2106. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2107. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2108. return ok
  2109. }
  2110. // ResetSourceName resets all changes to the "source_name" field.
  2111. func (m *AgentBaseMutation) ResetSourceName() {
  2112. m.source_name = nil
  2113. delete(m.clearedFields, agentbase.FieldSourceName)
  2114. }
  2115. // SetCanWrite sets the "can_write" field.
  2116. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2117. m.can_write = &b
  2118. m.appendcan_write = nil
  2119. }
  2120. // CanWrite returns the value of the "can_write" field in the mutation.
  2121. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2122. v := m.can_write
  2123. if v == nil {
  2124. return
  2125. }
  2126. return *v, true
  2127. }
  2128. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2129. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2131. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2132. if !m.op.Is(OpUpdateOne) {
  2133. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2134. }
  2135. if m.id == nil || m.oldValue == nil {
  2136. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2137. }
  2138. oldValue, err := m.oldValue(ctx)
  2139. if err != nil {
  2140. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2141. }
  2142. return oldValue.CanWrite, nil
  2143. }
  2144. // AppendCanWrite adds b to the "can_write" field.
  2145. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2146. m.appendcan_write = append(m.appendcan_write, b...)
  2147. }
  2148. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2149. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2150. if len(m.appendcan_write) == 0 {
  2151. return nil, false
  2152. }
  2153. return m.appendcan_write, true
  2154. }
  2155. // ClearCanWrite clears the value of the "can_write" field.
  2156. func (m *AgentBaseMutation) ClearCanWrite() {
  2157. m.can_write = nil
  2158. m.appendcan_write = nil
  2159. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2160. }
  2161. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2162. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2163. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2164. return ok
  2165. }
  2166. // ResetCanWrite resets all changes to the "can_write" field.
  2167. func (m *AgentBaseMutation) ResetCanWrite() {
  2168. m.can_write = nil
  2169. m.appendcan_write = nil
  2170. delete(m.clearedFields, agentbase.FieldCanWrite)
  2171. }
  2172. // SetIsOwner sets the "is_owner" field.
  2173. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2174. m.is_owner = &b
  2175. m.appendis_owner = nil
  2176. }
  2177. // IsOwner returns the value of the "is_owner" field in the mutation.
  2178. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2179. v := m.is_owner
  2180. if v == nil {
  2181. return
  2182. }
  2183. return *v, true
  2184. }
  2185. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2186. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2188. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2189. if !m.op.Is(OpUpdateOne) {
  2190. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2191. }
  2192. if m.id == nil || m.oldValue == nil {
  2193. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2194. }
  2195. oldValue, err := m.oldValue(ctx)
  2196. if err != nil {
  2197. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2198. }
  2199. return oldValue.IsOwner, nil
  2200. }
  2201. // AppendIsOwner adds b to the "is_owner" field.
  2202. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2203. m.appendis_owner = append(m.appendis_owner, b...)
  2204. }
  2205. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2206. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2207. if len(m.appendis_owner) == 0 {
  2208. return nil, false
  2209. }
  2210. return m.appendis_owner, true
  2211. }
  2212. // ClearIsOwner clears the value of the "is_owner" field.
  2213. func (m *AgentBaseMutation) ClearIsOwner() {
  2214. m.is_owner = nil
  2215. m.appendis_owner = nil
  2216. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2217. }
  2218. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2219. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2220. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2221. return ok
  2222. }
  2223. // ResetIsOwner resets all changes to the "is_owner" field.
  2224. func (m *AgentBaseMutation) ResetIsOwner() {
  2225. m.is_owner = nil
  2226. m.appendis_owner = nil
  2227. delete(m.clearedFields, agentbase.FieldIsOwner)
  2228. }
  2229. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2230. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2231. if m.wx_agent == nil {
  2232. m.wx_agent = make(map[uint64]struct{})
  2233. }
  2234. for i := range ids {
  2235. m.wx_agent[ids[i]] = struct{}{}
  2236. }
  2237. }
  2238. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2239. func (m *AgentBaseMutation) ClearWxAgent() {
  2240. m.clearedwx_agent = true
  2241. }
  2242. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2243. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2244. return m.clearedwx_agent
  2245. }
  2246. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2247. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2248. if m.removedwx_agent == nil {
  2249. m.removedwx_agent = make(map[uint64]struct{})
  2250. }
  2251. for i := range ids {
  2252. delete(m.wx_agent, ids[i])
  2253. m.removedwx_agent[ids[i]] = struct{}{}
  2254. }
  2255. }
  2256. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2257. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2258. for id := range m.removedwx_agent {
  2259. ids = append(ids, id)
  2260. }
  2261. return
  2262. }
  2263. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2264. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2265. for id := range m.wx_agent {
  2266. ids = append(ids, id)
  2267. }
  2268. return
  2269. }
  2270. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2271. func (m *AgentBaseMutation) ResetWxAgent() {
  2272. m.wx_agent = nil
  2273. m.clearedwx_agent = false
  2274. m.removedwx_agent = nil
  2275. }
  2276. // Where appends a list predicates to the AgentBaseMutation builder.
  2277. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2278. m.predicates = append(m.predicates, ps...)
  2279. }
  2280. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2281. // users can use type-assertion to append predicates that do not depend on any generated package.
  2282. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2283. p := make([]predicate.AgentBase, len(ps))
  2284. for i := range ps {
  2285. p[i] = ps[i]
  2286. }
  2287. m.Where(p...)
  2288. }
  2289. // Op returns the operation name.
  2290. func (m *AgentBaseMutation) Op() Op {
  2291. return m.op
  2292. }
  2293. // SetOp allows setting the mutation operation.
  2294. func (m *AgentBaseMutation) SetOp(op Op) {
  2295. m.op = op
  2296. }
  2297. // Type returns the node type of this mutation (AgentBase).
  2298. func (m *AgentBaseMutation) Type() string {
  2299. return m.typ
  2300. }
  2301. // Fields returns all fields that were changed during this mutation. Note that in
  2302. // order to get all numeric fields that were incremented/decremented, call
  2303. // AddedFields().
  2304. func (m *AgentBaseMutation) Fields() []string {
  2305. fields := make([]string, 0, 9)
  2306. if m.q != nil {
  2307. fields = append(fields, agentbase.FieldQ)
  2308. }
  2309. if m.a != nil {
  2310. fields = append(fields, agentbase.FieldA)
  2311. }
  2312. if m.chunk_index != nil {
  2313. fields = append(fields, agentbase.FieldChunkIndex)
  2314. }
  2315. if m.indexes != nil {
  2316. fields = append(fields, agentbase.FieldIndexes)
  2317. }
  2318. if m.dataset_id != nil {
  2319. fields = append(fields, agentbase.FieldDatasetID)
  2320. }
  2321. if m.collection_id != nil {
  2322. fields = append(fields, agentbase.FieldCollectionID)
  2323. }
  2324. if m.source_name != nil {
  2325. fields = append(fields, agentbase.FieldSourceName)
  2326. }
  2327. if m.can_write != nil {
  2328. fields = append(fields, agentbase.FieldCanWrite)
  2329. }
  2330. if m.is_owner != nil {
  2331. fields = append(fields, agentbase.FieldIsOwner)
  2332. }
  2333. return fields
  2334. }
  2335. // Field returns the value of a field with the given name. The second boolean
  2336. // return value indicates that this field was not set, or was not defined in the
  2337. // schema.
  2338. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2339. switch name {
  2340. case agentbase.FieldQ:
  2341. return m.Q()
  2342. case agentbase.FieldA:
  2343. return m.A()
  2344. case agentbase.FieldChunkIndex:
  2345. return m.ChunkIndex()
  2346. case agentbase.FieldIndexes:
  2347. return m.Indexes()
  2348. case agentbase.FieldDatasetID:
  2349. return m.DatasetID()
  2350. case agentbase.FieldCollectionID:
  2351. return m.CollectionID()
  2352. case agentbase.FieldSourceName:
  2353. return m.SourceName()
  2354. case agentbase.FieldCanWrite:
  2355. return m.CanWrite()
  2356. case agentbase.FieldIsOwner:
  2357. return m.IsOwner()
  2358. }
  2359. return nil, false
  2360. }
  2361. // OldField returns the old value of the field from the database. An error is
  2362. // returned if the mutation operation is not UpdateOne, or the query to the
  2363. // database failed.
  2364. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2365. switch name {
  2366. case agentbase.FieldQ:
  2367. return m.OldQ(ctx)
  2368. case agentbase.FieldA:
  2369. return m.OldA(ctx)
  2370. case agentbase.FieldChunkIndex:
  2371. return m.OldChunkIndex(ctx)
  2372. case agentbase.FieldIndexes:
  2373. return m.OldIndexes(ctx)
  2374. case agentbase.FieldDatasetID:
  2375. return m.OldDatasetID(ctx)
  2376. case agentbase.FieldCollectionID:
  2377. return m.OldCollectionID(ctx)
  2378. case agentbase.FieldSourceName:
  2379. return m.OldSourceName(ctx)
  2380. case agentbase.FieldCanWrite:
  2381. return m.OldCanWrite(ctx)
  2382. case agentbase.FieldIsOwner:
  2383. return m.OldIsOwner(ctx)
  2384. }
  2385. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2386. }
  2387. // SetField sets the value of a field with the given name. It returns an error if
  2388. // the field is not defined in the schema, or if the type mismatched the field
  2389. // type.
  2390. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2391. switch name {
  2392. case agentbase.FieldQ:
  2393. v, ok := value.(string)
  2394. if !ok {
  2395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2396. }
  2397. m.SetQ(v)
  2398. return nil
  2399. case agentbase.FieldA:
  2400. v, ok := value.(string)
  2401. if !ok {
  2402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2403. }
  2404. m.SetA(v)
  2405. return nil
  2406. case agentbase.FieldChunkIndex:
  2407. v, ok := value.(uint64)
  2408. if !ok {
  2409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2410. }
  2411. m.SetChunkIndex(v)
  2412. return nil
  2413. case agentbase.FieldIndexes:
  2414. v, ok := value.([]string)
  2415. if !ok {
  2416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2417. }
  2418. m.SetIndexes(v)
  2419. return nil
  2420. case agentbase.FieldDatasetID:
  2421. v, ok := value.(string)
  2422. if !ok {
  2423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2424. }
  2425. m.SetDatasetID(v)
  2426. return nil
  2427. case agentbase.FieldCollectionID:
  2428. v, ok := value.(string)
  2429. if !ok {
  2430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2431. }
  2432. m.SetCollectionID(v)
  2433. return nil
  2434. case agentbase.FieldSourceName:
  2435. v, ok := value.(string)
  2436. if !ok {
  2437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2438. }
  2439. m.SetSourceName(v)
  2440. return nil
  2441. case agentbase.FieldCanWrite:
  2442. v, ok := value.([]bool)
  2443. if !ok {
  2444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2445. }
  2446. m.SetCanWrite(v)
  2447. return nil
  2448. case agentbase.FieldIsOwner:
  2449. v, ok := value.([]bool)
  2450. if !ok {
  2451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2452. }
  2453. m.SetIsOwner(v)
  2454. return nil
  2455. }
  2456. return fmt.Errorf("unknown AgentBase field %s", name)
  2457. }
  2458. // AddedFields returns all numeric fields that were incremented/decremented during
  2459. // this mutation.
  2460. func (m *AgentBaseMutation) AddedFields() []string {
  2461. var fields []string
  2462. if m.addchunk_index != nil {
  2463. fields = append(fields, agentbase.FieldChunkIndex)
  2464. }
  2465. return fields
  2466. }
  2467. // AddedField returns the numeric value that was incremented/decremented on a field
  2468. // with the given name. The second boolean return value indicates that this field
  2469. // was not set, or was not defined in the schema.
  2470. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2471. switch name {
  2472. case agentbase.FieldChunkIndex:
  2473. return m.AddedChunkIndex()
  2474. }
  2475. return nil, false
  2476. }
  2477. // AddField adds the value to the field with the given name. It returns an error if
  2478. // the field is not defined in the schema, or if the type mismatched the field
  2479. // type.
  2480. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2481. switch name {
  2482. case agentbase.FieldChunkIndex:
  2483. v, ok := value.(int64)
  2484. if !ok {
  2485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2486. }
  2487. m.AddChunkIndex(v)
  2488. return nil
  2489. }
  2490. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2491. }
  2492. // ClearedFields returns all nullable fields that were cleared during this
  2493. // mutation.
  2494. func (m *AgentBaseMutation) ClearedFields() []string {
  2495. var fields []string
  2496. if m.FieldCleared(agentbase.FieldQ) {
  2497. fields = append(fields, agentbase.FieldQ)
  2498. }
  2499. if m.FieldCleared(agentbase.FieldA) {
  2500. fields = append(fields, agentbase.FieldA)
  2501. }
  2502. if m.FieldCleared(agentbase.FieldIndexes) {
  2503. fields = append(fields, agentbase.FieldIndexes)
  2504. }
  2505. if m.FieldCleared(agentbase.FieldDatasetID) {
  2506. fields = append(fields, agentbase.FieldDatasetID)
  2507. }
  2508. if m.FieldCleared(agentbase.FieldCollectionID) {
  2509. fields = append(fields, agentbase.FieldCollectionID)
  2510. }
  2511. if m.FieldCleared(agentbase.FieldSourceName) {
  2512. fields = append(fields, agentbase.FieldSourceName)
  2513. }
  2514. if m.FieldCleared(agentbase.FieldCanWrite) {
  2515. fields = append(fields, agentbase.FieldCanWrite)
  2516. }
  2517. if m.FieldCleared(agentbase.FieldIsOwner) {
  2518. fields = append(fields, agentbase.FieldIsOwner)
  2519. }
  2520. return fields
  2521. }
  2522. // FieldCleared returns a boolean indicating if a field with the given name was
  2523. // cleared in this mutation.
  2524. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2525. _, ok := m.clearedFields[name]
  2526. return ok
  2527. }
  2528. // ClearField clears the value of the field with the given name. It returns an
  2529. // error if the field is not defined in the schema.
  2530. func (m *AgentBaseMutation) ClearField(name string) error {
  2531. switch name {
  2532. case agentbase.FieldQ:
  2533. m.ClearQ()
  2534. return nil
  2535. case agentbase.FieldA:
  2536. m.ClearA()
  2537. return nil
  2538. case agentbase.FieldIndexes:
  2539. m.ClearIndexes()
  2540. return nil
  2541. case agentbase.FieldDatasetID:
  2542. m.ClearDatasetID()
  2543. return nil
  2544. case agentbase.FieldCollectionID:
  2545. m.ClearCollectionID()
  2546. return nil
  2547. case agentbase.FieldSourceName:
  2548. m.ClearSourceName()
  2549. return nil
  2550. case agentbase.FieldCanWrite:
  2551. m.ClearCanWrite()
  2552. return nil
  2553. case agentbase.FieldIsOwner:
  2554. m.ClearIsOwner()
  2555. return nil
  2556. }
  2557. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2558. }
  2559. // ResetField resets all changes in the mutation for the field with the given name.
  2560. // It returns an error if the field is not defined in the schema.
  2561. func (m *AgentBaseMutation) ResetField(name string) error {
  2562. switch name {
  2563. case agentbase.FieldQ:
  2564. m.ResetQ()
  2565. return nil
  2566. case agentbase.FieldA:
  2567. m.ResetA()
  2568. return nil
  2569. case agentbase.FieldChunkIndex:
  2570. m.ResetChunkIndex()
  2571. return nil
  2572. case agentbase.FieldIndexes:
  2573. m.ResetIndexes()
  2574. return nil
  2575. case agentbase.FieldDatasetID:
  2576. m.ResetDatasetID()
  2577. return nil
  2578. case agentbase.FieldCollectionID:
  2579. m.ResetCollectionID()
  2580. return nil
  2581. case agentbase.FieldSourceName:
  2582. m.ResetSourceName()
  2583. return nil
  2584. case agentbase.FieldCanWrite:
  2585. m.ResetCanWrite()
  2586. return nil
  2587. case agentbase.FieldIsOwner:
  2588. m.ResetIsOwner()
  2589. return nil
  2590. }
  2591. return fmt.Errorf("unknown AgentBase field %s", name)
  2592. }
  2593. // AddedEdges returns all edge names that were set/added in this mutation.
  2594. func (m *AgentBaseMutation) AddedEdges() []string {
  2595. edges := make([]string, 0, 1)
  2596. if m.wx_agent != nil {
  2597. edges = append(edges, agentbase.EdgeWxAgent)
  2598. }
  2599. return edges
  2600. }
  2601. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2602. // name in this mutation.
  2603. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2604. switch name {
  2605. case agentbase.EdgeWxAgent:
  2606. ids := make([]ent.Value, 0, len(m.wx_agent))
  2607. for id := range m.wx_agent {
  2608. ids = append(ids, id)
  2609. }
  2610. return ids
  2611. }
  2612. return nil
  2613. }
  2614. // RemovedEdges returns all edge names that were removed in this mutation.
  2615. func (m *AgentBaseMutation) RemovedEdges() []string {
  2616. edges := make([]string, 0, 1)
  2617. if m.removedwx_agent != nil {
  2618. edges = append(edges, agentbase.EdgeWxAgent)
  2619. }
  2620. return edges
  2621. }
  2622. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2623. // the given name in this mutation.
  2624. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2625. switch name {
  2626. case agentbase.EdgeWxAgent:
  2627. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2628. for id := range m.removedwx_agent {
  2629. ids = append(ids, id)
  2630. }
  2631. return ids
  2632. }
  2633. return nil
  2634. }
  2635. // ClearedEdges returns all edge names that were cleared in this mutation.
  2636. func (m *AgentBaseMutation) ClearedEdges() []string {
  2637. edges := make([]string, 0, 1)
  2638. if m.clearedwx_agent {
  2639. edges = append(edges, agentbase.EdgeWxAgent)
  2640. }
  2641. return edges
  2642. }
  2643. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2644. // was cleared in this mutation.
  2645. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2646. switch name {
  2647. case agentbase.EdgeWxAgent:
  2648. return m.clearedwx_agent
  2649. }
  2650. return false
  2651. }
  2652. // ClearEdge clears the value of the edge with the given name. It returns an error
  2653. // if that edge is not defined in the schema.
  2654. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2655. switch name {
  2656. }
  2657. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2658. }
  2659. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2660. // It returns an error if the edge is not defined in the schema.
  2661. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2662. switch name {
  2663. case agentbase.EdgeWxAgent:
  2664. m.ResetWxAgent()
  2665. return nil
  2666. }
  2667. return fmt.Errorf("unknown AgentBase edge %s", name)
  2668. }
  2669. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2670. type AliyunAvatarMutation struct {
  2671. config
  2672. op Op
  2673. typ string
  2674. id *uint64
  2675. created_at *time.Time
  2676. updated_at *time.Time
  2677. deleted_at *time.Time
  2678. user_id *uint64
  2679. adduser_id *int64
  2680. biz_id *string
  2681. access_key_id *string
  2682. access_key_secret *string
  2683. app_id *string
  2684. tenant_id *uint64
  2685. addtenant_id *int64
  2686. response *string
  2687. token *string
  2688. session_id *string
  2689. clearedFields map[string]struct{}
  2690. done bool
  2691. oldValue func(context.Context) (*AliyunAvatar, error)
  2692. predicates []predicate.AliyunAvatar
  2693. }
  2694. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2695. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2696. type aliyunavatarOption func(*AliyunAvatarMutation)
  2697. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2698. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2699. m := &AliyunAvatarMutation{
  2700. config: c,
  2701. op: op,
  2702. typ: TypeAliyunAvatar,
  2703. clearedFields: make(map[string]struct{}),
  2704. }
  2705. for _, opt := range opts {
  2706. opt(m)
  2707. }
  2708. return m
  2709. }
  2710. // withAliyunAvatarID sets the ID field of the mutation.
  2711. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2712. return func(m *AliyunAvatarMutation) {
  2713. var (
  2714. err error
  2715. once sync.Once
  2716. value *AliyunAvatar
  2717. )
  2718. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2719. once.Do(func() {
  2720. if m.done {
  2721. err = errors.New("querying old values post mutation is not allowed")
  2722. } else {
  2723. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2724. }
  2725. })
  2726. return value, err
  2727. }
  2728. m.id = &id
  2729. }
  2730. }
  2731. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2732. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2733. return func(m *AliyunAvatarMutation) {
  2734. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2735. return node, nil
  2736. }
  2737. m.id = &node.ID
  2738. }
  2739. }
  2740. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2741. // executed in a transaction (ent.Tx), a transactional client is returned.
  2742. func (m AliyunAvatarMutation) Client() *Client {
  2743. client := &Client{config: m.config}
  2744. client.init()
  2745. return client
  2746. }
  2747. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2748. // it returns an error otherwise.
  2749. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2750. if _, ok := m.driver.(*txDriver); !ok {
  2751. return nil, errors.New("ent: mutation is not running in a transaction")
  2752. }
  2753. tx := &Tx{config: m.config}
  2754. tx.init()
  2755. return tx, nil
  2756. }
  2757. // SetID sets the value of the id field. Note that this
  2758. // operation is only accepted on creation of AliyunAvatar entities.
  2759. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2760. m.id = &id
  2761. }
  2762. // ID returns the ID value in the mutation. Note that the ID is only available
  2763. // if it was provided to the builder or after it was returned from the database.
  2764. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2765. if m.id == nil {
  2766. return
  2767. }
  2768. return *m.id, true
  2769. }
  2770. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2771. // That means, if the mutation is applied within a transaction with an isolation level such
  2772. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2773. // or updated by the mutation.
  2774. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2775. switch {
  2776. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2777. id, exists := m.ID()
  2778. if exists {
  2779. return []uint64{id}, nil
  2780. }
  2781. fallthrough
  2782. case m.op.Is(OpUpdate | OpDelete):
  2783. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2784. default:
  2785. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2786. }
  2787. }
  2788. // SetCreatedAt sets the "created_at" field.
  2789. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2790. m.created_at = &t
  2791. }
  2792. // CreatedAt returns the value of the "created_at" field in the mutation.
  2793. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2794. v := m.created_at
  2795. if v == nil {
  2796. return
  2797. }
  2798. return *v, true
  2799. }
  2800. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2801. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2803. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2804. if !m.op.Is(OpUpdateOne) {
  2805. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2806. }
  2807. if m.id == nil || m.oldValue == nil {
  2808. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2809. }
  2810. oldValue, err := m.oldValue(ctx)
  2811. if err != nil {
  2812. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2813. }
  2814. return oldValue.CreatedAt, nil
  2815. }
  2816. // ResetCreatedAt resets all changes to the "created_at" field.
  2817. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2818. m.created_at = nil
  2819. }
  2820. // SetUpdatedAt sets the "updated_at" field.
  2821. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2822. m.updated_at = &t
  2823. }
  2824. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2825. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2826. v := m.updated_at
  2827. if v == nil {
  2828. return
  2829. }
  2830. return *v, true
  2831. }
  2832. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2833. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2835. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2836. if !m.op.Is(OpUpdateOne) {
  2837. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2838. }
  2839. if m.id == nil || m.oldValue == nil {
  2840. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2841. }
  2842. oldValue, err := m.oldValue(ctx)
  2843. if err != nil {
  2844. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2845. }
  2846. return oldValue.UpdatedAt, nil
  2847. }
  2848. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2849. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2850. m.updated_at = nil
  2851. }
  2852. // SetDeletedAt sets the "deleted_at" field.
  2853. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2854. m.deleted_at = &t
  2855. }
  2856. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2857. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2858. v := m.deleted_at
  2859. if v == nil {
  2860. return
  2861. }
  2862. return *v, true
  2863. }
  2864. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2865. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2867. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2868. if !m.op.Is(OpUpdateOne) {
  2869. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2870. }
  2871. if m.id == nil || m.oldValue == nil {
  2872. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2873. }
  2874. oldValue, err := m.oldValue(ctx)
  2875. if err != nil {
  2876. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2877. }
  2878. return oldValue.DeletedAt, nil
  2879. }
  2880. // ClearDeletedAt clears the value of the "deleted_at" field.
  2881. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2882. m.deleted_at = nil
  2883. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2884. }
  2885. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2886. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2887. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2888. return ok
  2889. }
  2890. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2891. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2892. m.deleted_at = nil
  2893. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2894. }
  2895. // SetUserID sets the "user_id" field.
  2896. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2897. m.user_id = &u
  2898. m.adduser_id = nil
  2899. }
  2900. // UserID returns the value of the "user_id" field in the mutation.
  2901. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2902. v := m.user_id
  2903. if v == nil {
  2904. return
  2905. }
  2906. return *v, true
  2907. }
  2908. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2909. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2911. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2912. if !m.op.Is(OpUpdateOne) {
  2913. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2914. }
  2915. if m.id == nil || m.oldValue == nil {
  2916. return v, errors.New("OldUserID requires an ID field in the mutation")
  2917. }
  2918. oldValue, err := m.oldValue(ctx)
  2919. if err != nil {
  2920. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2921. }
  2922. return oldValue.UserID, nil
  2923. }
  2924. // AddUserID adds u to the "user_id" field.
  2925. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2926. if m.adduser_id != nil {
  2927. *m.adduser_id += u
  2928. } else {
  2929. m.adduser_id = &u
  2930. }
  2931. }
  2932. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2933. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2934. v := m.adduser_id
  2935. if v == nil {
  2936. return
  2937. }
  2938. return *v, true
  2939. }
  2940. // ResetUserID resets all changes to the "user_id" field.
  2941. func (m *AliyunAvatarMutation) ResetUserID() {
  2942. m.user_id = nil
  2943. m.adduser_id = nil
  2944. }
  2945. // SetBizID sets the "biz_id" field.
  2946. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2947. m.biz_id = &s
  2948. }
  2949. // BizID returns the value of the "biz_id" field in the mutation.
  2950. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2951. v := m.biz_id
  2952. if v == nil {
  2953. return
  2954. }
  2955. return *v, true
  2956. }
  2957. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2958. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2960. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2961. if !m.op.Is(OpUpdateOne) {
  2962. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2963. }
  2964. if m.id == nil || m.oldValue == nil {
  2965. return v, errors.New("OldBizID requires an ID field in the mutation")
  2966. }
  2967. oldValue, err := m.oldValue(ctx)
  2968. if err != nil {
  2969. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2970. }
  2971. return oldValue.BizID, nil
  2972. }
  2973. // ResetBizID resets all changes to the "biz_id" field.
  2974. func (m *AliyunAvatarMutation) ResetBizID() {
  2975. m.biz_id = nil
  2976. }
  2977. // SetAccessKeyID sets the "access_key_id" field.
  2978. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2979. m.access_key_id = &s
  2980. }
  2981. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2982. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2983. v := m.access_key_id
  2984. if v == nil {
  2985. return
  2986. }
  2987. return *v, true
  2988. }
  2989. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2990. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2992. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2993. if !m.op.Is(OpUpdateOne) {
  2994. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2995. }
  2996. if m.id == nil || m.oldValue == nil {
  2997. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2998. }
  2999. oldValue, err := m.oldValue(ctx)
  3000. if err != nil {
  3001. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3002. }
  3003. return oldValue.AccessKeyID, nil
  3004. }
  3005. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3006. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3007. m.access_key_id = nil
  3008. }
  3009. // SetAccessKeySecret sets the "access_key_secret" field.
  3010. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3011. m.access_key_secret = &s
  3012. }
  3013. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3014. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3015. v := m.access_key_secret
  3016. if v == nil {
  3017. return
  3018. }
  3019. return *v, true
  3020. }
  3021. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3022. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3024. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3025. if !m.op.Is(OpUpdateOne) {
  3026. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3027. }
  3028. if m.id == nil || m.oldValue == nil {
  3029. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3030. }
  3031. oldValue, err := m.oldValue(ctx)
  3032. if err != nil {
  3033. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3034. }
  3035. return oldValue.AccessKeySecret, nil
  3036. }
  3037. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3038. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3039. m.access_key_secret = nil
  3040. }
  3041. // SetAppID sets the "app_id" field.
  3042. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3043. m.app_id = &s
  3044. }
  3045. // AppID returns the value of the "app_id" field in the mutation.
  3046. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3047. v := m.app_id
  3048. if v == nil {
  3049. return
  3050. }
  3051. return *v, true
  3052. }
  3053. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3054. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3056. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3057. if !m.op.Is(OpUpdateOne) {
  3058. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3059. }
  3060. if m.id == nil || m.oldValue == nil {
  3061. return v, errors.New("OldAppID requires an ID field in the mutation")
  3062. }
  3063. oldValue, err := m.oldValue(ctx)
  3064. if err != nil {
  3065. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3066. }
  3067. return oldValue.AppID, nil
  3068. }
  3069. // ClearAppID clears the value of the "app_id" field.
  3070. func (m *AliyunAvatarMutation) ClearAppID() {
  3071. m.app_id = nil
  3072. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3073. }
  3074. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3075. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3076. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3077. return ok
  3078. }
  3079. // ResetAppID resets all changes to the "app_id" field.
  3080. func (m *AliyunAvatarMutation) ResetAppID() {
  3081. m.app_id = nil
  3082. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3083. }
  3084. // SetTenantID sets the "tenant_id" field.
  3085. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3086. m.tenant_id = &u
  3087. m.addtenant_id = nil
  3088. }
  3089. // TenantID returns the value of the "tenant_id" field in the mutation.
  3090. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3091. v := m.tenant_id
  3092. if v == nil {
  3093. return
  3094. }
  3095. return *v, true
  3096. }
  3097. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3098. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3100. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3101. if !m.op.Is(OpUpdateOne) {
  3102. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3103. }
  3104. if m.id == nil || m.oldValue == nil {
  3105. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3106. }
  3107. oldValue, err := m.oldValue(ctx)
  3108. if err != nil {
  3109. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3110. }
  3111. return oldValue.TenantID, nil
  3112. }
  3113. // AddTenantID adds u to the "tenant_id" field.
  3114. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3115. if m.addtenant_id != nil {
  3116. *m.addtenant_id += u
  3117. } else {
  3118. m.addtenant_id = &u
  3119. }
  3120. }
  3121. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3122. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3123. v := m.addtenant_id
  3124. if v == nil {
  3125. return
  3126. }
  3127. return *v, true
  3128. }
  3129. // ResetTenantID resets all changes to the "tenant_id" field.
  3130. func (m *AliyunAvatarMutation) ResetTenantID() {
  3131. m.tenant_id = nil
  3132. m.addtenant_id = nil
  3133. }
  3134. // SetResponse sets the "response" field.
  3135. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3136. m.response = &s
  3137. }
  3138. // Response returns the value of the "response" field in the mutation.
  3139. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3140. v := m.response
  3141. if v == nil {
  3142. return
  3143. }
  3144. return *v, true
  3145. }
  3146. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3147. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3149. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3150. if !m.op.Is(OpUpdateOne) {
  3151. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3152. }
  3153. if m.id == nil || m.oldValue == nil {
  3154. return v, errors.New("OldResponse requires an ID field in the mutation")
  3155. }
  3156. oldValue, err := m.oldValue(ctx)
  3157. if err != nil {
  3158. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3159. }
  3160. return oldValue.Response, nil
  3161. }
  3162. // ResetResponse resets all changes to the "response" field.
  3163. func (m *AliyunAvatarMutation) ResetResponse() {
  3164. m.response = nil
  3165. }
  3166. // SetToken sets the "token" field.
  3167. func (m *AliyunAvatarMutation) SetToken(s string) {
  3168. m.token = &s
  3169. }
  3170. // Token returns the value of the "token" field in the mutation.
  3171. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3172. v := m.token
  3173. if v == nil {
  3174. return
  3175. }
  3176. return *v, true
  3177. }
  3178. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3179. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3181. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3182. if !m.op.Is(OpUpdateOne) {
  3183. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3184. }
  3185. if m.id == nil || m.oldValue == nil {
  3186. return v, errors.New("OldToken requires an ID field in the mutation")
  3187. }
  3188. oldValue, err := m.oldValue(ctx)
  3189. if err != nil {
  3190. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3191. }
  3192. return oldValue.Token, nil
  3193. }
  3194. // ResetToken resets all changes to the "token" field.
  3195. func (m *AliyunAvatarMutation) ResetToken() {
  3196. m.token = nil
  3197. }
  3198. // SetSessionID sets the "session_id" field.
  3199. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3200. m.session_id = &s
  3201. }
  3202. // SessionID returns the value of the "session_id" field in the mutation.
  3203. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3204. v := m.session_id
  3205. if v == nil {
  3206. return
  3207. }
  3208. return *v, true
  3209. }
  3210. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3211. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3213. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3214. if !m.op.Is(OpUpdateOne) {
  3215. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3216. }
  3217. if m.id == nil || m.oldValue == nil {
  3218. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3219. }
  3220. oldValue, err := m.oldValue(ctx)
  3221. if err != nil {
  3222. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3223. }
  3224. return oldValue.SessionID, nil
  3225. }
  3226. // ResetSessionID resets all changes to the "session_id" field.
  3227. func (m *AliyunAvatarMutation) ResetSessionID() {
  3228. m.session_id = nil
  3229. }
  3230. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3231. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3232. m.predicates = append(m.predicates, ps...)
  3233. }
  3234. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3235. // users can use type-assertion to append predicates that do not depend on any generated package.
  3236. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3237. p := make([]predicate.AliyunAvatar, len(ps))
  3238. for i := range ps {
  3239. p[i] = ps[i]
  3240. }
  3241. m.Where(p...)
  3242. }
  3243. // Op returns the operation name.
  3244. func (m *AliyunAvatarMutation) Op() Op {
  3245. return m.op
  3246. }
  3247. // SetOp allows setting the mutation operation.
  3248. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3249. m.op = op
  3250. }
  3251. // Type returns the node type of this mutation (AliyunAvatar).
  3252. func (m *AliyunAvatarMutation) Type() string {
  3253. return m.typ
  3254. }
  3255. // Fields returns all fields that were changed during this mutation. Note that in
  3256. // order to get all numeric fields that were incremented/decremented, call
  3257. // AddedFields().
  3258. func (m *AliyunAvatarMutation) Fields() []string {
  3259. fields := make([]string, 0, 12)
  3260. if m.created_at != nil {
  3261. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3262. }
  3263. if m.updated_at != nil {
  3264. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3265. }
  3266. if m.deleted_at != nil {
  3267. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3268. }
  3269. if m.user_id != nil {
  3270. fields = append(fields, aliyunavatar.FieldUserID)
  3271. }
  3272. if m.biz_id != nil {
  3273. fields = append(fields, aliyunavatar.FieldBizID)
  3274. }
  3275. if m.access_key_id != nil {
  3276. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3277. }
  3278. if m.access_key_secret != nil {
  3279. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3280. }
  3281. if m.app_id != nil {
  3282. fields = append(fields, aliyunavatar.FieldAppID)
  3283. }
  3284. if m.tenant_id != nil {
  3285. fields = append(fields, aliyunavatar.FieldTenantID)
  3286. }
  3287. if m.response != nil {
  3288. fields = append(fields, aliyunavatar.FieldResponse)
  3289. }
  3290. if m.token != nil {
  3291. fields = append(fields, aliyunavatar.FieldToken)
  3292. }
  3293. if m.session_id != nil {
  3294. fields = append(fields, aliyunavatar.FieldSessionID)
  3295. }
  3296. return fields
  3297. }
  3298. // Field returns the value of a field with the given name. The second boolean
  3299. // return value indicates that this field was not set, or was not defined in the
  3300. // schema.
  3301. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3302. switch name {
  3303. case aliyunavatar.FieldCreatedAt:
  3304. return m.CreatedAt()
  3305. case aliyunavatar.FieldUpdatedAt:
  3306. return m.UpdatedAt()
  3307. case aliyunavatar.FieldDeletedAt:
  3308. return m.DeletedAt()
  3309. case aliyunavatar.FieldUserID:
  3310. return m.UserID()
  3311. case aliyunavatar.FieldBizID:
  3312. return m.BizID()
  3313. case aliyunavatar.FieldAccessKeyID:
  3314. return m.AccessKeyID()
  3315. case aliyunavatar.FieldAccessKeySecret:
  3316. return m.AccessKeySecret()
  3317. case aliyunavatar.FieldAppID:
  3318. return m.AppID()
  3319. case aliyunavatar.FieldTenantID:
  3320. return m.TenantID()
  3321. case aliyunavatar.FieldResponse:
  3322. return m.Response()
  3323. case aliyunavatar.FieldToken:
  3324. return m.Token()
  3325. case aliyunavatar.FieldSessionID:
  3326. return m.SessionID()
  3327. }
  3328. return nil, false
  3329. }
  3330. // OldField returns the old value of the field from the database. An error is
  3331. // returned if the mutation operation is not UpdateOne, or the query to the
  3332. // database failed.
  3333. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3334. switch name {
  3335. case aliyunavatar.FieldCreatedAt:
  3336. return m.OldCreatedAt(ctx)
  3337. case aliyunavatar.FieldUpdatedAt:
  3338. return m.OldUpdatedAt(ctx)
  3339. case aliyunavatar.FieldDeletedAt:
  3340. return m.OldDeletedAt(ctx)
  3341. case aliyunavatar.FieldUserID:
  3342. return m.OldUserID(ctx)
  3343. case aliyunavatar.FieldBizID:
  3344. return m.OldBizID(ctx)
  3345. case aliyunavatar.FieldAccessKeyID:
  3346. return m.OldAccessKeyID(ctx)
  3347. case aliyunavatar.FieldAccessKeySecret:
  3348. return m.OldAccessKeySecret(ctx)
  3349. case aliyunavatar.FieldAppID:
  3350. return m.OldAppID(ctx)
  3351. case aliyunavatar.FieldTenantID:
  3352. return m.OldTenantID(ctx)
  3353. case aliyunavatar.FieldResponse:
  3354. return m.OldResponse(ctx)
  3355. case aliyunavatar.FieldToken:
  3356. return m.OldToken(ctx)
  3357. case aliyunavatar.FieldSessionID:
  3358. return m.OldSessionID(ctx)
  3359. }
  3360. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3361. }
  3362. // SetField sets the value of a field with the given name. It returns an error if
  3363. // the field is not defined in the schema, or if the type mismatched the field
  3364. // type.
  3365. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3366. switch name {
  3367. case aliyunavatar.FieldCreatedAt:
  3368. v, ok := value.(time.Time)
  3369. if !ok {
  3370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3371. }
  3372. m.SetCreatedAt(v)
  3373. return nil
  3374. case aliyunavatar.FieldUpdatedAt:
  3375. v, ok := value.(time.Time)
  3376. if !ok {
  3377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3378. }
  3379. m.SetUpdatedAt(v)
  3380. return nil
  3381. case aliyunavatar.FieldDeletedAt:
  3382. v, ok := value.(time.Time)
  3383. if !ok {
  3384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3385. }
  3386. m.SetDeletedAt(v)
  3387. return nil
  3388. case aliyunavatar.FieldUserID:
  3389. v, ok := value.(uint64)
  3390. if !ok {
  3391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3392. }
  3393. m.SetUserID(v)
  3394. return nil
  3395. case aliyunavatar.FieldBizID:
  3396. v, ok := value.(string)
  3397. if !ok {
  3398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3399. }
  3400. m.SetBizID(v)
  3401. return nil
  3402. case aliyunavatar.FieldAccessKeyID:
  3403. v, ok := value.(string)
  3404. if !ok {
  3405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3406. }
  3407. m.SetAccessKeyID(v)
  3408. return nil
  3409. case aliyunavatar.FieldAccessKeySecret:
  3410. v, ok := value.(string)
  3411. if !ok {
  3412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3413. }
  3414. m.SetAccessKeySecret(v)
  3415. return nil
  3416. case aliyunavatar.FieldAppID:
  3417. v, ok := value.(string)
  3418. if !ok {
  3419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3420. }
  3421. m.SetAppID(v)
  3422. return nil
  3423. case aliyunavatar.FieldTenantID:
  3424. v, ok := value.(uint64)
  3425. if !ok {
  3426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3427. }
  3428. m.SetTenantID(v)
  3429. return nil
  3430. case aliyunavatar.FieldResponse:
  3431. v, ok := value.(string)
  3432. if !ok {
  3433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3434. }
  3435. m.SetResponse(v)
  3436. return nil
  3437. case aliyunavatar.FieldToken:
  3438. v, ok := value.(string)
  3439. if !ok {
  3440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3441. }
  3442. m.SetToken(v)
  3443. return nil
  3444. case aliyunavatar.FieldSessionID:
  3445. v, ok := value.(string)
  3446. if !ok {
  3447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3448. }
  3449. m.SetSessionID(v)
  3450. return nil
  3451. }
  3452. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3453. }
  3454. // AddedFields returns all numeric fields that were incremented/decremented during
  3455. // this mutation.
  3456. func (m *AliyunAvatarMutation) AddedFields() []string {
  3457. var fields []string
  3458. if m.adduser_id != nil {
  3459. fields = append(fields, aliyunavatar.FieldUserID)
  3460. }
  3461. if m.addtenant_id != nil {
  3462. fields = append(fields, aliyunavatar.FieldTenantID)
  3463. }
  3464. return fields
  3465. }
  3466. // AddedField returns the numeric value that was incremented/decremented on a field
  3467. // with the given name. The second boolean return value indicates that this field
  3468. // was not set, or was not defined in the schema.
  3469. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3470. switch name {
  3471. case aliyunavatar.FieldUserID:
  3472. return m.AddedUserID()
  3473. case aliyunavatar.FieldTenantID:
  3474. return m.AddedTenantID()
  3475. }
  3476. return nil, false
  3477. }
  3478. // AddField adds the value to the field with the given name. It returns an error if
  3479. // the field is not defined in the schema, or if the type mismatched the field
  3480. // type.
  3481. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3482. switch name {
  3483. case aliyunavatar.FieldUserID:
  3484. v, ok := value.(int64)
  3485. if !ok {
  3486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3487. }
  3488. m.AddUserID(v)
  3489. return nil
  3490. case aliyunavatar.FieldTenantID:
  3491. v, ok := value.(int64)
  3492. if !ok {
  3493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3494. }
  3495. m.AddTenantID(v)
  3496. return nil
  3497. }
  3498. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3499. }
  3500. // ClearedFields returns all nullable fields that were cleared during this
  3501. // mutation.
  3502. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3503. var fields []string
  3504. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3505. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3506. }
  3507. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3508. fields = append(fields, aliyunavatar.FieldAppID)
  3509. }
  3510. return fields
  3511. }
  3512. // FieldCleared returns a boolean indicating if a field with the given name was
  3513. // cleared in this mutation.
  3514. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3515. _, ok := m.clearedFields[name]
  3516. return ok
  3517. }
  3518. // ClearField clears the value of the field with the given name. It returns an
  3519. // error if the field is not defined in the schema.
  3520. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3521. switch name {
  3522. case aliyunavatar.FieldDeletedAt:
  3523. m.ClearDeletedAt()
  3524. return nil
  3525. case aliyunavatar.FieldAppID:
  3526. m.ClearAppID()
  3527. return nil
  3528. }
  3529. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3530. }
  3531. // ResetField resets all changes in the mutation for the field with the given name.
  3532. // It returns an error if the field is not defined in the schema.
  3533. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3534. switch name {
  3535. case aliyunavatar.FieldCreatedAt:
  3536. m.ResetCreatedAt()
  3537. return nil
  3538. case aliyunavatar.FieldUpdatedAt:
  3539. m.ResetUpdatedAt()
  3540. return nil
  3541. case aliyunavatar.FieldDeletedAt:
  3542. m.ResetDeletedAt()
  3543. return nil
  3544. case aliyunavatar.FieldUserID:
  3545. m.ResetUserID()
  3546. return nil
  3547. case aliyunavatar.FieldBizID:
  3548. m.ResetBizID()
  3549. return nil
  3550. case aliyunavatar.FieldAccessKeyID:
  3551. m.ResetAccessKeyID()
  3552. return nil
  3553. case aliyunavatar.FieldAccessKeySecret:
  3554. m.ResetAccessKeySecret()
  3555. return nil
  3556. case aliyunavatar.FieldAppID:
  3557. m.ResetAppID()
  3558. return nil
  3559. case aliyunavatar.FieldTenantID:
  3560. m.ResetTenantID()
  3561. return nil
  3562. case aliyunavatar.FieldResponse:
  3563. m.ResetResponse()
  3564. return nil
  3565. case aliyunavatar.FieldToken:
  3566. m.ResetToken()
  3567. return nil
  3568. case aliyunavatar.FieldSessionID:
  3569. m.ResetSessionID()
  3570. return nil
  3571. }
  3572. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3573. }
  3574. // AddedEdges returns all edge names that were set/added in this mutation.
  3575. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3576. edges := make([]string, 0, 0)
  3577. return edges
  3578. }
  3579. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3580. // name in this mutation.
  3581. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3582. return nil
  3583. }
  3584. // RemovedEdges returns all edge names that were removed in this mutation.
  3585. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3586. edges := make([]string, 0, 0)
  3587. return edges
  3588. }
  3589. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3590. // the given name in this mutation.
  3591. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3592. return nil
  3593. }
  3594. // ClearedEdges returns all edge names that were cleared in this mutation.
  3595. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3596. edges := make([]string, 0, 0)
  3597. return edges
  3598. }
  3599. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3600. // was cleared in this mutation.
  3601. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3602. return false
  3603. }
  3604. // ClearEdge clears the value of the edge with the given name. It returns an error
  3605. // if that edge is not defined in the schema.
  3606. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3607. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3608. }
  3609. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3610. // It returns an error if the edge is not defined in the schema.
  3611. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3612. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3613. }
  3614. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3615. type AllocAgentMutation struct {
  3616. config
  3617. op Op
  3618. typ string
  3619. id *uint64
  3620. created_at *time.Time
  3621. updated_at *time.Time
  3622. deleted_at *time.Time
  3623. user_id *string
  3624. organization_id *uint64
  3625. addorganization_id *int64
  3626. agents *[]uint64
  3627. appendagents []uint64
  3628. status *int
  3629. addstatus *int
  3630. clearedFields map[string]struct{}
  3631. done bool
  3632. oldValue func(context.Context) (*AllocAgent, error)
  3633. predicates []predicate.AllocAgent
  3634. }
  3635. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3636. // allocagentOption allows management of the mutation configuration using functional options.
  3637. type allocagentOption func(*AllocAgentMutation)
  3638. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3639. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3640. m := &AllocAgentMutation{
  3641. config: c,
  3642. op: op,
  3643. typ: TypeAllocAgent,
  3644. clearedFields: make(map[string]struct{}),
  3645. }
  3646. for _, opt := range opts {
  3647. opt(m)
  3648. }
  3649. return m
  3650. }
  3651. // withAllocAgentID sets the ID field of the mutation.
  3652. func withAllocAgentID(id uint64) allocagentOption {
  3653. return func(m *AllocAgentMutation) {
  3654. var (
  3655. err error
  3656. once sync.Once
  3657. value *AllocAgent
  3658. )
  3659. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3660. once.Do(func() {
  3661. if m.done {
  3662. err = errors.New("querying old values post mutation is not allowed")
  3663. } else {
  3664. value, err = m.Client().AllocAgent.Get(ctx, id)
  3665. }
  3666. })
  3667. return value, err
  3668. }
  3669. m.id = &id
  3670. }
  3671. }
  3672. // withAllocAgent sets the old AllocAgent of the mutation.
  3673. func withAllocAgent(node *AllocAgent) allocagentOption {
  3674. return func(m *AllocAgentMutation) {
  3675. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3676. return node, nil
  3677. }
  3678. m.id = &node.ID
  3679. }
  3680. }
  3681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3682. // executed in a transaction (ent.Tx), a transactional client is returned.
  3683. func (m AllocAgentMutation) Client() *Client {
  3684. client := &Client{config: m.config}
  3685. client.init()
  3686. return client
  3687. }
  3688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3689. // it returns an error otherwise.
  3690. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3691. if _, ok := m.driver.(*txDriver); !ok {
  3692. return nil, errors.New("ent: mutation is not running in a transaction")
  3693. }
  3694. tx := &Tx{config: m.config}
  3695. tx.init()
  3696. return tx, nil
  3697. }
  3698. // SetID sets the value of the id field. Note that this
  3699. // operation is only accepted on creation of AllocAgent entities.
  3700. func (m *AllocAgentMutation) SetID(id uint64) {
  3701. m.id = &id
  3702. }
  3703. // ID returns the ID value in the mutation. Note that the ID is only available
  3704. // if it was provided to the builder or after it was returned from the database.
  3705. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3706. if m.id == nil {
  3707. return
  3708. }
  3709. return *m.id, true
  3710. }
  3711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3712. // That means, if the mutation is applied within a transaction with an isolation level such
  3713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3714. // or updated by the mutation.
  3715. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3716. switch {
  3717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3718. id, exists := m.ID()
  3719. if exists {
  3720. return []uint64{id}, nil
  3721. }
  3722. fallthrough
  3723. case m.op.Is(OpUpdate | OpDelete):
  3724. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3725. default:
  3726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3727. }
  3728. }
  3729. // SetCreatedAt sets the "created_at" field.
  3730. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3731. m.created_at = &t
  3732. }
  3733. // CreatedAt returns the value of the "created_at" field in the mutation.
  3734. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3735. v := m.created_at
  3736. if v == nil {
  3737. return
  3738. }
  3739. return *v, true
  3740. }
  3741. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3742. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3744. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3745. if !m.op.Is(OpUpdateOne) {
  3746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3747. }
  3748. if m.id == nil || m.oldValue == nil {
  3749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3750. }
  3751. oldValue, err := m.oldValue(ctx)
  3752. if err != nil {
  3753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3754. }
  3755. return oldValue.CreatedAt, nil
  3756. }
  3757. // ResetCreatedAt resets all changes to the "created_at" field.
  3758. func (m *AllocAgentMutation) ResetCreatedAt() {
  3759. m.created_at = nil
  3760. }
  3761. // SetUpdatedAt sets the "updated_at" field.
  3762. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3763. m.updated_at = &t
  3764. }
  3765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3766. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3767. v := m.updated_at
  3768. if v == nil {
  3769. return
  3770. }
  3771. return *v, true
  3772. }
  3773. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3774. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3776. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3777. if !m.op.Is(OpUpdateOne) {
  3778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3779. }
  3780. if m.id == nil || m.oldValue == nil {
  3781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3782. }
  3783. oldValue, err := m.oldValue(ctx)
  3784. if err != nil {
  3785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3786. }
  3787. return oldValue.UpdatedAt, nil
  3788. }
  3789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3790. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3791. m.updated_at = nil
  3792. }
  3793. // SetDeletedAt sets the "deleted_at" field.
  3794. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3795. m.deleted_at = &t
  3796. }
  3797. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3798. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3799. v := m.deleted_at
  3800. if v == nil {
  3801. return
  3802. }
  3803. return *v, true
  3804. }
  3805. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3806. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3808. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3809. if !m.op.Is(OpUpdateOne) {
  3810. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3811. }
  3812. if m.id == nil || m.oldValue == nil {
  3813. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3814. }
  3815. oldValue, err := m.oldValue(ctx)
  3816. if err != nil {
  3817. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3818. }
  3819. return oldValue.DeletedAt, nil
  3820. }
  3821. // ClearDeletedAt clears the value of the "deleted_at" field.
  3822. func (m *AllocAgentMutation) ClearDeletedAt() {
  3823. m.deleted_at = nil
  3824. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3825. }
  3826. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3827. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3828. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3829. return ok
  3830. }
  3831. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3832. func (m *AllocAgentMutation) ResetDeletedAt() {
  3833. m.deleted_at = nil
  3834. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3835. }
  3836. // SetUserID sets the "user_id" field.
  3837. func (m *AllocAgentMutation) SetUserID(s string) {
  3838. m.user_id = &s
  3839. }
  3840. // UserID returns the value of the "user_id" field in the mutation.
  3841. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3842. v := m.user_id
  3843. if v == nil {
  3844. return
  3845. }
  3846. return *v, true
  3847. }
  3848. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3849. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3851. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3852. if !m.op.Is(OpUpdateOne) {
  3853. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3854. }
  3855. if m.id == nil || m.oldValue == nil {
  3856. return v, errors.New("OldUserID requires an ID field in the mutation")
  3857. }
  3858. oldValue, err := m.oldValue(ctx)
  3859. if err != nil {
  3860. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3861. }
  3862. return oldValue.UserID, nil
  3863. }
  3864. // ClearUserID clears the value of the "user_id" field.
  3865. func (m *AllocAgentMutation) ClearUserID() {
  3866. m.user_id = nil
  3867. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3868. }
  3869. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3870. func (m *AllocAgentMutation) UserIDCleared() bool {
  3871. _, ok := m.clearedFields[allocagent.FieldUserID]
  3872. return ok
  3873. }
  3874. // ResetUserID resets all changes to the "user_id" field.
  3875. func (m *AllocAgentMutation) ResetUserID() {
  3876. m.user_id = nil
  3877. delete(m.clearedFields, allocagent.FieldUserID)
  3878. }
  3879. // SetOrganizationID sets the "organization_id" field.
  3880. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3881. m.organization_id = &u
  3882. m.addorganization_id = nil
  3883. }
  3884. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3885. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3886. v := m.organization_id
  3887. if v == nil {
  3888. return
  3889. }
  3890. return *v, true
  3891. }
  3892. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3893. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3895. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3896. if !m.op.Is(OpUpdateOne) {
  3897. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3898. }
  3899. if m.id == nil || m.oldValue == nil {
  3900. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3901. }
  3902. oldValue, err := m.oldValue(ctx)
  3903. if err != nil {
  3904. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3905. }
  3906. return oldValue.OrganizationID, nil
  3907. }
  3908. // AddOrganizationID adds u to the "organization_id" field.
  3909. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3910. if m.addorganization_id != nil {
  3911. *m.addorganization_id += u
  3912. } else {
  3913. m.addorganization_id = &u
  3914. }
  3915. }
  3916. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3917. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3918. v := m.addorganization_id
  3919. if v == nil {
  3920. return
  3921. }
  3922. return *v, true
  3923. }
  3924. // ClearOrganizationID clears the value of the "organization_id" field.
  3925. func (m *AllocAgentMutation) ClearOrganizationID() {
  3926. m.organization_id = nil
  3927. m.addorganization_id = nil
  3928. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3929. }
  3930. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3931. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3932. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3933. return ok
  3934. }
  3935. // ResetOrganizationID resets all changes to the "organization_id" field.
  3936. func (m *AllocAgentMutation) ResetOrganizationID() {
  3937. m.organization_id = nil
  3938. m.addorganization_id = nil
  3939. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3940. }
  3941. // SetAgents sets the "agents" field.
  3942. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3943. m.agents = &u
  3944. m.appendagents = nil
  3945. }
  3946. // Agents returns the value of the "agents" field in the mutation.
  3947. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3948. v := m.agents
  3949. if v == nil {
  3950. return
  3951. }
  3952. return *v, true
  3953. }
  3954. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3955. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3957. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3958. if !m.op.Is(OpUpdateOne) {
  3959. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3960. }
  3961. if m.id == nil || m.oldValue == nil {
  3962. return v, errors.New("OldAgents requires an ID field in the mutation")
  3963. }
  3964. oldValue, err := m.oldValue(ctx)
  3965. if err != nil {
  3966. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3967. }
  3968. return oldValue.Agents, nil
  3969. }
  3970. // AppendAgents adds u to the "agents" field.
  3971. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3972. m.appendagents = append(m.appendagents, u...)
  3973. }
  3974. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3975. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3976. if len(m.appendagents) == 0 {
  3977. return nil, false
  3978. }
  3979. return m.appendagents, true
  3980. }
  3981. // ResetAgents resets all changes to the "agents" field.
  3982. func (m *AllocAgentMutation) ResetAgents() {
  3983. m.agents = nil
  3984. m.appendagents = nil
  3985. }
  3986. // SetStatus sets the "status" field.
  3987. func (m *AllocAgentMutation) SetStatus(i int) {
  3988. m.status = &i
  3989. m.addstatus = nil
  3990. }
  3991. // Status returns the value of the "status" field in the mutation.
  3992. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3993. v := m.status
  3994. if v == nil {
  3995. return
  3996. }
  3997. return *v, true
  3998. }
  3999. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4000. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4002. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4003. if !m.op.Is(OpUpdateOne) {
  4004. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4005. }
  4006. if m.id == nil || m.oldValue == nil {
  4007. return v, errors.New("OldStatus requires an ID field in the mutation")
  4008. }
  4009. oldValue, err := m.oldValue(ctx)
  4010. if err != nil {
  4011. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4012. }
  4013. return oldValue.Status, nil
  4014. }
  4015. // AddStatus adds i to the "status" field.
  4016. func (m *AllocAgentMutation) AddStatus(i int) {
  4017. if m.addstatus != nil {
  4018. *m.addstatus += i
  4019. } else {
  4020. m.addstatus = &i
  4021. }
  4022. }
  4023. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4024. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4025. v := m.addstatus
  4026. if v == nil {
  4027. return
  4028. }
  4029. return *v, true
  4030. }
  4031. // ClearStatus clears the value of the "status" field.
  4032. func (m *AllocAgentMutation) ClearStatus() {
  4033. m.status = nil
  4034. m.addstatus = nil
  4035. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4036. }
  4037. // StatusCleared returns if the "status" field was cleared in this mutation.
  4038. func (m *AllocAgentMutation) StatusCleared() bool {
  4039. _, ok := m.clearedFields[allocagent.FieldStatus]
  4040. return ok
  4041. }
  4042. // ResetStatus resets all changes to the "status" field.
  4043. func (m *AllocAgentMutation) ResetStatus() {
  4044. m.status = nil
  4045. m.addstatus = nil
  4046. delete(m.clearedFields, allocagent.FieldStatus)
  4047. }
  4048. // Where appends a list predicates to the AllocAgentMutation builder.
  4049. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4050. m.predicates = append(m.predicates, ps...)
  4051. }
  4052. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4053. // users can use type-assertion to append predicates that do not depend on any generated package.
  4054. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4055. p := make([]predicate.AllocAgent, len(ps))
  4056. for i := range ps {
  4057. p[i] = ps[i]
  4058. }
  4059. m.Where(p...)
  4060. }
  4061. // Op returns the operation name.
  4062. func (m *AllocAgentMutation) Op() Op {
  4063. return m.op
  4064. }
  4065. // SetOp allows setting the mutation operation.
  4066. func (m *AllocAgentMutation) SetOp(op Op) {
  4067. m.op = op
  4068. }
  4069. // Type returns the node type of this mutation (AllocAgent).
  4070. func (m *AllocAgentMutation) Type() string {
  4071. return m.typ
  4072. }
  4073. // Fields returns all fields that were changed during this mutation. Note that in
  4074. // order to get all numeric fields that were incremented/decremented, call
  4075. // AddedFields().
  4076. func (m *AllocAgentMutation) Fields() []string {
  4077. fields := make([]string, 0, 7)
  4078. if m.created_at != nil {
  4079. fields = append(fields, allocagent.FieldCreatedAt)
  4080. }
  4081. if m.updated_at != nil {
  4082. fields = append(fields, allocagent.FieldUpdatedAt)
  4083. }
  4084. if m.deleted_at != nil {
  4085. fields = append(fields, allocagent.FieldDeletedAt)
  4086. }
  4087. if m.user_id != nil {
  4088. fields = append(fields, allocagent.FieldUserID)
  4089. }
  4090. if m.organization_id != nil {
  4091. fields = append(fields, allocagent.FieldOrganizationID)
  4092. }
  4093. if m.agents != nil {
  4094. fields = append(fields, allocagent.FieldAgents)
  4095. }
  4096. if m.status != nil {
  4097. fields = append(fields, allocagent.FieldStatus)
  4098. }
  4099. return fields
  4100. }
  4101. // Field returns the value of a field with the given name. The second boolean
  4102. // return value indicates that this field was not set, or was not defined in the
  4103. // schema.
  4104. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4105. switch name {
  4106. case allocagent.FieldCreatedAt:
  4107. return m.CreatedAt()
  4108. case allocagent.FieldUpdatedAt:
  4109. return m.UpdatedAt()
  4110. case allocagent.FieldDeletedAt:
  4111. return m.DeletedAt()
  4112. case allocagent.FieldUserID:
  4113. return m.UserID()
  4114. case allocagent.FieldOrganizationID:
  4115. return m.OrganizationID()
  4116. case allocagent.FieldAgents:
  4117. return m.Agents()
  4118. case allocagent.FieldStatus:
  4119. return m.Status()
  4120. }
  4121. return nil, false
  4122. }
  4123. // OldField returns the old value of the field from the database. An error is
  4124. // returned if the mutation operation is not UpdateOne, or the query to the
  4125. // database failed.
  4126. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4127. switch name {
  4128. case allocagent.FieldCreatedAt:
  4129. return m.OldCreatedAt(ctx)
  4130. case allocagent.FieldUpdatedAt:
  4131. return m.OldUpdatedAt(ctx)
  4132. case allocagent.FieldDeletedAt:
  4133. return m.OldDeletedAt(ctx)
  4134. case allocagent.FieldUserID:
  4135. return m.OldUserID(ctx)
  4136. case allocagent.FieldOrganizationID:
  4137. return m.OldOrganizationID(ctx)
  4138. case allocagent.FieldAgents:
  4139. return m.OldAgents(ctx)
  4140. case allocagent.FieldStatus:
  4141. return m.OldStatus(ctx)
  4142. }
  4143. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4144. }
  4145. // SetField sets the value of a field with the given name. It returns an error if
  4146. // the field is not defined in the schema, or if the type mismatched the field
  4147. // type.
  4148. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4149. switch name {
  4150. case allocagent.FieldCreatedAt:
  4151. v, ok := value.(time.Time)
  4152. if !ok {
  4153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4154. }
  4155. m.SetCreatedAt(v)
  4156. return nil
  4157. case allocagent.FieldUpdatedAt:
  4158. v, ok := value.(time.Time)
  4159. if !ok {
  4160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4161. }
  4162. m.SetUpdatedAt(v)
  4163. return nil
  4164. case allocagent.FieldDeletedAt:
  4165. v, ok := value.(time.Time)
  4166. if !ok {
  4167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4168. }
  4169. m.SetDeletedAt(v)
  4170. return nil
  4171. case allocagent.FieldUserID:
  4172. v, ok := value.(string)
  4173. if !ok {
  4174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4175. }
  4176. m.SetUserID(v)
  4177. return nil
  4178. case allocagent.FieldOrganizationID:
  4179. v, ok := value.(uint64)
  4180. if !ok {
  4181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4182. }
  4183. m.SetOrganizationID(v)
  4184. return nil
  4185. case allocagent.FieldAgents:
  4186. v, ok := value.([]uint64)
  4187. if !ok {
  4188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4189. }
  4190. m.SetAgents(v)
  4191. return nil
  4192. case allocagent.FieldStatus:
  4193. v, ok := value.(int)
  4194. if !ok {
  4195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4196. }
  4197. m.SetStatus(v)
  4198. return nil
  4199. }
  4200. return fmt.Errorf("unknown AllocAgent field %s", name)
  4201. }
  4202. // AddedFields returns all numeric fields that were incremented/decremented during
  4203. // this mutation.
  4204. func (m *AllocAgentMutation) AddedFields() []string {
  4205. var fields []string
  4206. if m.addorganization_id != nil {
  4207. fields = append(fields, allocagent.FieldOrganizationID)
  4208. }
  4209. if m.addstatus != nil {
  4210. fields = append(fields, allocagent.FieldStatus)
  4211. }
  4212. return fields
  4213. }
  4214. // AddedField returns the numeric value that was incremented/decremented on a field
  4215. // with the given name. The second boolean return value indicates that this field
  4216. // was not set, or was not defined in the schema.
  4217. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4218. switch name {
  4219. case allocagent.FieldOrganizationID:
  4220. return m.AddedOrganizationID()
  4221. case allocagent.FieldStatus:
  4222. return m.AddedStatus()
  4223. }
  4224. return nil, false
  4225. }
  4226. // AddField adds the value to the field with the given name. It returns an error if
  4227. // the field is not defined in the schema, or if the type mismatched the field
  4228. // type.
  4229. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4230. switch name {
  4231. case allocagent.FieldOrganizationID:
  4232. v, ok := value.(int64)
  4233. if !ok {
  4234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4235. }
  4236. m.AddOrganizationID(v)
  4237. return nil
  4238. case allocagent.FieldStatus:
  4239. v, ok := value.(int)
  4240. if !ok {
  4241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4242. }
  4243. m.AddStatus(v)
  4244. return nil
  4245. }
  4246. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4247. }
  4248. // ClearedFields returns all nullable fields that were cleared during this
  4249. // mutation.
  4250. func (m *AllocAgentMutation) ClearedFields() []string {
  4251. var fields []string
  4252. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4253. fields = append(fields, allocagent.FieldDeletedAt)
  4254. }
  4255. if m.FieldCleared(allocagent.FieldUserID) {
  4256. fields = append(fields, allocagent.FieldUserID)
  4257. }
  4258. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4259. fields = append(fields, allocagent.FieldOrganizationID)
  4260. }
  4261. if m.FieldCleared(allocagent.FieldStatus) {
  4262. fields = append(fields, allocagent.FieldStatus)
  4263. }
  4264. return fields
  4265. }
  4266. // FieldCleared returns a boolean indicating if a field with the given name was
  4267. // cleared in this mutation.
  4268. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4269. _, ok := m.clearedFields[name]
  4270. return ok
  4271. }
  4272. // ClearField clears the value of the field with the given name. It returns an
  4273. // error if the field is not defined in the schema.
  4274. func (m *AllocAgentMutation) ClearField(name string) error {
  4275. switch name {
  4276. case allocagent.FieldDeletedAt:
  4277. m.ClearDeletedAt()
  4278. return nil
  4279. case allocagent.FieldUserID:
  4280. m.ClearUserID()
  4281. return nil
  4282. case allocagent.FieldOrganizationID:
  4283. m.ClearOrganizationID()
  4284. return nil
  4285. case allocagent.FieldStatus:
  4286. m.ClearStatus()
  4287. return nil
  4288. }
  4289. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4290. }
  4291. // ResetField resets all changes in the mutation for the field with the given name.
  4292. // It returns an error if the field is not defined in the schema.
  4293. func (m *AllocAgentMutation) ResetField(name string) error {
  4294. switch name {
  4295. case allocagent.FieldCreatedAt:
  4296. m.ResetCreatedAt()
  4297. return nil
  4298. case allocagent.FieldUpdatedAt:
  4299. m.ResetUpdatedAt()
  4300. return nil
  4301. case allocagent.FieldDeletedAt:
  4302. m.ResetDeletedAt()
  4303. return nil
  4304. case allocagent.FieldUserID:
  4305. m.ResetUserID()
  4306. return nil
  4307. case allocagent.FieldOrganizationID:
  4308. m.ResetOrganizationID()
  4309. return nil
  4310. case allocagent.FieldAgents:
  4311. m.ResetAgents()
  4312. return nil
  4313. case allocagent.FieldStatus:
  4314. m.ResetStatus()
  4315. return nil
  4316. }
  4317. return fmt.Errorf("unknown AllocAgent field %s", name)
  4318. }
  4319. // AddedEdges returns all edge names that were set/added in this mutation.
  4320. func (m *AllocAgentMutation) AddedEdges() []string {
  4321. edges := make([]string, 0, 0)
  4322. return edges
  4323. }
  4324. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4325. // name in this mutation.
  4326. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4327. return nil
  4328. }
  4329. // RemovedEdges returns all edge names that were removed in this mutation.
  4330. func (m *AllocAgentMutation) RemovedEdges() []string {
  4331. edges := make([]string, 0, 0)
  4332. return edges
  4333. }
  4334. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4335. // the given name in this mutation.
  4336. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4337. return nil
  4338. }
  4339. // ClearedEdges returns all edge names that were cleared in this mutation.
  4340. func (m *AllocAgentMutation) ClearedEdges() []string {
  4341. edges := make([]string, 0, 0)
  4342. return edges
  4343. }
  4344. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4345. // was cleared in this mutation.
  4346. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4347. return false
  4348. }
  4349. // ClearEdge clears the value of the edge with the given name. It returns an error
  4350. // if that edge is not defined in the schema.
  4351. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4352. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4353. }
  4354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4355. // It returns an error if the edge is not defined in the schema.
  4356. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4357. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4358. }
  4359. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4360. type ApiKeyMutation struct {
  4361. config
  4362. op Op
  4363. typ string
  4364. id *uint64
  4365. created_at *time.Time
  4366. updated_at *time.Time
  4367. deleted_at *time.Time
  4368. title *string
  4369. key *string
  4370. organization_id *uint64
  4371. addorganization_id *int64
  4372. custom_agent_base *string
  4373. custom_agent_key *string
  4374. openai_base *string
  4375. openai_key *string
  4376. clearedFields map[string]struct{}
  4377. agent *uint64
  4378. clearedagent bool
  4379. done bool
  4380. oldValue func(context.Context) (*ApiKey, error)
  4381. predicates []predicate.ApiKey
  4382. }
  4383. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4384. // apikeyOption allows management of the mutation configuration using functional options.
  4385. type apikeyOption func(*ApiKeyMutation)
  4386. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4387. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4388. m := &ApiKeyMutation{
  4389. config: c,
  4390. op: op,
  4391. typ: TypeApiKey,
  4392. clearedFields: make(map[string]struct{}),
  4393. }
  4394. for _, opt := range opts {
  4395. opt(m)
  4396. }
  4397. return m
  4398. }
  4399. // withApiKeyID sets the ID field of the mutation.
  4400. func withApiKeyID(id uint64) apikeyOption {
  4401. return func(m *ApiKeyMutation) {
  4402. var (
  4403. err error
  4404. once sync.Once
  4405. value *ApiKey
  4406. )
  4407. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4408. once.Do(func() {
  4409. if m.done {
  4410. err = errors.New("querying old values post mutation is not allowed")
  4411. } else {
  4412. value, err = m.Client().ApiKey.Get(ctx, id)
  4413. }
  4414. })
  4415. return value, err
  4416. }
  4417. m.id = &id
  4418. }
  4419. }
  4420. // withApiKey sets the old ApiKey of the mutation.
  4421. func withApiKey(node *ApiKey) apikeyOption {
  4422. return func(m *ApiKeyMutation) {
  4423. m.oldValue = func(context.Context) (*ApiKey, error) {
  4424. return node, nil
  4425. }
  4426. m.id = &node.ID
  4427. }
  4428. }
  4429. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4430. // executed in a transaction (ent.Tx), a transactional client is returned.
  4431. func (m ApiKeyMutation) Client() *Client {
  4432. client := &Client{config: m.config}
  4433. client.init()
  4434. return client
  4435. }
  4436. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4437. // it returns an error otherwise.
  4438. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4439. if _, ok := m.driver.(*txDriver); !ok {
  4440. return nil, errors.New("ent: mutation is not running in a transaction")
  4441. }
  4442. tx := &Tx{config: m.config}
  4443. tx.init()
  4444. return tx, nil
  4445. }
  4446. // SetID sets the value of the id field. Note that this
  4447. // operation is only accepted on creation of ApiKey entities.
  4448. func (m *ApiKeyMutation) SetID(id uint64) {
  4449. m.id = &id
  4450. }
  4451. // ID returns the ID value in the mutation. Note that the ID is only available
  4452. // if it was provided to the builder or after it was returned from the database.
  4453. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4454. if m.id == nil {
  4455. return
  4456. }
  4457. return *m.id, true
  4458. }
  4459. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4460. // That means, if the mutation is applied within a transaction with an isolation level such
  4461. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4462. // or updated by the mutation.
  4463. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4464. switch {
  4465. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4466. id, exists := m.ID()
  4467. if exists {
  4468. return []uint64{id}, nil
  4469. }
  4470. fallthrough
  4471. case m.op.Is(OpUpdate | OpDelete):
  4472. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4473. default:
  4474. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4475. }
  4476. }
  4477. // SetCreatedAt sets the "created_at" field.
  4478. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4479. m.created_at = &t
  4480. }
  4481. // CreatedAt returns the value of the "created_at" field in the mutation.
  4482. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4483. v := m.created_at
  4484. if v == nil {
  4485. return
  4486. }
  4487. return *v, true
  4488. }
  4489. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4490. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4492. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4493. if !m.op.Is(OpUpdateOne) {
  4494. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4495. }
  4496. if m.id == nil || m.oldValue == nil {
  4497. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4498. }
  4499. oldValue, err := m.oldValue(ctx)
  4500. if err != nil {
  4501. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4502. }
  4503. return oldValue.CreatedAt, nil
  4504. }
  4505. // ResetCreatedAt resets all changes to the "created_at" field.
  4506. func (m *ApiKeyMutation) ResetCreatedAt() {
  4507. m.created_at = nil
  4508. }
  4509. // SetUpdatedAt sets the "updated_at" field.
  4510. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4511. m.updated_at = &t
  4512. }
  4513. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4514. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4515. v := m.updated_at
  4516. if v == nil {
  4517. return
  4518. }
  4519. return *v, true
  4520. }
  4521. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4522. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4524. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4525. if !m.op.Is(OpUpdateOne) {
  4526. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4527. }
  4528. if m.id == nil || m.oldValue == nil {
  4529. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4530. }
  4531. oldValue, err := m.oldValue(ctx)
  4532. if err != nil {
  4533. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4534. }
  4535. return oldValue.UpdatedAt, nil
  4536. }
  4537. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4538. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4539. m.updated_at = nil
  4540. }
  4541. // SetDeletedAt sets the "deleted_at" field.
  4542. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4543. m.deleted_at = &t
  4544. }
  4545. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4546. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4547. v := m.deleted_at
  4548. if v == nil {
  4549. return
  4550. }
  4551. return *v, true
  4552. }
  4553. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4554. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4556. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4557. if !m.op.Is(OpUpdateOne) {
  4558. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4559. }
  4560. if m.id == nil || m.oldValue == nil {
  4561. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4562. }
  4563. oldValue, err := m.oldValue(ctx)
  4564. if err != nil {
  4565. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4566. }
  4567. return oldValue.DeletedAt, nil
  4568. }
  4569. // ClearDeletedAt clears the value of the "deleted_at" field.
  4570. func (m *ApiKeyMutation) ClearDeletedAt() {
  4571. m.deleted_at = nil
  4572. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4573. }
  4574. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4575. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4576. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4577. return ok
  4578. }
  4579. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4580. func (m *ApiKeyMutation) ResetDeletedAt() {
  4581. m.deleted_at = nil
  4582. delete(m.clearedFields, apikey.FieldDeletedAt)
  4583. }
  4584. // SetTitle sets the "title" field.
  4585. func (m *ApiKeyMutation) SetTitle(s string) {
  4586. m.title = &s
  4587. }
  4588. // Title returns the value of the "title" field in the mutation.
  4589. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4590. v := m.title
  4591. if v == nil {
  4592. return
  4593. }
  4594. return *v, true
  4595. }
  4596. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4597. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4599. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4600. if !m.op.Is(OpUpdateOne) {
  4601. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4602. }
  4603. if m.id == nil || m.oldValue == nil {
  4604. return v, errors.New("OldTitle requires an ID field in the mutation")
  4605. }
  4606. oldValue, err := m.oldValue(ctx)
  4607. if err != nil {
  4608. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4609. }
  4610. return oldValue.Title, nil
  4611. }
  4612. // ClearTitle clears the value of the "title" field.
  4613. func (m *ApiKeyMutation) ClearTitle() {
  4614. m.title = nil
  4615. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4616. }
  4617. // TitleCleared returns if the "title" field was cleared in this mutation.
  4618. func (m *ApiKeyMutation) TitleCleared() bool {
  4619. _, ok := m.clearedFields[apikey.FieldTitle]
  4620. return ok
  4621. }
  4622. // ResetTitle resets all changes to the "title" field.
  4623. func (m *ApiKeyMutation) ResetTitle() {
  4624. m.title = nil
  4625. delete(m.clearedFields, apikey.FieldTitle)
  4626. }
  4627. // SetKey sets the "key" field.
  4628. func (m *ApiKeyMutation) SetKey(s string) {
  4629. m.key = &s
  4630. }
  4631. // Key returns the value of the "key" field in the mutation.
  4632. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4633. v := m.key
  4634. if v == nil {
  4635. return
  4636. }
  4637. return *v, true
  4638. }
  4639. // OldKey returns the old "key" field's value of the ApiKey entity.
  4640. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4642. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4643. if !m.op.Is(OpUpdateOne) {
  4644. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4645. }
  4646. if m.id == nil || m.oldValue == nil {
  4647. return v, errors.New("OldKey requires an ID field in the mutation")
  4648. }
  4649. oldValue, err := m.oldValue(ctx)
  4650. if err != nil {
  4651. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4652. }
  4653. return oldValue.Key, nil
  4654. }
  4655. // ClearKey clears the value of the "key" field.
  4656. func (m *ApiKeyMutation) ClearKey() {
  4657. m.key = nil
  4658. m.clearedFields[apikey.FieldKey] = struct{}{}
  4659. }
  4660. // KeyCleared returns if the "key" field was cleared in this mutation.
  4661. func (m *ApiKeyMutation) KeyCleared() bool {
  4662. _, ok := m.clearedFields[apikey.FieldKey]
  4663. return ok
  4664. }
  4665. // ResetKey resets all changes to the "key" field.
  4666. func (m *ApiKeyMutation) ResetKey() {
  4667. m.key = nil
  4668. delete(m.clearedFields, apikey.FieldKey)
  4669. }
  4670. // SetOrganizationID sets the "organization_id" field.
  4671. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4672. m.organization_id = &u
  4673. m.addorganization_id = nil
  4674. }
  4675. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4676. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4677. v := m.organization_id
  4678. if v == nil {
  4679. return
  4680. }
  4681. return *v, true
  4682. }
  4683. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4684. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4686. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4687. if !m.op.Is(OpUpdateOne) {
  4688. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4689. }
  4690. if m.id == nil || m.oldValue == nil {
  4691. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4692. }
  4693. oldValue, err := m.oldValue(ctx)
  4694. if err != nil {
  4695. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4696. }
  4697. return oldValue.OrganizationID, nil
  4698. }
  4699. // AddOrganizationID adds u to the "organization_id" field.
  4700. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4701. if m.addorganization_id != nil {
  4702. *m.addorganization_id += u
  4703. } else {
  4704. m.addorganization_id = &u
  4705. }
  4706. }
  4707. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4708. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4709. v := m.addorganization_id
  4710. if v == nil {
  4711. return
  4712. }
  4713. return *v, true
  4714. }
  4715. // ResetOrganizationID resets all changes to the "organization_id" field.
  4716. func (m *ApiKeyMutation) ResetOrganizationID() {
  4717. m.organization_id = nil
  4718. m.addorganization_id = nil
  4719. }
  4720. // SetAgentID sets the "agent_id" field.
  4721. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4722. m.agent = &u
  4723. }
  4724. // AgentID returns the value of the "agent_id" field in the mutation.
  4725. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4726. v := m.agent
  4727. if v == nil {
  4728. return
  4729. }
  4730. return *v, true
  4731. }
  4732. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4733. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4735. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4736. if !m.op.Is(OpUpdateOne) {
  4737. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4738. }
  4739. if m.id == nil || m.oldValue == nil {
  4740. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4741. }
  4742. oldValue, err := m.oldValue(ctx)
  4743. if err != nil {
  4744. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4745. }
  4746. return oldValue.AgentID, nil
  4747. }
  4748. // ResetAgentID resets all changes to the "agent_id" field.
  4749. func (m *ApiKeyMutation) ResetAgentID() {
  4750. m.agent = nil
  4751. }
  4752. // SetCustomAgentBase sets the "custom_agent_base" field.
  4753. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4754. m.custom_agent_base = &s
  4755. }
  4756. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4757. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4758. v := m.custom_agent_base
  4759. if v == nil {
  4760. return
  4761. }
  4762. return *v, true
  4763. }
  4764. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4765. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4767. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4768. if !m.op.Is(OpUpdateOne) {
  4769. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4770. }
  4771. if m.id == nil || m.oldValue == nil {
  4772. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4773. }
  4774. oldValue, err := m.oldValue(ctx)
  4775. if err != nil {
  4776. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4777. }
  4778. return oldValue.CustomAgentBase, nil
  4779. }
  4780. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4781. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4782. m.custom_agent_base = nil
  4783. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4784. }
  4785. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4786. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4787. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4788. return ok
  4789. }
  4790. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4791. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4792. m.custom_agent_base = nil
  4793. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4794. }
  4795. // SetCustomAgentKey sets the "custom_agent_key" field.
  4796. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4797. m.custom_agent_key = &s
  4798. }
  4799. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4800. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4801. v := m.custom_agent_key
  4802. if v == nil {
  4803. return
  4804. }
  4805. return *v, true
  4806. }
  4807. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4808. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4810. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4811. if !m.op.Is(OpUpdateOne) {
  4812. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4813. }
  4814. if m.id == nil || m.oldValue == nil {
  4815. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4816. }
  4817. oldValue, err := m.oldValue(ctx)
  4818. if err != nil {
  4819. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4820. }
  4821. return oldValue.CustomAgentKey, nil
  4822. }
  4823. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4824. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4825. m.custom_agent_key = nil
  4826. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4827. }
  4828. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4829. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4830. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4831. return ok
  4832. }
  4833. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4834. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4835. m.custom_agent_key = nil
  4836. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4837. }
  4838. // SetOpenaiBase sets the "openai_base" field.
  4839. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4840. m.openai_base = &s
  4841. }
  4842. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4843. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4844. v := m.openai_base
  4845. if v == nil {
  4846. return
  4847. }
  4848. return *v, true
  4849. }
  4850. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4851. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4853. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4854. if !m.op.Is(OpUpdateOne) {
  4855. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4856. }
  4857. if m.id == nil || m.oldValue == nil {
  4858. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4859. }
  4860. oldValue, err := m.oldValue(ctx)
  4861. if err != nil {
  4862. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4863. }
  4864. return oldValue.OpenaiBase, nil
  4865. }
  4866. // ClearOpenaiBase clears the value of the "openai_base" field.
  4867. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4868. m.openai_base = nil
  4869. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4870. }
  4871. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4872. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4873. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4874. return ok
  4875. }
  4876. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4877. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4878. m.openai_base = nil
  4879. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4880. }
  4881. // SetOpenaiKey sets the "openai_key" field.
  4882. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4883. m.openai_key = &s
  4884. }
  4885. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4886. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4887. v := m.openai_key
  4888. if v == nil {
  4889. return
  4890. }
  4891. return *v, true
  4892. }
  4893. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4894. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4896. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4897. if !m.op.Is(OpUpdateOne) {
  4898. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4899. }
  4900. if m.id == nil || m.oldValue == nil {
  4901. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4902. }
  4903. oldValue, err := m.oldValue(ctx)
  4904. if err != nil {
  4905. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4906. }
  4907. return oldValue.OpenaiKey, nil
  4908. }
  4909. // ClearOpenaiKey clears the value of the "openai_key" field.
  4910. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4911. m.openai_key = nil
  4912. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4913. }
  4914. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4915. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4916. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4917. return ok
  4918. }
  4919. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4920. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4921. m.openai_key = nil
  4922. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4923. }
  4924. // ClearAgent clears the "agent" edge to the Agent entity.
  4925. func (m *ApiKeyMutation) ClearAgent() {
  4926. m.clearedagent = true
  4927. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4928. }
  4929. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4930. func (m *ApiKeyMutation) AgentCleared() bool {
  4931. return m.clearedagent
  4932. }
  4933. // AgentIDs returns the "agent" edge IDs in the mutation.
  4934. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4935. // AgentID instead. It exists only for internal usage by the builders.
  4936. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4937. if id := m.agent; id != nil {
  4938. ids = append(ids, *id)
  4939. }
  4940. return
  4941. }
  4942. // ResetAgent resets all changes to the "agent" edge.
  4943. func (m *ApiKeyMutation) ResetAgent() {
  4944. m.agent = nil
  4945. m.clearedagent = false
  4946. }
  4947. // Where appends a list predicates to the ApiKeyMutation builder.
  4948. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4949. m.predicates = append(m.predicates, ps...)
  4950. }
  4951. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4952. // users can use type-assertion to append predicates that do not depend on any generated package.
  4953. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4954. p := make([]predicate.ApiKey, len(ps))
  4955. for i := range ps {
  4956. p[i] = ps[i]
  4957. }
  4958. m.Where(p...)
  4959. }
  4960. // Op returns the operation name.
  4961. func (m *ApiKeyMutation) Op() Op {
  4962. return m.op
  4963. }
  4964. // SetOp allows setting the mutation operation.
  4965. func (m *ApiKeyMutation) SetOp(op Op) {
  4966. m.op = op
  4967. }
  4968. // Type returns the node type of this mutation (ApiKey).
  4969. func (m *ApiKeyMutation) Type() string {
  4970. return m.typ
  4971. }
  4972. // Fields returns all fields that were changed during this mutation. Note that in
  4973. // order to get all numeric fields that were incremented/decremented, call
  4974. // AddedFields().
  4975. func (m *ApiKeyMutation) Fields() []string {
  4976. fields := make([]string, 0, 11)
  4977. if m.created_at != nil {
  4978. fields = append(fields, apikey.FieldCreatedAt)
  4979. }
  4980. if m.updated_at != nil {
  4981. fields = append(fields, apikey.FieldUpdatedAt)
  4982. }
  4983. if m.deleted_at != nil {
  4984. fields = append(fields, apikey.FieldDeletedAt)
  4985. }
  4986. if m.title != nil {
  4987. fields = append(fields, apikey.FieldTitle)
  4988. }
  4989. if m.key != nil {
  4990. fields = append(fields, apikey.FieldKey)
  4991. }
  4992. if m.organization_id != nil {
  4993. fields = append(fields, apikey.FieldOrganizationID)
  4994. }
  4995. if m.agent != nil {
  4996. fields = append(fields, apikey.FieldAgentID)
  4997. }
  4998. if m.custom_agent_base != nil {
  4999. fields = append(fields, apikey.FieldCustomAgentBase)
  5000. }
  5001. if m.custom_agent_key != nil {
  5002. fields = append(fields, apikey.FieldCustomAgentKey)
  5003. }
  5004. if m.openai_base != nil {
  5005. fields = append(fields, apikey.FieldOpenaiBase)
  5006. }
  5007. if m.openai_key != nil {
  5008. fields = append(fields, apikey.FieldOpenaiKey)
  5009. }
  5010. return fields
  5011. }
  5012. // Field returns the value of a field with the given name. The second boolean
  5013. // return value indicates that this field was not set, or was not defined in the
  5014. // schema.
  5015. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5016. switch name {
  5017. case apikey.FieldCreatedAt:
  5018. return m.CreatedAt()
  5019. case apikey.FieldUpdatedAt:
  5020. return m.UpdatedAt()
  5021. case apikey.FieldDeletedAt:
  5022. return m.DeletedAt()
  5023. case apikey.FieldTitle:
  5024. return m.Title()
  5025. case apikey.FieldKey:
  5026. return m.Key()
  5027. case apikey.FieldOrganizationID:
  5028. return m.OrganizationID()
  5029. case apikey.FieldAgentID:
  5030. return m.AgentID()
  5031. case apikey.FieldCustomAgentBase:
  5032. return m.CustomAgentBase()
  5033. case apikey.FieldCustomAgentKey:
  5034. return m.CustomAgentKey()
  5035. case apikey.FieldOpenaiBase:
  5036. return m.OpenaiBase()
  5037. case apikey.FieldOpenaiKey:
  5038. return m.OpenaiKey()
  5039. }
  5040. return nil, false
  5041. }
  5042. // OldField returns the old value of the field from the database. An error is
  5043. // returned if the mutation operation is not UpdateOne, or the query to the
  5044. // database failed.
  5045. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5046. switch name {
  5047. case apikey.FieldCreatedAt:
  5048. return m.OldCreatedAt(ctx)
  5049. case apikey.FieldUpdatedAt:
  5050. return m.OldUpdatedAt(ctx)
  5051. case apikey.FieldDeletedAt:
  5052. return m.OldDeletedAt(ctx)
  5053. case apikey.FieldTitle:
  5054. return m.OldTitle(ctx)
  5055. case apikey.FieldKey:
  5056. return m.OldKey(ctx)
  5057. case apikey.FieldOrganizationID:
  5058. return m.OldOrganizationID(ctx)
  5059. case apikey.FieldAgentID:
  5060. return m.OldAgentID(ctx)
  5061. case apikey.FieldCustomAgentBase:
  5062. return m.OldCustomAgentBase(ctx)
  5063. case apikey.FieldCustomAgentKey:
  5064. return m.OldCustomAgentKey(ctx)
  5065. case apikey.FieldOpenaiBase:
  5066. return m.OldOpenaiBase(ctx)
  5067. case apikey.FieldOpenaiKey:
  5068. return m.OldOpenaiKey(ctx)
  5069. }
  5070. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5071. }
  5072. // SetField sets the value of a field with the given name. It returns an error if
  5073. // the field is not defined in the schema, or if the type mismatched the field
  5074. // type.
  5075. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5076. switch name {
  5077. case apikey.FieldCreatedAt:
  5078. v, ok := value.(time.Time)
  5079. if !ok {
  5080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5081. }
  5082. m.SetCreatedAt(v)
  5083. return nil
  5084. case apikey.FieldUpdatedAt:
  5085. v, ok := value.(time.Time)
  5086. if !ok {
  5087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5088. }
  5089. m.SetUpdatedAt(v)
  5090. return nil
  5091. case apikey.FieldDeletedAt:
  5092. v, ok := value.(time.Time)
  5093. if !ok {
  5094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5095. }
  5096. m.SetDeletedAt(v)
  5097. return nil
  5098. case apikey.FieldTitle:
  5099. v, ok := value.(string)
  5100. if !ok {
  5101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5102. }
  5103. m.SetTitle(v)
  5104. return nil
  5105. case apikey.FieldKey:
  5106. v, ok := value.(string)
  5107. if !ok {
  5108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5109. }
  5110. m.SetKey(v)
  5111. return nil
  5112. case apikey.FieldOrganizationID:
  5113. v, ok := value.(uint64)
  5114. if !ok {
  5115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5116. }
  5117. m.SetOrganizationID(v)
  5118. return nil
  5119. case apikey.FieldAgentID:
  5120. v, ok := value.(uint64)
  5121. if !ok {
  5122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5123. }
  5124. m.SetAgentID(v)
  5125. return nil
  5126. case apikey.FieldCustomAgentBase:
  5127. v, ok := value.(string)
  5128. if !ok {
  5129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5130. }
  5131. m.SetCustomAgentBase(v)
  5132. return nil
  5133. case apikey.FieldCustomAgentKey:
  5134. v, ok := value.(string)
  5135. if !ok {
  5136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5137. }
  5138. m.SetCustomAgentKey(v)
  5139. return nil
  5140. case apikey.FieldOpenaiBase:
  5141. v, ok := value.(string)
  5142. if !ok {
  5143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5144. }
  5145. m.SetOpenaiBase(v)
  5146. return nil
  5147. case apikey.FieldOpenaiKey:
  5148. v, ok := value.(string)
  5149. if !ok {
  5150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5151. }
  5152. m.SetOpenaiKey(v)
  5153. return nil
  5154. }
  5155. return fmt.Errorf("unknown ApiKey field %s", name)
  5156. }
  5157. // AddedFields returns all numeric fields that were incremented/decremented during
  5158. // this mutation.
  5159. func (m *ApiKeyMutation) AddedFields() []string {
  5160. var fields []string
  5161. if m.addorganization_id != nil {
  5162. fields = append(fields, apikey.FieldOrganizationID)
  5163. }
  5164. return fields
  5165. }
  5166. // AddedField returns the numeric value that was incremented/decremented on a field
  5167. // with the given name. The second boolean return value indicates that this field
  5168. // was not set, or was not defined in the schema.
  5169. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5170. switch name {
  5171. case apikey.FieldOrganizationID:
  5172. return m.AddedOrganizationID()
  5173. }
  5174. return nil, false
  5175. }
  5176. // AddField adds the value to the field with the given name. It returns an error if
  5177. // the field is not defined in the schema, or if the type mismatched the field
  5178. // type.
  5179. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5180. switch name {
  5181. case apikey.FieldOrganizationID:
  5182. v, ok := value.(int64)
  5183. if !ok {
  5184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5185. }
  5186. m.AddOrganizationID(v)
  5187. return nil
  5188. }
  5189. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5190. }
  5191. // ClearedFields returns all nullable fields that were cleared during this
  5192. // mutation.
  5193. func (m *ApiKeyMutation) ClearedFields() []string {
  5194. var fields []string
  5195. if m.FieldCleared(apikey.FieldDeletedAt) {
  5196. fields = append(fields, apikey.FieldDeletedAt)
  5197. }
  5198. if m.FieldCleared(apikey.FieldTitle) {
  5199. fields = append(fields, apikey.FieldTitle)
  5200. }
  5201. if m.FieldCleared(apikey.FieldKey) {
  5202. fields = append(fields, apikey.FieldKey)
  5203. }
  5204. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5205. fields = append(fields, apikey.FieldCustomAgentBase)
  5206. }
  5207. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5208. fields = append(fields, apikey.FieldCustomAgentKey)
  5209. }
  5210. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5211. fields = append(fields, apikey.FieldOpenaiBase)
  5212. }
  5213. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5214. fields = append(fields, apikey.FieldOpenaiKey)
  5215. }
  5216. return fields
  5217. }
  5218. // FieldCleared returns a boolean indicating if a field with the given name was
  5219. // cleared in this mutation.
  5220. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5221. _, ok := m.clearedFields[name]
  5222. return ok
  5223. }
  5224. // ClearField clears the value of the field with the given name. It returns an
  5225. // error if the field is not defined in the schema.
  5226. func (m *ApiKeyMutation) ClearField(name string) error {
  5227. switch name {
  5228. case apikey.FieldDeletedAt:
  5229. m.ClearDeletedAt()
  5230. return nil
  5231. case apikey.FieldTitle:
  5232. m.ClearTitle()
  5233. return nil
  5234. case apikey.FieldKey:
  5235. m.ClearKey()
  5236. return nil
  5237. case apikey.FieldCustomAgentBase:
  5238. m.ClearCustomAgentBase()
  5239. return nil
  5240. case apikey.FieldCustomAgentKey:
  5241. m.ClearCustomAgentKey()
  5242. return nil
  5243. case apikey.FieldOpenaiBase:
  5244. m.ClearOpenaiBase()
  5245. return nil
  5246. case apikey.FieldOpenaiKey:
  5247. m.ClearOpenaiKey()
  5248. return nil
  5249. }
  5250. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5251. }
  5252. // ResetField resets all changes in the mutation for the field with the given name.
  5253. // It returns an error if the field is not defined in the schema.
  5254. func (m *ApiKeyMutation) ResetField(name string) error {
  5255. switch name {
  5256. case apikey.FieldCreatedAt:
  5257. m.ResetCreatedAt()
  5258. return nil
  5259. case apikey.FieldUpdatedAt:
  5260. m.ResetUpdatedAt()
  5261. return nil
  5262. case apikey.FieldDeletedAt:
  5263. m.ResetDeletedAt()
  5264. return nil
  5265. case apikey.FieldTitle:
  5266. m.ResetTitle()
  5267. return nil
  5268. case apikey.FieldKey:
  5269. m.ResetKey()
  5270. return nil
  5271. case apikey.FieldOrganizationID:
  5272. m.ResetOrganizationID()
  5273. return nil
  5274. case apikey.FieldAgentID:
  5275. m.ResetAgentID()
  5276. return nil
  5277. case apikey.FieldCustomAgentBase:
  5278. m.ResetCustomAgentBase()
  5279. return nil
  5280. case apikey.FieldCustomAgentKey:
  5281. m.ResetCustomAgentKey()
  5282. return nil
  5283. case apikey.FieldOpenaiBase:
  5284. m.ResetOpenaiBase()
  5285. return nil
  5286. case apikey.FieldOpenaiKey:
  5287. m.ResetOpenaiKey()
  5288. return nil
  5289. }
  5290. return fmt.Errorf("unknown ApiKey field %s", name)
  5291. }
  5292. // AddedEdges returns all edge names that were set/added in this mutation.
  5293. func (m *ApiKeyMutation) AddedEdges() []string {
  5294. edges := make([]string, 0, 1)
  5295. if m.agent != nil {
  5296. edges = append(edges, apikey.EdgeAgent)
  5297. }
  5298. return edges
  5299. }
  5300. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5301. // name in this mutation.
  5302. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5303. switch name {
  5304. case apikey.EdgeAgent:
  5305. if id := m.agent; id != nil {
  5306. return []ent.Value{*id}
  5307. }
  5308. }
  5309. return nil
  5310. }
  5311. // RemovedEdges returns all edge names that were removed in this mutation.
  5312. func (m *ApiKeyMutation) RemovedEdges() []string {
  5313. edges := make([]string, 0, 1)
  5314. return edges
  5315. }
  5316. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5317. // the given name in this mutation.
  5318. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5319. return nil
  5320. }
  5321. // ClearedEdges returns all edge names that were cleared in this mutation.
  5322. func (m *ApiKeyMutation) ClearedEdges() []string {
  5323. edges := make([]string, 0, 1)
  5324. if m.clearedagent {
  5325. edges = append(edges, apikey.EdgeAgent)
  5326. }
  5327. return edges
  5328. }
  5329. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5330. // was cleared in this mutation.
  5331. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5332. switch name {
  5333. case apikey.EdgeAgent:
  5334. return m.clearedagent
  5335. }
  5336. return false
  5337. }
  5338. // ClearEdge clears the value of the edge with the given name. It returns an error
  5339. // if that edge is not defined in the schema.
  5340. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5341. switch name {
  5342. case apikey.EdgeAgent:
  5343. m.ClearAgent()
  5344. return nil
  5345. }
  5346. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5347. }
  5348. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5349. // It returns an error if the edge is not defined in the schema.
  5350. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5351. switch name {
  5352. case apikey.EdgeAgent:
  5353. m.ResetAgent()
  5354. return nil
  5355. }
  5356. return fmt.Errorf("unknown ApiKey edge %s", name)
  5357. }
  5358. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5359. type BatchMsgMutation struct {
  5360. config
  5361. op Op
  5362. typ string
  5363. id *uint64
  5364. created_at *time.Time
  5365. updated_at *time.Time
  5366. deleted_at *time.Time
  5367. status *uint8
  5368. addstatus *int8
  5369. batch_no *string
  5370. task_name *string
  5371. fromwxid *string
  5372. msg *string
  5373. tag *string
  5374. tagids *string
  5375. total *int32
  5376. addtotal *int32
  5377. success *int32
  5378. addsuccess *int32
  5379. fail *int32
  5380. addfail *int32
  5381. start_time *time.Time
  5382. stop_time *time.Time
  5383. send_time *time.Time
  5384. _type *int32
  5385. add_type *int32
  5386. organization_id *uint64
  5387. addorganization_id *int64
  5388. ctype *uint64
  5389. addctype *int64
  5390. cc *string
  5391. phone *string
  5392. template_name *string
  5393. template_code *string
  5394. lang *string
  5395. clearedFields map[string]struct{}
  5396. done bool
  5397. oldValue func(context.Context) (*BatchMsg, error)
  5398. predicates []predicate.BatchMsg
  5399. }
  5400. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5401. // batchmsgOption allows management of the mutation configuration using functional options.
  5402. type batchmsgOption func(*BatchMsgMutation)
  5403. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5404. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5405. m := &BatchMsgMutation{
  5406. config: c,
  5407. op: op,
  5408. typ: TypeBatchMsg,
  5409. clearedFields: make(map[string]struct{}),
  5410. }
  5411. for _, opt := range opts {
  5412. opt(m)
  5413. }
  5414. return m
  5415. }
  5416. // withBatchMsgID sets the ID field of the mutation.
  5417. func withBatchMsgID(id uint64) batchmsgOption {
  5418. return func(m *BatchMsgMutation) {
  5419. var (
  5420. err error
  5421. once sync.Once
  5422. value *BatchMsg
  5423. )
  5424. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5425. once.Do(func() {
  5426. if m.done {
  5427. err = errors.New("querying old values post mutation is not allowed")
  5428. } else {
  5429. value, err = m.Client().BatchMsg.Get(ctx, id)
  5430. }
  5431. })
  5432. return value, err
  5433. }
  5434. m.id = &id
  5435. }
  5436. }
  5437. // withBatchMsg sets the old BatchMsg of the mutation.
  5438. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5439. return func(m *BatchMsgMutation) {
  5440. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5441. return node, nil
  5442. }
  5443. m.id = &node.ID
  5444. }
  5445. }
  5446. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5447. // executed in a transaction (ent.Tx), a transactional client is returned.
  5448. func (m BatchMsgMutation) Client() *Client {
  5449. client := &Client{config: m.config}
  5450. client.init()
  5451. return client
  5452. }
  5453. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5454. // it returns an error otherwise.
  5455. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5456. if _, ok := m.driver.(*txDriver); !ok {
  5457. return nil, errors.New("ent: mutation is not running in a transaction")
  5458. }
  5459. tx := &Tx{config: m.config}
  5460. tx.init()
  5461. return tx, nil
  5462. }
  5463. // SetID sets the value of the id field. Note that this
  5464. // operation is only accepted on creation of BatchMsg entities.
  5465. func (m *BatchMsgMutation) SetID(id uint64) {
  5466. m.id = &id
  5467. }
  5468. // ID returns the ID value in the mutation. Note that the ID is only available
  5469. // if it was provided to the builder or after it was returned from the database.
  5470. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5471. if m.id == nil {
  5472. return
  5473. }
  5474. return *m.id, true
  5475. }
  5476. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5477. // That means, if the mutation is applied within a transaction with an isolation level such
  5478. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5479. // or updated by the mutation.
  5480. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5481. switch {
  5482. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5483. id, exists := m.ID()
  5484. if exists {
  5485. return []uint64{id}, nil
  5486. }
  5487. fallthrough
  5488. case m.op.Is(OpUpdate | OpDelete):
  5489. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5490. default:
  5491. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5492. }
  5493. }
  5494. // SetCreatedAt sets the "created_at" field.
  5495. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5496. m.created_at = &t
  5497. }
  5498. // CreatedAt returns the value of the "created_at" field in the mutation.
  5499. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5500. v := m.created_at
  5501. if v == nil {
  5502. return
  5503. }
  5504. return *v, true
  5505. }
  5506. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5507. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5509. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5510. if !m.op.Is(OpUpdateOne) {
  5511. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5512. }
  5513. if m.id == nil || m.oldValue == nil {
  5514. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5515. }
  5516. oldValue, err := m.oldValue(ctx)
  5517. if err != nil {
  5518. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5519. }
  5520. return oldValue.CreatedAt, nil
  5521. }
  5522. // ResetCreatedAt resets all changes to the "created_at" field.
  5523. func (m *BatchMsgMutation) ResetCreatedAt() {
  5524. m.created_at = nil
  5525. }
  5526. // SetUpdatedAt sets the "updated_at" field.
  5527. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5528. m.updated_at = &t
  5529. }
  5530. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5531. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5532. v := m.updated_at
  5533. if v == nil {
  5534. return
  5535. }
  5536. return *v, true
  5537. }
  5538. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5539. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5541. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5542. if !m.op.Is(OpUpdateOne) {
  5543. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5544. }
  5545. if m.id == nil || m.oldValue == nil {
  5546. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5547. }
  5548. oldValue, err := m.oldValue(ctx)
  5549. if err != nil {
  5550. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5551. }
  5552. return oldValue.UpdatedAt, nil
  5553. }
  5554. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5555. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5556. m.updated_at = nil
  5557. }
  5558. // SetDeletedAt sets the "deleted_at" field.
  5559. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5560. m.deleted_at = &t
  5561. }
  5562. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5563. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5564. v := m.deleted_at
  5565. if v == nil {
  5566. return
  5567. }
  5568. return *v, true
  5569. }
  5570. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5571. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5573. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5574. if !m.op.Is(OpUpdateOne) {
  5575. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5576. }
  5577. if m.id == nil || m.oldValue == nil {
  5578. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5579. }
  5580. oldValue, err := m.oldValue(ctx)
  5581. if err != nil {
  5582. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5583. }
  5584. return oldValue.DeletedAt, nil
  5585. }
  5586. // ClearDeletedAt clears the value of the "deleted_at" field.
  5587. func (m *BatchMsgMutation) ClearDeletedAt() {
  5588. m.deleted_at = nil
  5589. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5590. }
  5591. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5592. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5593. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5594. return ok
  5595. }
  5596. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5597. func (m *BatchMsgMutation) ResetDeletedAt() {
  5598. m.deleted_at = nil
  5599. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5600. }
  5601. // SetStatus sets the "status" field.
  5602. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5603. m.status = &u
  5604. m.addstatus = nil
  5605. }
  5606. // Status returns the value of the "status" field in the mutation.
  5607. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5608. v := m.status
  5609. if v == nil {
  5610. return
  5611. }
  5612. return *v, true
  5613. }
  5614. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5615. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5617. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5618. if !m.op.Is(OpUpdateOne) {
  5619. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5620. }
  5621. if m.id == nil || m.oldValue == nil {
  5622. return v, errors.New("OldStatus requires an ID field in the mutation")
  5623. }
  5624. oldValue, err := m.oldValue(ctx)
  5625. if err != nil {
  5626. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5627. }
  5628. return oldValue.Status, nil
  5629. }
  5630. // AddStatus adds u to the "status" field.
  5631. func (m *BatchMsgMutation) AddStatus(u int8) {
  5632. if m.addstatus != nil {
  5633. *m.addstatus += u
  5634. } else {
  5635. m.addstatus = &u
  5636. }
  5637. }
  5638. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5639. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5640. v := m.addstatus
  5641. if v == nil {
  5642. return
  5643. }
  5644. return *v, true
  5645. }
  5646. // ClearStatus clears the value of the "status" field.
  5647. func (m *BatchMsgMutation) ClearStatus() {
  5648. m.status = nil
  5649. m.addstatus = nil
  5650. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5651. }
  5652. // StatusCleared returns if the "status" field was cleared in this mutation.
  5653. func (m *BatchMsgMutation) StatusCleared() bool {
  5654. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5655. return ok
  5656. }
  5657. // ResetStatus resets all changes to the "status" field.
  5658. func (m *BatchMsgMutation) ResetStatus() {
  5659. m.status = nil
  5660. m.addstatus = nil
  5661. delete(m.clearedFields, batchmsg.FieldStatus)
  5662. }
  5663. // SetBatchNo sets the "batch_no" field.
  5664. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5665. m.batch_no = &s
  5666. }
  5667. // BatchNo returns the value of the "batch_no" field in the mutation.
  5668. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5669. v := m.batch_no
  5670. if v == nil {
  5671. return
  5672. }
  5673. return *v, true
  5674. }
  5675. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5676. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5678. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5679. if !m.op.Is(OpUpdateOne) {
  5680. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5681. }
  5682. if m.id == nil || m.oldValue == nil {
  5683. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5684. }
  5685. oldValue, err := m.oldValue(ctx)
  5686. if err != nil {
  5687. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5688. }
  5689. return oldValue.BatchNo, nil
  5690. }
  5691. // ClearBatchNo clears the value of the "batch_no" field.
  5692. func (m *BatchMsgMutation) ClearBatchNo() {
  5693. m.batch_no = nil
  5694. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5695. }
  5696. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5697. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5698. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5699. return ok
  5700. }
  5701. // ResetBatchNo resets all changes to the "batch_no" field.
  5702. func (m *BatchMsgMutation) ResetBatchNo() {
  5703. m.batch_no = nil
  5704. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5705. }
  5706. // SetTaskName sets the "task_name" field.
  5707. func (m *BatchMsgMutation) SetTaskName(s string) {
  5708. m.task_name = &s
  5709. }
  5710. // TaskName returns the value of the "task_name" field in the mutation.
  5711. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5712. v := m.task_name
  5713. if v == nil {
  5714. return
  5715. }
  5716. return *v, true
  5717. }
  5718. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5719. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5721. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5722. if !m.op.Is(OpUpdateOne) {
  5723. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5724. }
  5725. if m.id == nil || m.oldValue == nil {
  5726. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5727. }
  5728. oldValue, err := m.oldValue(ctx)
  5729. if err != nil {
  5730. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5731. }
  5732. return oldValue.TaskName, nil
  5733. }
  5734. // ClearTaskName clears the value of the "task_name" field.
  5735. func (m *BatchMsgMutation) ClearTaskName() {
  5736. m.task_name = nil
  5737. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5738. }
  5739. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5740. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5741. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5742. return ok
  5743. }
  5744. // ResetTaskName resets all changes to the "task_name" field.
  5745. func (m *BatchMsgMutation) ResetTaskName() {
  5746. m.task_name = nil
  5747. delete(m.clearedFields, batchmsg.FieldTaskName)
  5748. }
  5749. // SetFromwxid sets the "fromwxid" field.
  5750. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5751. m.fromwxid = &s
  5752. }
  5753. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5754. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5755. v := m.fromwxid
  5756. if v == nil {
  5757. return
  5758. }
  5759. return *v, true
  5760. }
  5761. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5762. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5764. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5765. if !m.op.Is(OpUpdateOne) {
  5766. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5767. }
  5768. if m.id == nil || m.oldValue == nil {
  5769. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5770. }
  5771. oldValue, err := m.oldValue(ctx)
  5772. if err != nil {
  5773. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5774. }
  5775. return oldValue.Fromwxid, nil
  5776. }
  5777. // ClearFromwxid clears the value of the "fromwxid" field.
  5778. func (m *BatchMsgMutation) ClearFromwxid() {
  5779. m.fromwxid = nil
  5780. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5781. }
  5782. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5783. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5784. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5785. return ok
  5786. }
  5787. // ResetFromwxid resets all changes to the "fromwxid" field.
  5788. func (m *BatchMsgMutation) ResetFromwxid() {
  5789. m.fromwxid = nil
  5790. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5791. }
  5792. // SetMsg sets the "msg" field.
  5793. func (m *BatchMsgMutation) SetMsg(s string) {
  5794. m.msg = &s
  5795. }
  5796. // Msg returns the value of the "msg" field in the mutation.
  5797. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5798. v := m.msg
  5799. if v == nil {
  5800. return
  5801. }
  5802. return *v, true
  5803. }
  5804. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5805. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5807. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5808. if !m.op.Is(OpUpdateOne) {
  5809. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5810. }
  5811. if m.id == nil || m.oldValue == nil {
  5812. return v, errors.New("OldMsg requires an ID field in the mutation")
  5813. }
  5814. oldValue, err := m.oldValue(ctx)
  5815. if err != nil {
  5816. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5817. }
  5818. return oldValue.Msg, nil
  5819. }
  5820. // ClearMsg clears the value of the "msg" field.
  5821. func (m *BatchMsgMutation) ClearMsg() {
  5822. m.msg = nil
  5823. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5824. }
  5825. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5826. func (m *BatchMsgMutation) MsgCleared() bool {
  5827. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5828. return ok
  5829. }
  5830. // ResetMsg resets all changes to the "msg" field.
  5831. func (m *BatchMsgMutation) ResetMsg() {
  5832. m.msg = nil
  5833. delete(m.clearedFields, batchmsg.FieldMsg)
  5834. }
  5835. // SetTag sets the "tag" field.
  5836. func (m *BatchMsgMutation) SetTag(s string) {
  5837. m.tag = &s
  5838. }
  5839. // Tag returns the value of the "tag" field in the mutation.
  5840. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5841. v := m.tag
  5842. if v == nil {
  5843. return
  5844. }
  5845. return *v, true
  5846. }
  5847. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5848. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5850. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5851. if !m.op.Is(OpUpdateOne) {
  5852. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5853. }
  5854. if m.id == nil || m.oldValue == nil {
  5855. return v, errors.New("OldTag requires an ID field in the mutation")
  5856. }
  5857. oldValue, err := m.oldValue(ctx)
  5858. if err != nil {
  5859. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5860. }
  5861. return oldValue.Tag, nil
  5862. }
  5863. // ClearTag clears the value of the "tag" field.
  5864. func (m *BatchMsgMutation) ClearTag() {
  5865. m.tag = nil
  5866. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5867. }
  5868. // TagCleared returns if the "tag" field was cleared in this mutation.
  5869. func (m *BatchMsgMutation) TagCleared() bool {
  5870. _, ok := m.clearedFields[batchmsg.FieldTag]
  5871. return ok
  5872. }
  5873. // ResetTag resets all changes to the "tag" field.
  5874. func (m *BatchMsgMutation) ResetTag() {
  5875. m.tag = nil
  5876. delete(m.clearedFields, batchmsg.FieldTag)
  5877. }
  5878. // SetTagids sets the "tagids" field.
  5879. func (m *BatchMsgMutation) SetTagids(s string) {
  5880. m.tagids = &s
  5881. }
  5882. // Tagids returns the value of the "tagids" field in the mutation.
  5883. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5884. v := m.tagids
  5885. if v == nil {
  5886. return
  5887. }
  5888. return *v, true
  5889. }
  5890. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5891. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5893. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5894. if !m.op.Is(OpUpdateOne) {
  5895. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5896. }
  5897. if m.id == nil || m.oldValue == nil {
  5898. return v, errors.New("OldTagids requires an ID field in the mutation")
  5899. }
  5900. oldValue, err := m.oldValue(ctx)
  5901. if err != nil {
  5902. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5903. }
  5904. return oldValue.Tagids, nil
  5905. }
  5906. // ClearTagids clears the value of the "tagids" field.
  5907. func (m *BatchMsgMutation) ClearTagids() {
  5908. m.tagids = nil
  5909. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5910. }
  5911. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5912. func (m *BatchMsgMutation) TagidsCleared() bool {
  5913. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5914. return ok
  5915. }
  5916. // ResetTagids resets all changes to the "tagids" field.
  5917. func (m *BatchMsgMutation) ResetTagids() {
  5918. m.tagids = nil
  5919. delete(m.clearedFields, batchmsg.FieldTagids)
  5920. }
  5921. // SetTotal sets the "total" field.
  5922. func (m *BatchMsgMutation) SetTotal(i int32) {
  5923. m.total = &i
  5924. m.addtotal = nil
  5925. }
  5926. // Total returns the value of the "total" field in the mutation.
  5927. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5928. v := m.total
  5929. if v == nil {
  5930. return
  5931. }
  5932. return *v, true
  5933. }
  5934. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5935. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5937. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5938. if !m.op.Is(OpUpdateOne) {
  5939. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5940. }
  5941. if m.id == nil || m.oldValue == nil {
  5942. return v, errors.New("OldTotal requires an ID field in the mutation")
  5943. }
  5944. oldValue, err := m.oldValue(ctx)
  5945. if err != nil {
  5946. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5947. }
  5948. return oldValue.Total, nil
  5949. }
  5950. // AddTotal adds i to the "total" field.
  5951. func (m *BatchMsgMutation) AddTotal(i int32) {
  5952. if m.addtotal != nil {
  5953. *m.addtotal += i
  5954. } else {
  5955. m.addtotal = &i
  5956. }
  5957. }
  5958. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5959. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5960. v := m.addtotal
  5961. if v == nil {
  5962. return
  5963. }
  5964. return *v, true
  5965. }
  5966. // ClearTotal clears the value of the "total" field.
  5967. func (m *BatchMsgMutation) ClearTotal() {
  5968. m.total = nil
  5969. m.addtotal = nil
  5970. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5971. }
  5972. // TotalCleared returns if the "total" field was cleared in this mutation.
  5973. func (m *BatchMsgMutation) TotalCleared() bool {
  5974. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5975. return ok
  5976. }
  5977. // ResetTotal resets all changes to the "total" field.
  5978. func (m *BatchMsgMutation) ResetTotal() {
  5979. m.total = nil
  5980. m.addtotal = nil
  5981. delete(m.clearedFields, batchmsg.FieldTotal)
  5982. }
  5983. // SetSuccess sets the "success" field.
  5984. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5985. m.success = &i
  5986. m.addsuccess = nil
  5987. }
  5988. // Success returns the value of the "success" field in the mutation.
  5989. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5990. v := m.success
  5991. if v == nil {
  5992. return
  5993. }
  5994. return *v, true
  5995. }
  5996. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5997. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5999. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6000. if !m.op.Is(OpUpdateOne) {
  6001. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6002. }
  6003. if m.id == nil || m.oldValue == nil {
  6004. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6005. }
  6006. oldValue, err := m.oldValue(ctx)
  6007. if err != nil {
  6008. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6009. }
  6010. return oldValue.Success, nil
  6011. }
  6012. // AddSuccess adds i to the "success" field.
  6013. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6014. if m.addsuccess != nil {
  6015. *m.addsuccess += i
  6016. } else {
  6017. m.addsuccess = &i
  6018. }
  6019. }
  6020. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6021. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6022. v := m.addsuccess
  6023. if v == nil {
  6024. return
  6025. }
  6026. return *v, true
  6027. }
  6028. // ClearSuccess clears the value of the "success" field.
  6029. func (m *BatchMsgMutation) ClearSuccess() {
  6030. m.success = nil
  6031. m.addsuccess = nil
  6032. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6033. }
  6034. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6035. func (m *BatchMsgMutation) SuccessCleared() bool {
  6036. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6037. return ok
  6038. }
  6039. // ResetSuccess resets all changes to the "success" field.
  6040. func (m *BatchMsgMutation) ResetSuccess() {
  6041. m.success = nil
  6042. m.addsuccess = nil
  6043. delete(m.clearedFields, batchmsg.FieldSuccess)
  6044. }
  6045. // SetFail sets the "fail" field.
  6046. func (m *BatchMsgMutation) SetFail(i int32) {
  6047. m.fail = &i
  6048. m.addfail = nil
  6049. }
  6050. // Fail returns the value of the "fail" field in the mutation.
  6051. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6052. v := m.fail
  6053. if v == nil {
  6054. return
  6055. }
  6056. return *v, true
  6057. }
  6058. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6059. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6061. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6062. if !m.op.Is(OpUpdateOne) {
  6063. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6064. }
  6065. if m.id == nil || m.oldValue == nil {
  6066. return v, errors.New("OldFail requires an ID field in the mutation")
  6067. }
  6068. oldValue, err := m.oldValue(ctx)
  6069. if err != nil {
  6070. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6071. }
  6072. return oldValue.Fail, nil
  6073. }
  6074. // AddFail adds i to the "fail" field.
  6075. func (m *BatchMsgMutation) AddFail(i int32) {
  6076. if m.addfail != nil {
  6077. *m.addfail += i
  6078. } else {
  6079. m.addfail = &i
  6080. }
  6081. }
  6082. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6083. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6084. v := m.addfail
  6085. if v == nil {
  6086. return
  6087. }
  6088. return *v, true
  6089. }
  6090. // ClearFail clears the value of the "fail" field.
  6091. func (m *BatchMsgMutation) ClearFail() {
  6092. m.fail = nil
  6093. m.addfail = nil
  6094. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6095. }
  6096. // FailCleared returns if the "fail" field was cleared in this mutation.
  6097. func (m *BatchMsgMutation) FailCleared() bool {
  6098. _, ok := m.clearedFields[batchmsg.FieldFail]
  6099. return ok
  6100. }
  6101. // ResetFail resets all changes to the "fail" field.
  6102. func (m *BatchMsgMutation) ResetFail() {
  6103. m.fail = nil
  6104. m.addfail = nil
  6105. delete(m.clearedFields, batchmsg.FieldFail)
  6106. }
  6107. // SetStartTime sets the "start_time" field.
  6108. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6109. m.start_time = &t
  6110. }
  6111. // StartTime returns the value of the "start_time" field in the mutation.
  6112. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6113. v := m.start_time
  6114. if v == nil {
  6115. return
  6116. }
  6117. return *v, true
  6118. }
  6119. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6120. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6122. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6123. if !m.op.Is(OpUpdateOne) {
  6124. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6125. }
  6126. if m.id == nil || m.oldValue == nil {
  6127. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6128. }
  6129. oldValue, err := m.oldValue(ctx)
  6130. if err != nil {
  6131. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6132. }
  6133. return oldValue.StartTime, nil
  6134. }
  6135. // ClearStartTime clears the value of the "start_time" field.
  6136. func (m *BatchMsgMutation) ClearStartTime() {
  6137. m.start_time = nil
  6138. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6139. }
  6140. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6141. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6142. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6143. return ok
  6144. }
  6145. // ResetStartTime resets all changes to the "start_time" field.
  6146. func (m *BatchMsgMutation) ResetStartTime() {
  6147. m.start_time = nil
  6148. delete(m.clearedFields, batchmsg.FieldStartTime)
  6149. }
  6150. // SetStopTime sets the "stop_time" field.
  6151. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6152. m.stop_time = &t
  6153. }
  6154. // StopTime returns the value of the "stop_time" field in the mutation.
  6155. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6156. v := m.stop_time
  6157. if v == nil {
  6158. return
  6159. }
  6160. return *v, true
  6161. }
  6162. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6163. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6165. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6166. if !m.op.Is(OpUpdateOne) {
  6167. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6168. }
  6169. if m.id == nil || m.oldValue == nil {
  6170. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6171. }
  6172. oldValue, err := m.oldValue(ctx)
  6173. if err != nil {
  6174. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6175. }
  6176. return oldValue.StopTime, nil
  6177. }
  6178. // ClearStopTime clears the value of the "stop_time" field.
  6179. func (m *BatchMsgMutation) ClearStopTime() {
  6180. m.stop_time = nil
  6181. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6182. }
  6183. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6184. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6185. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6186. return ok
  6187. }
  6188. // ResetStopTime resets all changes to the "stop_time" field.
  6189. func (m *BatchMsgMutation) ResetStopTime() {
  6190. m.stop_time = nil
  6191. delete(m.clearedFields, batchmsg.FieldStopTime)
  6192. }
  6193. // SetSendTime sets the "send_time" field.
  6194. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6195. m.send_time = &t
  6196. }
  6197. // SendTime returns the value of the "send_time" field in the mutation.
  6198. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6199. v := m.send_time
  6200. if v == nil {
  6201. return
  6202. }
  6203. return *v, true
  6204. }
  6205. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6206. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6208. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6209. if !m.op.Is(OpUpdateOne) {
  6210. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6211. }
  6212. if m.id == nil || m.oldValue == nil {
  6213. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6214. }
  6215. oldValue, err := m.oldValue(ctx)
  6216. if err != nil {
  6217. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6218. }
  6219. return oldValue.SendTime, nil
  6220. }
  6221. // ClearSendTime clears the value of the "send_time" field.
  6222. func (m *BatchMsgMutation) ClearSendTime() {
  6223. m.send_time = nil
  6224. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6225. }
  6226. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6227. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6228. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6229. return ok
  6230. }
  6231. // ResetSendTime resets all changes to the "send_time" field.
  6232. func (m *BatchMsgMutation) ResetSendTime() {
  6233. m.send_time = nil
  6234. delete(m.clearedFields, batchmsg.FieldSendTime)
  6235. }
  6236. // SetType sets the "type" field.
  6237. func (m *BatchMsgMutation) SetType(i int32) {
  6238. m._type = &i
  6239. m.add_type = nil
  6240. }
  6241. // GetType returns the value of the "type" field in the mutation.
  6242. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6243. v := m._type
  6244. if v == nil {
  6245. return
  6246. }
  6247. return *v, true
  6248. }
  6249. // OldType returns the old "type" field's value of the BatchMsg entity.
  6250. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6252. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6253. if !m.op.Is(OpUpdateOne) {
  6254. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6255. }
  6256. if m.id == nil || m.oldValue == nil {
  6257. return v, errors.New("OldType requires an ID field in the mutation")
  6258. }
  6259. oldValue, err := m.oldValue(ctx)
  6260. if err != nil {
  6261. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6262. }
  6263. return oldValue.Type, nil
  6264. }
  6265. // AddType adds i to the "type" field.
  6266. func (m *BatchMsgMutation) AddType(i int32) {
  6267. if m.add_type != nil {
  6268. *m.add_type += i
  6269. } else {
  6270. m.add_type = &i
  6271. }
  6272. }
  6273. // AddedType returns the value that was added to the "type" field in this mutation.
  6274. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6275. v := m.add_type
  6276. if v == nil {
  6277. return
  6278. }
  6279. return *v, true
  6280. }
  6281. // ClearType clears the value of the "type" field.
  6282. func (m *BatchMsgMutation) ClearType() {
  6283. m._type = nil
  6284. m.add_type = nil
  6285. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6286. }
  6287. // TypeCleared returns if the "type" field was cleared in this mutation.
  6288. func (m *BatchMsgMutation) TypeCleared() bool {
  6289. _, ok := m.clearedFields[batchmsg.FieldType]
  6290. return ok
  6291. }
  6292. // ResetType resets all changes to the "type" field.
  6293. func (m *BatchMsgMutation) ResetType() {
  6294. m._type = nil
  6295. m.add_type = nil
  6296. delete(m.clearedFields, batchmsg.FieldType)
  6297. }
  6298. // SetOrganizationID sets the "organization_id" field.
  6299. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6300. m.organization_id = &u
  6301. m.addorganization_id = nil
  6302. }
  6303. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6304. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6305. v := m.organization_id
  6306. if v == nil {
  6307. return
  6308. }
  6309. return *v, true
  6310. }
  6311. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6314. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6315. if !m.op.Is(OpUpdateOne) {
  6316. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6317. }
  6318. if m.id == nil || m.oldValue == nil {
  6319. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6320. }
  6321. oldValue, err := m.oldValue(ctx)
  6322. if err != nil {
  6323. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6324. }
  6325. return oldValue.OrganizationID, nil
  6326. }
  6327. // AddOrganizationID adds u to the "organization_id" field.
  6328. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6329. if m.addorganization_id != nil {
  6330. *m.addorganization_id += u
  6331. } else {
  6332. m.addorganization_id = &u
  6333. }
  6334. }
  6335. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6336. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6337. v := m.addorganization_id
  6338. if v == nil {
  6339. return
  6340. }
  6341. return *v, true
  6342. }
  6343. // ResetOrganizationID resets all changes to the "organization_id" field.
  6344. func (m *BatchMsgMutation) ResetOrganizationID() {
  6345. m.organization_id = nil
  6346. m.addorganization_id = nil
  6347. }
  6348. // SetCtype sets the "ctype" field.
  6349. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6350. m.ctype = &u
  6351. m.addctype = nil
  6352. }
  6353. // Ctype returns the value of the "ctype" field in the mutation.
  6354. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6355. v := m.ctype
  6356. if v == nil {
  6357. return
  6358. }
  6359. return *v, true
  6360. }
  6361. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6362. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6364. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6365. if !m.op.Is(OpUpdateOne) {
  6366. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6367. }
  6368. if m.id == nil || m.oldValue == nil {
  6369. return v, errors.New("OldCtype requires an ID field in the mutation")
  6370. }
  6371. oldValue, err := m.oldValue(ctx)
  6372. if err != nil {
  6373. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6374. }
  6375. return oldValue.Ctype, nil
  6376. }
  6377. // AddCtype adds u to the "ctype" field.
  6378. func (m *BatchMsgMutation) AddCtype(u int64) {
  6379. if m.addctype != nil {
  6380. *m.addctype += u
  6381. } else {
  6382. m.addctype = &u
  6383. }
  6384. }
  6385. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6386. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6387. v := m.addctype
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // ResetCtype resets all changes to the "ctype" field.
  6394. func (m *BatchMsgMutation) ResetCtype() {
  6395. m.ctype = nil
  6396. m.addctype = nil
  6397. }
  6398. // SetCc sets the "cc" field.
  6399. func (m *BatchMsgMutation) SetCc(s string) {
  6400. m.cc = &s
  6401. }
  6402. // Cc returns the value of the "cc" field in the mutation.
  6403. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6404. v := m.cc
  6405. if v == nil {
  6406. return
  6407. }
  6408. return *v, true
  6409. }
  6410. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6411. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6413. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6414. if !m.op.Is(OpUpdateOne) {
  6415. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6416. }
  6417. if m.id == nil || m.oldValue == nil {
  6418. return v, errors.New("OldCc requires an ID field in the mutation")
  6419. }
  6420. oldValue, err := m.oldValue(ctx)
  6421. if err != nil {
  6422. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6423. }
  6424. return oldValue.Cc, nil
  6425. }
  6426. // ClearCc clears the value of the "cc" field.
  6427. func (m *BatchMsgMutation) ClearCc() {
  6428. m.cc = nil
  6429. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6430. }
  6431. // CcCleared returns if the "cc" field was cleared in this mutation.
  6432. func (m *BatchMsgMutation) CcCleared() bool {
  6433. _, ok := m.clearedFields[batchmsg.FieldCc]
  6434. return ok
  6435. }
  6436. // ResetCc resets all changes to the "cc" field.
  6437. func (m *BatchMsgMutation) ResetCc() {
  6438. m.cc = nil
  6439. delete(m.clearedFields, batchmsg.FieldCc)
  6440. }
  6441. // SetPhone sets the "phone" field.
  6442. func (m *BatchMsgMutation) SetPhone(s string) {
  6443. m.phone = &s
  6444. }
  6445. // Phone returns the value of the "phone" field in the mutation.
  6446. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6447. v := m.phone
  6448. if v == nil {
  6449. return
  6450. }
  6451. return *v, true
  6452. }
  6453. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6454. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6456. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6457. if !m.op.Is(OpUpdateOne) {
  6458. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6459. }
  6460. if m.id == nil || m.oldValue == nil {
  6461. return v, errors.New("OldPhone requires an ID field in the mutation")
  6462. }
  6463. oldValue, err := m.oldValue(ctx)
  6464. if err != nil {
  6465. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6466. }
  6467. return oldValue.Phone, nil
  6468. }
  6469. // ClearPhone clears the value of the "phone" field.
  6470. func (m *BatchMsgMutation) ClearPhone() {
  6471. m.phone = nil
  6472. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6473. }
  6474. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6475. func (m *BatchMsgMutation) PhoneCleared() bool {
  6476. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6477. return ok
  6478. }
  6479. // ResetPhone resets all changes to the "phone" field.
  6480. func (m *BatchMsgMutation) ResetPhone() {
  6481. m.phone = nil
  6482. delete(m.clearedFields, batchmsg.FieldPhone)
  6483. }
  6484. // SetTemplateName sets the "template_name" field.
  6485. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6486. m.template_name = &s
  6487. }
  6488. // TemplateName returns the value of the "template_name" field in the mutation.
  6489. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6490. v := m.template_name
  6491. if v == nil {
  6492. return
  6493. }
  6494. return *v, true
  6495. }
  6496. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6497. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6499. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6500. if !m.op.Is(OpUpdateOne) {
  6501. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6502. }
  6503. if m.id == nil || m.oldValue == nil {
  6504. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6505. }
  6506. oldValue, err := m.oldValue(ctx)
  6507. if err != nil {
  6508. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6509. }
  6510. return oldValue.TemplateName, nil
  6511. }
  6512. // ClearTemplateName clears the value of the "template_name" field.
  6513. func (m *BatchMsgMutation) ClearTemplateName() {
  6514. m.template_name = nil
  6515. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6516. }
  6517. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6518. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6519. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6520. return ok
  6521. }
  6522. // ResetTemplateName resets all changes to the "template_name" field.
  6523. func (m *BatchMsgMutation) ResetTemplateName() {
  6524. m.template_name = nil
  6525. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6526. }
  6527. // SetTemplateCode sets the "template_code" field.
  6528. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6529. m.template_code = &s
  6530. }
  6531. // TemplateCode returns the value of the "template_code" field in the mutation.
  6532. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6533. v := m.template_code
  6534. if v == nil {
  6535. return
  6536. }
  6537. return *v, true
  6538. }
  6539. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6540. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6542. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6543. if !m.op.Is(OpUpdateOne) {
  6544. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6545. }
  6546. if m.id == nil || m.oldValue == nil {
  6547. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6548. }
  6549. oldValue, err := m.oldValue(ctx)
  6550. if err != nil {
  6551. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6552. }
  6553. return oldValue.TemplateCode, nil
  6554. }
  6555. // ClearTemplateCode clears the value of the "template_code" field.
  6556. func (m *BatchMsgMutation) ClearTemplateCode() {
  6557. m.template_code = nil
  6558. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6559. }
  6560. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6561. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6562. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6563. return ok
  6564. }
  6565. // ResetTemplateCode resets all changes to the "template_code" field.
  6566. func (m *BatchMsgMutation) ResetTemplateCode() {
  6567. m.template_code = nil
  6568. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6569. }
  6570. // SetLang sets the "lang" field.
  6571. func (m *BatchMsgMutation) SetLang(s string) {
  6572. m.lang = &s
  6573. }
  6574. // Lang returns the value of the "lang" field in the mutation.
  6575. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6576. v := m.lang
  6577. if v == nil {
  6578. return
  6579. }
  6580. return *v, true
  6581. }
  6582. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6583. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6585. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6586. if !m.op.Is(OpUpdateOne) {
  6587. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6588. }
  6589. if m.id == nil || m.oldValue == nil {
  6590. return v, errors.New("OldLang requires an ID field in the mutation")
  6591. }
  6592. oldValue, err := m.oldValue(ctx)
  6593. if err != nil {
  6594. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6595. }
  6596. return oldValue.Lang, nil
  6597. }
  6598. // ClearLang clears the value of the "lang" field.
  6599. func (m *BatchMsgMutation) ClearLang() {
  6600. m.lang = nil
  6601. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6602. }
  6603. // LangCleared returns if the "lang" field was cleared in this mutation.
  6604. func (m *BatchMsgMutation) LangCleared() bool {
  6605. _, ok := m.clearedFields[batchmsg.FieldLang]
  6606. return ok
  6607. }
  6608. // ResetLang resets all changes to the "lang" field.
  6609. func (m *BatchMsgMutation) ResetLang() {
  6610. m.lang = nil
  6611. delete(m.clearedFields, batchmsg.FieldLang)
  6612. }
  6613. // Where appends a list predicates to the BatchMsgMutation builder.
  6614. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6615. m.predicates = append(m.predicates, ps...)
  6616. }
  6617. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6618. // users can use type-assertion to append predicates that do not depend on any generated package.
  6619. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6620. p := make([]predicate.BatchMsg, len(ps))
  6621. for i := range ps {
  6622. p[i] = ps[i]
  6623. }
  6624. m.Where(p...)
  6625. }
  6626. // Op returns the operation name.
  6627. func (m *BatchMsgMutation) Op() Op {
  6628. return m.op
  6629. }
  6630. // SetOp allows setting the mutation operation.
  6631. func (m *BatchMsgMutation) SetOp(op Op) {
  6632. m.op = op
  6633. }
  6634. // Type returns the node type of this mutation (BatchMsg).
  6635. func (m *BatchMsgMutation) Type() string {
  6636. return m.typ
  6637. }
  6638. // Fields returns all fields that were changed during this mutation. Note that in
  6639. // order to get all numeric fields that were incremented/decremented, call
  6640. // AddedFields().
  6641. func (m *BatchMsgMutation) Fields() []string {
  6642. fields := make([]string, 0, 24)
  6643. if m.created_at != nil {
  6644. fields = append(fields, batchmsg.FieldCreatedAt)
  6645. }
  6646. if m.updated_at != nil {
  6647. fields = append(fields, batchmsg.FieldUpdatedAt)
  6648. }
  6649. if m.deleted_at != nil {
  6650. fields = append(fields, batchmsg.FieldDeletedAt)
  6651. }
  6652. if m.status != nil {
  6653. fields = append(fields, batchmsg.FieldStatus)
  6654. }
  6655. if m.batch_no != nil {
  6656. fields = append(fields, batchmsg.FieldBatchNo)
  6657. }
  6658. if m.task_name != nil {
  6659. fields = append(fields, batchmsg.FieldTaskName)
  6660. }
  6661. if m.fromwxid != nil {
  6662. fields = append(fields, batchmsg.FieldFromwxid)
  6663. }
  6664. if m.msg != nil {
  6665. fields = append(fields, batchmsg.FieldMsg)
  6666. }
  6667. if m.tag != nil {
  6668. fields = append(fields, batchmsg.FieldTag)
  6669. }
  6670. if m.tagids != nil {
  6671. fields = append(fields, batchmsg.FieldTagids)
  6672. }
  6673. if m.total != nil {
  6674. fields = append(fields, batchmsg.FieldTotal)
  6675. }
  6676. if m.success != nil {
  6677. fields = append(fields, batchmsg.FieldSuccess)
  6678. }
  6679. if m.fail != nil {
  6680. fields = append(fields, batchmsg.FieldFail)
  6681. }
  6682. if m.start_time != nil {
  6683. fields = append(fields, batchmsg.FieldStartTime)
  6684. }
  6685. if m.stop_time != nil {
  6686. fields = append(fields, batchmsg.FieldStopTime)
  6687. }
  6688. if m.send_time != nil {
  6689. fields = append(fields, batchmsg.FieldSendTime)
  6690. }
  6691. if m._type != nil {
  6692. fields = append(fields, batchmsg.FieldType)
  6693. }
  6694. if m.organization_id != nil {
  6695. fields = append(fields, batchmsg.FieldOrganizationID)
  6696. }
  6697. if m.ctype != nil {
  6698. fields = append(fields, batchmsg.FieldCtype)
  6699. }
  6700. if m.cc != nil {
  6701. fields = append(fields, batchmsg.FieldCc)
  6702. }
  6703. if m.phone != nil {
  6704. fields = append(fields, batchmsg.FieldPhone)
  6705. }
  6706. if m.template_name != nil {
  6707. fields = append(fields, batchmsg.FieldTemplateName)
  6708. }
  6709. if m.template_code != nil {
  6710. fields = append(fields, batchmsg.FieldTemplateCode)
  6711. }
  6712. if m.lang != nil {
  6713. fields = append(fields, batchmsg.FieldLang)
  6714. }
  6715. return fields
  6716. }
  6717. // Field returns the value of a field with the given name. The second boolean
  6718. // return value indicates that this field was not set, or was not defined in the
  6719. // schema.
  6720. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6721. switch name {
  6722. case batchmsg.FieldCreatedAt:
  6723. return m.CreatedAt()
  6724. case batchmsg.FieldUpdatedAt:
  6725. return m.UpdatedAt()
  6726. case batchmsg.FieldDeletedAt:
  6727. return m.DeletedAt()
  6728. case batchmsg.FieldStatus:
  6729. return m.Status()
  6730. case batchmsg.FieldBatchNo:
  6731. return m.BatchNo()
  6732. case batchmsg.FieldTaskName:
  6733. return m.TaskName()
  6734. case batchmsg.FieldFromwxid:
  6735. return m.Fromwxid()
  6736. case batchmsg.FieldMsg:
  6737. return m.Msg()
  6738. case batchmsg.FieldTag:
  6739. return m.Tag()
  6740. case batchmsg.FieldTagids:
  6741. return m.Tagids()
  6742. case batchmsg.FieldTotal:
  6743. return m.Total()
  6744. case batchmsg.FieldSuccess:
  6745. return m.Success()
  6746. case batchmsg.FieldFail:
  6747. return m.Fail()
  6748. case batchmsg.FieldStartTime:
  6749. return m.StartTime()
  6750. case batchmsg.FieldStopTime:
  6751. return m.StopTime()
  6752. case batchmsg.FieldSendTime:
  6753. return m.SendTime()
  6754. case batchmsg.FieldType:
  6755. return m.GetType()
  6756. case batchmsg.FieldOrganizationID:
  6757. return m.OrganizationID()
  6758. case batchmsg.FieldCtype:
  6759. return m.Ctype()
  6760. case batchmsg.FieldCc:
  6761. return m.Cc()
  6762. case batchmsg.FieldPhone:
  6763. return m.Phone()
  6764. case batchmsg.FieldTemplateName:
  6765. return m.TemplateName()
  6766. case batchmsg.FieldTemplateCode:
  6767. return m.TemplateCode()
  6768. case batchmsg.FieldLang:
  6769. return m.Lang()
  6770. }
  6771. return nil, false
  6772. }
  6773. // OldField returns the old value of the field from the database. An error is
  6774. // returned if the mutation operation is not UpdateOne, or the query to the
  6775. // database failed.
  6776. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6777. switch name {
  6778. case batchmsg.FieldCreatedAt:
  6779. return m.OldCreatedAt(ctx)
  6780. case batchmsg.FieldUpdatedAt:
  6781. return m.OldUpdatedAt(ctx)
  6782. case batchmsg.FieldDeletedAt:
  6783. return m.OldDeletedAt(ctx)
  6784. case batchmsg.FieldStatus:
  6785. return m.OldStatus(ctx)
  6786. case batchmsg.FieldBatchNo:
  6787. return m.OldBatchNo(ctx)
  6788. case batchmsg.FieldTaskName:
  6789. return m.OldTaskName(ctx)
  6790. case batchmsg.FieldFromwxid:
  6791. return m.OldFromwxid(ctx)
  6792. case batchmsg.FieldMsg:
  6793. return m.OldMsg(ctx)
  6794. case batchmsg.FieldTag:
  6795. return m.OldTag(ctx)
  6796. case batchmsg.FieldTagids:
  6797. return m.OldTagids(ctx)
  6798. case batchmsg.FieldTotal:
  6799. return m.OldTotal(ctx)
  6800. case batchmsg.FieldSuccess:
  6801. return m.OldSuccess(ctx)
  6802. case batchmsg.FieldFail:
  6803. return m.OldFail(ctx)
  6804. case batchmsg.FieldStartTime:
  6805. return m.OldStartTime(ctx)
  6806. case batchmsg.FieldStopTime:
  6807. return m.OldStopTime(ctx)
  6808. case batchmsg.FieldSendTime:
  6809. return m.OldSendTime(ctx)
  6810. case batchmsg.FieldType:
  6811. return m.OldType(ctx)
  6812. case batchmsg.FieldOrganizationID:
  6813. return m.OldOrganizationID(ctx)
  6814. case batchmsg.FieldCtype:
  6815. return m.OldCtype(ctx)
  6816. case batchmsg.FieldCc:
  6817. return m.OldCc(ctx)
  6818. case batchmsg.FieldPhone:
  6819. return m.OldPhone(ctx)
  6820. case batchmsg.FieldTemplateName:
  6821. return m.OldTemplateName(ctx)
  6822. case batchmsg.FieldTemplateCode:
  6823. return m.OldTemplateCode(ctx)
  6824. case batchmsg.FieldLang:
  6825. return m.OldLang(ctx)
  6826. }
  6827. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6828. }
  6829. // SetField sets the value of a field with the given name. It returns an error if
  6830. // the field is not defined in the schema, or if the type mismatched the field
  6831. // type.
  6832. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6833. switch name {
  6834. case batchmsg.FieldCreatedAt:
  6835. v, ok := value.(time.Time)
  6836. if !ok {
  6837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6838. }
  6839. m.SetCreatedAt(v)
  6840. return nil
  6841. case batchmsg.FieldUpdatedAt:
  6842. v, ok := value.(time.Time)
  6843. if !ok {
  6844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6845. }
  6846. m.SetUpdatedAt(v)
  6847. return nil
  6848. case batchmsg.FieldDeletedAt:
  6849. v, ok := value.(time.Time)
  6850. if !ok {
  6851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6852. }
  6853. m.SetDeletedAt(v)
  6854. return nil
  6855. case batchmsg.FieldStatus:
  6856. v, ok := value.(uint8)
  6857. if !ok {
  6858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6859. }
  6860. m.SetStatus(v)
  6861. return nil
  6862. case batchmsg.FieldBatchNo:
  6863. v, ok := value.(string)
  6864. if !ok {
  6865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6866. }
  6867. m.SetBatchNo(v)
  6868. return nil
  6869. case batchmsg.FieldTaskName:
  6870. v, ok := value.(string)
  6871. if !ok {
  6872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6873. }
  6874. m.SetTaskName(v)
  6875. return nil
  6876. case batchmsg.FieldFromwxid:
  6877. v, ok := value.(string)
  6878. if !ok {
  6879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6880. }
  6881. m.SetFromwxid(v)
  6882. return nil
  6883. case batchmsg.FieldMsg:
  6884. v, ok := value.(string)
  6885. if !ok {
  6886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6887. }
  6888. m.SetMsg(v)
  6889. return nil
  6890. case batchmsg.FieldTag:
  6891. v, ok := value.(string)
  6892. if !ok {
  6893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6894. }
  6895. m.SetTag(v)
  6896. return nil
  6897. case batchmsg.FieldTagids:
  6898. v, ok := value.(string)
  6899. if !ok {
  6900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6901. }
  6902. m.SetTagids(v)
  6903. return nil
  6904. case batchmsg.FieldTotal:
  6905. v, ok := value.(int32)
  6906. if !ok {
  6907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6908. }
  6909. m.SetTotal(v)
  6910. return nil
  6911. case batchmsg.FieldSuccess:
  6912. v, ok := value.(int32)
  6913. if !ok {
  6914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6915. }
  6916. m.SetSuccess(v)
  6917. return nil
  6918. case batchmsg.FieldFail:
  6919. v, ok := value.(int32)
  6920. if !ok {
  6921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6922. }
  6923. m.SetFail(v)
  6924. return nil
  6925. case batchmsg.FieldStartTime:
  6926. v, ok := value.(time.Time)
  6927. if !ok {
  6928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6929. }
  6930. m.SetStartTime(v)
  6931. return nil
  6932. case batchmsg.FieldStopTime:
  6933. v, ok := value.(time.Time)
  6934. if !ok {
  6935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6936. }
  6937. m.SetStopTime(v)
  6938. return nil
  6939. case batchmsg.FieldSendTime:
  6940. v, ok := value.(time.Time)
  6941. if !ok {
  6942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6943. }
  6944. m.SetSendTime(v)
  6945. return nil
  6946. case batchmsg.FieldType:
  6947. v, ok := value.(int32)
  6948. if !ok {
  6949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6950. }
  6951. m.SetType(v)
  6952. return nil
  6953. case batchmsg.FieldOrganizationID:
  6954. v, ok := value.(uint64)
  6955. if !ok {
  6956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6957. }
  6958. m.SetOrganizationID(v)
  6959. return nil
  6960. case batchmsg.FieldCtype:
  6961. v, ok := value.(uint64)
  6962. if !ok {
  6963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6964. }
  6965. m.SetCtype(v)
  6966. return nil
  6967. case batchmsg.FieldCc:
  6968. v, ok := value.(string)
  6969. if !ok {
  6970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6971. }
  6972. m.SetCc(v)
  6973. return nil
  6974. case batchmsg.FieldPhone:
  6975. v, ok := value.(string)
  6976. if !ok {
  6977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6978. }
  6979. m.SetPhone(v)
  6980. return nil
  6981. case batchmsg.FieldTemplateName:
  6982. v, ok := value.(string)
  6983. if !ok {
  6984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6985. }
  6986. m.SetTemplateName(v)
  6987. return nil
  6988. case batchmsg.FieldTemplateCode:
  6989. v, ok := value.(string)
  6990. if !ok {
  6991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6992. }
  6993. m.SetTemplateCode(v)
  6994. return nil
  6995. case batchmsg.FieldLang:
  6996. v, ok := value.(string)
  6997. if !ok {
  6998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6999. }
  7000. m.SetLang(v)
  7001. return nil
  7002. }
  7003. return fmt.Errorf("unknown BatchMsg field %s", name)
  7004. }
  7005. // AddedFields returns all numeric fields that were incremented/decremented during
  7006. // this mutation.
  7007. func (m *BatchMsgMutation) AddedFields() []string {
  7008. var fields []string
  7009. if m.addstatus != nil {
  7010. fields = append(fields, batchmsg.FieldStatus)
  7011. }
  7012. if m.addtotal != nil {
  7013. fields = append(fields, batchmsg.FieldTotal)
  7014. }
  7015. if m.addsuccess != nil {
  7016. fields = append(fields, batchmsg.FieldSuccess)
  7017. }
  7018. if m.addfail != nil {
  7019. fields = append(fields, batchmsg.FieldFail)
  7020. }
  7021. if m.add_type != nil {
  7022. fields = append(fields, batchmsg.FieldType)
  7023. }
  7024. if m.addorganization_id != nil {
  7025. fields = append(fields, batchmsg.FieldOrganizationID)
  7026. }
  7027. if m.addctype != nil {
  7028. fields = append(fields, batchmsg.FieldCtype)
  7029. }
  7030. return fields
  7031. }
  7032. // AddedField returns the numeric value that was incremented/decremented on a field
  7033. // with the given name. The second boolean return value indicates that this field
  7034. // was not set, or was not defined in the schema.
  7035. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7036. switch name {
  7037. case batchmsg.FieldStatus:
  7038. return m.AddedStatus()
  7039. case batchmsg.FieldTotal:
  7040. return m.AddedTotal()
  7041. case batchmsg.FieldSuccess:
  7042. return m.AddedSuccess()
  7043. case batchmsg.FieldFail:
  7044. return m.AddedFail()
  7045. case batchmsg.FieldType:
  7046. return m.AddedType()
  7047. case batchmsg.FieldOrganizationID:
  7048. return m.AddedOrganizationID()
  7049. case batchmsg.FieldCtype:
  7050. return m.AddedCtype()
  7051. }
  7052. return nil, false
  7053. }
  7054. // AddField adds the value to the field with the given name. It returns an error if
  7055. // the field is not defined in the schema, or if the type mismatched the field
  7056. // type.
  7057. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7058. switch name {
  7059. case batchmsg.FieldStatus:
  7060. v, ok := value.(int8)
  7061. if !ok {
  7062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7063. }
  7064. m.AddStatus(v)
  7065. return nil
  7066. case batchmsg.FieldTotal:
  7067. v, ok := value.(int32)
  7068. if !ok {
  7069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7070. }
  7071. m.AddTotal(v)
  7072. return nil
  7073. case batchmsg.FieldSuccess:
  7074. v, ok := value.(int32)
  7075. if !ok {
  7076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7077. }
  7078. m.AddSuccess(v)
  7079. return nil
  7080. case batchmsg.FieldFail:
  7081. v, ok := value.(int32)
  7082. if !ok {
  7083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7084. }
  7085. m.AddFail(v)
  7086. return nil
  7087. case batchmsg.FieldType:
  7088. v, ok := value.(int32)
  7089. if !ok {
  7090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7091. }
  7092. m.AddType(v)
  7093. return nil
  7094. case batchmsg.FieldOrganizationID:
  7095. v, ok := value.(int64)
  7096. if !ok {
  7097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7098. }
  7099. m.AddOrganizationID(v)
  7100. return nil
  7101. case batchmsg.FieldCtype:
  7102. v, ok := value.(int64)
  7103. if !ok {
  7104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7105. }
  7106. m.AddCtype(v)
  7107. return nil
  7108. }
  7109. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7110. }
  7111. // ClearedFields returns all nullable fields that were cleared during this
  7112. // mutation.
  7113. func (m *BatchMsgMutation) ClearedFields() []string {
  7114. var fields []string
  7115. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7116. fields = append(fields, batchmsg.FieldDeletedAt)
  7117. }
  7118. if m.FieldCleared(batchmsg.FieldStatus) {
  7119. fields = append(fields, batchmsg.FieldStatus)
  7120. }
  7121. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7122. fields = append(fields, batchmsg.FieldBatchNo)
  7123. }
  7124. if m.FieldCleared(batchmsg.FieldTaskName) {
  7125. fields = append(fields, batchmsg.FieldTaskName)
  7126. }
  7127. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7128. fields = append(fields, batchmsg.FieldFromwxid)
  7129. }
  7130. if m.FieldCleared(batchmsg.FieldMsg) {
  7131. fields = append(fields, batchmsg.FieldMsg)
  7132. }
  7133. if m.FieldCleared(batchmsg.FieldTag) {
  7134. fields = append(fields, batchmsg.FieldTag)
  7135. }
  7136. if m.FieldCleared(batchmsg.FieldTagids) {
  7137. fields = append(fields, batchmsg.FieldTagids)
  7138. }
  7139. if m.FieldCleared(batchmsg.FieldTotal) {
  7140. fields = append(fields, batchmsg.FieldTotal)
  7141. }
  7142. if m.FieldCleared(batchmsg.FieldSuccess) {
  7143. fields = append(fields, batchmsg.FieldSuccess)
  7144. }
  7145. if m.FieldCleared(batchmsg.FieldFail) {
  7146. fields = append(fields, batchmsg.FieldFail)
  7147. }
  7148. if m.FieldCleared(batchmsg.FieldStartTime) {
  7149. fields = append(fields, batchmsg.FieldStartTime)
  7150. }
  7151. if m.FieldCleared(batchmsg.FieldStopTime) {
  7152. fields = append(fields, batchmsg.FieldStopTime)
  7153. }
  7154. if m.FieldCleared(batchmsg.FieldSendTime) {
  7155. fields = append(fields, batchmsg.FieldSendTime)
  7156. }
  7157. if m.FieldCleared(batchmsg.FieldType) {
  7158. fields = append(fields, batchmsg.FieldType)
  7159. }
  7160. if m.FieldCleared(batchmsg.FieldCc) {
  7161. fields = append(fields, batchmsg.FieldCc)
  7162. }
  7163. if m.FieldCleared(batchmsg.FieldPhone) {
  7164. fields = append(fields, batchmsg.FieldPhone)
  7165. }
  7166. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7167. fields = append(fields, batchmsg.FieldTemplateName)
  7168. }
  7169. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7170. fields = append(fields, batchmsg.FieldTemplateCode)
  7171. }
  7172. if m.FieldCleared(batchmsg.FieldLang) {
  7173. fields = append(fields, batchmsg.FieldLang)
  7174. }
  7175. return fields
  7176. }
  7177. // FieldCleared returns a boolean indicating if a field with the given name was
  7178. // cleared in this mutation.
  7179. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7180. _, ok := m.clearedFields[name]
  7181. return ok
  7182. }
  7183. // ClearField clears the value of the field with the given name. It returns an
  7184. // error if the field is not defined in the schema.
  7185. func (m *BatchMsgMutation) ClearField(name string) error {
  7186. switch name {
  7187. case batchmsg.FieldDeletedAt:
  7188. m.ClearDeletedAt()
  7189. return nil
  7190. case batchmsg.FieldStatus:
  7191. m.ClearStatus()
  7192. return nil
  7193. case batchmsg.FieldBatchNo:
  7194. m.ClearBatchNo()
  7195. return nil
  7196. case batchmsg.FieldTaskName:
  7197. m.ClearTaskName()
  7198. return nil
  7199. case batchmsg.FieldFromwxid:
  7200. m.ClearFromwxid()
  7201. return nil
  7202. case batchmsg.FieldMsg:
  7203. m.ClearMsg()
  7204. return nil
  7205. case batchmsg.FieldTag:
  7206. m.ClearTag()
  7207. return nil
  7208. case batchmsg.FieldTagids:
  7209. m.ClearTagids()
  7210. return nil
  7211. case batchmsg.FieldTotal:
  7212. m.ClearTotal()
  7213. return nil
  7214. case batchmsg.FieldSuccess:
  7215. m.ClearSuccess()
  7216. return nil
  7217. case batchmsg.FieldFail:
  7218. m.ClearFail()
  7219. return nil
  7220. case batchmsg.FieldStartTime:
  7221. m.ClearStartTime()
  7222. return nil
  7223. case batchmsg.FieldStopTime:
  7224. m.ClearStopTime()
  7225. return nil
  7226. case batchmsg.FieldSendTime:
  7227. m.ClearSendTime()
  7228. return nil
  7229. case batchmsg.FieldType:
  7230. m.ClearType()
  7231. return nil
  7232. case batchmsg.FieldCc:
  7233. m.ClearCc()
  7234. return nil
  7235. case batchmsg.FieldPhone:
  7236. m.ClearPhone()
  7237. return nil
  7238. case batchmsg.FieldTemplateName:
  7239. m.ClearTemplateName()
  7240. return nil
  7241. case batchmsg.FieldTemplateCode:
  7242. m.ClearTemplateCode()
  7243. return nil
  7244. case batchmsg.FieldLang:
  7245. m.ClearLang()
  7246. return nil
  7247. }
  7248. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7249. }
  7250. // ResetField resets all changes in the mutation for the field with the given name.
  7251. // It returns an error if the field is not defined in the schema.
  7252. func (m *BatchMsgMutation) ResetField(name string) error {
  7253. switch name {
  7254. case batchmsg.FieldCreatedAt:
  7255. m.ResetCreatedAt()
  7256. return nil
  7257. case batchmsg.FieldUpdatedAt:
  7258. m.ResetUpdatedAt()
  7259. return nil
  7260. case batchmsg.FieldDeletedAt:
  7261. m.ResetDeletedAt()
  7262. return nil
  7263. case batchmsg.FieldStatus:
  7264. m.ResetStatus()
  7265. return nil
  7266. case batchmsg.FieldBatchNo:
  7267. m.ResetBatchNo()
  7268. return nil
  7269. case batchmsg.FieldTaskName:
  7270. m.ResetTaskName()
  7271. return nil
  7272. case batchmsg.FieldFromwxid:
  7273. m.ResetFromwxid()
  7274. return nil
  7275. case batchmsg.FieldMsg:
  7276. m.ResetMsg()
  7277. return nil
  7278. case batchmsg.FieldTag:
  7279. m.ResetTag()
  7280. return nil
  7281. case batchmsg.FieldTagids:
  7282. m.ResetTagids()
  7283. return nil
  7284. case batchmsg.FieldTotal:
  7285. m.ResetTotal()
  7286. return nil
  7287. case batchmsg.FieldSuccess:
  7288. m.ResetSuccess()
  7289. return nil
  7290. case batchmsg.FieldFail:
  7291. m.ResetFail()
  7292. return nil
  7293. case batchmsg.FieldStartTime:
  7294. m.ResetStartTime()
  7295. return nil
  7296. case batchmsg.FieldStopTime:
  7297. m.ResetStopTime()
  7298. return nil
  7299. case batchmsg.FieldSendTime:
  7300. m.ResetSendTime()
  7301. return nil
  7302. case batchmsg.FieldType:
  7303. m.ResetType()
  7304. return nil
  7305. case batchmsg.FieldOrganizationID:
  7306. m.ResetOrganizationID()
  7307. return nil
  7308. case batchmsg.FieldCtype:
  7309. m.ResetCtype()
  7310. return nil
  7311. case batchmsg.FieldCc:
  7312. m.ResetCc()
  7313. return nil
  7314. case batchmsg.FieldPhone:
  7315. m.ResetPhone()
  7316. return nil
  7317. case batchmsg.FieldTemplateName:
  7318. m.ResetTemplateName()
  7319. return nil
  7320. case batchmsg.FieldTemplateCode:
  7321. m.ResetTemplateCode()
  7322. return nil
  7323. case batchmsg.FieldLang:
  7324. m.ResetLang()
  7325. return nil
  7326. }
  7327. return fmt.Errorf("unknown BatchMsg field %s", name)
  7328. }
  7329. // AddedEdges returns all edge names that were set/added in this mutation.
  7330. func (m *BatchMsgMutation) AddedEdges() []string {
  7331. edges := make([]string, 0, 0)
  7332. return edges
  7333. }
  7334. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7335. // name in this mutation.
  7336. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7337. return nil
  7338. }
  7339. // RemovedEdges returns all edge names that were removed in this mutation.
  7340. func (m *BatchMsgMutation) RemovedEdges() []string {
  7341. edges := make([]string, 0, 0)
  7342. return edges
  7343. }
  7344. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7345. // the given name in this mutation.
  7346. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7347. return nil
  7348. }
  7349. // ClearedEdges returns all edge names that were cleared in this mutation.
  7350. func (m *BatchMsgMutation) ClearedEdges() []string {
  7351. edges := make([]string, 0, 0)
  7352. return edges
  7353. }
  7354. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7355. // was cleared in this mutation.
  7356. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7357. return false
  7358. }
  7359. // ClearEdge clears the value of the edge with the given name. It returns an error
  7360. // if that edge is not defined in the schema.
  7361. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7362. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7363. }
  7364. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7365. // It returns an error if the edge is not defined in the schema.
  7366. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7367. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7368. }
  7369. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7370. type CategoryMutation struct {
  7371. config
  7372. op Op
  7373. typ string
  7374. id *uint64
  7375. created_at *time.Time
  7376. updated_at *time.Time
  7377. deleted_at *time.Time
  7378. name *string
  7379. organization_id *uint64
  7380. addorganization_id *int64
  7381. clearedFields map[string]struct{}
  7382. done bool
  7383. oldValue func(context.Context) (*Category, error)
  7384. predicates []predicate.Category
  7385. }
  7386. var _ ent.Mutation = (*CategoryMutation)(nil)
  7387. // categoryOption allows management of the mutation configuration using functional options.
  7388. type categoryOption func(*CategoryMutation)
  7389. // newCategoryMutation creates new mutation for the Category entity.
  7390. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7391. m := &CategoryMutation{
  7392. config: c,
  7393. op: op,
  7394. typ: TypeCategory,
  7395. clearedFields: make(map[string]struct{}),
  7396. }
  7397. for _, opt := range opts {
  7398. opt(m)
  7399. }
  7400. return m
  7401. }
  7402. // withCategoryID sets the ID field of the mutation.
  7403. func withCategoryID(id uint64) categoryOption {
  7404. return func(m *CategoryMutation) {
  7405. var (
  7406. err error
  7407. once sync.Once
  7408. value *Category
  7409. )
  7410. m.oldValue = func(ctx context.Context) (*Category, error) {
  7411. once.Do(func() {
  7412. if m.done {
  7413. err = errors.New("querying old values post mutation is not allowed")
  7414. } else {
  7415. value, err = m.Client().Category.Get(ctx, id)
  7416. }
  7417. })
  7418. return value, err
  7419. }
  7420. m.id = &id
  7421. }
  7422. }
  7423. // withCategory sets the old Category of the mutation.
  7424. func withCategory(node *Category) categoryOption {
  7425. return func(m *CategoryMutation) {
  7426. m.oldValue = func(context.Context) (*Category, error) {
  7427. return node, nil
  7428. }
  7429. m.id = &node.ID
  7430. }
  7431. }
  7432. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7433. // executed in a transaction (ent.Tx), a transactional client is returned.
  7434. func (m CategoryMutation) Client() *Client {
  7435. client := &Client{config: m.config}
  7436. client.init()
  7437. return client
  7438. }
  7439. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7440. // it returns an error otherwise.
  7441. func (m CategoryMutation) Tx() (*Tx, error) {
  7442. if _, ok := m.driver.(*txDriver); !ok {
  7443. return nil, errors.New("ent: mutation is not running in a transaction")
  7444. }
  7445. tx := &Tx{config: m.config}
  7446. tx.init()
  7447. return tx, nil
  7448. }
  7449. // SetID sets the value of the id field. Note that this
  7450. // operation is only accepted on creation of Category entities.
  7451. func (m *CategoryMutation) SetID(id uint64) {
  7452. m.id = &id
  7453. }
  7454. // ID returns the ID value in the mutation. Note that the ID is only available
  7455. // if it was provided to the builder or after it was returned from the database.
  7456. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7457. if m.id == nil {
  7458. return
  7459. }
  7460. return *m.id, true
  7461. }
  7462. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7463. // That means, if the mutation is applied within a transaction with an isolation level such
  7464. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7465. // or updated by the mutation.
  7466. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7467. switch {
  7468. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7469. id, exists := m.ID()
  7470. if exists {
  7471. return []uint64{id}, nil
  7472. }
  7473. fallthrough
  7474. case m.op.Is(OpUpdate | OpDelete):
  7475. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7476. default:
  7477. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7478. }
  7479. }
  7480. // SetCreatedAt sets the "created_at" field.
  7481. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7482. m.created_at = &t
  7483. }
  7484. // CreatedAt returns the value of the "created_at" field in the mutation.
  7485. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7486. v := m.created_at
  7487. if v == nil {
  7488. return
  7489. }
  7490. return *v, true
  7491. }
  7492. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7493. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7495. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7496. if !m.op.Is(OpUpdateOne) {
  7497. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7498. }
  7499. if m.id == nil || m.oldValue == nil {
  7500. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7501. }
  7502. oldValue, err := m.oldValue(ctx)
  7503. if err != nil {
  7504. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7505. }
  7506. return oldValue.CreatedAt, nil
  7507. }
  7508. // ResetCreatedAt resets all changes to the "created_at" field.
  7509. func (m *CategoryMutation) ResetCreatedAt() {
  7510. m.created_at = nil
  7511. }
  7512. // SetUpdatedAt sets the "updated_at" field.
  7513. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7514. m.updated_at = &t
  7515. }
  7516. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7517. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7518. v := m.updated_at
  7519. if v == nil {
  7520. return
  7521. }
  7522. return *v, true
  7523. }
  7524. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7525. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7527. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7528. if !m.op.Is(OpUpdateOne) {
  7529. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7530. }
  7531. if m.id == nil || m.oldValue == nil {
  7532. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7533. }
  7534. oldValue, err := m.oldValue(ctx)
  7535. if err != nil {
  7536. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7537. }
  7538. return oldValue.UpdatedAt, nil
  7539. }
  7540. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7541. func (m *CategoryMutation) ResetUpdatedAt() {
  7542. m.updated_at = nil
  7543. }
  7544. // SetDeletedAt sets the "deleted_at" field.
  7545. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7546. m.deleted_at = &t
  7547. }
  7548. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7549. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7550. v := m.deleted_at
  7551. if v == nil {
  7552. return
  7553. }
  7554. return *v, true
  7555. }
  7556. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7557. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7559. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7560. if !m.op.Is(OpUpdateOne) {
  7561. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7562. }
  7563. if m.id == nil || m.oldValue == nil {
  7564. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7565. }
  7566. oldValue, err := m.oldValue(ctx)
  7567. if err != nil {
  7568. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7569. }
  7570. return oldValue.DeletedAt, nil
  7571. }
  7572. // ClearDeletedAt clears the value of the "deleted_at" field.
  7573. func (m *CategoryMutation) ClearDeletedAt() {
  7574. m.deleted_at = nil
  7575. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7576. }
  7577. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7578. func (m *CategoryMutation) DeletedAtCleared() bool {
  7579. _, ok := m.clearedFields[category.FieldDeletedAt]
  7580. return ok
  7581. }
  7582. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7583. func (m *CategoryMutation) ResetDeletedAt() {
  7584. m.deleted_at = nil
  7585. delete(m.clearedFields, category.FieldDeletedAt)
  7586. }
  7587. // SetName sets the "name" field.
  7588. func (m *CategoryMutation) SetName(s string) {
  7589. m.name = &s
  7590. }
  7591. // Name returns the value of the "name" field in the mutation.
  7592. func (m *CategoryMutation) Name() (r string, exists bool) {
  7593. v := m.name
  7594. if v == nil {
  7595. return
  7596. }
  7597. return *v, true
  7598. }
  7599. // OldName returns the old "name" field's value of the Category entity.
  7600. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7602. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7603. if !m.op.Is(OpUpdateOne) {
  7604. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7605. }
  7606. if m.id == nil || m.oldValue == nil {
  7607. return v, errors.New("OldName requires an ID field in the mutation")
  7608. }
  7609. oldValue, err := m.oldValue(ctx)
  7610. if err != nil {
  7611. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7612. }
  7613. return oldValue.Name, nil
  7614. }
  7615. // ResetName resets all changes to the "name" field.
  7616. func (m *CategoryMutation) ResetName() {
  7617. m.name = nil
  7618. }
  7619. // SetOrganizationID sets the "organization_id" field.
  7620. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7621. m.organization_id = &u
  7622. m.addorganization_id = nil
  7623. }
  7624. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7625. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7626. v := m.organization_id
  7627. if v == nil {
  7628. return
  7629. }
  7630. return *v, true
  7631. }
  7632. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7633. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7635. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7636. if !m.op.Is(OpUpdateOne) {
  7637. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7638. }
  7639. if m.id == nil || m.oldValue == nil {
  7640. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7641. }
  7642. oldValue, err := m.oldValue(ctx)
  7643. if err != nil {
  7644. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7645. }
  7646. return oldValue.OrganizationID, nil
  7647. }
  7648. // AddOrganizationID adds u to the "organization_id" field.
  7649. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7650. if m.addorganization_id != nil {
  7651. *m.addorganization_id += u
  7652. } else {
  7653. m.addorganization_id = &u
  7654. }
  7655. }
  7656. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7657. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7658. v := m.addorganization_id
  7659. if v == nil {
  7660. return
  7661. }
  7662. return *v, true
  7663. }
  7664. // ResetOrganizationID resets all changes to the "organization_id" field.
  7665. func (m *CategoryMutation) ResetOrganizationID() {
  7666. m.organization_id = nil
  7667. m.addorganization_id = nil
  7668. }
  7669. // Where appends a list predicates to the CategoryMutation builder.
  7670. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7671. m.predicates = append(m.predicates, ps...)
  7672. }
  7673. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7674. // users can use type-assertion to append predicates that do not depend on any generated package.
  7675. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7676. p := make([]predicate.Category, len(ps))
  7677. for i := range ps {
  7678. p[i] = ps[i]
  7679. }
  7680. m.Where(p...)
  7681. }
  7682. // Op returns the operation name.
  7683. func (m *CategoryMutation) Op() Op {
  7684. return m.op
  7685. }
  7686. // SetOp allows setting the mutation operation.
  7687. func (m *CategoryMutation) SetOp(op Op) {
  7688. m.op = op
  7689. }
  7690. // Type returns the node type of this mutation (Category).
  7691. func (m *CategoryMutation) Type() string {
  7692. return m.typ
  7693. }
  7694. // Fields returns all fields that were changed during this mutation. Note that in
  7695. // order to get all numeric fields that were incremented/decremented, call
  7696. // AddedFields().
  7697. func (m *CategoryMutation) Fields() []string {
  7698. fields := make([]string, 0, 5)
  7699. if m.created_at != nil {
  7700. fields = append(fields, category.FieldCreatedAt)
  7701. }
  7702. if m.updated_at != nil {
  7703. fields = append(fields, category.FieldUpdatedAt)
  7704. }
  7705. if m.deleted_at != nil {
  7706. fields = append(fields, category.FieldDeletedAt)
  7707. }
  7708. if m.name != nil {
  7709. fields = append(fields, category.FieldName)
  7710. }
  7711. if m.organization_id != nil {
  7712. fields = append(fields, category.FieldOrganizationID)
  7713. }
  7714. return fields
  7715. }
  7716. // Field returns the value of a field with the given name. The second boolean
  7717. // return value indicates that this field was not set, or was not defined in the
  7718. // schema.
  7719. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7720. switch name {
  7721. case category.FieldCreatedAt:
  7722. return m.CreatedAt()
  7723. case category.FieldUpdatedAt:
  7724. return m.UpdatedAt()
  7725. case category.FieldDeletedAt:
  7726. return m.DeletedAt()
  7727. case category.FieldName:
  7728. return m.Name()
  7729. case category.FieldOrganizationID:
  7730. return m.OrganizationID()
  7731. }
  7732. return nil, false
  7733. }
  7734. // OldField returns the old value of the field from the database. An error is
  7735. // returned if the mutation operation is not UpdateOne, or the query to the
  7736. // database failed.
  7737. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7738. switch name {
  7739. case category.FieldCreatedAt:
  7740. return m.OldCreatedAt(ctx)
  7741. case category.FieldUpdatedAt:
  7742. return m.OldUpdatedAt(ctx)
  7743. case category.FieldDeletedAt:
  7744. return m.OldDeletedAt(ctx)
  7745. case category.FieldName:
  7746. return m.OldName(ctx)
  7747. case category.FieldOrganizationID:
  7748. return m.OldOrganizationID(ctx)
  7749. }
  7750. return nil, fmt.Errorf("unknown Category field %s", name)
  7751. }
  7752. // SetField sets the value of a field with the given name. It returns an error if
  7753. // the field is not defined in the schema, or if the type mismatched the field
  7754. // type.
  7755. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7756. switch name {
  7757. case category.FieldCreatedAt:
  7758. v, ok := value.(time.Time)
  7759. if !ok {
  7760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7761. }
  7762. m.SetCreatedAt(v)
  7763. return nil
  7764. case category.FieldUpdatedAt:
  7765. v, ok := value.(time.Time)
  7766. if !ok {
  7767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7768. }
  7769. m.SetUpdatedAt(v)
  7770. return nil
  7771. case category.FieldDeletedAt:
  7772. v, ok := value.(time.Time)
  7773. if !ok {
  7774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7775. }
  7776. m.SetDeletedAt(v)
  7777. return nil
  7778. case category.FieldName:
  7779. v, ok := value.(string)
  7780. if !ok {
  7781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7782. }
  7783. m.SetName(v)
  7784. return nil
  7785. case category.FieldOrganizationID:
  7786. v, ok := value.(uint64)
  7787. if !ok {
  7788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7789. }
  7790. m.SetOrganizationID(v)
  7791. return nil
  7792. }
  7793. return fmt.Errorf("unknown Category field %s", name)
  7794. }
  7795. // AddedFields returns all numeric fields that were incremented/decremented during
  7796. // this mutation.
  7797. func (m *CategoryMutation) AddedFields() []string {
  7798. var fields []string
  7799. if m.addorganization_id != nil {
  7800. fields = append(fields, category.FieldOrganizationID)
  7801. }
  7802. return fields
  7803. }
  7804. // AddedField returns the numeric value that was incremented/decremented on a field
  7805. // with the given name. The second boolean return value indicates that this field
  7806. // was not set, or was not defined in the schema.
  7807. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7808. switch name {
  7809. case category.FieldOrganizationID:
  7810. return m.AddedOrganizationID()
  7811. }
  7812. return nil, false
  7813. }
  7814. // AddField adds the value to the field with the given name. It returns an error if
  7815. // the field is not defined in the schema, or if the type mismatched the field
  7816. // type.
  7817. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7818. switch name {
  7819. case category.FieldOrganizationID:
  7820. v, ok := value.(int64)
  7821. if !ok {
  7822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7823. }
  7824. m.AddOrganizationID(v)
  7825. return nil
  7826. }
  7827. return fmt.Errorf("unknown Category numeric field %s", name)
  7828. }
  7829. // ClearedFields returns all nullable fields that were cleared during this
  7830. // mutation.
  7831. func (m *CategoryMutation) ClearedFields() []string {
  7832. var fields []string
  7833. if m.FieldCleared(category.FieldDeletedAt) {
  7834. fields = append(fields, category.FieldDeletedAt)
  7835. }
  7836. return fields
  7837. }
  7838. // FieldCleared returns a boolean indicating if a field with the given name was
  7839. // cleared in this mutation.
  7840. func (m *CategoryMutation) FieldCleared(name string) bool {
  7841. _, ok := m.clearedFields[name]
  7842. return ok
  7843. }
  7844. // ClearField clears the value of the field with the given name. It returns an
  7845. // error if the field is not defined in the schema.
  7846. func (m *CategoryMutation) ClearField(name string) error {
  7847. switch name {
  7848. case category.FieldDeletedAt:
  7849. m.ClearDeletedAt()
  7850. return nil
  7851. }
  7852. return fmt.Errorf("unknown Category nullable field %s", name)
  7853. }
  7854. // ResetField resets all changes in the mutation for the field with the given name.
  7855. // It returns an error if the field is not defined in the schema.
  7856. func (m *CategoryMutation) ResetField(name string) error {
  7857. switch name {
  7858. case category.FieldCreatedAt:
  7859. m.ResetCreatedAt()
  7860. return nil
  7861. case category.FieldUpdatedAt:
  7862. m.ResetUpdatedAt()
  7863. return nil
  7864. case category.FieldDeletedAt:
  7865. m.ResetDeletedAt()
  7866. return nil
  7867. case category.FieldName:
  7868. m.ResetName()
  7869. return nil
  7870. case category.FieldOrganizationID:
  7871. m.ResetOrganizationID()
  7872. return nil
  7873. }
  7874. return fmt.Errorf("unknown Category field %s", name)
  7875. }
  7876. // AddedEdges returns all edge names that were set/added in this mutation.
  7877. func (m *CategoryMutation) AddedEdges() []string {
  7878. edges := make([]string, 0, 0)
  7879. return edges
  7880. }
  7881. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7882. // name in this mutation.
  7883. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7884. return nil
  7885. }
  7886. // RemovedEdges returns all edge names that were removed in this mutation.
  7887. func (m *CategoryMutation) RemovedEdges() []string {
  7888. edges := make([]string, 0, 0)
  7889. return edges
  7890. }
  7891. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7892. // the given name in this mutation.
  7893. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7894. return nil
  7895. }
  7896. // ClearedEdges returns all edge names that were cleared in this mutation.
  7897. func (m *CategoryMutation) ClearedEdges() []string {
  7898. edges := make([]string, 0, 0)
  7899. return edges
  7900. }
  7901. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7902. // was cleared in this mutation.
  7903. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7904. return false
  7905. }
  7906. // ClearEdge clears the value of the edge with the given name. It returns an error
  7907. // if that edge is not defined in the schema.
  7908. func (m *CategoryMutation) ClearEdge(name string) error {
  7909. return fmt.Errorf("unknown Category unique edge %s", name)
  7910. }
  7911. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7912. // It returns an error if the edge is not defined in the schema.
  7913. func (m *CategoryMutation) ResetEdge(name string) error {
  7914. return fmt.Errorf("unknown Category edge %s", name)
  7915. }
  7916. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7917. type ChatRecordsMutation struct {
  7918. config
  7919. op Op
  7920. typ string
  7921. id *uint64
  7922. created_at *time.Time
  7923. updated_at *time.Time
  7924. deleted_at *time.Time
  7925. content *string
  7926. content_type *uint8
  7927. addcontent_type *int8
  7928. session_id *uint64
  7929. addsession_id *int64
  7930. user_id *uint64
  7931. adduser_id *int64
  7932. bot_id *uint64
  7933. addbot_id *int64
  7934. bot_type *uint8
  7935. addbot_type *int8
  7936. clearedFields map[string]struct{}
  7937. done bool
  7938. oldValue func(context.Context) (*ChatRecords, error)
  7939. predicates []predicate.ChatRecords
  7940. }
  7941. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7942. // chatrecordsOption allows management of the mutation configuration using functional options.
  7943. type chatrecordsOption func(*ChatRecordsMutation)
  7944. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7945. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7946. m := &ChatRecordsMutation{
  7947. config: c,
  7948. op: op,
  7949. typ: TypeChatRecords,
  7950. clearedFields: make(map[string]struct{}),
  7951. }
  7952. for _, opt := range opts {
  7953. opt(m)
  7954. }
  7955. return m
  7956. }
  7957. // withChatRecordsID sets the ID field of the mutation.
  7958. func withChatRecordsID(id uint64) chatrecordsOption {
  7959. return func(m *ChatRecordsMutation) {
  7960. var (
  7961. err error
  7962. once sync.Once
  7963. value *ChatRecords
  7964. )
  7965. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7966. once.Do(func() {
  7967. if m.done {
  7968. err = errors.New("querying old values post mutation is not allowed")
  7969. } else {
  7970. value, err = m.Client().ChatRecords.Get(ctx, id)
  7971. }
  7972. })
  7973. return value, err
  7974. }
  7975. m.id = &id
  7976. }
  7977. }
  7978. // withChatRecords sets the old ChatRecords of the mutation.
  7979. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7980. return func(m *ChatRecordsMutation) {
  7981. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7982. return node, nil
  7983. }
  7984. m.id = &node.ID
  7985. }
  7986. }
  7987. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7988. // executed in a transaction (ent.Tx), a transactional client is returned.
  7989. func (m ChatRecordsMutation) Client() *Client {
  7990. client := &Client{config: m.config}
  7991. client.init()
  7992. return client
  7993. }
  7994. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7995. // it returns an error otherwise.
  7996. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7997. if _, ok := m.driver.(*txDriver); !ok {
  7998. return nil, errors.New("ent: mutation is not running in a transaction")
  7999. }
  8000. tx := &Tx{config: m.config}
  8001. tx.init()
  8002. return tx, nil
  8003. }
  8004. // SetID sets the value of the id field. Note that this
  8005. // operation is only accepted on creation of ChatRecords entities.
  8006. func (m *ChatRecordsMutation) SetID(id uint64) {
  8007. m.id = &id
  8008. }
  8009. // ID returns the ID value in the mutation. Note that the ID is only available
  8010. // if it was provided to the builder or after it was returned from the database.
  8011. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8012. if m.id == nil {
  8013. return
  8014. }
  8015. return *m.id, true
  8016. }
  8017. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8018. // That means, if the mutation is applied within a transaction with an isolation level such
  8019. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8020. // or updated by the mutation.
  8021. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8022. switch {
  8023. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8024. id, exists := m.ID()
  8025. if exists {
  8026. return []uint64{id}, nil
  8027. }
  8028. fallthrough
  8029. case m.op.Is(OpUpdate | OpDelete):
  8030. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8031. default:
  8032. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8033. }
  8034. }
  8035. // SetCreatedAt sets the "created_at" field.
  8036. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8037. m.created_at = &t
  8038. }
  8039. // CreatedAt returns the value of the "created_at" field in the mutation.
  8040. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8041. v := m.created_at
  8042. if v == nil {
  8043. return
  8044. }
  8045. return *v, true
  8046. }
  8047. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8048. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8050. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8051. if !m.op.Is(OpUpdateOne) {
  8052. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8053. }
  8054. if m.id == nil || m.oldValue == nil {
  8055. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8056. }
  8057. oldValue, err := m.oldValue(ctx)
  8058. if err != nil {
  8059. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8060. }
  8061. return oldValue.CreatedAt, nil
  8062. }
  8063. // ResetCreatedAt resets all changes to the "created_at" field.
  8064. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8065. m.created_at = nil
  8066. }
  8067. // SetUpdatedAt sets the "updated_at" field.
  8068. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8069. m.updated_at = &t
  8070. }
  8071. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8072. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8073. v := m.updated_at
  8074. if v == nil {
  8075. return
  8076. }
  8077. return *v, true
  8078. }
  8079. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8080. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8082. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8083. if !m.op.Is(OpUpdateOne) {
  8084. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8085. }
  8086. if m.id == nil || m.oldValue == nil {
  8087. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8088. }
  8089. oldValue, err := m.oldValue(ctx)
  8090. if err != nil {
  8091. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8092. }
  8093. return oldValue.UpdatedAt, nil
  8094. }
  8095. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8096. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8097. m.updated_at = nil
  8098. }
  8099. // SetDeletedAt sets the "deleted_at" field.
  8100. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8101. m.deleted_at = &t
  8102. }
  8103. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8104. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8105. v := m.deleted_at
  8106. if v == nil {
  8107. return
  8108. }
  8109. return *v, true
  8110. }
  8111. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8112. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8114. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8115. if !m.op.Is(OpUpdateOne) {
  8116. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8117. }
  8118. if m.id == nil || m.oldValue == nil {
  8119. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8120. }
  8121. oldValue, err := m.oldValue(ctx)
  8122. if err != nil {
  8123. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8124. }
  8125. return oldValue.DeletedAt, nil
  8126. }
  8127. // ClearDeletedAt clears the value of the "deleted_at" field.
  8128. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8129. m.deleted_at = nil
  8130. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8131. }
  8132. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8133. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8134. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8135. return ok
  8136. }
  8137. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8138. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8139. m.deleted_at = nil
  8140. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8141. }
  8142. // SetContent sets the "content" field.
  8143. func (m *ChatRecordsMutation) SetContent(s string) {
  8144. m.content = &s
  8145. }
  8146. // Content returns the value of the "content" field in the mutation.
  8147. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8148. v := m.content
  8149. if v == nil {
  8150. return
  8151. }
  8152. return *v, true
  8153. }
  8154. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8155. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8157. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8158. if !m.op.Is(OpUpdateOne) {
  8159. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8160. }
  8161. if m.id == nil || m.oldValue == nil {
  8162. return v, errors.New("OldContent requires an ID field in the mutation")
  8163. }
  8164. oldValue, err := m.oldValue(ctx)
  8165. if err != nil {
  8166. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8167. }
  8168. return oldValue.Content, nil
  8169. }
  8170. // ResetContent resets all changes to the "content" field.
  8171. func (m *ChatRecordsMutation) ResetContent() {
  8172. m.content = nil
  8173. }
  8174. // SetContentType sets the "content_type" field.
  8175. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8176. m.content_type = &u
  8177. m.addcontent_type = nil
  8178. }
  8179. // ContentType returns the value of the "content_type" field in the mutation.
  8180. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8181. v := m.content_type
  8182. if v == nil {
  8183. return
  8184. }
  8185. return *v, true
  8186. }
  8187. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8188. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8190. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8191. if !m.op.Is(OpUpdateOne) {
  8192. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8193. }
  8194. if m.id == nil || m.oldValue == nil {
  8195. return v, errors.New("OldContentType requires an ID field in the mutation")
  8196. }
  8197. oldValue, err := m.oldValue(ctx)
  8198. if err != nil {
  8199. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8200. }
  8201. return oldValue.ContentType, nil
  8202. }
  8203. // AddContentType adds u to the "content_type" field.
  8204. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8205. if m.addcontent_type != nil {
  8206. *m.addcontent_type += u
  8207. } else {
  8208. m.addcontent_type = &u
  8209. }
  8210. }
  8211. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8212. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8213. v := m.addcontent_type
  8214. if v == nil {
  8215. return
  8216. }
  8217. return *v, true
  8218. }
  8219. // ResetContentType resets all changes to the "content_type" field.
  8220. func (m *ChatRecordsMutation) ResetContentType() {
  8221. m.content_type = nil
  8222. m.addcontent_type = nil
  8223. }
  8224. // SetSessionID sets the "session_id" field.
  8225. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8226. m.session_id = &u
  8227. m.addsession_id = nil
  8228. }
  8229. // SessionID returns the value of the "session_id" field in the mutation.
  8230. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8231. v := m.session_id
  8232. if v == nil {
  8233. return
  8234. }
  8235. return *v, true
  8236. }
  8237. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8238. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8240. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8241. if !m.op.Is(OpUpdateOne) {
  8242. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8243. }
  8244. if m.id == nil || m.oldValue == nil {
  8245. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8246. }
  8247. oldValue, err := m.oldValue(ctx)
  8248. if err != nil {
  8249. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8250. }
  8251. return oldValue.SessionID, nil
  8252. }
  8253. // AddSessionID adds u to the "session_id" field.
  8254. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8255. if m.addsession_id != nil {
  8256. *m.addsession_id += u
  8257. } else {
  8258. m.addsession_id = &u
  8259. }
  8260. }
  8261. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8262. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8263. v := m.addsession_id
  8264. if v == nil {
  8265. return
  8266. }
  8267. return *v, true
  8268. }
  8269. // ResetSessionID resets all changes to the "session_id" field.
  8270. func (m *ChatRecordsMutation) ResetSessionID() {
  8271. m.session_id = nil
  8272. m.addsession_id = nil
  8273. }
  8274. // SetUserID sets the "user_id" field.
  8275. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8276. m.user_id = &u
  8277. m.adduser_id = nil
  8278. }
  8279. // UserID returns the value of the "user_id" field in the mutation.
  8280. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8281. v := m.user_id
  8282. if v == nil {
  8283. return
  8284. }
  8285. return *v, true
  8286. }
  8287. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8288. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8290. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8291. if !m.op.Is(OpUpdateOne) {
  8292. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8293. }
  8294. if m.id == nil || m.oldValue == nil {
  8295. return v, errors.New("OldUserID requires an ID field in the mutation")
  8296. }
  8297. oldValue, err := m.oldValue(ctx)
  8298. if err != nil {
  8299. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8300. }
  8301. return oldValue.UserID, nil
  8302. }
  8303. // AddUserID adds u to the "user_id" field.
  8304. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8305. if m.adduser_id != nil {
  8306. *m.adduser_id += u
  8307. } else {
  8308. m.adduser_id = &u
  8309. }
  8310. }
  8311. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8312. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8313. v := m.adduser_id
  8314. if v == nil {
  8315. return
  8316. }
  8317. return *v, true
  8318. }
  8319. // ResetUserID resets all changes to the "user_id" field.
  8320. func (m *ChatRecordsMutation) ResetUserID() {
  8321. m.user_id = nil
  8322. m.adduser_id = nil
  8323. }
  8324. // SetBotID sets the "bot_id" field.
  8325. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8326. m.bot_id = &u
  8327. m.addbot_id = nil
  8328. }
  8329. // BotID returns the value of the "bot_id" field in the mutation.
  8330. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8331. v := m.bot_id
  8332. if v == nil {
  8333. return
  8334. }
  8335. return *v, true
  8336. }
  8337. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8338. // If the ChatRecords 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 *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8341. if !m.op.Is(OpUpdateOne) {
  8342. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8343. }
  8344. if m.id == nil || m.oldValue == nil {
  8345. return v, errors.New("OldBotID 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 OldBotID: %w", err)
  8350. }
  8351. return oldValue.BotID, nil
  8352. }
  8353. // AddBotID adds u to the "bot_id" field.
  8354. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8355. if m.addbot_id != nil {
  8356. *m.addbot_id += u
  8357. } else {
  8358. m.addbot_id = &u
  8359. }
  8360. }
  8361. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8362. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8363. v := m.addbot_id
  8364. if v == nil {
  8365. return
  8366. }
  8367. return *v, true
  8368. }
  8369. // ResetBotID resets all changes to the "bot_id" field.
  8370. func (m *ChatRecordsMutation) ResetBotID() {
  8371. m.bot_id = nil
  8372. m.addbot_id = nil
  8373. }
  8374. // SetBotType sets the "bot_type" field.
  8375. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8376. m.bot_type = &u
  8377. m.addbot_type = nil
  8378. }
  8379. // BotType returns the value of the "bot_type" field in the mutation.
  8380. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8381. v := m.bot_type
  8382. if v == nil {
  8383. return
  8384. }
  8385. return *v, true
  8386. }
  8387. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8388. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8390. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8391. if !m.op.Is(OpUpdateOne) {
  8392. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8393. }
  8394. if m.id == nil || m.oldValue == nil {
  8395. return v, errors.New("OldBotType requires an ID field in the mutation")
  8396. }
  8397. oldValue, err := m.oldValue(ctx)
  8398. if err != nil {
  8399. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8400. }
  8401. return oldValue.BotType, nil
  8402. }
  8403. // AddBotType adds u to the "bot_type" field.
  8404. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8405. if m.addbot_type != nil {
  8406. *m.addbot_type += u
  8407. } else {
  8408. m.addbot_type = &u
  8409. }
  8410. }
  8411. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8412. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8413. v := m.addbot_type
  8414. if v == nil {
  8415. return
  8416. }
  8417. return *v, true
  8418. }
  8419. // ResetBotType resets all changes to the "bot_type" field.
  8420. func (m *ChatRecordsMutation) ResetBotType() {
  8421. m.bot_type = nil
  8422. m.addbot_type = nil
  8423. }
  8424. // Where appends a list predicates to the ChatRecordsMutation builder.
  8425. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8426. m.predicates = append(m.predicates, ps...)
  8427. }
  8428. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8429. // users can use type-assertion to append predicates that do not depend on any generated package.
  8430. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8431. p := make([]predicate.ChatRecords, len(ps))
  8432. for i := range ps {
  8433. p[i] = ps[i]
  8434. }
  8435. m.Where(p...)
  8436. }
  8437. // Op returns the operation name.
  8438. func (m *ChatRecordsMutation) Op() Op {
  8439. return m.op
  8440. }
  8441. // SetOp allows setting the mutation operation.
  8442. func (m *ChatRecordsMutation) SetOp(op Op) {
  8443. m.op = op
  8444. }
  8445. // Type returns the node type of this mutation (ChatRecords).
  8446. func (m *ChatRecordsMutation) Type() string {
  8447. return m.typ
  8448. }
  8449. // Fields returns all fields that were changed during this mutation. Note that in
  8450. // order to get all numeric fields that were incremented/decremented, call
  8451. // AddedFields().
  8452. func (m *ChatRecordsMutation) Fields() []string {
  8453. fields := make([]string, 0, 9)
  8454. if m.created_at != nil {
  8455. fields = append(fields, chatrecords.FieldCreatedAt)
  8456. }
  8457. if m.updated_at != nil {
  8458. fields = append(fields, chatrecords.FieldUpdatedAt)
  8459. }
  8460. if m.deleted_at != nil {
  8461. fields = append(fields, chatrecords.FieldDeletedAt)
  8462. }
  8463. if m.content != nil {
  8464. fields = append(fields, chatrecords.FieldContent)
  8465. }
  8466. if m.content_type != nil {
  8467. fields = append(fields, chatrecords.FieldContentType)
  8468. }
  8469. if m.session_id != nil {
  8470. fields = append(fields, chatrecords.FieldSessionID)
  8471. }
  8472. if m.user_id != nil {
  8473. fields = append(fields, chatrecords.FieldUserID)
  8474. }
  8475. if m.bot_id != nil {
  8476. fields = append(fields, chatrecords.FieldBotID)
  8477. }
  8478. if m.bot_type != nil {
  8479. fields = append(fields, chatrecords.FieldBotType)
  8480. }
  8481. return fields
  8482. }
  8483. // Field returns the value of a field with the given name. The second boolean
  8484. // return value indicates that this field was not set, or was not defined in the
  8485. // schema.
  8486. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8487. switch name {
  8488. case chatrecords.FieldCreatedAt:
  8489. return m.CreatedAt()
  8490. case chatrecords.FieldUpdatedAt:
  8491. return m.UpdatedAt()
  8492. case chatrecords.FieldDeletedAt:
  8493. return m.DeletedAt()
  8494. case chatrecords.FieldContent:
  8495. return m.Content()
  8496. case chatrecords.FieldContentType:
  8497. return m.ContentType()
  8498. case chatrecords.FieldSessionID:
  8499. return m.SessionID()
  8500. case chatrecords.FieldUserID:
  8501. return m.UserID()
  8502. case chatrecords.FieldBotID:
  8503. return m.BotID()
  8504. case chatrecords.FieldBotType:
  8505. return m.BotType()
  8506. }
  8507. return nil, false
  8508. }
  8509. // OldField returns the old value of the field from the database. An error is
  8510. // returned if the mutation operation is not UpdateOne, or the query to the
  8511. // database failed.
  8512. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8513. switch name {
  8514. case chatrecords.FieldCreatedAt:
  8515. return m.OldCreatedAt(ctx)
  8516. case chatrecords.FieldUpdatedAt:
  8517. return m.OldUpdatedAt(ctx)
  8518. case chatrecords.FieldDeletedAt:
  8519. return m.OldDeletedAt(ctx)
  8520. case chatrecords.FieldContent:
  8521. return m.OldContent(ctx)
  8522. case chatrecords.FieldContentType:
  8523. return m.OldContentType(ctx)
  8524. case chatrecords.FieldSessionID:
  8525. return m.OldSessionID(ctx)
  8526. case chatrecords.FieldUserID:
  8527. return m.OldUserID(ctx)
  8528. case chatrecords.FieldBotID:
  8529. return m.OldBotID(ctx)
  8530. case chatrecords.FieldBotType:
  8531. return m.OldBotType(ctx)
  8532. }
  8533. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8534. }
  8535. // SetField sets the value of a field with the given name. It returns an error if
  8536. // the field is not defined in the schema, or if the type mismatched the field
  8537. // type.
  8538. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8539. switch name {
  8540. case chatrecords.FieldCreatedAt:
  8541. v, ok := value.(time.Time)
  8542. if !ok {
  8543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8544. }
  8545. m.SetCreatedAt(v)
  8546. return nil
  8547. case chatrecords.FieldUpdatedAt:
  8548. v, ok := value.(time.Time)
  8549. if !ok {
  8550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8551. }
  8552. m.SetUpdatedAt(v)
  8553. return nil
  8554. case chatrecords.FieldDeletedAt:
  8555. v, ok := value.(time.Time)
  8556. if !ok {
  8557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8558. }
  8559. m.SetDeletedAt(v)
  8560. return nil
  8561. case chatrecords.FieldContent:
  8562. v, ok := value.(string)
  8563. if !ok {
  8564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8565. }
  8566. m.SetContent(v)
  8567. return nil
  8568. case chatrecords.FieldContentType:
  8569. v, ok := value.(uint8)
  8570. if !ok {
  8571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8572. }
  8573. m.SetContentType(v)
  8574. return nil
  8575. case chatrecords.FieldSessionID:
  8576. v, ok := value.(uint64)
  8577. if !ok {
  8578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8579. }
  8580. m.SetSessionID(v)
  8581. return nil
  8582. case chatrecords.FieldUserID:
  8583. v, ok := value.(uint64)
  8584. if !ok {
  8585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8586. }
  8587. m.SetUserID(v)
  8588. return nil
  8589. case chatrecords.FieldBotID:
  8590. v, ok := value.(uint64)
  8591. if !ok {
  8592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8593. }
  8594. m.SetBotID(v)
  8595. return nil
  8596. case chatrecords.FieldBotType:
  8597. v, ok := value.(uint8)
  8598. if !ok {
  8599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8600. }
  8601. m.SetBotType(v)
  8602. return nil
  8603. }
  8604. return fmt.Errorf("unknown ChatRecords field %s", name)
  8605. }
  8606. // AddedFields returns all numeric fields that were incremented/decremented during
  8607. // this mutation.
  8608. func (m *ChatRecordsMutation) AddedFields() []string {
  8609. var fields []string
  8610. if m.addcontent_type != nil {
  8611. fields = append(fields, chatrecords.FieldContentType)
  8612. }
  8613. if m.addsession_id != nil {
  8614. fields = append(fields, chatrecords.FieldSessionID)
  8615. }
  8616. if m.adduser_id != nil {
  8617. fields = append(fields, chatrecords.FieldUserID)
  8618. }
  8619. if m.addbot_id != nil {
  8620. fields = append(fields, chatrecords.FieldBotID)
  8621. }
  8622. if m.addbot_type != nil {
  8623. fields = append(fields, chatrecords.FieldBotType)
  8624. }
  8625. return fields
  8626. }
  8627. // AddedField returns the numeric value that was incremented/decremented on a field
  8628. // with the given name. The second boolean return value indicates that this field
  8629. // was not set, or was not defined in the schema.
  8630. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8631. switch name {
  8632. case chatrecords.FieldContentType:
  8633. return m.AddedContentType()
  8634. case chatrecords.FieldSessionID:
  8635. return m.AddedSessionID()
  8636. case chatrecords.FieldUserID:
  8637. return m.AddedUserID()
  8638. case chatrecords.FieldBotID:
  8639. return m.AddedBotID()
  8640. case chatrecords.FieldBotType:
  8641. return m.AddedBotType()
  8642. }
  8643. return nil, false
  8644. }
  8645. // AddField adds the value to the field with the given name. It returns an error if
  8646. // the field is not defined in the schema, or if the type mismatched the field
  8647. // type.
  8648. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8649. switch name {
  8650. case chatrecords.FieldContentType:
  8651. v, ok := value.(int8)
  8652. if !ok {
  8653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8654. }
  8655. m.AddContentType(v)
  8656. return nil
  8657. case chatrecords.FieldSessionID:
  8658. v, ok := value.(int64)
  8659. if !ok {
  8660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8661. }
  8662. m.AddSessionID(v)
  8663. return nil
  8664. case chatrecords.FieldUserID:
  8665. v, ok := value.(int64)
  8666. if !ok {
  8667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8668. }
  8669. m.AddUserID(v)
  8670. return nil
  8671. case chatrecords.FieldBotID:
  8672. v, ok := value.(int64)
  8673. if !ok {
  8674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8675. }
  8676. m.AddBotID(v)
  8677. return nil
  8678. case chatrecords.FieldBotType:
  8679. v, ok := value.(int8)
  8680. if !ok {
  8681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8682. }
  8683. m.AddBotType(v)
  8684. return nil
  8685. }
  8686. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8687. }
  8688. // ClearedFields returns all nullable fields that were cleared during this
  8689. // mutation.
  8690. func (m *ChatRecordsMutation) ClearedFields() []string {
  8691. var fields []string
  8692. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8693. fields = append(fields, chatrecords.FieldDeletedAt)
  8694. }
  8695. return fields
  8696. }
  8697. // FieldCleared returns a boolean indicating if a field with the given name was
  8698. // cleared in this mutation.
  8699. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8700. _, ok := m.clearedFields[name]
  8701. return ok
  8702. }
  8703. // ClearField clears the value of the field with the given name. It returns an
  8704. // error if the field is not defined in the schema.
  8705. func (m *ChatRecordsMutation) ClearField(name string) error {
  8706. switch name {
  8707. case chatrecords.FieldDeletedAt:
  8708. m.ClearDeletedAt()
  8709. return nil
  8710. }
  8711. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8712. }
  8713. // ResetField resets all changes in the mutation for the field with the given name.
  8714. // It returns an error if the field is not defined in the schema.
  8715. func (m *ChatRecordsMutation) ResetField(name string) error {
  8716. switch name {
  8717. case chatrecords.FieldCreatedAt:
  8718. m.ResetCreatedAt()
  8719. return nil
  8720. case chatrecords.FieldUpdatedAt:
  8721. m.ResetUpdatedAt()
  8722. return nil
  8723. case chatrecords.FieldDeletedAt:
  8724. m.ResetDeletedAt()
  8725. return nil
  8726. case chatrecords.FieldContent:
  8727. m.ResetContent()
  8728. return nil
  8729. case chatrecords.FieldContentType:
  8730. m.ResetContentType()
  8731. return nil
  8732. case chatrecords.FieldSessionID:
  8733. m.ResetSessionID()
  8734. return nil
  8735. case chatrecords.FieldUserID:
  8736. m.ResetUserID()
  8737. return nil
  8738. case chatrecords.FieldBotID:
  8739. m.ResetBotID()
  8740. return nil
  8741. case chatrecords.FieldBotType:
  8742. m.ResetBotType()
  8743. return nil
  8744. }
  8745. return fmt.Errorf("unknown ChatRecords field %s", name)
  8746. }
  8747. // AddedEdges returns all edge names that were set/added in this mutation.
  8748. func (m *ChatRecordsMutation) AddedEdges() []string {
  8749. edges := make([]string, 0, 0)
  8750. return edges
  8751. }
  8752. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8753. // name in this mutation.
  8754. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8755. return nil
  8756. }
  8757. // RemovedEdges returns all edge names that were removed in this mutation.
  8758. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8759. edges := make([]string, 0, 0)
  8760. return edges
  8761. }
  8762. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8763. // the given name in this mutation.
  8764. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8765. return nil
  8766. }
  8767. // ClearedEdges returns all edge names that were cleared in this mutation.
  8768. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8769. edges := make([]string, 0, 0)
  8770. return edges
  8771. }
  8772. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8773. // was cleared in this mutation.
  8774. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8775. return false
  8776. }
  8777. // ClearEdge clears the value of the edge with the given name. It returns an error
  8778. // if that edge is not defined in the schema.
  8779. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8780. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8781. }
  8782. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8783. // It returns an error if the edge is not defined in the schema.
  8784. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8785. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8786. }
  8787. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8788. type ChatSessionMutation struct {
  8789. config
  8790. op Op
  8791. typ string
  8792. id *uint64
  8793. created_at *time.Time
  8794. updated_at *time.Time
  8795. deleted_at *time.Time
  8796. name *string
  8797. user_id *uint64
  8798. adduser_id *int64
  8799. bot_id *uint64
  8800. addbot_id *int64
  8801. bot_type *uint8
  8802. addbot_type *int8
  8803. clearedFields map[string]struct{}
  8804. done bool
  8805. oldValue func(context.Context) (*ChatSession, error)
  8806. predicates []predicate.ChatSession
  8807. }
  8808. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8809. // chatsessionOption allows management of the mutation configuration using functional options.
  8810. type chatsessionOption func(*ChatSessionMutation)
  8811. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8812. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8813. m := &ChatSessionMutation{
  8814. config: c,
  8815. op: op,
  8816. typ: TypeChatSession,
  8817. clearedFields: make(map[string]struct{}),
  8818. }
  8819. for _, opt := range opts {
  8820. opt(m)
  8821. }
  8822. return m
  8823. }
  8824. // withChatSessionID sets the ID field of the mutation.
  8825. func withChatSessionID(id uint64) chatsessionOption {
  8826. return func(m *ChatSessionMutation) {
  8827. var (
  8828. err error
  8829. once sync.Once
  8830. value *ChatSession
  8831. )
  8832. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8833. once.Do(func() {
  8834. if m.done {
  8835. err = errors.New("querying old values post mutation is not allowed")
  8836. } else {
  8837. value, err = m.Client().ChatSession.Get(ctx, id)
  8838. }
  8839. })
  8840. return value, err
  8841. }
  8842. m.id = &id
  8843. }
  8844. }
  8845. // withChatSession sets the old ChatSession of the mutation.
  8846. func withChatSession(node *ChatSession) chatsessionOption {
  8847. return func(m *ChatSessionMutation) {
  8848. m.oldValue = func(context.Context) (*ChatSession, error) {
  8849. return node, nil
  8850. }
  8851. m.id = &node.ID
  8852. }
  8853. }
  8854. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8855. // executed in a transaction (ent.Tx), a transactional client is returned.
  8856. func (m ChatSessionMutation) Client() *Client {
  8857. client := &Client{config: m.config}
  8858. client.init()
  8859. return client
  8860. }
  8861. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8862. // it returns an error otherwise.
  8863. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8864. if _, ok := m.driver.(*txDriver); !ok {
  8865. return nil, errors.New("ent: mutation is not running in a transaction")
  8866. }
  8867. tx := &Tx{config: m.config}
  8868. tx.init()
  8869. return tx, nil
  8870. }
  8871. // SetID sets the value of the id field. Note that this
  8872. // operation is only accepted on creation of ChatSession entities.
  8873. func (m *ChatSessionMutation) SetID(id uint64) {
  8874. m.id = &id
  8875. }
  8876. // ID returns the ID value in the mutation. Note that the ID is only available
  8877. // if it was provided to the builder or after it was returned from the database.
  8878. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8879. if m.id == nil {
  8880. return
  8881. }
  8882. return *m.id, true
  8883. }
  8884. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8885. // That means, if the mutation is applied within a transaction with an isolation level such
  8886. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8887. // or updated by the mutation.
  8888. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8889. switch {
  8890. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8891. id, exists := m.ID()
  8892. if exists {
  8893. return []uint64{id}, nil
  8894. }
  8895. fallthrough
  8896. case m.op.Is(OpUpdate | OpDelete):
  8897. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8898. default:
  8899. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8900. }
  8901. }
  8902. // SetCreatedAt sets the "created_at" field.
  8903. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8904. m.created_at = &t
  8905. }
  8906. // CreatedAt returns the value of the "created_at" field in the mutation.
  8907. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8908. v := m.created_at
  8909. if v == nil {
  8910. return
  8911. }
  8912. return *v, true
  8913. }
  8914. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8915. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8917. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8918. if !m.op.Is(OpUpdateOne) {
  8919. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8920. }
  8921. if m.id == nil || m.oldValue == nil {
  8922. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8923. }
  8924. oldValue, err := m.oldValue(ctx)
  8925. if err != nil {
  8926. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8927. }
  8928. return oldValue.CreatedAt, nil
  8929. }
  8930. // ResetCreatedAt resets all changes to the "created_at" field.
  8931. func (m *ChatSessionMutation) ResetCreatedAt() {
  8932. m.created_at = nil
  8933. }
  8934. // SetUpdatedAt sets the "updated_at" field.
  8935. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8936. m.updated_at = &t
  8937. }
  8938. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8939. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8940. v := m.updated_at
  8941. if v == nil {
  8942. return
  8943. }
  8944. return *v, true
  8945. }
  8946. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8947. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8949. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8950. if !m.op.Is(OpUpdateOne) {
  8951. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8952. }
  8953. if m.id == nil || m.oldValue == nil {
  8954. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8955. }
  8956. oldValue, err := m.oldValue(ctx)
  8957. if err != nil {
  8958. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8959. }
  8960. return oldValue.UpdatedAt, nil
  8961. }
  8962. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8963. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8964. m.updated_at = nil
  8965. }
  8966. // SetDeletedAt sets the "deleted_at" field.
  8967. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8968. m.deleted_at = &t
  8969. }
  8970. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8971. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8972. v := m.deleted_at
  8973. if v == nil {
  8974. return
  8975. }
  8976. return *v, true
  8977. }
  8978. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8979. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8981. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8982. if !m.op.Is(OpUpdateOne) {
  8983. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8984. }
  8985. if m.id == nil || m.oldValue == nil {
  8986. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8987. }
  8988. oldValue, err := m.oldValue(ctx)
  8989. if err != nil {
  8990. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8991. }
  8992. return oldValue.DeletedAt, nil
  8993. }
  8994. // ClearDeletedAt clears the value of the "deleted_at" field.
  8995. func (m *ChatSessionMutation) ClearDeletedAt() {
  8996. m.deleted_at = nil
  8997. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8998. }
  8999. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9000. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9001. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9002. return ok
  9003. }
  9004. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9005. func (m *ChatSessionMutation) ResetDeletedAt() {
  9006. m.deleted_at = nil
  9007. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9008. }
  9009. // SetName sets the "name" field.
  9010. func (m *ChatSessionMutation) SetName(s string) {
  9011. m.name = &s
  9012. }
  9013. // Name returns the value of the "name" field in the mutation.
  9014. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9015. v := m.name
  9016. if v == nil {
  9017. return
  9018. }
  9019. return *v, true
  9020. }
  9021. // OldName returns the old "name" field's value of the ChatSession entity.
  9022. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9024. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9025. if !m.op.Is(OpUpdateOne) {
  9026. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9027. }
  9028. if m.id == nil || m.oldValue == nil {
  9029. return v, errors.New("OldName requires an ID field in the mutation")
  9030. }
  9031. oldValue, err := m.oldValue(ctx)
  9032. if err != nil {
  9033. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9034. }
  9035. return oldValue.Name, nil
  9036. }
  9037. // ResetName resets all changes to the "name" field.
  9038. func (m *ChatSessionMutation) ResetName() {
  9039. m.name = nil
  9040. }
  9041. // SetUserID sets the "user_id" field.
  9042. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9043. m.user_id = &u
  9044. m.adduser_id = nil
  9045. }
  9046. // UserID returns the value of the "user_id" field in the mutation.
  9047. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9048. v := m.user_id
  9049. if v == nil {
  9050. return
  9051. }
  9052. return *v, true
  9053. }
  9054. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9055. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9057. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9058. if !m.op.Is(OpUpdateOne) {
  9059. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9060. }
  9061. if m.id == nil || m.oldValue == nil {
  9062. return v, errors.New("OldUserID requires an ID field in the mutation")
  9063. }
  9064. oldValue, err := m.oldValue(ctx)
  9065. if err != nil {
  9066. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9067. }
  9068. return oldValue.UserID, nil
  9069. }
  9070. // AddUserID adds u to the "user_id" field.
  9071. func (m *ChatSessionMutation) AddUserID(u int64) {
  9072. if m.adduser_id != nil {
  9073. *m.adduser_id += u
  9074. } else {
  9075. m.adduser_id = &u
  9076. }
  9077. }
  9078. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9079. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9080. v := m.adduser_id
  9081. if v == nil {
  9082. return
  9083. }
  9084. return *v, true
  9085. }
  9086. // ResetUserID resets all changes to the "user_id" field.
  9087. func (m *ChatSessionMutation) ResetUserID() {
  9088. m.user_id = nil
  9089. m.adduser_id = nil
  9090. }
  9091. // SetBotID sets the "bot_id" field.
  9092. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9093. m.bot_id = &u
  9094. m.addbot_id = nil
  9095. }
  9096. // BotID returns the value of the "bot_id" field in the mutation.
  9097. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9098. v := m.bot_id
  9099. if v == nil {
  9100. return
  9101. }
  9102. return *v, true
  9103. }
  9104. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9105. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9107. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9108. if !m.op.Is(OpUpdateOne) {
  9109. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9110. }
  9111. if m.id == nil || m.oldValue == nil {
  9112. return v, errors.New("OldBotID requires an ID field in the mutation")
  9113. }
  9114. oldValue, err := m.oldValue(ctx)
  9115. if err != nil {
  9116. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9117. }
  9118. return oldValue.BotID, nil
  9119. }
  9120. // AddBotID adds u to the "bot_id" field.
  9121. func (m *ChatSessionMutation) AddBotID(u int64) {
  9122. if m.addbot_id != nil {
  9123. *m.addbot_id += u
  9124. } else {
  9125. m.addbot_id = &u
  9126. }
  9127. }
  9128. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9129. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9130. v := m.addbot_id
  9131. if v == nil {
  9132. return
  9133. }
  9134. return *v, true
  9135. }
  9136. // ResetBotID resets all changes to the "bot_id" field.
  9137. func (m *ChatSessionMutation) ResetBotID() {
  9138. m.bot_id = nil
  9139. m.addbot_id = nil
  9140. }
  9141. // SetBotType sets the "bot_type" field.
  9142. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9143. m.bot_type = &u
  9144. m.addbot_type = nil
  9145. }
  9146. // BotType returns the value of the "bot_type" field in the mutation.
  9147. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9148. v := m.bot_type
  9149. if v == nil {
  9150. return
  9151. }
  9152. return *v, true
  9153. }
  9154. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9155. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9157. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9158. if !m.op.Is(OpUpdateOne) {
  9159. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9160. }
  9161. if m.id == nil || m.oldValue == nil {
  9162. return v, errors.New("OldBotType requires an ID field in the mutation")
  9163. }
  9164. oldValue, err := m.oldValue(ctx)
  9165. if err != nil {
  9166. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9167. }
  9168. return oldValue.BotType, nil
  9169. }
  9170. // AddBotType adds u to the "bot_type" field.
  9171. func (m *ChatSessionMutation) AddBotType(u int8) {
  9172. if m.addbot_type != nil {
  9173. *m.addbot_type += u
  9174. } else {
  9175. m.addbot_type = &u
  9176. }
  9177. }
  9178. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9179. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9180. v := m.addbot_type
  9181. if v == nil {
  9182. return
  9183. }
  9184. return *v, true
  9185. }
  9186. // ResetBotType resets all changes to the "bot_type" field.
  9187. func (m *ChatSessionMutation) ResetBotType() {
  9188. m.bot_type = nil
  9189. m.addbot_type = nil
  9190. }
  9191. // Where appends a list predicates to the ChatSessionMutation builder.
  9192. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9193. m.predicates = append(m.predicates, ps...)
  9194. }
  9195. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9196. // users can use type-assertion to append predicates that do not depend on any generated package.
  9197. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9198. p := make([]predicate.ChatSession, len(ps))
  9199. for i := range ps {
  9200. p[i] = ps[i]
  9201. }
  9202. m.Where(p...)
  9203. }
  9204. // Op returns the operation name.
  9205. func (m *ChatSessionMutation) Op() Op {
  9206. return m.op
  9207. }
  9208. // SetOp allows setting the mutation operation.
  9209. func (m *ChatSessionMutation) SetOp(op Op) {
  9210. m.op = op
  9211. }
  9212. // Type returns the node type of this mutation (ChatSession).
  9213. func (m *ChatSessionMutation) Type() string {
  9214. return m.typ
  9215. }
  9216. // Fields returns all fields that were changed during this mutation. Note that in
  9217. // order to get all numeric fields that were incremented/decremented, call
  9218. // AddedFields().
  9219. func (m *ChatSessionMutation) Fields() []string {
  9220. fields := make([]string, 0, 7)
  9221. if m.created_at != nil {
  9222. fields = append(fields, chatsession.FieldCreatedAt)
  9223. }
  9224. if m.updated_at != nil {
  9225. fields = append(fields, chatsession.FieldUpdatedAt)
  9226. }
  9227. if m.deleted_at != nil {
  9228. fields = append(fields, chatsession.FieldDeletedAt)
  9229. }
  9230. if m.name != nil {
  9231. fields = append(fields, chatsession.FieldName)
  9232. }
  9233. if m.user_id != nil {
  9234. fields = append(fields, chatsession.FieldUserID)
  9235. }
  9236. if m.bot_id != nil {
  9237. fields = append(fields, chatsession.FieldBotID)
  9238. }
  9239. if m.bot_type != nil {
  9240. fields = append(fields, chatsession.FieldBotType)
  9241. }
  9242. return fields
  9243. }
  9244. // Field returns the value of a field with the given name. The second boolean
  9245. // return value indicates that this field was not set, or was not defined in the
  9246. // schema.
  9247. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9248. switch name {
  9249. case chatsession.FieldCreatedAt:
  9250. return m.CreatedAt()
  9251. case chatsession.FieldUpdatedAt:
  9252. return m.UpdatedAt()
  9253. case chatsession.FieldDeletedAt:
  9254. return m.DeletedAt()
  9255. case chatsession.FieldName:
  9256. return m.Name()
  9257. case chatsession.FieldUserID:
  9258. return m.UserID()
  9259. case chatsession.FieldBotID:
  9260. return m.BotID()
  9261. case chatsession.FieldBotType:
  9262. return m.BotType()
  9263. }
  9264. return nil, false
  9265. }
  9266. // OldField returns the old value of the field from the database. An error is
  9267. // returned if the mutation operation is not UpdateOne, or the query to the
  9268. // database failed.
  9269. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9270. switch name {
  9271. case chatsession.FieldCreatedAt:
  9272. return m.OldCreatedAt(ctx)
  9273. case chatsession.FieldUpdatedAt:
  9274. return m.OldUpdatedAt(ctx)
  9275. case chatsession.FieldDeletedAt:
  9276. return m.OldDeletedAt(ctx)
  9277. case chatsession.FieldName:
  9278. return m.OldName(ctx)
  9279. case chatsession.FieldUserID:
  9280. return m.OldUserID(ctx)
  9281. case chatsession.FieldBotID:
  9282. return m.OldBotID(ctx)
  9283. case chatsession.FieldBotType:
  9284. return m.OldBotType(ctx)
  9285. }
  9286. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9287. }
  9288. // SetField sets the value of a field with the given name. It returns an error if
  9289. // the field is not defined in the schema, or if the type mismatched the field
  9290. // type.
  9291. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9292. switch name {
  9293. case chatsession.FieldCreatedAt:
  9294. v, ok := value.(time.Time)
  9295. if !ok {
  9296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9297. }
  9298. m.SetCreatedAt(v)
  9299. return nil
  9300. case chatsession.FieldUpdatedAt:
  9301. v, ok := value.(time.Time)
  9302. if !ok {
  9303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9304. }
  9305. m.SetUpdatedAt(v)
  9306. return nil
  9307. case chatsession.FieldDeletedAt:
  9308. v, ok := value.(time.Time)
  9309. if !ok {
  9310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9311. }
  9312. m.SetDeletedAt(v)
  9313. return nil
  9314. case chatsession.FieldName:
  9315. v, ok := value.(string)
  9316. if !ok {
  9317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9318. }
  9319. m.SetName(v)
  9320. return nil
  9321. case chatsession.FieldUserID:
  9322. v, ok := value.(uint64)
  9323. if !ok {
  9324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9325. }
  9326. m.SetUserID(v)
  9327. return nil
  9328. case chatsession.FieldBotID:
  9329. v, ok := value.(uint64)
  9330. if !ok {
  9331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9332. }
  9333. m.SetBotID(v)
  9334. return nil
  9335. case chatsession.FieldBotType:
  9336. v, ok := value.(uint8)
  9337. if !ok {
  9338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9339. }
  9340. m.SetBotType(v)
  9341. return nil
  9342. }
  9343. return fmt.Errorf("unknown ChatSession field %s", name)
  9344. }
  9345. // AddedFields returns all numeric fields that were incremented/decremented during
  9346. // this mutation.
  9347. func (m *ChatSessionMutation) AddedFields() []string {
  9348. var fields []string
  9349. if m.adduser_id != nil {
  9350. fields = append(fields, chatsession.FieldUserID)
  9351. }
  9352. if m.addbot_id != nil {
  9353. fields = append(fields, chatsession.FieldBotID)
  9354. }
  9355. if m.addbot_type != nil {
  9356. fields = append(fields, chatsession.FieldBotType)
  9357. }
  9358. return fields
  9359. }
  9360. // AddedField returns the numeric value that was incremented/decremented on a field
  9361. // with the given name. The second boolean return value indicates that this field
  9362. // was not set, or was not defined in the schema.
  9363. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9364. switch name {
  9365. case chatsession.FieldUserID:
  9366. return m.AddedUserID()
  9367. case chatsession.FieldBotID:
  9368. return m.AddedBotID()
  9369. case chatsession.FieldBotType:
  9370. return m.AddedBotType()
  9371. }
  9372. return nil, false
  9373. }
  9374. // AddField adds the value to the field with the given name. It returns an error if
  9375. // the field is not defined in the schema, or if the type mismatched the field
  9376. // type.
  9377. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9378. switch name {
  9379. case chatsession.FieldUserID:
  9380. v, ok := value.(int64)
  9381. if !ok {
  9382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9383. }
  9384. m.AddUserID(v)
  9385. return nil
  9386. case chatsession.FieldBotID:
  9387. v, ok := value.(int64)
  9388. if !ok {
  9389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9390. }
  9391. m.AddBotID(v)
  9392. return nil
  9393. case chatsession.FieldBotType:
  9394. v, ok := value.(int8)
  9395. if !ok {
  9396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9397. }
  9398. m.AddBotType(v)
  9399. return nil
  9400. }
  9401. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9402. }
  9403. // ClearedFields returns all nullable fields that were cleared during this
  9404. // mutation.
  9405. func (m *ChatSessionMutation) ClearedFields() []string {
  9406. var fields []string
  9407. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9408. fields = append(fields, chatsession.FieldDeletedAt)
  9409. }
  9410. return fields
  9411. }
  9412. // FieldCleared returns a boolean indicating if a field with the given name was
  9413. // cleared in this mutation.
  9414. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9415. _, ok := m.clearedFields[name]
  9416. return ok
  9417. }
  9418. // ClearField clears the value of the field with the given name. It returns an
  9419. // error if the field is not defined in the schema.
  9420. func (m *ChatSessionMutation) ClearField(name string) error {
  9421. switch name {
  9422. case chatsession.FieldDeletedAt:
  9423. m.ClearDeletedAt()
  9424. return nil
  9425. }
  9426. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9427. }
  9428. // ResetField resets all changes in the mutation for the field with the given name.
  9429. // It returns an error if the field is not defined in the schema.
  9430. func (m *ChatSessionMutation) ResetField(name string) error {
  9431. switch name {
  9432. case chatsession.FieldCreatedAt:
  9433. m.ResetCreatedAt()
  9434. return nil
  9435. case chatsession.FieldUpdatedAt:
  9436. m.ResetUpdatedAt()
  9437. return nil
  9438. case chatsession.FieldDeletedAt:
  9439. m.ResetDeletedAt()
  9440. return nil
  9441. case chatsession.FieldName:
  9442. m.ResetName()
  9443. return nil
  9444. case chatsession.FieldUserID:
  9445. m.ResetUserID()
  9446. return nil
  9447. case chatsession.FieldBotID:
  9448. m.ResetBotID()
  9449. return nil
  9450. case chatsession.FieldBotType:
  9451. m.ResetBotType()
  9452. return nil
  9453. }
  9454. return fmt.Errorf("unknown ChatSession field %s", name)
  9455. }
  9456. // AddedEdges returns all edge names that were set/added in this mutation.
  9457. func (m *ChatSessionMutation) AddedEdges() []string {
  9458. edges := make([]string, 0, 0)
  9459. return edges
  9460. }
  9461. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9462. // name in this mutation.
  9463. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9464. return nil
  9465. }
  9466. // RemovedEdges returns all edge names that were removed in this mutation.
  9467. func (m *ChatSessionMutation) RemovedEdges() []string {
  9468. edges := make([]string, 0, 0)
  9469. return edges
  9470. }
  9471. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9472. // the given name in this mutation.
  9473. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9474. return nil
  9475. }
  9476. // ClearedEdges returns all edge names that were cleared in this mutation.
  9477. func (m *ChatSessionMutation) ClearedEdges() []string {
  9478. edges := make([]string, 0, 0)
  9479. return edges
  9480. }
  9481. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9482. // was cleared in this mutation.
  9483. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9484. return false
  9485. }
  9486. // ClearEdge clears the value of the edge with the given name. It returns an error
  9487. // if that edge is not defined in the schema.
  9488. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9489. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9490. }
  9491. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9492. // It returns an error if the edge is not defined in the schema.
  9493. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9494. return fmt.Errorf("unknown ChatSession edge %s", name)
  9495. }
  9496. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9497. type CompapiAsynctaskMutation struct {
  9498. config
  9499. op Op
  9500. typ string
  9501. id *uint64
  9502. created_at *time.Time
  9503. updated_at *time.Time
  9504. auth_token *string
  9505. event_type *string
  9506. chat_id *string
  9507. response_chat_item_id *string
  9508. organization_id *uint64
  9509. addorganization_id *int64
  9510. openai_base *string
  9511. openai_key *string
  9512. request_raw *string
  9513. response_raw *string
  9514. callback_url *string
  9515. callback_response_raw *string
  9516. model *string
  9517. task_status *int8
  9518. addtask_status *int8
  9519. retry_count *int8
  9520. addretry_count *int8
  9521. last_error *string
  9522. clearedFields map[string]struct{}
  9523. done bool
  9524. oldValue func(context.Context) (*CompapiAsynctask, error)
  9525. predicates []predicate.CompapiAsynctask
  9526. }
  9527. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9528. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9529. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9530. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9531. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9532. m := &CompapiAsynctaskMutation{
  9533. config: c,
  9534. op: op,
  9535. typ: TypeCompapiAsynctask,
  9536. clearedFields: make(map[string]struct{}),
  9537. }
  9538. for _, opt := range opts {
  9539. opt(m)
  9540. }
  9541. return m
  9542. }
  9543. // withCompapiAsynctaskID sets the ID field of the mutation.
  9544. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9545. return func(m *CompapiAsynctaskMutation) {
  9546. var (
  9547. err error
  9548. once sync.Once
  9549. value *CompapiAsynctask
  9550. )
  9551. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9552. once.Do(func() {
  9553. if m.done {
  9554. err = errors.New("querying old values post mutation is not allowed")
  9555. } else {
  9556. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9557. }
  9558. })
  9559. return value, err
  9560. }
  9561. m.id = &id
  9562. }
  9563. }
  9564. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9565. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9566. return func(m *CompapiAsynctaskMutation) {
  9567. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9568. return node, nil
  9569. }
  9570. m.id = &node.ID
  9571. }
  9572. }
  9573. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9574. // executed in a transaction (ent.Tx), a transactional client is returned.
  9575. func (m CompapiAsynctaskMutation) Client() *Client {
  9576. client := &Client{config: m.config}
  9577. client.init()
  9578. return client
  9579. }
  9580. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9581. // it returns an error otherwise.
  9582. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9583. if _, ok := m.driver.(*txDriver); !ok {
  9584. return nil, errors.New("ent: mutation is not running in a transaction")
  9585. }
  9586. tx := &Tx{config: m.config}
  9587. tx.init()
  9588. return tx, nil
  9589. }
  9590. // SetID sets the value of the id field. Note that this
  9591. // operation is only accepted on creation of CompapiAsynctask entities.
  9592. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9593. m.id = &id
  9594. }
  9595. // ID returns the ID value in the mutation. Note that the ID is only available
  9596. // if it was provided to the builder or after it was returned from the database.
  9597. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9598. if m.id == nil {
  9599. return
  9600. }
  9601. return *m.id, true
  9602. }
  9603. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9604. // That means, if the mutation is applied within a transaction with an isolation level such
  9605. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9606. // or updated by the mutation.
  9607. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9608. switch {
  9609. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9610. id, exists := m.ID()
  9611. if exists {
  9612. return []uint64{id}, nil
  9613. }
  9614. fallthrough
  9615. case m.op.Is(OpUpdate | OpDelete):
  9616. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9617. default:
  9618. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9619. }
  9620. }
  9621. // SetCreatedAt sets the "created_at" field.
  9622. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9623. m.created_at = &t
  9624. }
  9625. // CreatedAt returns the value of the "created_at" field in the mutation.
  9626. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9627. v := m.created_at
  9628. if v == nil {
  9629. return
  9630. }
  9631. return *v, true
  9632. }
  9633. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9634. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9636. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9637. if !m.op.Is(OpUpdateOne) {
  9638. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9639. }
  9640. if m.id == nil || m.oldValue == nil {
  9641. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9642. }
  9643. oldValue, err := m.oldValue(ctx)
  9644. if err != nil {
  9645. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9646. }
  9647. return oldValue.CreatedAt, nil
  9648. }
  9649. // ResetCreatedAt resets all changes to the "created_at" field.
  9650. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9651. m.created_at = nil
  9652. }
  9653. // SetUpdatedAt sets the "updated_at" field.
  9654. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9655. m.updated_at = &t
  9656. }
  9657. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9658. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9659. v := m.updated_at
  9660. if v == nil {
  9661. return
  9662. }
  9663. return *v, true
  9664. }
  9665. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9666. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9668. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9669. if !m.op.Is(OpUpdateOne) {
  9670. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9671. }
  9672. if m.id == nil || m.oldValue == nil {
  9673. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9674. }
  9675. oldValue, err := m.oldValue(ctx)
  9676. if err != nil {
  9677. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9678. }
  9679. return oldValue.UpdatedAt, nil
  9680. }
  9681. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9682. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9683. m.updated_at = nil
  9684. }
  9685. // SetAuthToken sets the "auth_token" field.
  9686. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9687. m.auth_token = &s
  9688. }
  9689. // AuthToken returns the value of the "auth_token" field in the mutation.
  9690. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9691. v := m.auth_token
  9692. if v == nil {
  9693. return
  9694. }
  9695. return *v, true
  9696. }
  9697. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9698. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9700. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9701. if !m.op.Is(OpUpdateOne) {
  9702. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9703. }
  9704. if m.id == nil || m.oldValue == nil {
  9705. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9706. }
  9707. oldValue, err := m.oldValue(ctx)
  9708. if err != nil {
  9709. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9710. }
  9711. return oldValue.AuthToken, nil
  9712. }
  9713. // ResetAuthToken resets all changes to the "auth_token" field.
  9714. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9715. m.auth_token = nil
  9716. }
  9717. // SetEventType sets the "event_type" field.
  9718. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9719. m.event_type = &s
  9720. }
  9721. // EventType returns the value of the "event_type" field in the mutation.
  9722. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9723. v := m.event_type
  9724. if v == nil {
  9725. return
  9726. }
  9727. return *v, true
  9728. }
  9729. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9730. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9732. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9733. if !m.op.Is(OpUpdateOne) {
  9734. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9735. }
  9736. if m.id == nil || m.oldValue == nil {
  9737. return v, errors.New("OldEventType requires an ID field in the mutation")
  9738. }
  9739. oldValue, err := m.oldValue(ctx)
  9740. if err != nil {
  9741. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9742. }
  9743. return oldValue.EventType, nil
  9744. }
  9745. // ResetEventType resets all changes to the "event_type" field.
  9746. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9747. m.event_type = nil
  9748. }
  9749. // SetChatID sets the "chat_id" field.
  9750. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9751. m.chat_id = &s
  9752. }
  9753. // ChatID returns the value of the "chat_id" field in the mutation.
  9754. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9755. v := m.chat_id
  9756. if v == nil {
  9757. return
  9758. }
  9759. return *v, true
  9760. }
  9761. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9762. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9764. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9765. if !m.op.Is(OpUpdateOne) {
  9766. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9767. }
  9768. if m.id == nil || m.oldValue == nil {
  9769. return v, errors.New("OldChatID requires an ID field in the mutation")
  9770. }
  9771. oldValue, err := m.oldValue(ctx)
  9772. if err != nil {
  9773. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9774. }
  9775. return oldValue.ChatID, nil
  9776. }
  9777. // ClearChatID clears the value of the "chat_id" field.
  9778. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9779. m.chat_id = nil
  9780. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9781. }
  9782. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9783. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9784. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9785. return ok
  9786. }
  9787. // ResetChatID resets all changes to the "chat_id" field.
  9788. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9789. m.chat_id = nil
  9790. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9791. }
  9792. // SetResponseChatItemID sets the "response_chat_item_id" field.
  9793. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  9794. m.response_chat_item_id = &s
  9795. }
  9796. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  9797. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  9798. v := m.response_chat_item_id
  9799. if v == nil {
  9800. return
  9801. }
  9802. return *v, true
  9803. }
  9804. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  9805. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9807. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  9808. if !m.op.Is(OpUpdateOne) {
  9809. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  9810. }
  9811. if m.id == nil || m.oldValue == nil {
  9812. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  9813. }
  9814. oldValue, err := m.oldValue(ctx)
  9815. if err != nil {
  9816. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  9817. }
  9818. return oldValue.ResponseChatItemID, nil
  9819. }
  9820. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  9821. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  9822. m.response_chat_item_id = nil
  9823. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  9824. }
  9825. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  9826. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  9827. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  9828. return ok
  9829. }
  9830. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  9831. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  9832. m.response_chat_item_id = nil
  9833. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  9834. }
  9835. // SetOrganizationID sets the "organization_id" field.
  9836. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  9837. m.organization_id = &u
  9838. m.addorganization_id = nil
  9839. }
  9840. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9841. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  9842. v := m.organization_id
  9843. if v == nil {
  9844. return
  9845. }
  9846. return *v, true
  9847. }
  9848. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  9849. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9851. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9852. if !m.op.Is(OpUpdateOne) {
  9853. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9854. }
  9855. if m.id == nil || m.oldValue == nil {
  9856. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9857. }
  9858. oldValue, err := m.oldValue(ctx)
  9859. if err != nil {
  9860. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9861. }
  9862. return oldValue.OrganizationID, nil
  9863. }
  9864. // AddOrganizationID adds u to the "organization_id" field.
  9865. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  9866. if m.addorganization_id != nil {
  9867. *m.addorganization_id += u
  9868. } else {
  9869. m.addorganization_id = &u
  9870. }
  9871. }
  9872. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9873. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  9874. v := m.addorganization_id
  9875. if v == nil {
  9876. return
  9877. }
  9878. return *v, true
  9879. }
  9880. // ResetOrganizationID resets all changes to the "organization_id" field.
  9881. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  9882. m.organization_id = nil
  9883. m.addorganization_id = nil
  9884. }
  9885. // SetOpenaiBase sets the "openai_base" field.
  9886. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9887. m.openai_base = &s
  9888. }
  9889. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9890. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9891. v := m.openai_base
  9892. if v == nil {
  9893. return
  9894. }
  9895. return *v, true
  9896. }
  9897. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9898. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9900. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9901. if !m.op.Is(OpUpdateOne) {
  9902. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9903. }
  9904. if m.id == nil || m.oldValue == nil {
  9905. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9906. }
  9907. oldValue, err := m.oldValue(ctx)
  9908. if err != nil {
  9909. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9910. }
  9911. return oldValue.OpenaiBase, nil
  9912. }
  9913. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9914. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9915. m.openai_base = nil
  9916. }
  9917. // SetOpenaiKey sets the "openai_key" field.
  9918. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  9919. m.openai_key = &s
  9920. }
  9921. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  9922. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  9923. v := m.openai_key
  9924. if v == nil {
  9925. return
  9926. }
  9927. return *v, true
  9928. }
  9929. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  9930. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9932. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  9933. if !m.op.Is(OpUpdateOne) {
  9934. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  9935. }
  9936. if m.id == nil || m.oldValue == nil {
  9937. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  9938. }
  9939. oldValue, err := m.oldValue(ctx)
  9940. if err != nil {
  9941. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  9942. }
  9943. return oldValue.OpenaiKey, nil
  9944. }
  9945. // ResetOpenaiKey resets all changes to the "openai_key" field.
  9946. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  9947. m.openai_key = nil
  9948. }
  9949. // SetRequestRaw sets the "request_raw" field.
  9950. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  9951. m.request_raw = &s
  9952. }
  9953. // RequestRaw returns the value of the "request_raw" field in the mutation.
  9954. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  9955. v := m.request_raw
  9956. if v == nil {
  9957. return
  9958. }
  9959. return *v, true
  9960. }
  9961. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  9962. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9964. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  9965. if !m.op.Is(OpUpdateOne) {
  9966. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  9967. }
  9968. if m.id == nil || m.oldValue == nil {
  9969. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  9970. }
  9971. oldValue, err := m.oldValue(ctx)
  9972. if err != nil {
  9973. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  9974. }
  9975. return oldValue.RequestRaw, nil
  9976. }
  9977. // ResetRequestRaw resets all changes to the "request_raw" field.
  9978. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  9979. m.request_raw = nil
  9980. }
  9981. // SetResponseRaw sets the "response_raw" field.
  9982. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  9983. m.response_raw = &s
  9984. }
  9985. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  9986. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  9987. v := m.response_raw
  9988. if v == nil {
  9989. return
  9990. }
  9991. return *v, true
  9992. }
  9993. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  9994. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9996. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  9997. if !m.op.Is(OpUpdateOne) {
  9998. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  9999. }
  10000. if m.id == nil || m.oldValue == nil {
  10001. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  10002. }
  10003. oldValue, err := m.oldValue(ctx)
  10004. if err != nil {
  10005. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  10006. }
  10007. return oldValue.ResponseRaw, nil
  10008. }
  10009. // ClearResponseRaw clears the value of the "response_raw" field.
  10010. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  10011. m.response_raw = nil
  10012. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  10013. }
  10014. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  10015. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  10016. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  10017. return ok
  10018. }
  10019. // ResetResponseRaw resets all changes to the "response_raw" field.
  10020. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  10021. m.response_raw = nil
  10022. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  10023. }
  10024. // SetCallbackURL sets the "callback_url" field.
  10025. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  10026. m.callback_url = &s
  10027. }
  10028. // CallbackURL returns the value of the "callback_url" field in the mutation.
  10029. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  10030. v := m.callback_url
  10031. if v == nil {
  10032. return
  10033. }
  10034. return *v, true
  10035. }
  10036. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  10037. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10039. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  10040. if !m.op.Is(OpUpdateOne) {
  10041. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  10042. }
  10043. if m.id == nil || m.oldValue == nil {
  10044. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  10045. }
  10046. oldValue, err := m.oldValue(ctx)
  10047. if err != nil {
  10048. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  10049. }
  10050. return oldValue.CallbackURL, nil
  10051. }
  10052. // ResetCallbackURL resets all changes to the "callback_url" field.
  10053. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  10054. m.callback_url = nil
  10055. }
  10056. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  10057. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  10058. m.callback_response_raw = &s
  10059. }
  10060. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  10061. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  10062. v := m.callback_response_raw
  10063. if v == nil {
  10064. return
  10065. }
  10066. return *v, true
  10067. }
  10068. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  10069. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10071. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  10072. if !m.op.Is(OpUpdateOne) {
  10073. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  10074. }
  10075. if m.id == nil || m.oldValue == nil {
  10076. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  10077. }
  10078. oldValue, err := m.oldValue(ctx)
  10079. if err != nil {
  10080. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  10081. }
  10082. return oldValue.CallbackResponseRaw, nil
  10083. }
  10084. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  10085. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  10086. m.callback_response_raw = nil
  10087. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  10088. }
  10089. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  10090. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  10091. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  10092. return ok
  10093. }
  10094. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  10095. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  10096. m.callback_response_raw = nil
  10097. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  10098. }
  10099. // SetModel sets the "model" field.
  10100. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  10101. m.model = &s
  10102. }
  10103. // Model returns the value of the "model" field in the mutation.
  10104. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  10105. v := m.model
  10106. if v == nil {
  10107. return
  10108. }
  10109. return *v, true
  10110. }
  10111. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  10112. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10114. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  10115. if !m.op.Is(OpUpdateOne) {
  10116. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10117. }
  10118. if m.id == nil || m.oldValue == nil {
  10119. return v, errors.New("OldModel requires an ID field in the mutation")
  10120. }
  10121. oldValue, err := m.oldValue(ctx)
  10122. if err != nil {
  10123. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10124. }
  10125. return oldValue.Model, nil
  10126. }
  10127. // ClearModel clears the value of the "model" field.
  10128. func (m *CompapiAsynctaskMutation) ClearModel() {
  10129. m.model = nil
  10130. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  10131. }
  10132. // ModelCleared returns if the "model" field was cleared in this mutation.
  10133. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  10134. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  10135. return ok
  10136. }
  10137. // ResetModel resets all changes to the "model" field.
  10138. func (m *CompapiAsynctaskMutation) ResetModel() {
  10139. m.model = nil
  10140. delete(m.clearedFields, compapiasynctask.FieldModel)
  10141. }
  10142. // SetTaskStatus sets the "task_status" field.
  10143. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  10144. m.task_status = &i
  10145. m.addtask_status = nil
  10146. }
  10147. // TaskStatus returns the value of the "task_status" field in the mutation.
  10148. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  10149. v := m.task_status
  10150. if v == nil {
  10151. return
  10152. }
  10153. return *v, true
  10154. }
  10155. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  10156. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10158. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  10159. if !m.op.Is(OpUpdateOne) {
  10160. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  10161. }
  10162. if m.id == nil || m.oldValue == nil {
  10163. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  10164. }
  10165. oldValue, err := m.oldValue(ctx)
  10166. if err != nil {
  10167. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  10168. }
  10169. return oldValue.TaskStatus, nil
  10170. }
  10171. // AddTaskStatus adds i to the "task_status" field.
  10172. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  10173. if m.addtask_status != nil {
  10174. *m.addtask_status += i
  10175. } else {
  10176. m.addtask_status = &i
  10177. }
  10178. }
  10179. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  10180. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  10181. v := m.addtask_status
  10182. if v == nil {
  10183. return
  10184. }
  10185. return *v, true
  10186. }
  10187. // ClearTaskStatus clears the value of the "task_status" field.
  10188. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  10189. m.task_status = nil
  10190. m.addtask_status = nil
  10191. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  10192. }
  10193. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  10194. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  10195. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  10196. return ok
  10197. }
  10198. // ResetTaskStatus resets all changes to the "task_status" field.
  10199. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  10200. m.task_status = nil
  10201. m.addtask_status = nil
  10202. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  10203. }
  10204. // SetRetryCount sets the "retry_count" field.
  10205. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  10206. m.retry_count = &i
  10207. m.addretry_count = nil
  10208. }
  10209. // RetryCount returns the value of the "retry_count" field in the mutation.
  10210. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  10211. v := m.retry_count
  10212. if v == nil {
  10213. return
  10214. }
  10215. return *v, true
  10216. }
  10217. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  10218. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10220. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  10221. if !m.op.Is(OpUpdateOne) {
  10222. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  10223. }
  10224. if m.id == nil || m.oldValue == nil {
  10225. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  10226. }
  10227. oldValue, err := m.oldValue(ctx)
  10228. if err != nil {
  10229. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  10230. }
  10231. return oldValue.RetryCount, nil
  10232. }
  10233. // AddRetryCount adds i to the "retry_count" field.
  10234. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  10235. if m.addretry_count != nil {
  10236. *m.addretry_count += i
  10237. } else {
  10238. m.addretry_count = &i
  10239. }
  10240. }
  10241. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  10242. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  10243. v := m.addretry_count
  10244. if v == nil {
  10245. return
  10246. }
  10247. return *v, true
  10248. }
  10249. // ClearRetryCount clears the value of the "retry_count" field.
  10250. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  10251. m.retry_count = nil
  10252. m.addretry_count = nil
  10253. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  10254. }
  10255. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  10256. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  10257. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  10258. return ok
  10259. }
  10260. // ResetRetryCount resets all changes to the "retry_count" field.
  10261. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  10262. m.retry_count = nil
  10263. m.addretry_count = nil
  10264. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  10265. }
  10266. // SetLastError sets the "last_error" field.
  10267. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  10268. m.last_error = &s
  10269. }
  10270. // LastError returns the value of the "last_error" field in the mutation.
  10271. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  10272. v := m.last_error
  10273. if v == nil {
  10274. return
  10275. }
  10276. return *v, true
  10277. }
  10278. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  10279. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10281. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  10282. if !m.op.Is(OpUpdateOne) {
  10283. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  10284. }
  10285. if m.id == nil || m.oldValue == nil {
  10286. return v, errors.New("OldLastError requires an ID field in the mutation")
  10287. }
  10288. oldValue, err := m.oldValue(ctx)
  10289. if err != nil {
  10290. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  10291. }
  10292. return oldValue.LastError, nil
  10293. }
  10294. // ClearLastError clears the value of the "last_error" field.
  10295. func (m *CompapiAsynctaskMutation) ClearLastError() {
  10296. m.last_error = nil
  10297. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  10298. }
  10299. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  10300. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  10301. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  10302. return ok
  10303. }
  10304. // ResetLastError resets all changes to the "last_error" field.
  10305. func (m *CompapiAsynctaskMutation) ResetLastError() {
  10306. m.last_error = nil
  10307. delete(m.clearedFields, compapiasynctask.FieldLastError)
  10308. }
  10309. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  10310. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  10311. m.predicates = append(m.predicates, ps...)
  10312. }
  10313. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  10314. // users can use type-assertion to append predicates that do not depend on any generated package.
  10315. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10316. p := make([]predicate.CompapiAsynctask, len(ps))
  10317. for i := range ps {
  10318. p[i] = ps[i]
  10319. }
  10320. m.Where(p...)
  10321. }
  10322. // Op returns the operation name.
  10323. func (m *CompapiAsynctaskMutation) Op() Op {
  10324. return m.op
  10325. }
  10326. // SetOp allows setting the mutation operation.
  10327. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  10328. m.op = op
  10329. }
  10330. // Type returns the node type of this mutation (CompapiAsynctask).
  10331. func (m *CompapiAsynctaskMutation) Type() string {
  10332. return m.typ
  10333. }
  10334. // Fields returns all fields that were changed during this mutation. Note that in
  10335. // order to get all numeric fields that were incremented/decremented, call
  10336. // AddedFields().
  10337. func (m *CompapiAsynctaskMutation) Fields() []string {
  10338. fields := make([]string, 0, 17)
  10339. if m.created_at != nil {
  10340. fields = append(fields, compapiasynctask.FieldCreatedAt)
  10341. }
  10342. if m.updated_at != nil {
  10343. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  10344. }
  10345. if m.auth_token != nil {
  10346. fields = append(fields, compapiasynctask.FieldAuthToken)
  10347. }
  10348. if m.event_type != nil {
  10349. fields = append(fields, compapiasynctask.FieldEventType)
  10350. }
  10351. if m.chat_id != nil {
  10352. fields = append(fields, compapiasynctask.FieldChatID)
  10353. }
  10354. if m.response_chat_item_id != nil {
  10355. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10356. }
  10357. if m.organization_id != nil {
  10358. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10359. }
  10360. if m.openai_base != nil {
  10361. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  10362. }
  10363. if m.openai_key != nil {
  10364. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  10365. }
  10366. if m.request_raw != nil {
  10367. fields = append(fields, compapiasynctask.FieldRequestRaw)
  10368. }
  10369. if m.response_raw != nil {
  10370. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10371. }
  10372. if m.callback_url != nil {
  10373. fields = append(fields, compapiasynctask.FieldCallbackURL)
  10374. }
  10375. if m.callback_response_raw != nil {
  10376. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10377. }
  10378. if m.model != nil {
  10379. fields = append(fields, compapiasynctask.FieldModel)
  10380. }
  10381. if m.task_status != nil {
  10382. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10383. }
  10384. if m.retry_count != nil {
  10385. fields = append(fields, compapiasynctask.FieldRetryCount)
  10386. }
  10387. if m.last_error != nil {
  10388. fields = append(fields, compapiasynctask.FieldLastError)
  10389. }
  10390. return fields
  10391. }
  10392. // Field returns the value of a field with the given name. The second boolean
  10393. // return value indicates that this field was not set, or was not defined in the
  10394. // schema.
  10395. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  10396. switch name {
  10397. case compapiasynctask.FieldCreatedAt:
  10398. return m.CreatedAt()
  10399. case compapiasynctask.FieldUpdatedAt:
  10400. return m.UpdatedAt()
  10401. case compapiasynctask.FieldAuthToken:
  10402. return m.AuthToken()
  10403. case compapiasynctask.FieldEventType:
  10404. return m.EventType()
  10405. case compapiasynctask.FieldChatID:
  10406. return m.ChatID()
  10407. case compapiasynctask.FieldResponseChatItemID:
  10408. return m.ResponseChatItemID()
  10409. case compapiasynctask.FieldOrganizationID:
  10410. return m.OrganizationID()
  10411. case compapiasynctask.FieldOpenaiBase:
  10412. return m.OpenaiBase()
  10413. case compapiasynctask.FieldOpenaiKey:
  10414. return m.OpenaiKey()
  10415. case compapiasynctask.FieldRequestRaw:
  10416. return m.RequestRaw()
  10417. case compapiasynctask.FieldResponseRaw:
  10418. return m.ResponseRaw()
  10419. case compapiasynctask.FieldCallbackURL:
  10420. return m.CallbackURL()
  10421. case compapiasynctask.FieldCallbackResponseRaw:
  10422. return m.CallbackResponseRaw()
  10423. case compapiasynctask.FieldModel:
  10424. return m.Model()
  10425. case compapiasynctask.FieldTaskStatus:
  10426. return m.TaskStatus()
  10427. case compapiasynctask.FieldRetryCount:
  10428. return m.RetryCount()
  10429. case compapiasynctask.FieldLastError:
  10430. return m.LastError()
  10431. }
  10432. return nil, false
  10433. }
  10434. // OldField returns the old value of the field from the database. An error is
  10435. // returned if the mutation operation is not UpdateOne, or the query to the
  10436. // database failed.
  10437. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10438. switch name {
  10439. case compapiasynctask.FieldCreatedAt:
  10440. return m.OldCreatedAt(ctx)
  10441. case compapiasynctask.FieldUpdatedAt:
  10442. return m.OldUpdatedAt(ctx)
  10443. case compapiasynctask.FieldAuthToken:
  10444. return m.OldAuthToken(ctx)
  10445. case compapiasynctask.FieldEventType:
  10446. return m.OldEventType(ctx)
  10447. case compapiasynctask.FieldChatID:
  10448. return m.OldChatID(ctx)
  10449. case compapiasynctask.FieldResponseChatItemID:
  10450. return m.OldResponseChatItemID(ctx)
  10451. case compapiasynctask.FieldOrganizationID:
  10452. return m.OldOrganizationID(ctx)
  10453. case compapiasynctask.FieldOpenaiBase:
  10454. return m.OldOpenaiBase(ctx)
  10455. case compapiasynctask.FieldOpenaiKey:
  10456. return m.OldOpenaiKey(ctx)
  10457. case compapiasynctask.FieldRequestRaw:
  10458. return m.OldRequestRaw(ctx)
  10459. case compapiasynctask.FieldResponseRaw:
  10460. return m.OldResponseRaw(ctx)
  10461. case compapiasynctask.FieldCallbackURL:
  10462. return m.OldCallbackURL(ctx)
  10463. case compapiasynctask.FieldCallbackResponseRaw:
  10464. return m.OldCallbackResponseRaw(ctx)
  10465. case compapiasynctask.FieldModel:
  10466. return m.OldModel(ctx)
  10467. case compapiasynctask.FieldTaskStatus:
  10468. return m.OldTaskStatus(ctx)
  10469. case compapiasynctask.FieldRetryCount:
  10470. return m.OldRetryCount(ctx)
  10471. case compapiasynctask.FieldLastError:
  10472. return m.OldLastError(ctx)
  10473. }
  10474. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10475. }
  10476. // SetField sets the value of a field with the given name. It returns an error if
  10477. // the field is not defined in the schema, or if the type mismatched the field
  10478. // type.
  10479. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10480. switch name {
  10481. case compapiasynctask.FieldCreatedAt:
  10482. v, ok := value.(time.Time)
  10483. if !ok {
  10484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10485. }
  10486. m.SetCreatedAt(v)
  10487. return nil
  10488. case compapiasynctask.FieldUpdatedAt:
  10489. v, ok := value.(time.Time)
  10490. if !ok {
  10491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10492. }
  10493. m.SetUpdatedAt(v)
  10494. return nil
  10495. case compapiasynctask.FieldAuthToken:
  10496. v, ok := value.(string)
  10497. if !ok {
  10498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10499. }
  10500. m.SetAuthToken(v)
  10501. return nil
  10502. case compapiasynctask.FieldEventType:
  10503. v, ok := value.(string)
  10504. if !ok {
  10505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10506. }
  10507. m.SetEventType(v)
  10508. return nil
  10509. case compapiasynctask.FieldChatID:
  10510. v, ok := value.(string)
  10511. if !ok {
  10512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10513. }
  10514. m.SetChatID(v)
  10515. return nil
  10516. case compapiasynctask.FieldResponseChatItemID:
  10517. v, ok := value.(string)
  10518. if !ok {
  10519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10520. }
  10521. m.SetResponseChatItemID(v)
  10522. return nil
  10523. case compapiasynctask.FieldOrganizationID:
  10524. v, ok := value.(uint64)
  10525. if !ok {
  10526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10527. }
  10528. m.SetOrganizationID(v)
  10529. return nil
  10530. case compapiasynctask.FieldOpenaiBase:
  10531. v, ok := value.(string)
  10532. if !ok {
  10533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10534. }
  10535. m.SetOpenaiBase(v)
  10536. return nil
  10537. case compapiasynctask.FieldOpenaiKey:
  10538. v, ok := value.(string)
  10539. if !ok {
  10540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10541. }
  10542. m.SetOpenaiKey(v)
  10543. return nil
  10544. case compapiasynctask.FieldRequestRaw:
  10545. v, ok := value.(string)
  10546. if !ok {
  10547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10548. }
  10549. m.SetRequestRaw(v)
  10550. return nil
  10551. case compapiasynctask.FieldResponseRaw:
  10552. v, ok := value.(string)
  10553. if !ok {
  10554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10555. }
  10556. m.SetResponseRaw(v)
  10557. return nil
  10558. case compapiasynctask.FieldCallbackURL:
  10559. v, ok := value.(string)
  10560. if !ok {
  10561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10562. }
  10563. m.SetCallbackURL(v)
  10564. return nil
  10565. case compapiasynctask.FieldCallbackResponseRaw:
  10566. v, ok := value.(string)
  10567. if !ok {
  10568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10569. }
  10570. m.SetCallbackResponseRaw(v)
  10571. return nil
  10572. case compapiasynctask.FieldModel:
  10573. v, ok := value.(string)
  10574. if !ok {
  10575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10576. }
  10577. m.SetModel(v)
  10578. return nil
  10579. case compapiasynctask.FieldTaskStatus:
  10580. v, ok := value.(int8)
  10581. if !ok {
  10582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10583. }
  10584. m.SetTaskStatus(v)
  10585. return nil
  10586. case compapiasynctask.FieldRetryCount:
  10587. v, ok := value.(int8)
  10588. if !ok {
  10589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10590. }
  10591. m.SetRetryCount(v)
  10592. return nil
  10593. case compapiasynctask.FieldLastError:
  10594. v, ok := value.(string)
  10595. if !ok {
  10596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10597. }
  10598. m.SetLastError(v)
  10599. return nil
  10600. }
  10601. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10602. }
  10603. // AddedFields returns all numeric fields that were incremented/decremented during
  10604. // this mutation.
  10605. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10606. var fields []string
  10607. if m.addorganization_id != nil {
  10608. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10609. }
  10610. if m.addtask_status != nil {
  10611. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10612. }
  10613. if m.addretry_count != nil {
  10614. fields = append(fields, compapiasynctask.FieldRetryCount)
  10615. }
  10616. return fields
  10617. }
  10618. // AddedField returns the numeric value that was incremented/decremented on a field
  10619. // with the given name. The second boolean return value indicates that this field
  10620. // was not set, or was not defined in the schema.
  10621. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10622. switch name {
  10623. case compapiasynctask.FieldOrganizationID:
  10624. return m.AddedOrganizationID()
  10625. case compapiasynctask.FieldTaskStatus:
  10626. return m.AddedTaskStatus()
  10627. case compapiasynctask.FieldRetryCount:
  10628. return m.AddedRetryCount()
  10629. }
  10630. return nil, false
  10631. }
  10632. // AddField adds the value to the field with the given name. It returns an error if
  10633. // the field is not defined in the schema, or if the type mismatched the field
  10634. // type.
  10635. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10636. switch name {
  10637. case compapiasynctask.FieldOrganizationID:
  10638. v, ok := value.(int64)
  10639. if !ok {
  10640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10641. }
  10642. m.AddOrganizationID(v)
  10643. return nil
  10644. case compapiasynctask.FieldTaskStatus:
  10645. v, ok := value.(int8)
  10646. if !ok {
  10647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10648. }
  10649. m.AddTaskStatus(v)
  10650. return nil
  10651. case compapiasynctask.FieldRetryCount:
  10652. v, ok := value.(int8)
  10653. if !ok {
  10654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10655. }
  10656. m.AddRetryCount(v)
  10657. return nil
  10658. }
  10659. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10660. }
  10661. // ClearedFields returns all nullable fields that were cleared during this
  10662. // mutation.
  10663. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10664. var fields []string
  10665. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10666. fields = append(fields, compapiasynctask.FieldChatID)
  10667. }
  10668. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  10669. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10670. }
  10671. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10672. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10673. }
  10674. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  10675. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10676. }
  10677. if m.FieldCleared(compapiasynctask.FieldModel) {
  10678. fields = append(fields, compapiasynctask.FieldModel)
  10679. }
  10680. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10681. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10682. }
  10683. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10684. fields = append(fields, compapiasynctask.FieldRetryCount)
  10685. }
  10686. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10687. fields = append(fields, compapiasynctask.FieldLastError)
  10688. }
  10689. return fields
  10690. }
  10691. // FieldCleared returns a boolean indicating if a field with the given name was
  10692. // cleared in this mutation.
  10693. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10694. _, ok := m.clearedFields[name]
  10695. return ok
  10696. }
  10697. // ClearField clears the value of the field with the given name. It returns an
  10698. // error if the field is not defined in the schema.
  10699. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10700. switch name {
  10701. case compapiasynctask.FieldChatID:
  10702. m.ClearChatID()
  10703. return nil
  10704. case compapiasynctask.FieldResponseChatItemID:
  10705. m.ClearResponseChatItemID()
  10706. return nil
  10707. case compapiasynctask.FieldResponseRaw:
  10708. m.ClearResponseRaw()
  10709. return nil
  10710. case compapiasynctask.FieldCallbackResponseRaw:
  10711. m.ClearCallbackResponseRaw()
  10712. return nil
  10713. case compapiasynctask.FieldModel:
  10714. m.ClearModel()
  10715. return nil
  10716. case compapiasynctask.FieldTaskStatus:
  10717. m.ClearTaskStatus()
  10718. return nil
  10719. case compapiasynctask.FieldRetryCount:
  10720. m.ClearRetryCount()
  10721. return nil
  10722. case compapiasynctask.FieldLastError:
  10723. m.ClearLastError()
  10724. return nil
  10725. }
  10726. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10727. }
  10728. // ResetField resets all changes in the mutation for the field with the given name.
  10729. // It returns an error if the field is not defined in the schema.
  10730. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10731. switch name {
  10732. case compapiasynctask.FieldCreatedAt:
  10733. m.ResetCreatedAt()
  10734. return nil
  10735. case compapiasynctask.FieldUpdatedAt:
  10736. m.ResetUpdatedAt()
  10737. return nil
  10738. case compapiasynctask.FieldAuthToken:
  10739. m.ResetAuthToken()
  10740. return nil
  10741. case compapiasynctask.FieldEventType:
  10742. m.ResetEventType()
  10743. return nil
  10744. case compapiasynctask.FieldChatID:
  10745. m.ResetChatID()
  10746. return nil
  10747. case compapiasynctask.FieldResponseChatItemID:
  10748. m.ResetResponseChatItemID()
  10749. return nil
  10750. case compapiasynctask.FieldOrganizationID:
  10751. m.ResetOrganizationID()
  10752. return nil
  10753. case compapiasynctask.FieldOpenaiBase:
  10754. m.ResetOpenaiBase()
  10755. return nil
  10756. case compapiasynctask.FieldOpenaiKey:
  10757. m.ResetOpenaiKey()
  10758. return nil
  10759. case compapiasynctask.FieldRequestRaw:
  10760. m.ResetRequestRaw()
  10761. return nil
  10762. case compapiasynctask.FieldResponseRaw:
  10763. m.ResetResponseRaw()
  10764. return nil
  10765. case compapiasynctask.FieldCallbackURL:
  10766. m.ResetCallbackURL()
  10767. return nil
  10768. case compapiasynctask.FieldCallbackResponseRaw:
  10769. m.ResetCallbackResponseRaw()
  10770. return nil
  10771. case compapiasynctask.FieldModel:
  10772. m.ResetModel()
  10773. return nil
  10774. case compapiasynctask.FieldTaskStatus:
  10775. m.ResetTaskStatus()
  10776. return nil
  10777. case compapiasynctask.FieldRetryCount:
  10778. m.ResetRetryCount()
  10779. return nil
  10780. case compapiasynctask.FieldLastError:
  10781. m.ResetLastError()
  10782. return nil
  10783. }
  10784. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10785. }
  10786. // AddedEdges returns all edge names that were set/added in this mutation.
  10787. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10788. edges := make([]string, 0, 0)
  10789. return edges
  10790. }
  10791. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10792. // name in this mutation.
  10793. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10794. return nil
  10795. }
  10796. // RemovedEdges returns all edge names that were removed in this mutation.
  10797. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10798. edges := make([]string, 0, 0)
  10799. return edges
  10800. }
  10801. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10802. // the given name in this mutation.
  10803. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10804. return nil
  10805. }
  10806. // ClearedEdges returns all edge names that were cleared in this mutation.
  10807. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10808. edges := make([]string, 0, 0)
  10809. return edges
  10810. }
  10811. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10812. // was cleared in this mutation.
  10813. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10814. return false
  10815. }
  10816. // ClearEdge clears the value of the edge with the given name. It returns an error
  10817. // if that edge is not defined in the schema.
  10818. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10819. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10820. }
  10821. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10822. // It returns an error if the edge is not defined in the schema.
  10823. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10824. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10825. }
  10826. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10827. type ContactMutation struct {
  10828. config
  10829. op Op
  10830. typ string
  10831. id *uint64
  10832. created_at *time.Time
  10833. updated_at *time.Time
  10834. status *uint8
  10835. addstatus *int8
  10836. deleted_at *time.Time
  10837. wx_wxid *string
  10838. _type *int
  10839. add_type *int
  10840. wxid *string
  10841. account *string
  10842. nickname *string
  10843. markname *string
  10844. headimg *string
  10845. sex *int
  10846. addsex *int
  10847. starrole *string
  10848. dontseeit *int
  10849. adddontseeit *int
  10850. dontseeme *int
  10851. adddontseeme *int
  10852. lag *string
  10853. gid *string
  10854. gname *string
  10855. v3 *string
  10856. organization_id *uint64
  10857. addorganization_id *int64
  10858. ctype *uint64
  10859. addctype *int64
  10860. cage *int
  10861. addcage *int
  10862. cname *string
  10863. carea *string
  10864. cbirthday *string
  10865. cbirtharea *string
  10866. cidcard_no *string
  10867. ctitle *string
  10868. cc *string
  10869. phone *string
  10870. clearedFields map[string]struct{}
  10871. contact_relationships map[uint64]struct{}
  10872. removedcontact_relationships map[uint64]struct{}
  10873. clearedcontact_relationships bool
  10874. contact_fields map[uint64]struct{}
  10875. removedcontact_fields map[uint64]struct{}
  10876. clearedcontact_fields bool
  10877. contact_messages map[uint64]struct{}
  10878. removedcontact_messages map[uint64]struct{}
  10879. clearedcontact_messages bool
  10880. done bool
  10881. oldValue func(context.Context) (*Contact, error)
  10882. predicates []predicate.Contact
  10883. }
  10884. var _ ent.Mutation = (*ContactMutation)(nil)
  10885. // contactOption allows management of the mutation configuration using functional options.
  10886. type contactOption func(*ContactMutation)
  10887. // newContactMutation creates new mutation for the Contact entity.
  10888. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10889. m := &ContactMutation{
  10890. config: c,
  10891. op: op,
  10892. typ: TypeContact,
  10893. clearedFields: make(map[string]struct{}),
  10894. }
  10895. for _, opt := range opts {
  10896. opt(m)
  10897. }
  10898. return m
  10899. }
  10900. // withContactID sets the ID field of the mutation.
  10901. func withContactID(id uint64) contactOption {
  10902. return func(m *ContactMutation) {
  10903. var (
  10904. err error
  10905. once sync.Once
  10906. value *Contact
  10907. )
  10908. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10909. once.Do(func() {
  10910. if m.done {
  10911. err = errors.New("querying old values post mutation is not allowed")
  10912. } else {
  10913. value, err = m.Client().Contact.Get(ctx, id)
  10914. }
  10915. })
  10916. return value, err
  10917. }
  10918. m.id = &id
  10919. }
  10920. }
  10921. // withContact sets the old Contact of the mutation.
  10922. func withContact(node *Contact) contactOption {
  10923. return func(m *ContactMutation) {
  10924. m.oldValue = func(context.Context) (*Contact, error) {
  10925. return node, nil
  10926. }
  10927. m.id = &node.ID
  10928. }
  10929. }
  10930. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10931. // executed in a transaction (ent.Tx), a transactional client is returned.
  10932. func (m ContactMutation) Client() *Client {
  10933. client := &Client{config: m.config}
  10934. client.init()
  10935. return client
  10936. }
  10937. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10938. // it returns an error otherwise.
  10939. func (m ContactMutation) Tx() (*Tx, error) {
  10940. if _, ok := m.driver.(*txDriver); !ok {
  10941. return nil, errors.New("ent: mutation is not running in a transaction")
  10942. }
  10943. tx := &Tx{config: m.config}
  10944. tx.init()
  10945. return tx, nil
  10946. }
  10947. // SetID sets the value of the id field. Note that this
  10948. // operation is only accepted on creation of Contact entities.
  10949. func (m *ContactMutation) SetID(id uint64) {
  10950. m.id = &id
  10951. }
  10952. // ID returns the ID value in the mutation. Note that the ID is only available
  10953. // if it was provided to the builder or after it was returned from the database.
  10954. func (m *ContactMutation) ID() (id uint64, exists bool) {
  10955. if m.id == nil {
  10956. return
  10957. }
  10958. return *m.id, true
  10959. }
  10960. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10961. // That means, if the mutation is applied within a transaction with an isolation level such
  10962. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10963. // or updated by the mutation.
  10964. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  10965. switch {
  10966. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10967. id, exists := m.ID()
  10968. if exists {
  10969. return []uint64{id}, nil
  10970. }
  10971. fallthrough
  10972. case m.op.Is(OpUpdate | OpDelete):
  10973. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  10974. default:
  10975. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10976. }
  10977. }
  10978. // SetCreatedAt sets the "created_at" field.
  10979. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  10980. m.created_at = &t
  10981. }
  10982. // CreatedAt returns the value of the "created_at" field in the mutation.
  10983. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  10984. v := m.created_at
  10985. if v == nil {
  10986. return
  10987. }
  10988. return *v, true
  10989. }
  10990. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  10991. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10993. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10994. if !m.op.Is(OpUpdateOne) {
  10995. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10996. }
  10997. if m.id == nil || m.oldValue == nil {
  10998. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10999. }
  11000. oldValue, err := m.oldValue(ctx)
  11001. if err != nil {
  11002. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11003. }
  11004. return oldValue.CreatedAt, nil
  11005. }
  11006. // ResetCreatedAt resets all changes to the "created_at" field.
  11007. func (m *ContactMutation) ResetCreatedAt() {
  11008. m.created_at = nil
  11009. }
  11010. // SetUpdatedAt sets the "updated_at" field.
  11011. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  11012. m.updated_at = &t
  11013. }
  11014. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11015. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  11016. v := m.updated_at
  11017. if v == nil {
  11018. return
  11019. }
  11020. return *v, true
  11021. }
  11022. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  11023. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11025. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11026. if !m.op.Is(OpUpdateOne) {
  11027. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11028. }
  11029. if m.id == nil || m.oldValue == nil {
  11030. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11031. }
  11032. oldValue, err := m.oldValue(ctx)
  11033. if err != nil {
  11034. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11035. }
  11036. return oldValue.UpdatedAt, nil
  11037. }
  11038. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11039. func (m *ContactMutation) ResetUpdatedAt() {
  11040. m.updated_at = nil
  11041. }
  11042. // SetStatus sets the "status" field.
  11043. func (m *ContactMutation) SetStatus(u uint8) {
  11044. m.status = &u
  11045. m.addstatus = nil
  11046. }
  11047. // Status returns the value of the "status" field in the mutation.
  11048. func (m *ContactMutation) Status() (r uint8, exists bool) {
  11049. v := m.status
  11050. if v == nil {
  11051. return
  11052. }
  11053. return *v, true
  11054. }
  11055. // OldStatus returns the old "status" field's value of the Contact entity.
  11056. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11058. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11059. if !m.op.Is(OpUpdateOne) {
  11060. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11061. }
  11062. if m.id == nil || m.oldValue == nil {
  11063. return v, errors.New("OldStatus requires an ID field in the mutation")
  11064. }
  11065. oldValue, err := m.oldValue(ctx)
  11066. if err != nil {
  11067. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11068. }
  11069. return oldValue.Status, nil
  11070. }
  11071. // AddStatus adds u to the "status" field.
  11072. func (m *ContactMutation) AddStatus(u int8) {
  11073. if m.addstatus != nil {
  11074. *m.addstatus += u
  11075. } else {
  11076. m.addstatus = &u
  11077. }
  11078. }
  11079. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11080. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  11081. v := m.addstatus
  11082. if v == nil {
  11083. return
  11084. }
  11085. return *v, true
  11086. }
  11087. // ClearStatus clears the value of the "status" field.
  11088. func (m *ContactMutation) ClearStatus() {
  11089. m.status = nil
  11090. m.addstatus = nil
  11091. m.clearedFields[contact.FieldStatus] = struct{}{}
  11092. }
  11093. // StatusCleared returns if the "status" field was cleared in this mutation.
  11094. func (m *ContactMutation) StatusCleared() bool {
  11095. _, ok := m.clearedFields[contact.FieldStatus]
  11096. return ok
  11097. }
  11098. // ResetStatus resets all changes to the "status" field.
  11099. func (m *ContactMutation) ResetStatus() {
  11100. m.status = nil
  11101. m.addstatus = nil
  11102. delete(m.clearedFields, contact.FieldStatus)
  11103. }
  11104. // SetDeletedAt sets the "deleted_at" field.
  11105. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  11106. m.deleted_at = &t
  11107. }
  11108. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11109. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  11110. v := m.deleted_at
  11111. if v == nil {
  11112. return
  11113. }
  11114. return *v, true
  11115. }
  11116. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  11117. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11119. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11120. if !m.op.Is(OpUpdateOne) {
  11121. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11122. }
  11123. if m.id == nil || m.oldValue == nil {
  11124. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11125. }
  11126. oldValue, err := m.oldValue(ctx)
  11127. if err != nil {
  11128. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11129. }
  11130. return oldValue.DeletedAt, nil
  11131. }
  11132. // ClearDeletedAt clears the value of the "deleted_at" field.
  11133. func (m *ContactMutation) ClearDeletedAt() {
  11134. m.deleted_at = nil
  11135. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  11136. }
  11137. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11138. func (m *ContactMutation) DeletedAtCleared() bool {
  11139. _, ok := m.clearedFields[contact.FieldDeletedAt]
  11140. return ok
  11141. }
  11142. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11143. func (m *ContactMutation) ResetDeletedAt() {
  11144. m.deleted_at = nil
  11145. delete(m.clearedFields, contact.FieldDeletedAt)
  11146. }
  11147. // SetWxWxid sets the "wx_wxid" field.
  11148. func (m *ContactMutation) SetWxWxid(s string) {
  11149. m.wx_wxid = &s
  11150. }
  11151. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11152. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  11153. v := m.wx_wxid
  11154. if v == nil {
  11155. return
  11156. }
  11157. return *v, true
  11158. }
  11159. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  11160. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11162. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11163. if !m.op.Is(OpUpdateOne) {
  11164. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11165. }
  11166. if m.id == nil || m.oldValue == nil {
  11167. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11168. }
  11169. oldValue, err := m.oldValue(ctx)
  11170. if err != nil {
  11171. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11172. }
  11173. return oldValue.WxWxid, nil
  11174. }
  11175. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11176. func (m *ContactMutation) ResetWxWxid() {
  11177. m.wx_wxid = nil
  11178. }
  11179. // SetType sets the "type" field.
  11180. func (m *ContactMutation) SetType(i int) {
  11181. m._type = &i
  11182. m.add_type = nil
  11183. }
  11184. // GetType returns the value of the "type" field in the mutation.
  11185. func (m *ContactMutation) GetType() (r int, exists bool) {
  11186. v := m._type
  11187. if v == nil {
  11188. return
  11189. }
  11190. return *v, true
  11191. }
  11192. // OldType returns the old "type" field's value of the Contact entity.
  11193. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11195. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  11196. if !m.op.Is(OpUpdateOne) {
  11197. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11198. }
  11199. if m.id == nil || m.oldValue == nil {
  11200. return v, errors.New("OldType requires an ID field in the mutation")
  11201. }
  11202. oldValue, err := m.oldValue(ctx)
  11203. if err != nil {
  11204. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11205. }
  11206. return oldValue.Type, nil
  11207. }
  11208. // AddType adds i to the "type" field.
  11209. func (m *ContactMutation) AddType(i int) {
  11210. if m.add_type != nil {
  11211. *m.add_type += i
  11212. } else {
  11213. m.add_type = &i
  11214. }
  11215. }
  11216. // AddedType returns the value that was added to the "type" field in this mutation.
  11217. func (m *ContactMutation) AddedType() (r int, exists bool) {
  11218. v := m.add_type
  11219. if v == nil {
  11220. return
  11221. }
  11222. return *v, true
  11223. }
  11224. // ClearType clears the value of the "type" field.
  11225. func (m *ContactMutation) ClearType() {
  11226. m._type = nil
  11227. m.add_type = nil
  11228. m.clearedFields[contact.FieldType] = struct{}{}
  11229. }
  11230. // TypeCleared returns if the "type" field was cleared in this mutation.
  11231. func (m *ContactMutation) TypeCleared() bool {
  11232. _, ok := m.clearedFields[contact.FieldType]
  11233. return ok
  11234. }
  11235. // ResetType resets all changes to the "type" field.
  11236. func (m *ContactMutation) ResetType() {
  11237. m._type = nil
  11238. m.add_type = nil
  11239. delete(m.clearedFields, contact.FieldType)
  11240. }
  11241. // SetWxid sets the "wxid" field.
  11242. func (m *ContactMutation) SetWxid(s string) {
  11243. m.wxid = &s
  11244. }
  11245. // Wxid returns the value of the "wxid" field in the mutation.
  11246. func (m *ContactMutation) Wxid() (r string, exists bool) {
  11247. v := m.wxid
  11248. if v == nil {
  11249. return
  11250. }
  11251. return *v, true
  11252. }
  11253. // OldWxid returns the old "wxid" field's value of the Contact entity.
  11254. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11256. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  11257. if !m.op.Is(OpUpdateOne) {
  11258. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11259. }
  11260. if m.id == nil || m.oldValue == nil {
  11261. return v, errors.New("OldWxid requires an ID field in the mutation")
  11262. }
  11263. oldValue, err := m.oldValue(ctx)
  11264. if err != nil {
  11265. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11266. }
  11267. return oldValue.Wxid, nil
  11268. }
  11269. // ResetWxid resets all changes to the "wxid" field.
  11270. func (m *ContactMutation) ResetWxid() {
  11271. m.wxid = nil
  11272. }
  11273. // SetAccount sets the "account" field.
  11274. func (m *ContactMutation) SetAccount(s string) {
  11275. m.account = &s
  11276. }
  11277. // Account returns the value of the "account" field in the mutation.
  11278. func (m *ContactMutation) Account() (r string, exists bool) {
  11279. v := m.account
  11280. if v == nil {
  11281. return
  11282. }
  11283. return *v, true
  11284. }
  11285. // OldAccount returns the old "account" field's value of the Contact entity.
  11286. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11288. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  11289. if !m.op.Is(OpUpdateOne) {
  11290. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11291. }
  11292. if m.id == nil || m.oldValue == nil {
  11293. return v, errors.New("OldAccount requires an ID field in the mutation")
  11294. }
  11295. oldValue, err := m.oldValue(ctx)
  11296. if err != nil {
  11297. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11298. }
  11299. return oldValue.Account, nil
  11300. }
  11301. // ResetAccount resets all changes to the "account" field.
  11302. func (m *ContactMutation) ResetAccount() {
  11303. m.account = nil
  11304. }
  11305. // SetNickname sets the "nickname" field.
  11306. func (m *ContactMutation) SetNickname(s string) {
  11307. m.nickname = &s
  11308. }
  11309. // Nickname returns the value of the "nickname" field in the mutation.
  11310. func (m *ContactMutation) Nickname() (r string, exists bool) {
  11311. v := m.nickname
  11312. if v == nil {
  11313. return
  11314. }
  11315. return *v, true
  11316. }
  11317. // OldNickname returns the old "nickname" field's value of the Contact entity.
  11318. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11320. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  11321. if !m.op.Is(OpUpdateOne) {
  11322. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11323. }
  11324. if m.id == nil || m.oldValue == nil {
  11325. return v, errors.New("OldNickname requires an ID field in the mutation")
  11326. }
  11327. oldValue, err := m.oldValue(ctx)
  11328. if err != nil {
  11329. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11330. }
  11331. return oldValue.Nickname, nil
  11332. }
  11333. // ResetNickname resets all changes to the "nickname" field.
  11334. func (m *ContactMutation) ResetNickname() {
  11335. m.nickname = nil
  11336. }
  11337. // SetMarkname sets the "markname" field.
  11338. func (m *ContactMutation) SetMarkname(s string) {
  11339. m.markname = &s
  11340. }
  11341. // Markname returns the value of the "markname" field in the mutation.
  11342. func (m *ContactMutation) Markname() (r string, exists bool) {
  11343. v := m.markname
  11344. if v == nil {
  11345. return
  11346. }
  11347. return *v, true
  11348. }
  11349. // OldMarkname returns the old "markname" field's value of the Contact entity.
  11350. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11352. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  11353. if !m.op.Is(OpUpdateOne) {
  11354. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  11355. }
  11356. if m.id == nil || m.oldValue == nil {
  11357. return v, errors.New("OldMarkname requires an ID field in the mutation")
  11358. }
  11359. oldValue, err := m.oldValue(ctx)
  11360. if err != nil {
  11361. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  11362. }
  11363. return oldValue.Markname, nil
  11364. }
  11365. // ResetMarkname resets all changes to the "markname" field.
  11366. func (m *ContactMutation) ResetMarkname() {
  11367. m.markname = nil
  11368. }
  11369. // SetHeadimg sets the "headimg" field.
  11370. func (m *ContactMutation) SetHeadimg(s string) {
  11371. m.headimg = &s
  11372. }
  11373. // Headimg returns the value of the "headimg" field in the mutation.
  11374. func (m *ContactMutation) Headimg() (r string, exists bool) {
  11375. v := m.headimg
  11376. if v == nil {
  11377. return
  11378. }
  11379. return *v, true
  11380. }
  11381. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  11382. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11384. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  11385. if !m.op.Is(OpUpdateOne) {
  11386. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  11387. }
  11388. if m.id == nil || m.oldValue == nil {
  11389. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  11390. }
  11391. oldValue, err := m.oldValue(ctx)
  11392. if err != nil {
  11393. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  11394. }
  11395. return oldValue.Headimg, nil
  11396. }
  11397. // ResetHeadimg resets all changes to the "headimg" field.
  11398. func (m *ContactMutation) ResetHeadimg() {
  11399. m.headimg = nil
  11400. }
  11401. // SetSex sets the "sex" field.
  11402. func (m *ContactMutation) SetSex(i int) {
  11403. m.sex = &i
  11404. m.addsex = nil
  11405. }
  11406. // Sex returns the value of the "sex" field in the mutation.
  11407. func (m *ContactMutation) Sex() (r int, exists bool) {
  11408. v := m.sex
  11409. if v == nil {
  11410. return
  11411. }
  11412. return *v, true
  11413. }
  11414. // OldSex returns the old "sex" field's value of the Contact entity.
  11415. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11417. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  11418. if !m.op.Is(OpUpdateOne) {
  11419. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  11420. }
  11421. if m.id == nil || m.oldValue == nil {
  11422. return v, errors.New("OldSex requires an ID field in the mutation")
  11423. }
  11424. oldValue, err := m.oldValue(ctx)
  11425. if err != nil {
  11426. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  11427. }
  11428. return oldValue.Sex, nil
  11429. }
  11430. // AddSex adds i to the "sex" field.
  11431. func (m *ContactMutation) AddSex(i int) {
  11432. if m.addsex != nil {
  11433. *m.addsex += i
  11434. } else {
  11435. m.addsex = &i
  11436. }
  11437. }
  11438. // AddedSex returns the value that was added to the "sex" field in this mutation.
  11439. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  11440. v := m.addsex
  11441. if v == nil {
  11442. return
  11443. }
  11444. return *v, true
  11445. }
  11446. // ResetSex resets all changes to the "sex" field.
  11447. func (m *ContactMutation) ResetSex() {
  11448. m.sex = nil
  11449. m.addsex = nil
  11450. }
  11451. // SetStarrole sets the "starrole" field.
  11452. func (m *ContactMutation) SetStarrole(s string) {
  11453. m.starrole = &s
  11454. }
  11455. // Starrole returns the value of the "starrole" field in the mutation.
  11456. func (m *ContactMutation) Starrole() (r string, exists bool) {
  11457. v := m.starrole
  11458. if v == nil {
  11459. return
  11460. }
  11461. return *v, true
  11462. }
  11463. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  11464. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11466. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  11467. if !m.op.Is(OpUpdateOne) {
  11468. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  11469. }
  11470. if m.id == nil || m.oldValue == nil {
  11471. return v, errors.New("OldStarrole requires an ID field in the mutation")
  11472. }
  11473. oldValue, err := m.oldValue(ctx)
  11474. if err != nil {
  11475. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  11476. }
  11477. return oldValue.Starrole, nil
  11478. }
  11479. // ResetStarrole resets all changes to the "starrole" field.
  11480. func (m *ContactMutation) ResetStarrole() {
  11481. m.starrole = nil
  11482. }
  11483. // SetDontseeit sets the "dontseeit" field.
  11484. func (m *ContactMutation) SetDontseeit(i int) {
  11485. m.dontseeit = &i
  11486. m.adddontseeit = nil
  11487. }
  11488. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  11489. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  11490. v := m.dontseeit
  11491. if v == nil {
  11492. return
  11493. }
  11494. return *v, true
  11495. }
  11496. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  11497. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11499. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  11500. if !m.op.Is(OpUpdateOne) {
  11501. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  11502. }
  11503. if m.id == nil || m.oldValue == nil {
  11504. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  11505. }
  11506. oldValue, err := m.oldValue(ctx)
  11507. if err != nil {
  11508. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11509. }
  11510. return oldValue.Dontseeit, nil
  11511. }
  11512. // AddDontseeit adds i to the "dontseeit" field.
  11513. func (m *ContactMutation) AddDontseeit(i int) {
  11514. if m.adddontseeit != nil {
  11515. *m.adddontseeit += i
  11516. } else {
  11517. m.adddontseeit = &i
  11518. }
  11519. }
  11520. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11521. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11522. v := m.adddontseeit
  11523. if v == nil {
  11524. return
  11525. }
  11526. return *v, true
  11527. }
  11528. // ResetDontseeit resets all changes to the "dontseeit" field.
  11529. func (m *ContactMutation) ResetDontseeit() {
  11530. m.dontseeit = nil
  11531. m.adddontseeit = nil
  11532. }
  11533. // SetDontseeme sets the "dontseeme" field.
  11534. func (m *ContactMutation) SetDontseeme(i int) {
  11535. m.dontseeme = &i
  11536. m.adddontseeme = nil
  11537. }
  11538. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11539. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11540. v := m.dontseeme
  11541. if v == nil {
  11542. return
  11543. }
  11544. return *v, true
  11545. }
  11546. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11547. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11549. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11550. if !m.op.Is(OpUpdateOne) {
  11551. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11552. }
  11553. if m.id == nil || m.oldValue == nil {
  11554. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11555. }
  11556. oldValue, err := m.oldValue(ctx)
  11557. if err != nil {
  11558. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11559. }
  11560. return oldValue.Dontseeme, nil
  11561. }
  11562. // AddDontseeme adds i to the "dontseeme" field.
  11563. func (m *ContactMutation) AddDontseeme(i int) {
  11564. if m.adddontseeme != nil {
  11565. *m.adddontseeme += i
  11566. } else {
  11567. m.adddontseeme = &i
  11568. }
  11569. }
  11570. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11571. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11572. v := m.adddontseeme
  11573. if v == nil {
  11574. return
  11575. }
  11576. return *v, true
  11577. }
  11578. // ResetDontseeme resets all changes to the "dontseeme" field.
  11579. func (m *ContactMutation) ResetDontseeme() {
  11580. m.dontseeme = nil
  11581. m.adddontseeme = nil
  11582. }
  11583. // SetLag sets the "lag" field.
  11584. func (m *ContactMutation) SetLag(s string) {
  11585. m.lag = &s
  11586. }
  11587. // Lag returns the value of the "lag" field in the mutation.
  11588. func (m *ContactMutation) Lag() (r string, exists bool) {
  11589. v := m.lag
  11590. if v == nil {
  11591. return
  11592. }
  11593. return *v, true
  11594. }
  11595. // OldLag returns the old "lag" field's value of the Contact entity.
  11596. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11598. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11599. if !m.op.Is(OpUpdateOne) {
  11600. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11601. }
  11602. if m.id == nil || m.oldValue == nil {
  11603. return v, errors.New("OldLag requires an ID field in the mutation")
  11604. }
  11605. oldValue, err := m.oldValue(ctx)
  11606. if err != nil {
  11607. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11608. }
  11609. return oldValue.Lag, nil
  11610. }
  11611. // ResetLag resets all changes to the "lag" field.
  11612. func (m *ContactMutation) ResetLag() {
  11613. m.lag = nil
  11614. }
  11615. // SetGid sets the "gid" field.
  11616. func (m *ContactMutation) SetGid(s string) {
  11617. m.gid = &s
  11618. }
  11619. // Gid returns the value of the "gid" field in the mutation.
  11620. func (m *ContactMutation) Gid() (r string, exists bool) {
  11621. v := m.gid
  11622. if v == nil {
  11623. return
  11624. }
  11625. return *v, true
  11626. }
  11627. // OldGid returns the old "gid" field's value of the Contact entity.
  11628. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11630. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11631. if !m.op.Is(OpUpdateOne) {
  11632. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11633. }
  11634. if m.id == nil || m.oldValue == nil {
  11635. return v, errors.New("OldGid requires an ID field in the mutation")
  11636. }
  11637. oldValue, err := m.oldValue(ctx)
  11638. if err != nil {
  11639. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11640. }
  11641. return oldValue.Gid, nil
  11642. }
  11643. // ResetGid resets all changes to the "gid" field.
  11644. func (m *ContactMutation) ResetGid() {
  11645. m.gid = nil
  11646. }
  11647. // SetGname sets the "gname" field.
  11648. func (m *ContactMutation) SetGname(s string) {
  11649. m.gname = &s
  11650. }
  11651. // Gname returns the value of the "gname" field in the mutation.
  11652. func (m *ContactMutation) Gname() (r string, exists bool) {
  11653. v := m.gname
  11654. if v == nil {
  11655. return
  11656. }
  11657. return *v, true
  11658. }
  11659. // OldGname returns the old "gname" field's value of the Contact entity.
  11660. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11662. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11663. if !m.op.Is(OpUpdateOne) {
  11664. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11665. }
  11666. if m.id == nil || m.oldValue == nil {
  11667. return v, errors.New("OldGname requires an ID field in the mutation")
  11668. }
  11669. oldValue, err := m.oldValue(ctx)
  11670. if err != nil {
  11671. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11672. }
  11673. return oldValue.Gname, nil
  11674. }
  11675. // ResetGname resets all changes to the "gname" field.
  11676. func (m *ContactMutation) ResetGname() {
  11677. m.gname = nil
  11678. }
  11679. // SetV3 sets the "v3" field.
  11680. func (m *ContactMutation) SetV3(s string) {
  11681. m.v3 = &s
  11682. }
  11683. // V3 returns the value of the "v3" field in the mutation.
  11684. func (m *ContactMutation) V3() (r string, exists bool) {
  11685. v := m.v3
  11686. if v == nil {
  11687. return
  11688. }
  11689. return *v, true
  11690. }
  11691. // OldV3 returns the old "v3" field's value of the Contact entity.
  11692. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11694. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11695. if !m.op.Is(OpUpdateOne) {
  11696. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11697. }
  11698. if m.id == nil || m.oldValue == nil {
  11699. return v, errors.New("OldV3 requires an ID field in the mutation")
  11700. }
  11701. oldValue, err := m.oldValue(ctx)
  11702. if err != nil {
  11703. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11704. }
  11705. return oldValue.V3, nil
  11706. }
  11707. // ResetV3 resets all changes to the "v3" field.
  11708. func (m *ContactMutation) ResetV3() {
  11709. m.v3 = nil
  11710. }
  11711. // SetOrganizationID sets the "organization_id" field.
  11712. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11713. m.organization_id = &u
  11714. m.addorganization_id = nil
  11715. }
  11716. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11717. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11718. v := m.organization_id
  11719. if v == nil {
  11720. return
  11721. }
  11722. return *v, true
  11723. }
  11724. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11725. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11727. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11728. if !m.op.Is(OpUpdateOne) {
  11729. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11730. }
  11731. if m.id == nil || m.oldValue == nil {
  11732. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11733. }
  11734. oldValue, err := m.oldValue(ctx)
  11735. if err != nil {
  11736. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11737. }
  11738. return oldValue.OrganizationID, nil
  11739. }
  11740. // AddOrganizationID adds u to the "organization_id" field.
  11741. func (m *ContactMutation) AddOrganizationID(u int64) {
  11742. if m.addorganization_id != nil {
  11743. *m.addorganization_id += u
  11744. } else {
  11745. m.addorganization_id = &u
  11746. }
  11747. }
  11748. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11749. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11750. v := m.addorganization_id
  11751. if v == nil {
  11752. return
  11753. }
  11754. return *v, true
  11755. }
  11756. // ClearOrganizationID clears the value of the "organization_id" field.
  11757. func (m *ContactMutation) ClearOrganizationID() {
  11758. m.organization_id = nil
  11759. m.addorganization_id = nil
  11760. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11761. }
  11762. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11763. func (m *ContactMutation) OrganizationIDCleared() bool {
  11764. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11765. return ok
  11766. }
  11767. // ResetOrganizationID resets all changes to the "organization_id" field.
  11768. func (m *ContactMutation) ResetOrganizationID() {
  11769. m.organization_id = nil
  11770. m.addorganization_id = nil
  11771. delete(m.clearedFields, contact.FieldOrganizationID)
  11772. }
  11773. // SetCtype sets the "ctype" field.
  11774. func (m *ContactMutation) SetCtype(u uint64) {
  11775. m.ctype = &u
  11776. m.addctype = nil
  11777. }
  11778. // Ctype returns the value of the "ctype" field in the mutation.
  11779. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11780. v := m.ctype
  11781. if v == nil {
  11782. return
  11783. }
  11784. return *v, true
  11785. }
  11786. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11787. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11789. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11790. if !m.op.Is(OpUpdateOne) {
  11791. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11792. }
  11793. if m.id == nil || m.oldValue == nil {
  11794. return v, errors.New("OldCtype requires an ID field in the mutation")
  11795. }
  11796. oldValue, err := m.oldValue(ctx)
  11797. if err != nil {
  11798. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11799. }
  11800. return oldValue.Ctype, nil
  11801. }
  11802. // AddCtype adds u to the "ctype" field.
  11803. func (m *ContactMutation) AddCtype(u int64) {
  11804. if m.addctype != nil {
  11805. *m.addctype += u
  11806. } else {
  11807. m.addctype = &u
  11808. }
  11809. }
  11810. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11811. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11812. v := m.addctype
  11813. if v == nil {
  11814. return
  11815. }
  11816. return *v, true
  11817. }
  11818. // ResetCtype resets all changes to the "ctype" field.
  11819. func (m *ContactMutation) ResetCtype() {
  11820. m.ctype = nil
  11821. m.addctype = nil
  11822. }
  11823. // SetCage sets the "cage" field.
  11824. func (m *ContactMutation) SetCage(i int) {
  11825. m.cage = &i
  11826. m.addcage = nil
  11827. }
  11828. // Cage returns the value of the "cage" field in the mutation.
  11829. func (m *ContactMutation) Cage() (r int, exists bool) {
  11830. v := m.cage
  11831. if v == nil {
  11832. return
  11833. }
  11834. return *v, true
  11835. }
  11836. // OldCage returns the old "cage" field's value of the Contact entity.
  11837. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11839. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11840. if !m.op.Is(OpUpdateOne) {
  11841. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11842. }
  11843. if m.id == nil || m.oldValue == nil {
  11844. return v, errors.New("OldCage requires an ID field in the mutation")
  11845. }
  11846. oldValue, err := m.oldValue(ctx)
  11847. if err != nil {
  11848. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11849. }
  11850. return oldValue.Cage, nil
  11851. }
  11852. // AddCage adds i to the "cage" field.
  11853. func (m *ContactMutation) AddCage(i int) {
  11854. if m.addcage != nil {
  11855. *m.addcage += i
  11856. } else {
  11857. m.addcage = &i
  11858. }
  11859. }
  11860. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11861. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11862. v := m.addcage
  11863. if v == nil {
  11864. return
  11865. }
  11866. return *v, true
  11867. }
  11868. // ResetCage resets all changes to the "cage" field.
  11869. func (m *ContactMutation) ResetCage() {
  11870. m.cage = nil
  11871. m.addcage = nil
  11872. }
  11873. // SetCname sets the "cname" field.
  11874. func (m *ContactMutation) SetCname(s string) {
  11875. m.cname = &s
  11876. }
  11877. // Cname returns the value of the "cname" field in the mutation.
  11878. func (m *ContactMutation) Cname() (r string, exists bool) {
  11879. v := m.cname
  11880. if v == nil {
  11881. return
  11882. }
  11883. return *v, true
  11884. }
  11885. // OldCname returns the old "cname" field's value of the Contact entity.
  11886. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11888. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11889. if !m.op.Is(OpUpdateOne) {
  11890. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11891. }
  11892. if m.id == nil || m.oldValue == nil {
  11893. return v, errors.New("OldCname requires an ID field in the mutation")
  11894. }
  11895. oldValue, err := m.oldValue(ctx)
  11896. if err != nil {
  11897. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11898. }
  11899. return oldValue.Cname, nil
  11900. }
  11901. // ResetCname resets all changes to the "cname" field.
  11902. func (m *ContactMutation) ResetCname() {
  11903. m.cname = nil
  11904. }
  11905. // SetCarea sets the "carea" field.
  11906. func (m *ContactMutation) SetCarea(s string) {
  11907. m.carea = &s
  11908. }
  11909. // Carea returns the value of the "carea" field in the mutation.
  11910. func (m *ContactMutation) Carea() (r string, exists bool) {
  11911. v := m.carea
  11912. if v == nil {
  11913. return
  11914. }
  11915. return *v, true
  11916. }
  11917. // OldCarea returns the old "carea" field's value of the Contact entity.
  11918. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11920. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  11921. if !m.op.Is(OpUpdateOne) {
  11922. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  11923. }
  11924. if m.id == nil || m.oldValue == nil {
  11925. return v, errors.New("OldCarea requires an ID field in the mutation")
  11926. }
  11927. oldValue, err := m.oldValue(ctx)
  11928. if err != nil {
  11929. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  11930. }
  11931. return oldValue.Carea, nil
  11932. }
  11933. // ResetCarea resets all changes to the "carea" field.
  11934. func (m *ContactMutation) ResetCarea() {
  11935. m.carea = nil
  11936. }
  11937. // SetCbirthday sets the "cbirthday" field.
  11938. func (m *ContactMutation) SetCbirthday(s string) {
  11939. m.cbirthday = &s
  11940. }
  11941. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  11942. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  11943. v := m.cbirthday
  11944. if v == nil {
  11945. return
  11946. }
  11947. return *v, true
  11948. }
  11949. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  11950. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11952. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  11953. if !m.op.Is(OpUpdateOne) {
  11954. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  11955. }
  11956. if m.id == nil || m.oldValue == nil {
  11957. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  11958. }
  11959. oldValue, err := m.oldValue(ctx)
  11960. if err != nil {
  11961. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  11962. }
  11963. return oldValue.Cbirthday, nil
  11964. }
  11965. // ResetCbirthday resets all changes to the "cbirthday" field.
  11966. func (m *ContactMutation) ResetCbirthday() {
  11967. m.cbirthday = nil
  11968. }
  11969. // SetCbirtharea sets the "cbirtharea" field.
  11970. func (m *ContactMutation) SetCbirtharea(s string) {
  11971. m.cbirtharea = &s
  11972. }
  11973. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  11974. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  11975. v := m.cbirtharea
  11976. if v == nil {
  11977. return
  11978. }
  11979. return *v, true
  11980. }
  11981. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  11982. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11984. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  11985. if !m.op.Is(OpUpdateOne) {
  11986. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  11987. }
  11988. if m.id == nil || m.oldValue == nil {
  11989. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  11990. }
  11991. oldValue, err := m.oldValue(ctx)
  11992. if err != nil {
  11993. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  11994. }
  11995. return oldValue.Cbirtharea, nil
  11996. }
  11997. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  11998. func (m *ContactMutation) ResetCbirtharea() {
  11999. m.cbirtharea = nil
  12000. }
  12001. // SetCidcardNo sets the "cidcard_no" field.
  12002. func (m *ContactMutation) SetCidcardNo(s string) {
  12003. m.cidcard_no = &s
  12004. }
  12005. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  12006. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  12007. v := m.cidcard_no
  12008. if v == nil {
  12009. return
  12010. }
  12011. return *v, true
  12012. }
  12013. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  12014. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12016. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  12017. if !m.op.Is(OpUpdateOne) {
  12018. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  12019. }
  12020. if m.id == nil || m.oldValue == nil {
  12021. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  12022. }
  12023. oldValue, err := m.oldValue(ctx)
  12024. if err != nil {
  12025. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  12026. }
  12027. return oldValue.CidcardNo, nil
  12028. }
  12029. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  12030. func (m *ContactMutation) ResetCidcardNo() {
  12031. m.cidcard_no = nil
  12032. }
  12033. // SetCtitle sets the "ctitle" field.
  12034. func (m *ContactMutation) SetCtitle(s string) {
  12035. m.ctitle = &s
  12036. }
  12037. // Ctitle returns the value of the "ctitle" field in the mutation.
  12038. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  12039. v := m.ctitle
  12040. if v == nil {
  12041. return
  12042. }
  12043. return *v, true
  12044. }
  12045. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  12046. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12048. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  12049. if !m.op.Is(OpUpdateOne) {
  12050. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  12051. }
  12052. if m.id == nil || m.oldValue == nil {
  12053. return v, errors.New("OldCtitle requires an ID field in the mutation")
  12054. }
  12055. oldValue, err := m.oldValue(ctx)
  12056. if err != nil {
  12057. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  12058. }
  12059. return oldValue.Ctitle, nil
  12060. }
  12061. // ResetCtitle resets all changes to the "ctitle" field.
  12062. func (m *ContactMutation) ResetCtitle() {
  12063. m.ctitle = nil
  12064. }
  12065. // SetCc sets the "cc" field.
  12066. func (m *ContactMutation) SetCc(s string) {
  12067. m.cc = &s
  12068. }
  12069. // Cc returns the value of the "cc" field in the mutation.
  12070. func (m *ContactMutation) Cc() (r string, exists bool) {
  12071. v := m.cc
  12072. if v == nil {
  12073. return
  12074. }
  12075. return *v, true
  12076. }
  12077. // OldCc returns the old "cc" field's value of the Contact entity.
  12078. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12080. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  12081. if !m.op.Is(OpUpdateOne) {
  12082. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  12083. }
  12084. if m.id == nil || m.oldValue == nil {
  12085. return v, errors.New("OldCc requires an ID field in the mutation")
  12086. }
  12087. oldValue, err := m.oldValue(ctx)
  12088. if err != nil {
  12089. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  12090. }
  12091. return oldValue.Cc, nil
  12092. }
  12093. // ResetCc resets all changes to the "cc" field.
  12094. func (m *ContactMutation) ResetCc() {
  12095. m.cc = nil
  12096. }
  12097. // SetPhone sets the "phone" field.
  12098. func (m *ContactMutation) SetPhone(s string) {
  12099. m.phone = &s
  12100. }
  12101. // Phone returns the value of the "phone" field in the mutation.
  12102. func (m *ContactMutation) Phone() (r string, exists bool) {
  12103. v := m.phone
  12104. if v == nil {
  12105. return
  12106. }
  12107. return *v, true
  12108. }
  12109. // OldPhone returns the old "phone" field's value of the Contact entity.
  12110. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12112. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  12113. if !m.op.Is(OpUpdateOne) {
  12114. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  12115. }
  12116. if m.id == nil || m.oldValue == nil {
  12117. return v, errors.New("OldPhone requires an ID field in the mutation")
  12118. }
  12119. oldValue, err := m.oldValue(ctx)
  12120. if err != nil {
  12121. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  12122. }
  12123. return oldValue.Phone, nil
  12124. }
  12125. // ResetPhone resets all changes to the "phone" field.
  12126. func (m *ContactMutation) ResetPhone() {
  12127. m.phone = nil
  12128. }
  12129. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  12130. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  12131. if m.contact_relationships == nil {
  12132. m.contact_relationships = make(map[uint64]struct{})
  12133. }
  12134. for i := range ids {
  12135. m.contact_relationships[ids[i]] = struct{}{}
  12136. }
  12137. }
  12138. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  12139. func (m *ContactMutation) ClearContactRelationships() {
  12140. m.clearedcontact_relationships = true
  12141. }
  12142. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  12143. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  12144. return m.clearedcontact_relationships
  12145. }
  12146. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  12147. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  12148. if m.removedcontact_relationships == nil {
  12149. m.removedcontact_relationships = make(map[uint64]struct{})
  12150. }
  12151. for i := range ids {
  12152. delete(m.contact_relationships, ids[i])
  12153. m.removedcontact_relationships[ids[i]] = struct{}{}
  12154. }
  12155. }
  12156. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  12157. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  12158. for id := range m.removedcontact_relationships {
  12159. ids = append(ids, id)
  12160. }
  12161. return
  12162. }
  12163. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  12164. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  12165. for id := range m.contact_relationships {
  12166. ids = append(ids, id)
  12167. }
  12168. return
  12169. }
  12170. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  12171. func (m *ContactMutation) ResetContactRelationships() {
  12172. m.contact_relationships = nil
  12173. m.clearedcontact_relationships = false
  12174. m.removedcontact_relationships = nil
  12175. }
  12176. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  12177. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  12178. if m.contact_fields == nil {
  12179. m.contact_fields = make(map[uint64]struct{})
  12180. }
  12181. for i := range ids {
  12182. m.contact_fields[ids[i]] = struct{}{}
  12183. }
  12184. }
  12185. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  12186. func (m *ContactMutation) ClearContactFields() {
  12187. m.clearedcontact_fields = true
  12188. }
  12189. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  12190. func (m *ContactMutation) ContactFieldsCleared() bool {
  12191. return m.clearedcontact_fields
  12192. }
  12193. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  12194. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  12195. if m.removedcontact_fields == nil {
  12196. m.removedcontact_fields = make(map[uint64]struct{})
  12197. }
  12198. for i := range ids {
  12199. delete(m.contact_fields, ids[i])
  12200. m.removedcontact_fields[ids[i]] = struct{}{}
  12201. }
  12202. }
  12203. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  12204. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  12205. for id := range m.removedcontact_fields {
  12206. ids = append(ids, id)
  12207. }
  12208. return
  12209. }
  12210. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  12211. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  12212. for id := range m.contact_fields {
  12213. ids = append(ids, id)
  12214. }
  12215. return
  12216. }
  12217. // ResetContactFields resets all changes to the "contact_fields" edge.
  12218. func (m *ContactMutation) ResetContactFields() {
  12219. m.contact_fields = nil
  12220. m.clearedcontact_fields = false
  12221. m.removedcontact_fields = nil
  12222. }
  12223. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  12224. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  12225. if m.contact_messages == nil {
  12226. m.contact_messages = make(map[uint64]struct{})
  12227. }
  12228. for i := range ids {
  12229. m.contact_messages[ids[i]] = struct{}{}
  12230. }
  12231. }
  12232. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  12233. func (m *ContactMutation) ClearContactMessages() {
  12234. m.clearedcontact_messages = true
  12235. }
  12236. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  12237. func (m *ContactMutation) ContactMessagesCleared() bool {
  12238. return m.clearedcontact_messages
  12239. }
  12240. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  12241. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  12242. if m.removedcontact_messages == nil {
  12243. m.removedcontact_messages = make(map[uint64]struct{})
  12244. }
  12245. for i := range ids {
  12246. delete(m.contact_messages, ids[i])
  12247. m.removedcontact_messages[ids[i]] = struct{}{}
  12248. }
  12249. }
  12250. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  12251. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  12252. for id := range m.removedcontact_messages {
  12253. ids = append(ids, id)
  12254. }
  12255. return
  12256. }
  12257. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  12258. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  12259. for id := range m.contact_messages {
  12260. ids = append(ids, id)
  12261. }
  12262. return
  12263. }
  12264. // ResetContactMessages resets all changes to the "contact_messages" edge.
  12265. func (m *ContactMutation) ResetContactMessages() {
  12266. m.contact_messages = nil
  12267. m.clearedcontact_messages = false
  12268. m.removedcontact_messages = nil
  12269. }
  12270. // Where appends a list predicates to the ContactMutation builder.
  12271. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  12272. m.predicates = append(m.predicates, ps...)
  12273. }
  12274. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  12275. // users can use type-assertion to append predicates that do not depend on any generated package.
  12276. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  12277. p := make([]predicate.Contact, len(ps))
  12278. for i := range ps {
  12279. p[i] = ps[i]
  12280. }
  12281. m.Where(p...)
  12282. }
  12283. // Op returns the operation name.
  12284. func (m *ContactMutation) Op() Op {
  12285. return m.op
  12286. }
  12287. // SetOp allows setting the mutation operation.
  12288. func (m *ContactMutation) SetOp(op Op) {
  12289. m.op = op
  12290. }
  12291. // Type returns the node type of this mutation (Contact).
  12292. func (m *ContactMutation) Type() string {
  12293. return m.typ
  12294. }
  12295. // Fields returns all fields that were changed during this mutation. Note that in
  12296. // order to get all numeric fields that were incremented/decremented, call
  12297. // AddedFields().
  12298. func (m *ContactMutation) Fields() []string {
  12299. fields := make([]string, 0, 30)
  12300. if m.created_at != nil {
  12301. fields = append(fields, contact.FieldCreatedAt)
  12302. }
  12303. if m.updated_at != nil {
  12304. fields = append(fields, contact.FieldUpdatedAt)
  12305. }
  12306. if m.status != nil {
  12307. fields = append(fields, contact.FieldStatus)
  12308. }
  12309. if m.deleted_at != nil {
  12310. fields = append(fields, contact.FieldDeletedAt)
  12311. }
  12312. if m.wx_wxid != nil {
  12313. fields = append(fields, contact.FieldWxWxid)
  12314. }
  12315. if m._type != nil {
  12316. fields = append(fields, contact.FieldType)
  12317. }
  12318. if m.wxid != nil {
  12319. fields = append(fields, contact.FieldWxid)
  12320. }
  12321. if m.account != nil {
  12322. fields = append(fields, contact.FieldAccount)
  12323. }
  12324. if m.nickname != nil {
  12325. fields = append(fields, contact.FieldNickname)
  12326. }
  12327. if m.markname != nil {
  12328. fields = append(fields, contact.FieldMarkname)
  12329. }
  12330. if m.headimg != nil {
  12331. fields = append(fields, contact.FieldHeadimg)
  12332. }
  12333. if m.sex != nil {
  12334. fields = append(fields, contact.FieldSex)
  12335. }
  12336. if m.starrole != nil {
  12337. fields = append(fields, contact.FieldStarrole)
  12338. }
  12339. if m.dontseeit != nil {
  12340. fields = append(fields, contact.FieldDontseeit)
  12341. }
  12342. if m.dontseeme != nil {
  12343. fields = append(fields, contact.FieldDontseeme)
  12344. }
  12345. if m.lag != nil {
  12346. fields = append(fields, contact.FieldLag)
  12347. }
  12348. if m.gid != nil {
  12349. fields = append(fields, contact.FieldGid)
  12350. }
  12351. if m.gname != nil {
  12352. fields = append(fields, contact.FieldGname)
  12353. }
  12354. if m.v3 != nil {
  12355. fields = append(fields, contact.FieldV3)
  12356. }
  12357. if m.organization_id != nil {
  12358. fields = append(fields, contact.FieldOrganizationID)
  12359. }
  12360. if m.ctype != nil {
  12361. fields = append(fields, contact.FieldCtype)
  12362. }
  12363. if m.cage != nil {
  12364. fields = append(fields, contact.FieldCage)
  12365. }
  12366. if m.cname != nil {
  12367. fields = append(fields, contact.FieldCname)
  12368. }
  12369. if m.carea != nil {
  12370. fields = append(fields, contact.FieldCarea)
  12371. }
  12372. if m.cbirthday != nil {
  12373. fields = append(fields, contact.FieldCbirthday)
  12374. }
  12375. if m.cbirtharea != nil {
  12376. fields = append(fields, contact.FieldCbirtharea)
  12377. }
  12378. if m.cidcard_no != nil {
  12379. fields = append(fields, contact.FieldCidcardNo)
  12380. }
  12381. if m.ctitle != nil {
  12382. fields = append(fields, contact.FieldCtitle)
  12383. }
  12384. if m.cc != nil {
  12385. fields = append(fields, contact.FieldCc)
  12386. }
  12387. if m.phone != nil {
  12388. fields = append(fields, contact.FieldPhone)
  12389. }
  12390. return fields
  12391. }
  12392. // Field returns the value of a field with the given name. The second boolean
  12393. // return value indicates that this field was not set, or was not defined in the
  12394. // schema.
  12395. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  12396. switch name {
  12397. case contact.FieldCreatedAt:
  12398. return m.CreatedAt()
  12399. case contact.FieldUpdatedAt:
  12400. return m.UpdatedAt()
  12401. case contact.FieldStatus:
  12402. return m.Status()
  12403. case contact.FieldDeletedAt:
  12404. return m.DeletedAt()
  12405. case contact.FieldWxWxid:
  12406. return m.WxWxid()
  12407. case contact.FieldType:
  12408. return m.GetType()
  12409. case contact.FieldWxid:
  12410. return m.Wxid()
  12411. case contact.FieldAccount:
  12412. return m.Account()
  12413. case contact.FieldNickname:
  12414. return m.Nickname()
  12415. case contact.FieldMarkname:
  12416. return m.Markname()
  12417. case contact.FieldHeadimg:
  12418. return m.Headimg()
  12419. case contact.FieldSex:
  12420. return m.Sex()
  12421. case contact.FieldStarrole:
  12422. return m.Starrole()
  12423. case contact.FieldDontseeit:
  12424. return m.Dontseeit()
  12425. case contact.FieldDontseeme:
  12426. return m.Dontseeme()
  12427. case contact.FieldLag:
  12428. return m.Lag()
  12429. case contact.FieldGid:
  12430. return m.Gid()
  12431. case contact.FieldGname:
  12432. return m.Gname()
  12433. case contact.FieldV3:
  12434. return m.V3()
  12435. case contact.FieldOrganizationID:
  12436. return m.OrganizationID()
  12437. case contact.FieldCtype:
  12438. return m.Ctype()
  12439. case contact.FieldCage:
  12440. return m.Cage()
  12441. case contact.FieldCname:
  12442. return m.Cname()
  12443. case contact.FieldCarea:
  12444. return m.Carea()
  12445. case contact.FieldCbirthday:
  12446. return m.Cbirthday()
  12447. case contact.FieldCbirtharea:
  12448. return m.Cbirtharea()
  12449. case contact.FieldCidcardNo:
  12450. return m.CidcardNo()
  12451. case contact.FieldCtitle:
  12452. return m.Ctitle()
  12453. case contact.FieldCc:
  12454. return m.Cc()
  12455. case contact.FieldPhone:
  12456. return m.Phone()
  12457. }
  12458. return nil, false
  12459. }
  12460. // OldField returns the old value of the field from the database. An error is
  12461. // returned if the mutation operation is not UpdateOne, or the query to the
  12462. // database failed.
  12463. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12464. switch name {
  12465. case contact.FieldCreatedAt:
  12466. return m.OldCreatedAt(ctx)
  12467. case contact.FieldUpdatedAt:
  12468. return m.OldUpdatedAt(ctx)
  12469. case contact.FieldStatus:
  12470. return m.OldStatus(ctx)
  12471. case contact.FieldDeletedAt:
  12472. return m.OldDeletedAt(ctx)
  12473. case contact.FieldWxWxid:
  12474. return m.OldWxWxid(ctx)
  12475. case contact.FieldType:
  12476. return m.OldType(ctx)
  12477. case contact.FieldWxid:
  12478. return m.OldWxid(ctx)
  12479. case contact.FieldAccount:
  12480. return m.OldAccount(ctx)
  12481. case contact.FieldNickname:
  12482. return m.OldNickname(ctx)
  12483. case contact.FieldMarkname:
  12484. return m.OldMarkname(ctx)
  12485. case contact.FieldHeadimg:
  12486. return m.OldHeadimg(ctx)
  12487. case contact.FieldSex:
  12488. return m.OldSex(ctx)
  12489. case contact.FieldStarrole:
  12490. return m.OldStarrole(ctx)
  12491. case contact.FieldDontseeit:
  12492. return m.OldDontseeit(ctx)
  12493. case contact.FieldDontseeme:
  12494. return m.OldDontseeme(ctx)
  12495. case contact.FieldLag:
  12496. return m.OldLag(ctx)
  12497. case contact.FieldGid:
  12498. return m.OldGid(ctx)
  12499. case contact.FieldGname:
  12500. return m.OldGname(ctx)
  12501. case contact.FieldV3:
  12502. return m.OldV3(ctx)
  12503. case contact.FieldOrganizationID:
  12504. return m.OldOrganizationID(ctx)
  12505. case contact.FieldCtype:
  12506. return m.OldCtype(ctx)
  12507. case contact.FieldCage:
  12508. return m.OldCage(ctx)
  12509. case contact.FieldCname:
  12510. return m.OldCname(ctx)
  12511. case contact.FieldCarea:
  12512. return m.OldCarea(ctx)
  12513. case contact.FieldCbirthday:
  12514. return m.OldCbirthday(ctx)
  12515. case contact.FieldCbirtharea:
  12516. return m.OldCbirtharea(ctx)
  12517. case contact.FieldCidcardNo:
  12518. return m.OldCidcardNo(ctx)
  12519. case contact.FieldCtitle:
  12520. return m.OldCtitle(ctx)
  12521. case contact.FieldCc:
  12522. return m.OldCc(ctx)
  12523. case contact.FieldPhone:
  12524. return m.OldPhone(ctx)
  12525. }
  12526. return nil, fmt.Errorf("unknown Contact field %s", name)
  12527. }
  12528. // SetField sets the value of a field with the given name. It returns an error if
  12529. // the field is not defined in the schema, or if the type mismatched the field
  12530. // type.
  12531. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  12532. switch name {
  12533. case contact.FieldCreatedAt:
  12534. v, ok := value.(time.Time)
  12535. if !ok {
  12536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12537. }
  12538. m.SetCreatedAt(v)
  12539. return nil
  12540. case contact.FieldUpdatedAt:
  12541. v, ok := value.(time.Time)
  12542. if !ok {
  12543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12544. }
  12545. m.SetUpdatedAt(v)
  12546. return nil
  12547. case contact.FieldStatus:
  12548. v, ok := value.(uint8)
  12549. if !ok {
  12550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12551. }
  12552. m.SetStatus(v)
  12553. return nil
  12554. case contact.FieldDeletedAt:
  12555. v, ok := value.(time.Time)
  12556. if !ok {
  12557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12558. }
  12559. m.SetDeletedAt(v)
  12560. return nil
  12561. case contact.FieldWxWxid:
  12562. v, ok := value.(string)
  12563. if !ok {
  12564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12565. }
  12566. m.SetWxWxid(v)
  12567. return nil
  12568. case contact.FieldType:
  12569. v, ok := value.(int)
  12570. if !ok {
  12571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12572. }
  12573. m.SetType(v)
  12574. return nil
  12575. case contact.FieldWxid:
  12576. v, ok := value.(string)
  12577. if !ok {
  12578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12579. }
  12580. m.SetWxid(v)
  12581. return nil
  12582. case contact.FieldAccount:
  12583. v, ok := value.(string)
  12584. if !ok {
  12585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12586. }
  12587. m.SetAccount(v)
  12588. return nil
  12589. case contact.FieldNickname:
  12590. v, ok := value.(string)
  12591. if !ok {
  12592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12593. }
  12594. m.SetNickname(v)
  12595. return nil
  12596. case contact.FieldMarkname:
  12597. v, ok := value.(string)
  12598. if !ok {
  12599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12600. }
  12601. m.SetMarkname(v)
  12602. return nil
  12603. case contact.FieldHeadimg:
  12604. v, ok := value.(string)
  12605. if !ok {
  12606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12607. }
  12608. m.SetHeadimg(v)
  12609. return nil
  12610. case contact.FieldSex:
  12611. v, ok := value.(int)
  12612. if !ok {
  12613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12614. }
  12615. m.SetSex(v)
  12616. return nil
  12617. case contact.FieldStarrole:
  12618. v, ok := value.(string)
  12619. if !ok {
  12620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12621. }
  12622. m.SetStarrole(v)
  12623. return nil
  12624. case contact.FieldDontseeit:
  12625. v, ok := value.(int)
  12626. if !ok {
  12627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12628. }
  12629. m.SetDontseeit(v)
  12630. return nil
  12631. case contact.FieldDontseeme:
  12632. v, ok := value.(int)
  12633. if !ok {
  12634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12635. }
  12636. m.SetDontseeme(v)
  12637. return nil
  12638. case contact.FieldLag:
  12639. v, ok := value.(string)
  12640. if !ok {
  12641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12642. }
  12643. m.SetLag(v)
  12644. return nil
  12645. case contact.FieldGid:
  12646. v, ok := value.(string)
  12647. if !ok {
  12648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12649. }
  12650. m.SetGid(v)
  12651. return nil
  12652. case contact.FieldGname:
  12653. v, ok := value.(string)
  12654. if !ok {
  12655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12656. }
  12657. m.SetGname(v)
  12658. return nil
  12659. case contact.FieldV3:
  12660. v, ok := value.(string)
  12661. if !ok {
  12662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12663. }
  12664. m.SetV3(v)
  12665. return nil
  12666. case contact.FieldOrganizationID:
  12667. v, ok := value.(uint64)
  12668. if !ok {
  12669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12670. }
  12671. m.SetOrganizationID(v)
  12672. return nil
  12673. case contact.FieldCtype:
  12674. v, ok := value.(uint64)
  12675. if !ok {
  12676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12677. }
  12678. m.SetCtype(v)
  12679. return nil
  12680. case contact.FieldCage:
  12681. v, ok := value.(int)
  12682. if !ok {
  12683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12684. }
  12685. m.SetCage(v)
  12686. return nil
  12687. case contact.FieldCname:
  12688. v, ok := value.(string)
  12689. if !ok {
  12690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12691. }
  12692. m.SetCname(v)
  12693. return nil
  12694. case contact.FieldCarea:
  12695. v, ok := value.(string)
  12696. if !ok {
  12697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12698. }
  12699. m.SetCarea(v)
  12700. return nil
  12701. case contact.FieldCbirthday:
  12702. v, ok := value.(string)
  12703. if !ok {
  12704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12705. }
  12706. m.SetCbirthday(v)
  12707. return nil
  12708. case contact.FieldCbirtharea:
  12709. v, ok := value.(string)
  12710. if !ok {
  12711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12712. }
  12713. m.SetCbirtharea(v)
  12714. return nil
  12715. case contact.FieldCidcardNo:
  12716. v, ok := value.(string)
  12717. if !ok {
  12718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12719. }
  12720. m.SetCidcardNo(v)
  12721. return nil
  12722. case contact.FieldCtitle:
  12723. v, ok := value.(string)
  12724. if !ok {
  12725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12726. }
  12727. m.SetCtitle(v)
  12728. return nil
  12729. case contact.FieldCc:
  12730. v, ok := value.(string)
  12731. if !ok {
  12732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12733. }
  12734. m.SetCc(v)
  12735. return nil
  12736. case contact.FieldPhone:
  12737. v, ok := value.(string)
  12738. if !ok {
  12739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12740. }
  12741. m.SetPhone(v)
  12742. return nil
  12743. }
  12744. return fmt.Errorf("unknown Contact field %s", name)
  12745. }
  12746. // AddedFields returns all numeric fields that were incremented/decremented during
  12747. // this mutation.
  12748. func (m *ContactMutation) AddedFields() []string {
  12749. var fields []string
  12750. if m.addstatus != nil {
  12751. fields = append(fields, contact.FieldStatus)
  12752. }
  12753. if m.add_type != nil {
  12754. fields = append(fields, contact.FieldType)
  12755. }
  12756. if m.addsex != nil {
  12757. fields = append(fields, contact.FieldSex)
  12758. }
  12759. if m.adddontseeit != nil {
  12760. fields = append(fields, contact.FieldDontseeit)
  12761. }
  12762. if m.adddontseeme != nil {
  12763. fields = append(fields, contact.FieldDontseeme)
  12764. }
  12765. if m.addorganization_id != nil {
  12766. fields = append(fields, contact.FieldOrganizationID)
  12767. }
  12768. if m.addctype != nil {
  12769. fields = append(fields, contact.FieldCtype)
  12770. }
  12771. if m.addcage != nil {
  12772. fields = append(fields, contact.FieldCage)
  12773. }
  12774. return fields
  12775. }
  12776. // AddedField returns the numeric value that was incremented/decremented on a field
  12777. // with the given name. The second boolean return value indicates that this field
  12778. // was not set, or was not defined in the schema.
  12779. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12780. switch name {
  12781. case contact.FieldStatus:
  12782. return m.AddedStatus()
  12783. case contact.FieldType:
  12784. return m.AddedType()
  12785. case contact.FieldSex:
  12786. return m.AddedSex()
  12787. case contact.FieldDontseeit:
  12788. return m.AddedDontseeit()
  12789. case contact.FieldDontseeme:
  12790. return m.AddedDontseeme()
  12791. case contact.FieldOrganizationID:
  12792. return m.AddedOrganizationID()
  12793. case contact.FieldCtype:
  12794. return m.AddedCtype()
  12795. case contact.FieldCage:
  12796. return m.AddedCage()
  12797. }
  12798. return nil, false
  12799. }
  12800. // AddField adds the value to the field with the given name. It returns an error if
  12801. // the field is not defined in the schema, or if the type mismatched the field
  12802. // type.
  12803. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12804. switch name {
  12805. case contact.FieldStatus:
  12806. v, ok := value.(int8)
  12807. if !ok {
  12808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12809. }
  12810. m.AddStatus(v)
  12811. return nil
  12812. case contact.FieldType:
  12813. v, ok := value.(int)
  12814. if !ok {
  12815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12816. }
  12817. m.AddType(v)
  12818. return nil
  12819. case contact.FieldSex:
  12820. v, ok := value.(int)
  12821. if !ok {
  12822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12823. }
  12824. m.AddSex(v)
  12825. return nil
  12826. case contact.FieldDontseeit:
  12827. v, ok := value.(int)
  12828. if !ok {
  12829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12830. }
  12831. m.AddDontseeit(v)
  12832. return nil
  12833. case contact.FieldDontseeme:
  12834. v, ok := value.(int)
  12835. if !ok {
  12836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12837. }
  12838. m.AddDontseeme(v)
  12839. return nil
  12840. case contact.FieldOrganizationID:
  12841. v, ok := value.(int64)
  12842. if !ok {
  12843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12844. }
  12845. m.AddOrganizationID(v)
  12846. return nil
  12847. case contact.FieldCtype:
  12848. v, ok := value.(int64)
  12849. if !ok {
  12850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12851. }
  12852. m.AddCtype(v)
  12853. return nil
  12854. case contact.FieldCage:
  12855. v, ok := value.(int)
  12856. if !ok {
  12857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12858. }
  12859. m.AddCage(v)
  12860. return nil
  12861. }
  12862. return fmt.Errorf("unknown Contact numeric field %s", name)
  12863. }
  12864. // ClearedFields returns all nullable fields that were cleared during this
  12865. // mutation.
  12866. func (m *ContactMutation) ClearedFields() []string {
  12867. var fields []string
  12868. if m.FieldCleared(contact.FieldStatus) {
  12869. fields = append(fields, contact.FieldStatus)
  12870. }
  12871. if m.FieldCleared(contact.FieldDeletedAt) {
  12872. fields = append(fields, contact.FieldDeletedAt)
  12873. }
  12874. if m.FieldCleared(contact.FieldType) {
  12875. fields = append(fields, contact.FieldType)
  12876. }
  12877. if m.FieldCleared(contact.FieldOrganizationID) {
  12878. fields = append(fields, contact.FieldOrganizationID)
  12879. }
  12880. return fields
  12881. }
  12882. // FieldCleared returns a boolean indicating if a field with the given name was
  12883. // cleared in this mutation.
  12884. func (m *ContactMutation) FieldCleared(name string) bool {
  12885. _, ok := m.clearedFields[name]
  12886. return ok
  12887. }
  12888. // ClearField clears the value of the field with the given name. It returns an
  12889. // error if the field is not defined in the schema.
  12890. func (m *ContactMutation) ClearField(name string) error {
  12891. switch name {
  12892. case contact.FieldStatus:
  12893. m.ClearStatus()
  12894. return nil
  12895. case contact.FieldDeletedAt:
  12896. m.ClearDeletedAt()
  12897. return nil
  12898. case contact.FieldType:
  12899. m.ClearType()
  12900. return nil
  12901. case contact.FieldOrganizationID:
  12902. m.ClearOrganizationID()
  12903. return nil
  12904. }
  12905. return fmt.Errorf("unknown Contact nullable field %s", name)
  12906. }
  12907. // ResetField resets all changes in the mutation for the field with the given name.
  12908. // It returns an error if the field is not defined in the schema.
  12909. func (m *ContactMutation) ResetField(name string) error {
  12910. switch name {
  12911. case contact.FieldCreatedAt:
  12912. m.ResetCreatedAt()
  12913. return nil
  12914. case contact.FieldUpdatedAt:
  12915. m.ResetUpdatedAt()
  12916. return nil
  12917. case contact.FieldStatus:
  12918. m.ResetStatus()
  12919. return nil
  12920. case contact.FieldDeletedAt:
  12921. m.ResetDeletedAt()
  12922. return nil
  12923. case contact.FieldWxWxid:
  12924. m.ResetWxWxid()
  12925. return nil
  12926. case contact.FieldType:
  12927. m.ResetType()
  12928. return nil
  12929. case contact.FieldWxid:
  12930. m.ResetWxid()
  12931. return nil
  12932. case contact.FieldAccount:
  12933. m.ResetAccount()
  12934. return nil
  12935. case contact.FieldNickname:
  12936. m.ResetNickname()
  12937. return nil
  12938. case contact.FieldMarkname:
  12939. m.ResetMarkname()
  12940. return nil
  12941. case contact.FieldHeadimg:
  12942. m.ResetHeadimg()
  12943. return nil
  12944. case contact.FieldSex:
  12945. m.ResetSex()
  12946. return nil
  12947. case contact.FieldStarrole:
  12948. m.ResetStarrole()
  12949. return nil
  12950. case contact.FieldDontseeit:
  12951. m.ResetDontseeit()
  12952. return nil
  12953. case contact.FieldDontseeme:
  12954. m.ResetDontseeme()
  12955. return nil
  12956. case contact.FieldLag:
  12957. m.ResetLag()
  12958. return nil
  12959. case contact.FieldGid:
  12960. m.ResetGid()
  12961. return nil
  12962. case contact.FieldGname:
  12963. m.ResetGname()
  12964. return nil
  12965. case contact.FieldV3:
  12966. m.ResetV3()
  12967. return nil
  12968. case contact.FieldOrganizationID:
  12969. m.ResetOrganizationID()
  12970. return nil
  12971. case contact.FieldCtype:
  12972. m.ResetCtype()
  12973. return nil
  12974. case contact.FieldCage:
  12975. m.ResetCage()
  12976. return nil
  12977. case contact.FieldCname:
  12978. m.ResetCname()
  12979. return nil
  12980. case contact.FieldCarea:
  12981. m.ResetCarea()
  12982. return nil
  12983. case contact.FieldCbirthday:
  12984. m.ResetCbirthday()
  12985. return nil
  12986. case contact.FieldCbirtharea:
  12987. m.ResetCbirtharea()
  12988. return nil
  12989. case contact.FieldCidcardNo:
  12990. m.ResetCidcardNo()
  12991. return nil
  12992. case contact.FieldCtitle:
  12993. m.ResetCtitle()
  12994. return nil
  12995. case contact.FieldCc:
  12996. m.ResetCc()
  12997. return nil
  12998. case contact.FieldPhone:
  12999. m.ResetPhone()
  13000. return nil
  13001. }
  13002. return fmt.Errorf("unknown Contact field %s", name)
  13003. }
  13004. // AddedEdges returns all edge names that were set/added in this mutation.
  13005. func (m *ContactMutation) AddedEdges() []string {
  13006. edges := make([]string, 0, 3)
  13007. if m.contact_relationships != nil {
  13008. edges = append(edges, contact.EdgeContactRelationships)
  13009. }
  13010. if m.contact_fields != nil {
  13011. edges = append(edges, contact.EdgeContactFields)
  13012. }
  13013. if m.contact_messages != nil {
  13014. edges = append(edges, contact.EdgeContactMessages)
  13015. }
  13016. return edges
  13017. }
  13018. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13019. // name in this mutation.
  13020. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  13021. switch name {
  13022. case contact.EdgeContactRelationships:
  13023. ids := make([]ent.Value, 0, len(m.contact_relationships))
  13024. for id := range m.contact_relationships {
  13025. ids = append(ids, id)
  13026. }
  13027. return ids
  13028. case contact.EdgeContactFields:
  13029. ids := make([]ent.Value, 0, len(m.contact_fields))
  13030. for id := range m.contact_fields {
  13031. ids = append(ids, id)
  13032. }
  13033. return ids
  13034. case contact.EdgeContactMessages:
  13035. ids := make([]ent.Value, 0, len(m.contact_messages))
  13036. for id := range m.contact_messages {
  13037. ids = append(ids, id)
  13038. }
  13039. return ids
  13040. }
  13041. return nil
  13042. }
  13043. // RemovedEdges returns all edge names that were removed in this mutation.
  13044. func (m *ContactMutation) RemovedEdges() []string {
  13045. edges := make([]string, 0, 3)
  13046. if m.removedcontact_relationships != nil {
  13047. edges = append(edges, contact.EdgeContactRelationships)
  13048. }
  13049. if m.removedcontact_fields != nil {
  13050. edges = append(edges, contact.EdgeContactFields)
  13051. }
  13052. if m.removedcontact_messages != nil {
  13053. edges = append(edges, contact.EdgeContactMessages)
  13054. }
  13055. return edges
  13056. }
  13057. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13058. // the given name in this mutation.
  13059. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  13060. switch name {
  13061. case contact.EdgeContactRelationships:
  13062. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  13063. for id := range m.removedcontact_relationships {
  13064. ids = append(ids, id)
  13065. }
  13066. return ids
  13067. case contact.EdgeContactFields:
  13068. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  13069. for id := range m.removedcontact_fields {
  13070. ids = append(ids, id)
  13071. }
  13072. return ids
  13073. case contact.EdgeContactMessages:
  13074. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  13075. for id := range m.removedcontact_messages {
  13076. ids = append(ids, id)
  13077. }
  13078. return ids
  13079. }
  13080. return nil
  13081. }
  13082. // ClearedEdges returns all edge names that were cleared in this mutation.
  13083. func (m *ContactMutation) ClearedEdges() []string {
  13084. edges := make([]string, 0, 3)
  13085. if m.clearedcontact_relationships {
  13086. edges = append(edges, contact.EdgeContactRelationships)
  13087. }
  13088. if m.clearedcontact_fields {
  13089. edges = append(edges, contact.EdgeContactFields)
  13090. }
  13091. if m.clearedcontact_messages {
  13092. edges = append(edges, contact.EdgeContactMessages)
  13093. }
  13094. return edges
  13095. }
  13096. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13097. // was cleared in this mutation.
  13098. func (m *ContactMutation) EdgeCleared(name string) bool {
  13099. switch name {
  13100. case contact.EdgeContactRelationships:
  13101. return m.clearedcontact_relationships
  13102. case contact.EdgeContactFields:
  13103. return m.clearedcontact_fields
  13104. case contact.EdgeContactMessages:
  13105. return m.clearedcontact_messages
  13106. }
  13107. return false
  13108. }
  13109. // ClearEdge clears the value of the edge with the given name. It returns an error
  13110. // if that edge is not defined in the schema.
  13111. func (m *ContactMutation) ClearEdge(name string) error {
  13112. switch name {
  13113. }
  13114. return fmt.Errorf("unknown Contact unique edge %s", name)
  13115. }
  13116. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13117. // It returns an error if the edge is not defined in the schema.
  13118. func (m *ContactMutation) ResetEdge(name string) error {
  13119. switch name {
  13120. case contact.EdgeContactRelationships:
  13121. m.ResetContactRelationships()
  13122. return nil
  13123. case contact.EdgeContactFields:
  13124. m.ResetContactFields()
  13125. return nil
  13126. case contact.EdgeContactMessages:
  13127. m.ResetContactMessages()
  13128. return nil
  13129. }
  13130. return fmt.Errorf("unknown Contact edge %s", name)
  13131. }
  13132. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  13133. type ContactFieldMutation struct {
  13134. config
  13135. op Op
  13136. typ string
  13137. id *uint64
  13138. created_at *time.Time
  13139. updated_at *time.Time
  13140. status *uint8
  13141. addstatus *int8
  13142. deleted_at *time.Time
  13143. form_id *string
  13144. value *[]string
  13145. appendvalue []string
  13146. clearedFields map[string]struct{}
  13147. field_contact *uint64
  13148. clearedfield_contact bool
  13149. done bool
  13150. oldValue func(context.Context) (*ContactField, error)
  13151. predicates []predicate.ContactField
  13152. }
  13153. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  13154. // contactfieldOption allows management of the mutation configuration using functional options.
  13155. type contactfieldOption func(*ContactFieldMutation)
  13156. // newContactFieldMutation creates new mutation for the ContactField entity.
  13157. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  13158. m := &ContactFieldMutation{
  13159. config: c,
  13160. op: op,
  13161. typ: TypeContactField,
  13162. clearedFields: make(map[string]struct{}),
  13163. }
  13164. for _, opt := range opts {
  13165. opt(m)
  13166. }
  13167. return m
  13168. }
  13169. // withContactFieldID sets the ID field of the mutation.
  13170. func withContactFieldID(id uint64) contactfieldOption {
  13171. return func(m *ContactFieldMutation) {
  13172. var (
  13173. err error
  13174. once sync.Once
  13175. value *ContactField
  13176. )
  13177. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  13178. once.Do(func() {
  13179. if m.done {
  13180. err = errors.New("querying old values post mutation is not allowed")
  13181. } else {
  13182. value, err = m.Client().ContactField.Get(ctx, id)
  13183. }
  13184. })
  13185. return value, err
  13186. }
  13187. m.id = &id
  13188. }
  13189. }
  13190. // withContactField sets the old ContactField of the mutation.
  13191. func withContactField(node *ContactField) contactfieldOption {
  13192. return func(m *ContactFieldMutation) {
  13193. m.oldValue = func(context.Context) (*ContactField, error) {
  13194. return node, nil
  13195. }
  13196. m.id = &node.ID
  13197. }
  13198. }
  13199. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13200. // executed in a transaction (ent.Tx), a transactional client is returned.
  13201. func (m ContactFieldMutation) Client() *Client {
  13202. client := &Client{config: m.config}
  13203. client.init()
  13204. return client
  13205. }
  13206. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13207. // it returns an error otherwise.
  13208. func (m ContactFieldMutation) Tx() (*Tx, error) {
  13209. if _, ok := m.driver.(*txDriver); !ok {
  13210. return nil, errors.New("ent: mutation is not running in a transaction")
  13211. }
  13212. tx := &Tx{config: m.config}
  13213. tx.init()
  13214. return tx, nil
  13215. }
  13216. // SetID sets the value of the id field. Note that this
  13217. // operation is only accepted on creation of ContactField entities.
  13218. func (m *ContactFieldMutation) SetID(id uint64) {
  13219. m.id = &id
  13220. }
  13221. // ID returns the ID value in the mutation. Note that the ID is only available
  13222. // if it was provided to the builder or after it was returned from the database.
  13223. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  13224. if m.id == nil {
  13225. return
  13226. }
  13227. return *m.id, true
  13228. }
  13229. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13230. // That means, if the mutation is applied within a transaction with an isolation level such
  13231. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13232. // or updated by the mutation.
  13233. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  13234. switch {
  13235. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13236. id, exists := m.ID()
  13237. if exists {
  13238. return []uint64{id}, nil
  13239. }
  13240. fallthrough
  13241. case m.op.Is(OpUpdate | OpDelete):
  13242. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  13243. default:
  13244. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13245. }
  13246. }
  13247. // SetCreatedAt sets the "created_at" field.
  13248. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  13249. m.created_at = &t
  13250. }
  13251. // CreatedAt returns the value of the "created_at" field in the mutation.
  13252. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  13253. v := m.created_at
  13254. if v == nil {
  13255. return
  13256. }
  13257. return *v, true
  13258. }
  13259. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  13260. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13262. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13263. if !m.op.Is(OpUpdateOne) {
  13264. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13265. }
  13266. if m.id == nil || m.oldValue == nil {
  13267. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13268. }
  13269. oldValue, err := m.oldValue(ctx)
  13270. if err != nil {
  13271. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13272. }
  13273. return oldValue.CreatedAt, nil
  13274. }
  13275. // ResetCreatedAt resets all changes to the "created_at" field.
  13276. func (m *ContactFieldMutation) ResetCreatedAt() {
  13277. m.created_at = nil
  13278. }
  13279. // SetUpdatedAt sets the "updated_at" field.
  13280. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  13281. m.updated_at = &t
  13282. }
  13283. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13284. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  13285. v := m.updated_at
  13286. if v == nil {
  13287. return
  13288. }
  13289. return *v, true
  13290. }
  13291. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  13292. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13294. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13295. if !m.op.Is(OpUpdateOne) {
  13296. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13297. }
  13298. if m.id == nil || m.oldValue == nil {
  13299. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13300. }
  13301. oldValue, err := m.oldValue(ctx)
  13302. if err != nil {
  13303. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13304. }
  13305. return oldValue.UpdatedAt, nil
  13306. }
  13307. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13308. func (m *ContactFieldMutation) ResetUpdatedAt() {
  13309. m.updated_at = nil
  13310. }
  13311. // SetStatus sets the "status" field.
  13312. func (m *ContactFieldMutation) SetStatus(u uint8) {
  13313. m.status = &u
  13314. m.addstatus = nil
  13315. }
  13316. // Status returns the value of the "status" field in the mutation.
  13317. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  13318. v := m.status
  13319. if v == nil {
  13320. return
  13321. }
  13322. return *v, true
  13323. }
  13324. // OldStatus returns the old "status" field's value of the ContactField entity.
  13325. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13327. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13328. if !m.op.Is(OpUpdateOne) {
  13329. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13330. }
  13331. if m.id == nil || m.oldValue == nil {
  13332. return v, errors.New("OldStatus requires an ID field in the mutation")
  13333. }
  13334. oldValue, err := m.oldValue(ctx)
  13335. if err != nil {
  13336. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13337. }
  13338. return oldValue.Status, nil
  13339. }
  13340. // AddStatus adds u to the "status" field.
  13341. func (m *ContactFieldMutation) AddStatus(u int8) {
  13342. if m.addstatus != nil {
  13343. *m.addstatus += u
  13344. } else {
  13345. m.addstatus = &u
  13346. }
  13347. }
  13348. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13349. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  13350. v := m.addstatus
  13351. if v == nil {
  13352. return
  13353. }
  13354. return *v, true
  13355. }
  13356. // ClearStatus clears the value of the "status" field.
  13357. func (m *ContactFieldMutation) ClearStatus() {
  13358. m.status = nil
  13359. m.addstatus = nil
  13360. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  13361. }
  13362. // StatusCleared returns if the "status" field was cleared in this mutation.
  13363. func (m *ContactFieldMutation) StatusCleared() bool {
  13364. _, ok := m.clearedFields[contactfield.FieldStatus]
  13365. return ok
  13366. }
  13367. // ResetStatus resets all changes to the "status" field.
  13368. func (m *ContactFieldMutation) ResetStatus() {
  13369. m.status = nil
  13370. m.addstatus = nil
  13371. delete(m.clearedFields, contactfield.FieldStatus)
  13372. }
  13373. // SetDeletedAt sets the "deleted_at" field.
  13374. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  13375. m.deleted_at = &t
  13376. }
  13377. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13378. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  13379. v := m.deleted_at
  13380. if v == nil {
  13381. return
  13382. }
  13383. return *v, true
  13384. }
  13385. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  13386. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13388. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13389. if !m.op.Is(OpUpdateOne) {
  13390. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13391. }
  13392. if m.id == nil || m.oldValue == nil {
  13393. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13394. }
  13395. oldValue, err := m.oldValue(ctx)
  13396. if err != nil {
  13397. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13398. }
  13399. return oldValue.DeletedAt, nil
  13400. }
  13401. // ClearDeletedAt clears the value of the "deleted_at" field.
  13402. func (m *ContactFieldMutation) ClearDeletedAt() {
  13403. m.deleted_at = nil
  13404. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  13405. }
  13406. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13407. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  13408. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  13409. return ok
  13410. }
  13411. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13412. func (m *ContactFieldMutation) ResetDeletedAt() {
  13413. m.deleted_at = nil
  13414. delete(m.clearedFields, contactfield.FieldDeletedAt)
  13415. }
  13416. // SetContactID sets the "contact_id" field.
  13417. func (m *ContactFieldMutation) SetContactID(u uint64) {
  13418. m.field_contact = &u
  13419. }
  13420. // ContactID returns the value of the "contact_id" field in the mutation.
  13421. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  13422. v := m.field_contact
  13423. if v == nil {
  13424. return
  13425. }
  13426. return *v, true
  13427. }
  13428. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  13429. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13431. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13432. if !m.op.Is(OpUpdateOne) {
  13433. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13434. }
  13435. if m.id == nil || m.oldValue == nil {
  13436. return v, errors.New("OldContactID requires an ID field in the mutation")
  13437. }
  13438. oldValue, err := m.oldValue(ctx)
  13439. if err != nil {
  13440. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13441. }
  13442. return oldValue.ContactID, nil
  13443. }
  13444. // ResetContactID resets all changes to the "contact_id" field.
  13445. func (m *ContactFieldMutation) ResetContactID() {
  13446. m.field_contact = nil
  13447. }
  13448. // SetFormID sets the "form_id" field.
  13449. func (m *ContactFieldMutation) SetFormID(s string) {
  13450. m.form_id = &s
  13451. }
  13452. // FormID returns the value of the "form_id" field in the mutation.
  13453. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  13454. v := m.form_id
  13455. if v == nil {
  13456. return
  13457. }
  13458. return *v, true
  13459. }
  13460. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  13461. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13463. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  13464. if !m.op.Is(OpUpdateOne) {
  13465. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  13466. }
  13467. if m.id == nil || m.oldValue == nil {
  13468. return v, errors.New("OldFormID requires an ID field in the mutation")
  13469. }
  13470. oldValue, err := m.oldValue(ctx)
  13471. if err != nil {
  13472. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  13473. }
  13474. return oldValue.FormID, nil
  13475. }
  13476. // ResetFormID resets all changes to the "form_id" field.
  13477. func (m *ContactFieldMutation) ResetFormID() {
  13478. m.form_id = nil
  13479. }
  13480. // SetValue sets the "value" field.
  13481. func (m *ContactFieldMutation) SetValue(s []string) {
  13482. m.value = &s
  13483. m.appendvalue = nil
  13484. }
  13485. // Value returns the value of the "value" field in the mutation.
  13486. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  13487. v := m.value
  13488. if v == nil {
  13489. return
  13490. }
  13491. return *v, true
  13492. }
  13493. // OldValue returns the old "value" field's value of the ContactField entity.
  13494. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13496. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  13497. if !m.op.Is(OpUpdateOne) {
  13498. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  13499. }
  13500. if m.id == nil || m.oldValue == nil {
  13501. return v, errors.New("OldValue requires an ID field in the mutation")
  13502. }
  13503. oldValue, err := m.oldValue(ctx)
  13504. if err != nil {
  13505. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  13506. }
  13507. return oldValue.Value, nil
  13508. }
  13509. // AppendValue adds s to the "value" field.
  13510. func (m *ContactFieldMutation) AppendValue(s []string) {
  13511. m.appendvalue = append(m.appendvalue, s...)
  13512. }
  13513. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  13514. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  13515. if len(m.appendvalue) == 0 {
  13516. return nil, false
  13517. }
  13518. return m.appendvalue, true
  13519. }
  13520. // ResetValue resets all changes to the "value" field.
  13521. func (m *ContactFieldMutation) ResetValue() {
  13522. m.value = nil
  13523. m.appendvalue = nil
  13524. }
  13525. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  13526. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  13527. m.field_contact = &id
  13528. }
  13529. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  13530. func (m *ContactFieldMutation) ClearFieldContact() {
  13531. m.clearedfield_contact = true
  13532. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  13533. }
  13534. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  13535. func (m *ContactFieldMutation) FieldContactCleared() bool {
  13536. return m.clearedfield_contact
  13537. }
  13538. // FieldContactID returns the "field_contact" edge ID in the mutation.
  13539. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  13540. if m.field_contact != nil {
  13541. return *m.field_contact, true
  13542. }
  13543. return
  13544. }
  13545. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  13546. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13547. // FieldContactID instead. It exists only for internal usage by the builders.
  13548. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  13549. if id := m.field_contact; id != nil {
  13550. ids = append(ids, *id)
  13551. }
  13552. return
  13553. }
  13554. // ResetFieldContact resets all changes to the "field_contact" edge.
  13555. func (m *ContactFieldMutation) ResetFieldContact() {
  13556. m.field_contact = nil
  13557. m.clearedfield_contact = false
  13558. }
  13559. // Where appends a list predicates to the ContactFieldMutation builder.
  13560. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  13561. m.predicates = append(m.predicates, ps...)
  13562. }
  13563. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  13564. // users can use type-assertion to append predicates that do not depend on any generated package.
  13565. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  13566. p := make([]predicate.ContactField, len(ps))
  13567. for i := range ps {
  13568. p[i] = ps[i]
  13569. }
  13570. m.Where(p...)
  13571. }
  13572. // Op returns the operation name.
  13573. func (m *ContactFieldMutation) Op() Op {
  13574. return m.op
  13575. }
  13576. // SetOp allows setting the mutation operation.
  13577. func (m *ContactFieldMutation) SetOp(op Op) {
  13578. m.op = op
  13579. }
  13580. // Type returns the node type of this mutation (ContactField).
  13581. func (m *ContactFieldMutation) Type() string {
  13582. return m.typ
  13583. }
  13584. // Fields returns all fields that were changed during this mutation. Note that in
  13585. // order to get all numeric fields that were incremented/decremented, call
  13586. // AddedFields().
  13587. func (m *ContactFieldMutation) Fields() []string {
  13588. fields := make([]string, 0, 7)
  13589. if m.created_at != nil {
  13590. fields = append(fields, contactfield.FieldCreatedAt)
  13591. }
  13592. if m.updated_at != nil {
  13593. fields = append(fields, contactfield.FieldUpdatedAt)
  13594. }
  13595. if m.status != nil {
  13596. fields = append(fields, contactfield.FieldStatus)
  13597. }
  13598. if m.deleted_at != nil {
  13599. fields = append(fields, contactfield.FieldDeletedAt)
  13600. }
  13601. if m.field_contact != nil {
  13602. fields = append(fields, contactfield.FieldContactID)
  13603. }
  13604. if m.form_id != nil {
  13605. fields = append(fields, contactfield.FieldFormID)
  13606. }
  13607. if m.value != nil {
  13608. fields = append(fields, contactfield.FieldValue)
  13609. }
  13610. return fields
  13611. }
  13612. // Field returns the value of a field with the given name. The second boolean
  13613. // return value indicates that this field was not set, or was not defined in the
  13614. // schema.
  13615. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  13616. switch name {
  13617. case contactfield.FieldCreatedAt:
  13618. return m.CreatedAt()
  13619. case contactfield.FieldUpdatedAt:
  13620. return m.UpdatedAt()
  13621. case contactfield.FieldStatus:
  13622. return m.Status()
  13623. case contactfield.FieldDeletedAt:
  13624. return m.DeletedAt()
  13625. case contactfield.FieldContactID:
  13626. return m.ContactID()
  13627. case contactfield.FieldFormID:
  13628. return m.FormID()
  13629. case contactfield.FieldValue:
  13630. return m.Value()
  13631. }
  13632. return nil, false
  13633. }
  13634. // OldField returns the old value of the field from the database. An error is
  13635. // returned if the mutation operation is not UpdateOne, or the query to the
  13636. // database failed.
  13637. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13638. switch name {
  13639. case contactfield.FieldCreatedAt:
  13640. return m.OldCreatedAt(ctx)
  13641. case contactfield.FieldUpdatedAt:
  13642. return m.OldUpdatedAt(ctx)
  13643. case contactfield.FieldStatus:
  13644. return m.OldStatus(ctx)
  13645. case contactfield.FieldDeletedAt:
  13646. return m.OldDeletedAt(ctx)
  13647. case contactfield.FieldContactID:
  13648. return m.OldContactID(ctx)
  13649. case contactfield.FieldFormID:
  13650. return m.OldFormID(ctx)
  13651. case contactfield.FieldValue:
  13652. return m.OldValue(ctx)
  13653. }
  13654. return nil, fmt.Errorf("unknown ContactField field %s", name)
  13655. }
  13656. // SetField sets the value of a field with the given name. It returns an error if
  13657. // the field is not defined in the schema, or if the type mismatched the field
  13658. // type.
  13659. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  13660. switch name {
  13661. case contactfield.FieldCreatedAt:
  13662. v, ok := value.(time.Time)
  13663. if !ok {
  13664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13665. }
  13666. m.SetCreatedAt(v)
  13667. return nil
  13668. case contactfield.FieldUpdatedAt:
  13669. v, ok := value.(time.Time)
  13670. if !ok {
  13671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13672. }
  13673. m.SetUpdatedAt(v)
  13674. return nil
  13675. case contactfield.FieldStatus:
  13676. v, ok := value.(uint8)
  13677. if !ok {
  13678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13679. }
  13680. m.SetStatus(v)
  13681. return nil
  13682. case contactfield.FieldDeletedAt:
  13683. v, ok := value.(time.Time)
  13684. if !ok {
  13685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13686. }
  13687. m.SetDeletedAt(v)
  13688. return nil
  13689. case contactfield.FieldContactID:
  13690. v, ok := value.(uint64)
  13691. if !ok {
  13692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13693. }
  13694. m.SetContactID(v)
  13695. return nil
  13696. case contactfield.FieldFormID:
  13697. v, ok := value.(string)
  13698. if !ok {
  13699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13700. }
  13701. m.SetFormID(v)
  13702. return nil
  13703. case contactfield.FieldValue:
  13704. v, ok := value.([]string)
  13705. if !ok {
  13706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13707. }
  13708. m.SetValue(v)
  13709. return nil
  13710. }
  13711. return fmt.Errorf("unknown ContactField field %s", name)
  13712. }
  13713. // AddedFields returns all numeric fields that were incremented/decremented during
  13714. // this mutation.
  13715. func (m *ContactFieldMutation) AddedFields() []string {
  13716. var fields []string
  13717. if m.addstatus != nil {
  13718. fields = append(fields, contactfield.FieldStatus)
  13719. }
  13720. return fields
  13721. }
  13722. // AddedField returns the numeric value that was incremented/decremented on a field
  13723. // with the given name. The second boolean return value indicates that this field
  13724. // was not set, or was not defined in the schema.
  13725. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  13726. switch name {
  13727. case contactfield.FieldStatus:
  13728. return m.AddedStatus()
  13729. }
  13730. return nil, false
  13731. }
  13732. // AddField adds the value to the field with the given name. It returns an error if
  13733. // the field is not defined in the schema, or if the type mismatched the field
  13734. // type.
  13735. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  13736. switch name {
  13737. case contactfield.FieldStatus:
  13738. v, ok := value.(int8)
  13739. if !ok {
  13740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13741. }
  13742. m.AddStatus(v)
  13743. return nil
  13744. }
  13745. return fmt.Errorf("unknown ContactField numeric field %s", name)
  13746. }
  13747. // ClearedFields returns all nullable fields that were cleared during this
  13748. // mutation.
  13749. func (m *ContactFieldMutation) ClearedFields() []string {
  13750. var fields []string
  13751. if m.FieldCleared(contactfield.FieldStatus) {
  13752. fields = append(fields, contactfield.FieldStatus)
  13753. }
  13754. if m.FieldCleared(contactfield.FieldDeletedAt) {
  13755. fields = append(fields, contactfield.FieldDeletedAt)
  13756. }
  13757. return fields
  13758. }
  13759. // FieldCleared returns a boolean indicating if a field with the given name was
  13760. // cleared in this mutation.
  13761. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  13762. _, ok := m.clearedFields[name]
  13763. return ok
  13764. }
  13765. // ClearField clears the value of the field with the given name. It returns an
  13766. // error if the field is not defined in the schema.
  13767. func (m *ContactFieldMutation) ClearField(name string) error {
  13768. switch name {
  13769. case contactfield.FieldStatus:
  13770. m.ClearStatus()
  13771. return nil
  13772. case contactfield.FieldDeletedAt:
  13773. m.ClearDeletedAt()
  13774. return nil
  13775. }
  13776. return fmt.Errorf("unknown ContactField nullable field %s", name)
  13777. }
  13778. // ResetField resets all changes in the mutation for the field with the given name.
  13779. // It returns an error if the field is not defined in the schema.
  13780. func (m *ContactFieldMutation) ResetField(name string) error {
  13781. switch name {
  13782. case contactfield.FieldCreatedAt:
  13783. m.ResetCreatedAt()
  13784. return nil
  13785. case contactfield.FieldUpdatedAt:
  13786. m.ResetUpdatedAt()
  13787. return nil
  13788. case contactfield.FieldStatus:
  13789. m.ResetStatus()
  13790. return nil
  13791. case contactfield.FieldDeletedAt:
  13792. m.ResetDeletedAt()
  13793. return nil
  13794. case contactfield.FieldContactID:
  13795. m.ResetContactID()
  13796. return nil
  13797. case contactfield.FieldFormID:
  13798. m.ResetFormID()
  13799. return nil
  13800. case contactfield.FieldValue:
  13801. m.ResetValue()
  13802. return nil
  13803. }
  13804. return fmt.Errorf("unknown ContactField field %s", name)
  13805. }
  13806. // AddedEdges returns all edge names that were set/added in this mutation.
  13807. func (m *ContactFieldMutation) AddedEdges() []string {
  13808. edges := make([]string, 0, 1)
  13809. if m.field_contact != nil {
  13810. edges = append(edges, contactfield.EdgeFieldContact)
  13811. }
  13812. return edges
  13813. }
  13814. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13815. // name in this mutation.
  13816. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  13817. switch name {
  13818. case contactfield.EdgeFieldContact:
  13819. if id := m.field_contact; id != nil {
  13820. return []ent.Value{*id}
  13821. }
  13822. }
  13823. return nil
  13824. }
  13825. // RemovedEdges returns all edge names that were removed in this mutation.
  13826. func (m *ContactFieldMutation) RemovedEdges() []string {
  13827. edges := make([]string, 0, 1)
  13828. return edges
  13829. }
  13830. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13831. // the given name in this mutation.
  13832. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  13833. return nil
  13834. }
  13835. // ClearedEdges returns all edge names that were cleared in this mutation.
  13836. func (m *ContactFieldMutation) ClearedEdges() []string {
  13837. edges := make([]string, 0, 1)
  13838. if m.clearedfield_contact {
  13839. edges = append(edges, contactfield.EdgeFieldContact)
  13840. }
  13841. return edges
  13842. }
  13843. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13844. // was cleared in this mutation.
  13845. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  13846. switch name {
  13847. case contactfield.EdgeFieldContact:
  13848. return m.clearedfield_contact
  13849. }
  13850. return false
  13851. }
  13852. // ClearEdge clears the value of the edge with the given name. It returns an error
  13853. // if that edge is not defined in the schema.
  13854. func (m *ContactFieldMutation) ClearEdge(name string) error {
  13855. switch name {
  13856. case contactfield.EdgeFieldContact:
  13857. m.ClearFieldContact()
  13858. return nil
  13859. }
  13860. return fmt.Errorf("unknown ContactField unique edge %s", name)
  13861. }
  13862. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13863. // It returns an error if the edge is not defined in the schema.
  13864. func (m *ContactFieldMutation) ResetEdge(name string) error {
  13865. switch name {
  13866. case contactfield.EdgeFieldContact:
  13867. m.ResetFieldContact()
  13868. return nil
  13869. }
  13870. return fmt.Errorf("unknown ContactField edge %s", name)
  13871. }
  13872. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  13873. type ContactFieldTemplateMutation struct {
  13874. config
  13875. op Op
  13876. typ string
  13877. id *uint64
  13878. created_at *time.Time
  13879. updated_at *time.Time
  13880. status *uint8
  13881. addstatus *int8
  13882. deleted_at *time.Time
  13883. organization_id *uint64
  13884. addorganization_id *int64
  13885. template *[]custom_types.ContactFieldTemplate
  13886. appendtemplate []custom_types.ContactFieldTemplate
  13887. clearedFields map[string]struct{}
  13888. done bool
  13889. oldValue func(context.Context) (*ContactFieldTemplate, error)
  13890. predicates []predicate.ContactFieldTemplate
  13891. }
  13892. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  13893. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  13894. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  13895. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  13896. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  13897. m := &ContactFieldTemplateMutation{
  13898. config: c,
  13899. op: op,
  13900. typ: TypeContactFieldTemplate,
  13901. clearedFields: make(map[string]struct{}),
  13902. }
  13903. for _, opt := range opts {
  13904. opt(m)
  13905. }
  13906. return m
  13907. }
  13908. // withContactFieldTemplateID sets the ID field of the mutation.
  13909. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  13910. return func(m *ContactFieldTemplateMutation) {
  13911. var (
  13912. err error
  13913. once sync.Once
  13914. value *ContactFieldTemplate
  13915. )
  13916. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  13917. once.Do(func() {
  13918. if m.done {
  13919. err = errors.New("querying old values post mutation is not allowed")
  13920. } else {
  13921. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  13922. }
  13923. })
  13924. return value, err
  13925. }
  13926. m.id = &id
  13927. }
  13928. }
  13929. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  13930. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  13931. return func(m *ContactFieldTemplateMutation) {
  13932. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  13933. return node, nil
  13934. }
  13935. m.id = &node.ID
  13936. }
  13937. }
  13938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13939. // executed in a transaction (ent.Tx), a transactional client is returned.
  13940. func (m ContactFieldTemplateMutation) Client() *Client {
  13941. client := &Client{config: m.config}
  13942. client.init()
  13943. return client
  13944. }
  13945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13946. // it returns an error otherwise.
  13947. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  13948. if _, ok := m.driver.(*txDriver); !ok {
  13949. return nil, errors.New("ent: mutation is not running in a transaction")
  13950. }
  13951. tx := &Tx{config: m.config}
  13952. tx.init()
  13953. return tx, nil
  13954. }
  13955. // SetID sets the value of the id field. Note that this
  13956. // operation is only accepted on creation of ContactFieldTemplate entities.
  13957. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  13958. m.id = &id
  13959. }
  13960. // ID returns the ID value in the mutation. Note that the ID is only available
  13961. // if it was provided to the builder or after it was returned from the database.
  13962. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  13963. if m.id == nil {
  13964. return
  13965. }
  13966. return *m.id, true
  13967. }
  13968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13969. // That means, if the mutation is applied within a transaction with an isolation level such
  13970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13971. // or updated by the mutation.
  13972. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  13973. switch {
  13974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13975. id, exists := m.ID()
  13976. if exists {
  13977. return []uint64{id}, nil
  13978. }
  13979. fallthrough
  13980. case m.op.Is(OpUpdate | OpDelete):
  13981. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  13982. default:
  13983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13984. }
  13985. }
  13986. // SetCreatedAt sets the "created_at" field.
  13987. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  13988. m.created_at = &t
  13989. }
  13990. // CreatedAt returns the value of the "created_at" field in the mutation.
  13991. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  13992. v := m.created_at
  13993. if v == nil {
  13994. return
  13995. }
  13996. return *v, true
  13997. }
  13998. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  13999. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14001. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14002. if !m.op.Is(OpUpdateOne) {
  14003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14004. }
  14005. if m.id == nil || m.oldValue == nil {
  14006. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14007. }
  14008. oldValue, err := m.oldValue(ctx)
  14009. if err != nil {
  14010. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14011. }
  14012. return oldValue.CreatedAt, nil
  14013. }
  14014. // ResetCreatedAt resets all changes to the "created_at" field.
  14015. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  14016. m.created_at = nil
  14017. }
  14018. // SetUpdatedAt sets the "updated_at" field.
  14019. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  14020. m.updated_at = &t
  14021. }
  14022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14023. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  14024. v := m.updated_at
  14025. if v == nil {
  14026. return
  14027. }
  14028. return *v, true
  14029. }
  14030. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  14031. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14033. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14034. if !m.op.Is(OpUpdateOne) {
  14035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14036. }
  14037. if m.id == nil || m.oldValue == nil {
  14038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14039. }
  14040. oldValue, err := m.oldValue(ctx)
  14041. if err != nil {
  14042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14043. }
  14044. return oldValue.UpdatedAt, nil
  14045. }
  14046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14047. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  14048. m.updated_at = nil
  14049. }
  14050. // SetStatus sets the "status" field.
  14051. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  14052. m.status = &u
  14053. m.addstatus = nil
  14054. }
  14055. // Status returns the value of the "status" field in the mutation.
  14056. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  14057. v := m.status
  14058. if v == nil {
  14059. return
  14060. }
  14061. return *v, true
  14062. }
  14063. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  14064. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14066. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14067. if !m.op.Is(OpUpdateOne) {
  14068. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14069. }
  14070. if m.id == nil || m.oldValue == nil {
  14071. return v, errors.New("OldStatus requires an ID field in the mutation")
  14072. }
  14073. oldValue, err := m.oldValue(ctx)
  14074. if err != nil {
  14075. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14076. }
  14077. return oldValue.Status, nil
  14078. }
  14079. // AddStatus adds u to the "status" field.
  14080. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  14081. if m.addstatus != nil {
  14082. *m.addstatus += u
  14083. } else {
  14084. m.addstatus = &u
  14085. }
  14086. }
  14087. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14088. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  14089. v := m.addstatus
  14090. if v == nil {
  14091. return
  14092. }
  14093. return *v, true
  14094. }
  14095. // ClearStatus clears the value of the "status" field.
  14096. func (m *ContactFieldTemplateMutation) ClearStatus() {
  14097. m.status = nil
  14098. m.addstatus = nil
  14099. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  14100. }
  14101. // StatusCleared returns if the "status" field was cleared in this mutation.
  14102. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  14103. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  14104. return ok
  14105. }
  14106. // ResetStatus resets all changes to the "status" field.
  14107. func (m *ContactFieldTemplateMutation) ResetStatus() {
  14108. m.status = nil
  14109. m.addstatus = nil
  14110. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  14111. }
  14112. // SetDeletedAt sets the "deleted_at" field.
  14113. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  14114. m.deleted_at = &t
  14115. }
  14116. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14117. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  14118. v := m.deleted_at
  14119. if v == nil {
  14120. return
  14121. }
  14122. return *v, true
  14123. }
  14124. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  14125. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14127. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14128. if !m.op.Is(OpUpdateOne) {
  14129. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14130. }
  14131. if m.id == nil || m.oldValue == nil {
  14132. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14133. }
  14134. oldValue, err := m.oldValue(ctx)
  14135. if err != nil {
  14136. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14137. }
  14138. return oldValue.DeletedAt, nil
  14139. }
  14140. // ClearDeletedAt clears the value of the "deleted_at" field.
  14141. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  14142. m.deleted_at = nil
  14143. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  14144. }
  14145. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14146. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  14147. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  14148. return ok
  14149. }
  14150. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14151. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  14152. m.deleted_at = nil
  14153. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  14154. }
  14155. // SetOrganizationID sets the "organization_id" field.
  14156. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  14157. m.organization_id = &u
  14158. m.addorganization_id = nil
  14159. }
  14160. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14161. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  14162. v := m.organization_id
  14163. if v == nil {
  14164. return
  14165. }
  14166. return *v, true
  14167. }
  14168. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  14169. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14171. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14172. if !m.op.Is(OpUpdateOne) {
  14173. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14174. }
  14175. if m.id == nil || m.oldValue == nil {
  14176. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14177. }
  14178. oldValue, err := m.oldValue(ctx)
  14179. if err != nil {
  14180. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14181. }
  14182. return oldValue.OrganizationID, nil
  14183. }
  14184. // AddOrganizationID adds u to the "organization_id" field.
  14185. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  14186. if m.addorganization_id != nil {
  14187. *m.addorganization_id += u
  14188. } else {
  14189. m.addorganization_id = &u
  14190. }
  14191. }
  14192. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14193. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  14194. v := m.addorganization_id
  14195. if v == nil {
  14196. return
  14197. }
  14198. return *v, true
  14199. }
  14200. // ResetOrganizationID resets all changes to the "organization_id" field.
  14201. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  14202. m.organization_id = nil
  14203. m.addorganization_id = nil
  14204. }
  14205. // SetTemplate sets the "template" field.
  14206. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  14207. m.template = &ctft
  14208. m.appendtemplate = nil
  14209. }
  14210. // Template returns the value of the "template" field in the mutation.
  14211. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  14212. v := m.template
  14213. if v == nil {
  14214. return
  14215. }
  14216. return *v, true
  14217. }
  14218. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  14219. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14221. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  14222. if !m.op.Is(OpUpdateOne) {
  14223. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  14224. }
  14225. if m.id == nil || m.oldValue == nil {
  14226. return v, errors.New("OldTemplate requires an ID field in the mutation")
  14227. }
  14228. oldValue, err := m.oldValue(ctx)
  14229. if err != nil {
  14230. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  14231. }
  14232. return oldValue.Template, nil
  14233. }
  14234. // AppendTemplate adds ctft to the "template" field.
  14235. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  14236. m.appendtemplate = append(m.appendtemplate, ctft...)
  14237. }
  14238. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  14239. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  14240. if len(m.appendtemplate) == 0 {
  14241. return nil, false
  14242. }
  14243. return m.appendtemplate, true
  14244. }
  14245. // ResetTemplate resets all changes to the "template" field.
  14246. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  14247. m.template = nil
  14248. m.appendtemplate = nil
  14249. }
  14250. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  14251. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  14252. m.predicates = append(m.predicates, ps...)
  14253. }
  14254. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  14255. // users can use type-assertion to append predicates that do not depend on any generated package.
  14256. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  14257. p := make([]predicate.ContactFieldTemplate, len(ps))
  14258. for i := range ps {
  14259. p[i] = ps[i]
  14260. }
  14261. m.Where(p...)
  14262. }
  14263. // Op returns the operation name.
  14264. func (m *ContactFieldTemplateMutation) Op() Op {
  14265. return m.op
  14266. }
  14267. // SetOp allows setting the mutation operation.
  14268. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  14269. m.op = op
  14270. }
  14271. // Type returns the node type of this mutation (ContactFieldTemplate).
  14272. func (m *ContactFieldTemplateMutation) Type() string {
  14273. return m.typ
  14274. }
  14275. // Fields returns all fields that were changed during this mutation. Note that in
  14276. // order to get all numeric fields that were incremented/decremented, call
  14277. // AddedFields().
  14278. func (m *ContactFieldTemplateMutation) Fields() []string {
  14279. fields := make([]string, 0, 6)
  14280. if m.created_at != nil {
  14281. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  14282. }
  14283. if m.updated_at != nil {
  14284. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  14285. }
  14286. if m.status != nil {
  14287. fields = append(fields, contactfieldtemplate.FieldStatus)
  14288. }
  14289. if m.deleted_at != nil {
  14290. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14291. }
  14292. if m.organization_id != nil {
  14293. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14294. }
  14295. if m.template != nil {
  14296. fields = append(fields, contactfieldtemplate.FieldTemplate)
  14297. }
  14298. return fields
  14299. }
  14300. // Field returns the value of a field with the given name. The second boolean
  14301. // return value indicates that this field was not set, or was not defined in the
  14302. // schema.
  14303. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  14304. switch name {
  14305. case contactfieldtemplate.FieldCreatedAt:
  14306. return m.CreatedAt()
  14307. case contactfieldtemplate.FieldUpdatedAt:
  14308. return m.UpdatedAt()
  14309. case contactfieldtemplate.FieldStatus:
  14310. return m.Status()
  14311. case contactfieldtemplate.FieldDeletedAt:
  14312. return m.DeletedAt()
  14313. case contactfieldtemplate.FieldOrganizationID:
  14314. return m.OrganizationID()
  14315. case contactfieldtemplate.FieldTemplate:
  14316. return m.Template()
  14317. }
  14318. return nil, false
  14319. }
  14320. // OldField returns the old value of the field from the database. An error is
  14321. // returned if the mutation operation is not UpdateOne, or the query to the
  14322. // database failed.
  14323. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14324. switch name {
  14325. case contactfieldtemplate.FieldCreatedAt:
  14326. return m.OldCreatedAt(ctx)
  14327. case contactfieldtemplate.FieldUpdatedAt:
  14328. return m.OldUpdatedAt(ctx)
  14329. case contactfieldtemplate.FieldStatus:
  14330. return m.OldStatus(ctx)
  14331. case contactfieldtemplate.FieldDeletedAt:
  14332. return m.OldDeletedAt(ctx)
  14333. case contactfieldtemplate.FieldOrganizationID:
  14334. return m.OldOrganizationID(ctx)
  14335. case contactfieldtemplate.FieldTemplate:
  14336. return m.OldTemplate(ctx)
  14337. }
  14338. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14339. }
  14340. // SetField sets the value of a field with the given name. It returns an error if
  14341. // the field is not defined in the schema, or if the type mismatched the field
  14342. // type.
  14343. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  14344. switch name {
  14345. case contactfieldtemplate.FieldCreatedAt:
  14346. v, ok := value.(time.Time)
  14347. if !ok {
  14348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14349. }
  14350. m.SetCreatedAt(v)
  14351. return nil
  14352. case contactfieldtemplate.FieldUpdatedAt:
  14353. v, ok := value.(time.Time)
  14354. if !ok {
  14355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14356. }
  14357. m.SetUpdatedAt(v)
  14358. return nil
  14359. case contactfieldtemplate.FieldStatus:
  14360. v, ok := value.(uint8)
  14361. if !ok {
  14362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14363. }
  14364. m.SetStatus(v)
  14365. return nil
  14366. case contactfieldtemplate.FieldDeletedAt:
  14367. v, ok := value.(time.Time)
  14368. if !ok {
  14369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14370. }
  14371. m.SetDeletedAt(v)
  14372. return nil
  14373. case contactfieldtemplate.FieldOrganizationID:
  14374. v, ok := value.(uint64)
  14375. if !ok {
  14376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14377. }
  14378. m.SetOrganizationID(v)
  14379. return nil
  14380. case contactfieldtemplate.FieldTemplate:
  14381. v, ok := value.([]custom_types.ContactFieldTemplate)
  14382. if !ok {
  14383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14384. }
  14385. m.SetTemplate(v)
  14386. return nil
  14387. }
  14388. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14389. }
  14390. // AddedFields returns all numeric fields that were incremented/decremented during
  14391. // this mutation.
  14392. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  14393. var fields []string
  14394. if m.addstatus != nil {
  14395. fields = append(fields, contactfieldtemplate.FieldStatus)
  14396. }
  14397. if m.addorganization_id != nil {
  14398. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14399. }
  14400. return fields
  14401. }
  14402. // AddedField returns the numeric value that was incremented/decremented on a field
  14403. // with the given name. The second boolean return value indicates that this field
  14404. // was not set, or was not defined in the schema.
  14405. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  14406. switch name {
  14407. case contactfieldtemplate.FieldStatus:
  14408. return m.AddedStatus()
  14409. case contactfieldtemplate.FieldOrganizationID:
  14410. return m.AddedOrganizationID()
  14411. }
  14412. return nil, false
  14413. }
  14414. // AddField adds the value to the field with the given name. It returns an error if
  14415. // the field is not defined in the schema, or if the type mismatched the field
  14416. // type.
  14417. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  14418. switch name {
  14419. case contactfieldtemplate.FieldStatus:
  14420. v, ok := value.(int8)
  14421. if !ok {
  14422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14423. }
  14424. m.AddStatus(v)
  14425. return nil
  14426. case contactfieldtemplate.FieldOrganizationID:
  14427. v, ok := value.(int64)
  14428. if !ok {
  14429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14430. }
  14431. m.AddOrganizationID(v)
  14432. return nil
  14433. }
  14434. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  14435. }
  14436. // ClearedFields returns all nullable fields that were cleared during this
  14437. // mutation.
  14438. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  14439. var fields []string
  14440. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  14441. fields = append(fields, contactfieldtemplate.FieldStatus)
  14442. }
  14443. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  14444. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14445. }
  14446. return fields
  14447. }
  14448. // FieldCleared returns a boolean indicating if a field with the given name was
  14449. // cleared in this mutation.
  14450. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  14451. _, ok := m.clearedFields[name]
  14452. return ok
  14453. }
  14454. // ClearField clears the value of the field with the given name. It returns an
  14455. // error if the field is not defined in the schema.
  14456. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  14457. switch name {
  14458. case contactfieldtemplate.FieldStatus:
  14459. m.ClearStatus()
  14460. return nil
  14461. case contactfieldtemplate.FieldDeletedAt:
  14462. m.ClearDeletedAt()
  14463. return nil
  14464. }
  14465. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  14466. }
  14467. // ResetField resets all changes in the mutation for the field with the given name.
  14468. // It returns an error if the field is not defined in the schema.
  14469. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  14470. switch name {
  14471. case contactfieldtemplate.FieldCreatedAt:
  14472. m.ResetCreatedAt()
  14473. return nil
  14474. case contactfieldtemplate.FieldUpdatedAt:
  14475. m.ResetUpdatedAt()
  14476. return nil
  14477. case contactfieldtemplate.FieldStatus:
  14478. m.ResetStatus()
  14479. return nil
  14480. case contactfieldtemplate.FieldDeletedAt:
  14481. m.ResetDeletedAt()
  14482. return nil
  14483. case contactfieldtemplate.FieldOrganizationID:
  14484. m.ResetOrganizationID()
  14485. return nil
  14486. case contactfieldtemplate.FieldTemplate:
  14487. m.ResetTemplate()
  14488. return nil
  14489. }
  14490. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14491. }
  14492. // AddedEdges returns all edge names that were set/added in this mutation.
  14493. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  14494. edges := make([]string, 0, 0)
  14495. return edges
  14496. }
  14497. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14498. // name in this mutation.
  14499. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  14500. return nil
  14501. }
  14502. // RemovedEdges returns all edge names that were removed in this mutation.
  14503. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  14504. edges := make([]string, 0, 0)
  14505. return edges
  14506. }
  14507. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14508. // the given name in this mutation.
  14509. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  14510. return nil
  14511. }
  14512. // ClearedEdges returns all edge names that were cleared in this mutation.
  14513. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  14514. edges := make([]string, 0, 0)
  14515. return edges
  14516. }
  14517. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14518. // was cleared in this mutation.
  14519. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  14520. return false
  14521. }
  14522. // ClearEdge clears the value of the edge with the given name. It returns an error
  14523. // if that edge is not defined in the schema.
  14524. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  14525. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  14526. }
  14527. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14528. // It returns an error if the edge is not defined in the schema.
  14529. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  14530. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  14531. }
  14532. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  14533. type CreditBalanceMutation struct {
  14534. config
  14535. op Op
  14536. typ string
  14537. id *uint64
  14538. created_at *time.Time
  14539. updated_at *time.Time
  14540. deleted_at *time.Time
  14541. user_id *string
  14542. balance *float32
  14543. addbalance *float32
  14544. status *int
  14545. addstatus *int
  14546. organization_id *uint64
  14547. addorganization_id *int64
  14548. clearedFields map[string]struct{}
  14549. done bool
  14550. oldValue func(context.Context) (*CreditBalance, error)
  14551. predicates []predicate.CreditBalance
  14552. }
  14553. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  14554. // creditbalanceOption allows management of the mutation configuration using functional options.
  14555. type creditbalanceOption func(*CreditBalanceMutation)
  14556. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  14557. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  14558. m := &CreditBalanceMutation{
  14559. config: c,
  14560. op: op,
  14561. typ: TypeCreditBalance,
  14562. clearedFields: make(map[string]struct{}),
  14563. }
  14564. for _, opt := range opts {
  14565. opt(m)
  14566. }
  14567. return m
  14568. }
  14569. // withCreditBalanceID sets the ID field of the mutation.
  14570. func withCreditBalanceID(id uint64) creditbalanceOption {
  14571. return func(m *CreditBalanceMutation) {
  14572. var (
  14573. err error
  14574. once sync.Once
  14575. value *CreditBalance
  14576. )
  14577. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  14578. once.Do(func() {
  14579. if m.done {
  14580. err = errors.New("querying old values post mutation is not allowed")
  14581. } else {
  14582. value, err = m.Client().CreditBalance.Get(ctx, id)
  14583. }
  14584. })
  14585. return value, err
  14586. }
  14587. m.id = &id
  14588. }
  14589. }
  14590. // withCreditBalance sets the old CreditBalance of the mutation.
  14591. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  14592. return func(m *CreditBalanceMutation) {
  14593. m.oldValue = func(context.Context) (*CreditBalance, error) {
  14594. return node, nil
  14595. }
  14596. m.id = &node.ID
  14597. }
  14598. }
  14599. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14600. // executed in a transaction (ent.Tx), a transactional client is returned.
  14601. func (m CreditBalanceMutation) Client() *Client {
  14602. client := &Client{config: m.config}
  14603. client.init()
  14604. return client
  14605. }
  14606. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14607. // it returns an error otherwise.
  14608. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  14609. if _, ok := m.driver.(*txDriver); !ok {
  14610. return nil, errors.New("ent: mutation is not running in a transaction")
  14611. }
  14612. tx := &Tx{config: m.config}
  14613. tx.init()
  14614. return tx, nil
  14615. }
  14616. // SetID sets the value of the id field. Note that this
  14617. // operation is only accepted on creation of CreditBalance entities.
  14618. func (m *CreditBalanceMutation) SetID(id uint64) {
  14619. m.id = &id
  14620. }
  14621. // ID returns the ID value in the mutation. Note that the ID is only available
  14622. // if it was provided to the builder or after it was returned from the database.
  14623. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  14624. if m.id == nil {
  14625. return
  14626. }
  14627. return *m.id, true
  14628. }
  14629. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14630. // That means, if the mutation is applied within a transaction with an isolation level such
  14631. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14632. // or updated by the mutation.
  14633. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  14634. switch {
  14635. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14636. id, exists := m.ID()
  14637. if exists {
  14638. return []uint64{id}, nil
  14639. }
  14640. fallthrough
  14641. case m.op.Is(OpUpdate | OpDelete):
  14642. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  14643. default:
  14644. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14645. }
  14646. }
  14647. // SetCreatedAt sets the "created_at" field.
  14648. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  14649. m.created_at = &t
  14650. }
  14651. // CreatedAt returns the value of the "created_at" field in the mutation.
  14652. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  14653. v := m.created_at
  14654. if v == nil {
  14655. return
  14656. }
  14657. return *v, true
  14658. }
  14659. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  14660. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14662. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14663. if !m.op.Is(OpUpdateOne) {
  14664. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14665. }
  14666. if m.id == nil || m.oldValue == nil {
  14667. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14668. }
  14669. oldValue, err := m.oldValue(ctx)
  14670. if err != nil {
  14671. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14672. }
  14673. return oldValue.CreatedAt, nil
  14674. }
  14675. // ResetCreatedAt resets all changes to the "created_at" field.
  14676. func (m *CreditBalanceMutation) ResetCreatedAt() {
  14677. m.created_at = nil
  14678. }
  14679. // SetUpdatedAt sets the "updated_at" field.
  14680. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  14681. m.updated_at = &t
  14682. }
  14683. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14684. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  14685. v := m.updated_at
  14686. if v == nil {
  14687. return
  14688. }
  14689. return *v, true
  14690. }
  14691. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  14692. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14694. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14695. if !m.op.Is(OpUpdateOne) {
  14696. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14697. }
  14698. if m.id == nil || m.oldValue == nil {
  14699. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14700. }
  14701. oldValue, err := m.oldValue(ctx)
  14702. if err != nil {
  14703. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14704. }
  14705. return oldValue.UpdatedAt, nil
  14706. }
  14707. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14708. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  14709. m.updated_at = nil
  14710. }
  14711. // SetDeletedAt sets the "deleted_at" field.
  14712. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  14713. m.deleted_at = &t
  14714. }
  14715. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14716. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  14717. v := m.deleted_at
  14718. if v == nil {
  14719. return
  14720. }
  14721. return *v, true
  14722. }
  14723. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  14724. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14726. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14727. if !m.op.Is(OpUpdateOne) {
  14728. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14729. }
  14730. if m.id == nil || m.oldValue == nil {
  14731. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14732. }
  14733. oldValue, err := m.oldValue(ctx)
  14734. if err != nil {
  14735. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14736. }
  14737. return oldValue.DeletedAt, nil
  14738. }
  14739. // ClearDeletedAt clears the value of the "deleted_at" field.
  14740. func (m *CreditBalanceMutation) ClearDeletedAt() {
  14741. m.deleted_at = nil
  14742. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  14743. }
  14744. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14745. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  14746. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  14747. return ok
  14748. }
  14749. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14750. func (m *CreditBalanceMutation) ResetDeletedAt() {
  14751. m.deleted_at = nil
  14752. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  14753. }
  14754. // SetUserID sets the "user_id" field.
  14755. func (m *CreditBalanceMutation) SetUserID(s string) {
  14756. m.user_id = &s
  14757. }
  14758. // UserID returns the value of the "user_id" field in the mutation.
  14759. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  14760. v := m.user_id
  14761. if v == nil {
  14762. return
  14763. }
  14764. return *v, true
  14765. }
  14766. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  14767. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14769. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  14770. if !m.op.Is(OpUpdateOne) {
  14771. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14772. }
  14773. if m.id == nil || m.oldValue == nil {
  14774. return v, errors.New("OldUserID requires an ID field in the mutation")
  14775. }
  14776. oldValue, err := m.oldValue(ctx)
  14777. if err != nil {
  14778. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14779. }
  14780. return oldValue.UserID, nil
  14781. }
  14782. // ClearUserID clears the value of the "user_id" field.
  14783. func (m *CreditBalanceMutation) ClearUserID() {
  14784. m.user_id = nil
  14785. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  14786. }
  14787. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14788. func (m *CreditBalanceMutation) UserIDCleared() bool {
  14789. _, ok := m.clearedFields[creditbalance.FieldUserID]
  14790. return ok
  14791. }
  14792. // ResetUserID resets all changes to the "user_id" field.
  14793. func (m *CreditBalanceMutation) ResetUserID() {
  14794. m.user_id = nil
  14795. delete(m.clearedFields, creditbalance.FieldUserID)
  14796. }
  14797. // SetBalance sets the "balance" field.
  14798. func (m *CreditBalanceMutation) SetBalance(f float32) {
  14799. m.balance = &f
  14800. m.addbalance = nil
  14801. }
  14802. // Balance returns the value of the "balance" field in the mutation.
  14803. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  14804. v := m.balance
  14805. if v == nil {
  14806. return
  14807. }
  14808. return *v, true
  14809. }
  14810. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  14811. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14813. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  14814. if !m.op.Is(OpUpdateOne) {
  14815. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  14816. }
  14817. if m.id == nil || m.oldValue == nil {
  14818. return v, errors.New("OldBalance requires an ID field in the mutation")
  14819. }
  14820. oldValue, err := m.oldValue(ctx)
  14821. if err != nil {
  14822. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  14823. }
  14824. return oldValue.Balance, nil
  14825. }
  14826. // AddBalance adds f to the "balance" field.
  14827. func (m *CreditBalanceMutation) AddBalance(f float32) {
  14828. if m.addbalance != nil {
  14829. *m.addbalance += f
  14830. } else {
  14831. m.addbalance = &f
  14832. }
  14833. }
  14834. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  14835. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  14836. v := m.addbalance
  14837. if v == nil {
  14838. return
  14839. }
  14840. return *v, true
  14841. }
  14842. // ResetBalance resets all changes to the "balance" field.
  14843. func (m *CreditBalanceMutation) ResetBalance() {
  14844. m.balance = nil
  14845. m.addbalance = nil
  14846. }
  14847. // SetStatus sets the "status" field.
  14848. func (m *CreditBalanceMutation) SetStatus(i int) {
  14849. m.status = &i
  14850. m.addstatus = nil
  14851. }
  14852. // Status returns the value of the "status" field in the mutation.
  14853. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  14854. v := m.status
  14855. if v == nil {
  14856. return
  14857. }
  14858. return *v, true
  14859. }
  14860. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  14861. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14863. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  14864. if !m.op.Is(OpUpdateOne) {
  14865. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14866. }
  14867. if m.id == nil || m.oldValue == nil {
  14868. return v, errors.New("OldStatus requires an ID field in the mutation")
  14869. }
  14870. oldValue, err := m.oldValue(ctx)
  14871. if err != nil {
  14872. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14873. }
  14874. return oldValue.Status, nil
  14875. }
  14876. // AddStatus adds i to the "status" field.
  14877. func (m *CreditBalanceMutation) AddStatus(i int) {
  14878. if m.addstatus != nil {
  14879. *m.addstatus += i
  14880. } else {
  14881. m.addstatus = &i
  14882. }
  14883. }
  14884. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14885. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  14886. v := m.addstatus
  14887. if v == nil {
  14888. return
  14889. }
  14890. return *v, true
  14891. }
  14892. // ClearStatus clears the value of the "status" field.
  14893. func (m *CreditBalanceMutation) ClearStatus() {
  14894. m.status = nil
  14895. m.addstatus = nil
  14896. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  14897. }
  14898. // StatusCleared returns if the "status" field was cleared in this mutation.
  14899. func (m *CreditBalanceMutation) StatusCleared() bool {
  14900. _, ok := m.clearedFields[creditbalance.FieldStatus]
  14901. return ok
  14902. }
  14903. // ResetStatus resets all changes to the "status" field.
  14904. func (m *CreditBalanceMutation) ResetStatus() {
  14905. m.status = nil
  14906. m.addstatus = nil
  14907. delete(m.clearedFields, creditbalance.FieldStatus)
  14908. }
  14909. // SetOrganizationID sets the "organization_id" field.
  14910. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  14911. m.organization_id = &u
  14912. m.addorganization_id = nil
  14913. }
  14914. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14915. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  14916. v := m.organization_id
  14917. if v == nil {
  14918. return
  14919. }
  14920. return *v, true
  14921. }
  14922. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  14923. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14925. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14926. if !m.op.Is(OpUpdateOne) {
  14927. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14928. }
  14929. if m.id == nil || m.oldValue == nil {
  14930. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14931. }
  14932. oldValue, err := m.oldValue(ctx)
  14933. if err != nil {
  14934. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14935. }
  14936. return oldValue.OrganizationID, nil
  14937. }
  14938. // AddOrganizationID adds u to the "organization_id" field.
  14939. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  14940. if m.addorganization_id != nil {
  14941. *m.addorganization_id += u
  14942. } else {
  14943. m.addorganization_id = &u
  14944. }
  14945. }
  14946. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14947. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  14948. v := m.addorganization_id
  14949. if v == nil {
  14950. return
  14951. }
  14952. return *v, true
  14953. }
  14954. // ClearOrganizationID clears the value of the "organization_id" field.
  14955. func (m *CreditBalanceMutation) ClearOrganizationID() {
  14956. m.organization_id = nil
  14957. m.addorganization_id = nil
  14958. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  14959. }
  14960. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14961. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  14962. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  14963. return ok
  14964. }
  14965. // ResetOrganizationID resets all changes to the "organization_id" field.
  14966. func (m *CreditBalanceMutation) ResetOrganizationID() {
  14967. m.organization_id = nil
  14968. m.addorganization_id = nil
  14969. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  14970. }
  14971. // Where appends a list predicates to the CreditBalanceMutation builder.
  14972. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  14973. m.predicates = append(m.predicates, ps...)
  14974. }
  14975. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  14976. // users can use type-assertion to append predicates that do not depend on any generated package.
  14977. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  14978. p := make([]predicate.CreditBalance, len(ps))
  14979. for i := range ps {
  14980. p[i] = ps[i]
  14981. }
  14982. m.Where(p...)
  14983. }
  14984. // Op returns the operation name.
  14985. func (m *CreditBalanceMutation) Op() Op {
  14986. return m.op
  14987. }
  14988. // SetOp allows setting the mutation operation.
  14989. func (m *CreditBalanceMutation) SetOp(op Op) {
  14990. m.op = op
  14991. }
  14992. // Type returns the node type of this mutation (CreditBalance).
  14993. func (m *CreditBalanceMutation) Type() string {
  14994. return m.typ
  14995. }
  14996. // Fields returns all fields that were changed during this mutation. Note that in
  14997. // order to get all numeric fields that were incremented/decremented, call
  14998. // AddedFields().
  14999. func (m *CreditBalanceMutation) Fields() []string {
  15000. fields := make([]string, 0, 7)
  15001. if m.created_at != nil {
  15002. fields = append(fields, creditbalance.FieldCreatedAt)
  15003. }
  15004. if m.updated_at != nil {
  15005. fields = append(fields, creditbalance.FieldUpdatedAt)
  15006. }
  15007. if m.deleted_at != nil {
  15008. fields = append(fields, creditbalance.FieldDeletedAt)
  15009. }
  15010. if m.user_id != nil {
  15011. fields = append(fields, creditbalance.FieldUserID)
  15012. }
  15013. if m.balance != nil {
  15014. fields = append(fields, creditbalance.FieldBalance)
  15015. }
  15016. if m.status != nil {
  15017. fields = append(fields, creditbalance.FieldStatus)
  15018. }
  15019. if m.organization_id != nil {
  15020. fields = append(fields, creditbalance.FieldOrganizationID)
  15021. }
  15022. return fields
  15023. }
  15024. // Field returns the value of a field with the given name. The second boolean
  15025. // return value indicates that this field was not set, or was not defined in the
  15026. // schema.
  15027. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  15028. switch name {
  15029. case creditbalance.FieldCreatedAt:
  15030. return m.CreatedAt()
  15031. case creditbalance.FieldUpdatedAt:
  15032. return m.UpdatedAt()
  15033. case creditbalance.FieldDeletedAt:
  15034. return m.DeletedAt()
  15035. case creditbalance.FieldUserID:
  15036. return m.UserID()
  15037. case creditbalance.FieldBalance:
  15038. return m.Balance()
  15039. case creditbalance.FieldStatus:
  15040. return m.Status()
  15041. case creditbalance.FieldOrganizationID:
  15042. return m.OrganizationID()
  15043. }
  15044. return nil, false
  15045. }
  15046. // OldField returns the old value of the field from the database. An error is
  15047. // returned if the mutation operation is not UpdateOne, or the query to the
  15048. // database failed.
  15049. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15050. switch name {
  15051. case creditbalance.FieldCreatedAt:
  15052. return m.OldCreatedAt(ctx)
  15053. case creditbalance.FieldUpdatedAt:
  15054. return m.OldUpdatedAt(ctx)
  15055. case creditbalance.FieldDeletedAt:
  15056. return m.OldDeletedAt(ctx)
  15057. case creditbalance.FieldUserID:
  15058. return m.OldUserID(ctx)
  15059. case creditbalance.FieldBalance:
  15060. return m.OldBalance(ctx)
  15061. case creditbalance.FieldStatus:
  15062. return m.OldStatus(ctx)
  15063. case creditbalance.FieldOrganizationID:
  15064. return m.OldOrganizationID(ctx)
  15065. }
  15066. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  15067. }
  15068. // SetField sets the value of a field with the given name. It returns an error if
  15069. // the field is not defined in the schema, or if the type mismatched the field
  15070. // type.
  15071. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  15072. switch name {
  15073. case creditbalance.FieldCreatedAt:
  15074. v, ok := value.(time.Time)
  15075. if !ok {
  15076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15077. }
  15078. m.SetCreatedAt(v)
  15079. return nil
  15080. case creditbalance.FieldUpdatedAt:
  15081. v, ok := value.(time.Time)
  15082. if !ok {
  15083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15084. }
  15085. m.SetUpdatedAt(v)
  15086. return nil
  15087. case creditbalance.FieldDeletedAt:
  15088. v, ok := value.(time.Time)
  15089. if !ok {
  15090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15091. }
  15092. m.SetDeletedAt(v)
  15093. return nil
  15094. case creditbalance.FieldUserID:
  15095. v, ok := value.(string)
  15096. if !ok {
  15097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15098. }
  15099. m.SetUserID(v)
  15100. return nil
  15101. case creditbalance.FieldBalance:
  15102. v, ok := value.(float32)
  15103. if !ok {
  15104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15105. }
  15106. m.SetBalance(v)
  15107. return nil
  15108. case creditbalance.FieldStatus:
  15109. v, ok := value.(int)
  15110. if !ok {
  15111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15112. }
  15113. m.SetStatus(v)
  15114. return nil
  15115. case creditbalance.FieldOrganizationID:
  15116. v, ok := value.(uint64)
  15117. if !ok {
  15118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15119. }
  15120. m.SetOrganizationID(v)
  15121. return nil
  15122. }
  15123. return fmt.Errorf("unknown CreditBalance field %s", name)
  15124. }
  15125. // AddedFields returns all numeric fields that were incremented/decremented during
  15126. // this mutation.
  15127. func (m *CreditBalanceMutation) AddedFields() []string {
  15128. var fields []string
  15129. if m.addbalance != nil {
  15130. fields = append(fields, creditbalance.FieldBalance)
  15131. }
  15132. if m.addstatus != nil {
  15133. fields = append(fields, creditbalance.FieldStatus)
  15134. }
  15135. if m.addorganization_id != nil {
  15136. fields = append(fields, creditbalance.FieldOrganizationID)
  15137. }
  15138. return fields
  15139. }
  15140. // AddedField returns the numeric value that was incremented/decremented on a field
  15141. // with the given name. The second boolean return value indicates that this field
  15142. // was not set, or was not defined in the schema.
  15143. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  15144. switch name {
  15145. case creditbalance.FieldBalance:
  15146. return m.AddedBalance()
  15147. case creditbalance.FieldStatus:
  15148. return m.AddedStatus()
  15149. case creditbalance.FieldOrganizationID:
  15150. return m.AddedOrganizationID()
  15151. }
  15152. return nil, false
  15153. }
  15154. // AddField adds the value to the field with the given name. It returns an error if
  15155. // the field is not defined in the schema, or if the type mismatched the field
  15156. // type.
  15157. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  15158. switch name {
  15159. case creditbalance.FieldBalance:
  15160. v, ok := value.(float32)
  15161. if !ok {
  15162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15163. }
  15164. m.AddBalance(v)
  15165. return nil
  15166. case creditbalance.FieldStatus:
  15167. v, ok := value.(int)
  15168. if !ok {
  15169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15170. }
  15171. m.AddStatus(v)
  15172. return nil
  15173. case creditbalance.FieldOrganizationID:
  15174. v, ok := value.(int64)
  15175. if !ok {
  15176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15177. }
  15178. m.AddOrganizationID(v)
  15179. return nil
  15180. }
  15181. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  15182. }
  15183. // ClearedFields returns all nullable fields that were cleared during this
  15184. // mutation.
  15185. func (m *CreditBalanceMutation) ClearedFields() []string {
  15186. var fields []string
  15187. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  15188. fields = append(fields, creditbalance.FieldDeletedAt)
  15189. }
  15190. if m.FieldCleared(creditbalance.FieldUserID) {
  15191. fields = append(fields, creditbalance.FieldUserID)
  15192. }
  15193. if m.FieldCleared(creditbalance.FieldStatus) {
  15194. fields = append(fields, creditbalance.FieldStatus)
  15195. }
  15196. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  15197. fields = append(fields, creditbalance.FieldOrganizationID)
  15198. }
  15199. return fields
  15200. }
  15201. // FieldCleared returns a boolean indicating if a field with the given name was
  15202. // cleared in this mutation.
  15203. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  15204. _, ok := m.clearedFields[name]
  15205. return ok
  15206. }
  15207. // ClearField clears the value of the field with the given name. It returns an
  15208. // error if the field is not defined in the schema.
  15209. func (m *CreditBalanceMutation) ClearField(name string) error {
  15210. switch name {
  15211. case creditbalance.FieldDeletedAt:
  15212. m.ClearDeletedAt()
  15213. return nil
  15214. case creditbalance.FieldUserID:
  15215. m.ClearUserID()
  15216. return nil
  15217. case creditbalance.FieldStatus:
  15218. m.ClearStatus()
  15219. return nil
  15220. case creditbalance.FieldOrganizationID:
  15221. m.ClearOrganizationID()
  15222. return nil
  15223. }
  15224. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  15225. }
  15226. // ResetField resets all changes in the mutation for the field with the given name.
  15227. // It returns an error if the field is not defined in the schema.
  15228. func (m *CreditBalanceMutation) ResetField(name string) error {
  15229. switch name {
  15230. case creditbalance.FieldCreatedAt:
  15231. m.ResetCreatedAt()
  15232. return nil
  15233. case creditbalance.FieldUpdatedAt:
  15234. m.ResetUpdatedAt()
  15235. return nil
  15236. case creditbalance.FieldDeletedAt:
  15237. m.ResetDeletedAt()
  15238. return nil
  15239. case creditbalance.FieldUserID:
  15240. m.ResetUserID()
  15241. return nil
  15242. case creditbalance.FieldBalance:
  15243. m.ResetBalance()
  15244. return nil
  15245. case creditbalance.FieldStatus:
  15246. m.ResetStatus()
  15247. return nil
  15248. case creditbalance.FieldOrganizationID:
  15249. m.ResetOrganizationID()
  15250. return nil
  15251. }
  15252. return fmt.Errorf("unknown CreditBalance field %s", name)
  15253. }
  15254. // AddedEdges returns all edge names that were set/added in this mutation.
  15255. func (m *CreditBalanceMutation) AddedEdges() []string {
  15256. edges := make([]string, 0, 0)
  15257. return edges
  15258. }
  15259. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15260. // name in this mutation.
  15261. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  15262. return nil
  15263. }
  15264. // RemovedEdges returns all edge names that were removed in this mutation.
  15265. func (m *CreditBalanceMutation) RemovedEdges() []string {
  15266. edges := make([]string, 0, 0)
  15267. return edges
  15268. }
  15269. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15270. // the given name in this mutation.
  15271. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  15272. return nil
  15273. }
  15274. // ClearedEdges returns all edge names that were cleared in this mutation.
  15275. func (m *CreditBalanceMutation) ClearedEdges() []string {
  15276. edges := make([]string, 0, 0)
  15277. return edges
  15278. }
  15279. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15280. // was cleared in this mutation.
  15281. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  15282. return false
  15283. }
  15284. // ClearEdge clears the value of the edge with the given name. It returns an error
  15285. // if that edge is not defined in the schema.
  15286. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  15287. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  15288. }
  15289. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15290. // It returns an error if the edge is not defined in the schema.
  15291. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  15292. return fmt.Errorf("unknown CreditBalance edge %s", name)
  15293. }
  15294. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  15295. type CreditUsageMutation struct {
  15296. config
  15297. op Op
  15298. typ string
  15299. id *uint64
  15300. created_at *time.Time
  15301. updated_at *time.Time
  15302. deleted_at *time.Time
  15303. user_id *string
  15304. number *float32
  15305. addnumber *float32
  15306. status *int
  15307. addstatus *int
  15308. ntype *int
  15309. addntype *int
  15310. table *string
  15311. organization_id *uint64
  15312. addorganization_id *int64
  15313. nid *uint64
  15314. addnid *int64
  15315. reason *string
  15316. operator *string
  15317. clearedFields map[string]struct{}
  15318. done bool
  15319. oldValue func(context.Context) (*CreditUsage, error)
  15320. predicates []predicate.CreditUsage
  15321. }
  15322. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  15323. // creditusageOption allows management of the mutation configuration using functional options.
  15324. type creditusageOption func(*CreditUsageMutation)
  15325. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  15326. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  15327. m := &CreditUsageMutation{
  15328. config: c,
  15329. op: op,
  15330. typ: TypeCreditUsage,
  15331. clearedFields: make(map[string]struct{}),
  15332. }
  15333. for _, opt := range opts {
  15334. opt(m)
  15335. }
  15336. return m
  15337. }
  15338. // withCreditUsageID sets the ID field of the mutation.
  15339. func withCreditUsageID(id uint64) creditusageOption {
  15340. return func(m *CreditUsageMutation) {
  15341. var (
  15342. err error
  15343. once sync.Once
  15344. value *CreditUsage
  15345. )
  15346. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  15347. once.Do(func() {
  15348. if m.done {
  15349. err = errors.New("querying old values post mutation is not allowed")
  15350. } else {
  15351. value, err = m.Client().CreditUsage.Get(ctx, id)
  15352. }
  15353. })
  15354. return value, err
  15355. }
  15356. m.id = &id
  15357. }
  15358. }
  15359. // withCreditUsage sets the old CreditUsage of the mutation.
  15360. func withCreditUsage(node *CreditUsage) creditusageOption {
  15361. return func(m *CreditUsageMutation) {
  15362. m.oldValue = func(context.Context) (*CreditUsage, error) {
  15363. return node, nil
  15364. }
  15365. m.id = &node.ID
  15366. }
  15367. }
  15368. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15369. // executed in a transaction (ent.Tx), a transactional client is returned.
  15370. func (m CreditUsageMutation) Client() *Client {
  15371. client := &Client{config: m.config}
  15372. client.init()
  15373. return client
  15374. }
  15375. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15376. // it returns an error otherwise.
  15377. func (m CreditUsageMutation) Tx() (*Tx, error) {
  15378. if _, ok := m.driver.(*txDriver); !ok {
  15379. return nil, errors.New("ent: mutation is not running in a transaction")
  15380. }
  15381. tx := &Tx{config: m.config}
  15382. tx.init()
  15383. return tx, nil
  15384. }
  15385. // SetID sets the value of the id field. Note that this
  15386. // operation is only accepted on creation of CreditUsage entities.
  15387. func (m *CreditUsageMutation) SetID(id uint64) {
  15388. m.id = &id
  15389. }
  15390. // ID returns the ID value in the mutation. Note that the ID is only available
  15391. // if it was provided to the builder or after it was returned from the database.
  15392. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  15393. if m.id == nil {
  15394. return
  15395. }
  15396. return *m.id, true
  15397. }
  15398. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15399. // That means, if the mutation is applied within a transaction with an isolation level such
  15400. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15401. // or updated by the mutation.
  15402. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  15403. switch {
  15404. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15405. id, exists := m.ID()
  15406. if exists {
  15407. return []uint64{id}, nil
  15408. }
  15409. fallthrough
  15410. case m.op.Is(OpUpdate | OpDelete):
  15411. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  15412. default:
  15413. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15414. }
  15415. }
  15416. // SetCreatedAt sets the "created_at" field.
  15417. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  15418. m.created_at = &t
  15419. }
  15420. // CreatedAt returns the value of the "created_at" field in the mutation.
  15421. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  15422. v := m.created_at
  15423. if v == nil {
  15424. return
  15425. }
  15426. return *v, true
  15427. }
  15428. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  15429. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15431. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15432. if !m.op.Is(OpUpdateOne) {
  15433. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15434. }
  15435. if m.id == nil || m.oldValue == nil {
  15436. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15437. }
  15438. oldValue, err := m.oldValue(ctx)
  15439. if err != nil {
  15440. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15441. }
  15442. return oldValue.CreatedAt, nil
  15443. }
  15444. // ResetCreatedAt resets all changes to the "created_at" field.
  15445. func (m *CreditUsageMutation) ResetCreatedAt() {
  15446. m.created_at = nil
  15447. }
  15448. // SetUpdatedAt sets the "updated_at" field.
  15449. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  15450. m.updated_at = &t
  15451. }
  15452. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15453. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  15454. v := m.updated_at
  15455. if v == nil {
  15456. return
  15457. }
  15458. return *v, true
  15459. }
  15460. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  15461. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15463. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15464. if !m.op.Is(OpUpdateOne) {
  15465. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15466. }
  15467. if m.id == nil || m.oldValue == nil {
  15468. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15469. }
  15470. oldValue, err := m.oldValue(ctx)
  15471. if err != nil {
  15472. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15473. }
  15474. return oldValue.UpdatedAt, nil
  15475. }
  15476. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15477. func (m *CreditUsageMutation) ResetUpdatedAt() {
  15478. m.updated_at = nil
  15479. }
  15480. // SetDeletedAt sets the "deleted_at" field.
  15481. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  15482. m.deleted_at = &t
  15483. }
  15484. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15485. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  15486. v := m.deleted_at
  15487. if v == nil {
  15488. return
  15489. }
  15490. return *v, true
  15491. }
  15492. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  15493. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15495. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15496. if !m.op.Is(OpUpdateOne) {
  15497. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15498. }
  15499. if m.id == nil || m.oldValue == nil {
  15500. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15501. }
  15502. oldValue, err := m.oldValue(ctx)
  15503. if err != nil {
  15504. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15505. }
  15506. return oldValue.DeletedAt, nil
  15507. }
  15508. // ClearDeletedAt clears the value of the "deleted_at" field.
  15509. func (m *CreditUsageMutation) ClearDeletedAt() {
  15510. m.deleted_at = nil
  15511. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  15512. }
  15513. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15514. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  15515. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  15516. return ok
  15517. }
  15518. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15519. func (m *CreditUsageMutation) ResetDeletedAt() {
  15520. m.deleted_at = nil
  15521. delete(m.clearedFields, creditusage.FieldDeletedAt)
  15522. }
  15523. // SetUserID sets the "user_id" field.
  15524. func (m *CreditUsageMutation) SetUserID(s string) {
  15525. m.user_id = &s
  15526. }
  15527. // UserID returns the value of the "user_id" field in the mutation.
  15528. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  15529. v := m.user_id
  15530. if v == nil {
  15531. return
  15532. }
  15533. return *v, true
  15534. }
  15535. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  15536. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15538. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  15539. if !m.op.Is(OpUpdateOne) {
  15540. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15541. }
  15542. if m.id == nil || m.oldValue == nil {
  15543. return v, errors.New("OldUserID requires an ID field in the mutation")
  15544. }
  15545. oldValue, err := m.oldValue(ctx)
  15546. if err != nil {
  15547. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15548. }
  15549. return oldValue.UserID, nil
  15550. }
  15551. // ClearUserID clears the value of the "user_id" field.
  15552. func (m *CreditUsageMutation) ClearUserID() {
  15553. m.user_id = nil
  15554. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  15555. }
  15556. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15557. func (m *CreditUsageMutation) UserIDCleared() bool {
  15558. _, ok := m.clearedFields[creditusage.FieldUserID]
  15559. return ok
  15560. }
  15561. // ResetUserID resets all changes to the "user_id" field.
  15562. func (m *CreditUsageMutation) ResetUserID() {
  15563. m.user_id = nil
  15564. delete(m.clearedFields, creditusage.FieldUserID)
  15565. }
  15566. // SetNumber sets the "number" field.
  15567. func (m *CreditUsageMutation) SetNumber(f float32) {
  15568. m.number = &f
  15569. m.addnumber = nil
  15570. }
  15571. // Number returns the value of the "number" field in the mutation.
  15572. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  15573. v := m.number
  15574. if v == nil {
  15575. return
  15576. }
  15577. return *v, true
  15578. }
  15579. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  15580. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15582. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  15583. if !m.op.Is(OpUpdateOne) {
  15584. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  15585. }
  15586. if m.id == nil || m.oldValue == nil {
  15587. return v, errors.New("OldNumber requires an ID field in the mutation")
  15588. }
  15589. oldValue, err := m.oldValue(ctx)
  15590. if err != nil {
  15591. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  15592. }
  15593. return oldValue.Number, nil
  15594. }
  15595. // AddNumber adds f to the "number" field.
  15596. func (m *CreditUsageMutation) AddNumber(f float32) {
  15597. if m.addnumber != nil {
  15598. *m.addnumber += f
  15599. } else {
  15600. m.addnumber = &f
  15601. }
  15602. }
  15603. // AddedNumber returns the value that was added to the "number" field in this mutation.
  15604. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  15605. v := m.addnumber
  15606. if v == nil {
  15607. return
  15608. }
  15609. return *v, true
  15610. }
  15611. // ResetNumber resets all changes to the "number" field.
  15612. func (m *CreditUsageMutation) ResetNumber() {
  15613. m.number = nil
  15614. m.addnumber = nil
  15615. }
  15616. // SetStatus sets the "status" field.
  15617. func (m *CreditUsageMutation) SetStatus(i int) {
  15618. m.status = &i
  15619. m.addstatus = nil
  15620. }
  15621. // Status returns the value of the "status" field in the mutation.
  15622. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  15623. v := m.status
  15624. if v == nil {
  15625. return
  15626. }
  15627. return *v, true
  15628. }
  15629. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  15630. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15632. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  15633. if !m.op.Is(OpUpdateOne) {
  15634. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15635. }
  15636. if m.id == nil || m.oldValue == nil {
  15637. return v, errors.New("OldStatus requires an ID field in the mutation")
  15638. }
  15639. oldValue, err := m.oldValue(ctx)
  15640. if err != nil {
  15641. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15642. }
  15643. return oldValue.Status, nil
  15644. }
  15645. // AddStatus adds i to the "status" field.
  15646. func (m *CreditUsageMutation) AddStatus(i int) {
  15647. if m.addstatus != nil {
  15648. *m.addstatus += i
  15649. } else {
  15650. m.addstatus = &i
  15651. }
  15652. }
  15653. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15654. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  15655. v := m.addstatus
  15656. if v == nil {
  15657. return
  15658. }
  15659. return *v, true
  15660. }
  15661. // ClearStatus clears the value of the "status" field.
  15662. func (m *CreditUsageMutation) ClearStatus() {
  15663. m.status = nil
  15664. m.addstatus = nil
  15665. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  15666. }
  15667. // StatusCleared returns if the "status" field was cleared in this mutation.
  15668. func (m *CreditUsageMutation) StatusCleared() bool {
  15669. _, ok := m.clearedFields[creditusage.FieldStatus]
  15670. return ok
  15671. }
  15672. // ResetStatus resets all changes to the "status" field.
  15673. func (m *CreditUsageMutation) ResetStatus() {
  15674. m.status = nil
  15675. m.addstatus = nil
  15676. delete(m.clearedFields, creditusage.FieldStatus)
  15677. }
  15678. // SetNtype sets the "ntype" field.
  15679. func (m *CreditUsageMutation) SetNtype(i int) {
  15680. m.ntype = &i
  15681. m.addntype = nil
  15682. }
  15683. // Ntype returns the value of the "ntype" field in the mutation.
  15684. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  15685. v := m.ntype
  15686. if v == nil {
  15687. return
  15688. }
  15689. return *v, true
  15690. }
  15691. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  15692. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15694. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  15695. if !m.op.Is(OpUpdateOne) {
  15696. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  15697. }
  15698. if m.id == nil || m.oldValue == nil {
  15699. return v, errors.New("OldNtype requires an ID field in the mutation")
  15700. }
  15701. oldValue, err := m.oldValue(ctx)
  15702. if err != nil {
  15703. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  15704. }
  15705. return oldValue.Ntype, nil
  15706. }
  15707. // AddNtype adds i to the "ntype" field.
  15708. func (m *CreditUsageMutation) AddNtype(i int) {
  15709. if m.addntype != nil {
  15710. *m.addntype += i
  15711. } else {
  15712. m.addntype = &i
  15713. }
  15714. }
  15715. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  15716. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  15717. v := m.addntype
  15718. if v == nil {
  15719. return
  15720. }
  15721. return *v, true
  15722. }
  15723. // ResetNtype resets all changes to the "ntype" field.
  15724. func (m *CreditUsageMutation) ResetNtype() {
  15725. m.ntype = nil
  15726. m.addntype = nil
  15727. }
  15728. // SetTable sets the "table" field.
  15729. func (m *CreditUsageMutation) SetTable(s string) {
  15730. m.table = &s
  15731. }
  15732. // Table returns the value of the "table" field in the mutation.
  15733. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  15734. v := m.table
  15735. if v == nil {
  15736. return
  15737. }
  15738. return *v, true
  15739. }
  15740. // OldTable returns the old "table" field's value of the CreditUsage entity.
  15741. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15743. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  15744. if !m.op.Is(OpUpdateOne) {
  15745. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  15746. }
  15747. if m.id == nil || m.oldValue == nil {
  15748. return v, errors.New("OldTable requires an ID field in the mutation")
  15749. }
  15750. oldValue, err := m.oldValue(ctx)
  15751. if err != nil {
  15752. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  15753. }
  15754. return oldValue.Table, nil
  15755. }
  15756. // ResetTable resets all changes to the "table" field.
  15757. func (m *CreditUsageMutation) ResetTable() {
  15758. m.table = nil
  15759. }
  15760. // SetOrganizationID sets the "organization_id" field.
  15761. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  15762. m.organization_id = &u
  15763. m.addorganization_id = nil
  15764. }
  15765. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15766. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  15767. v := m.organization_id
  15768. if v == nil {
  15769. return
  15770. }
  15771. return *v, true
  15772. }
  15773. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  15774. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15776. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15777. if !m.op.Is(OpUpdateOne) {
  15778. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15779. }
  15780. if m.id == nil || m.oldValue == nil {
  15781. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15782. }
  15783. oldValue, err := m.oldValue(ctx)
  15784. if err != nil {
  15785. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15786. }
  15787. return oldValue.OrganizationID, nil
  15788. }
  15789. // AddOrganizationID adds u to the "organization_id" field.
  15790. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  15791. if m.addorganization_id != nil {
  15792. *m.addorganization_id += u
  15793. } else {
  15794. m.addorganization_id = &u
  15795. }
  15796. }
  15797. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15798. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  15799. v := m.addorganization_id
  15800. if v == nil {
  15801. return
  15802. }
  15803. return *v, true
  15804. }
  15805. // ClearOrganizationID clears the value of the "organization_id" field.
  15806. func (m *CreditUsageMutation) ClearOrganizationID() {
  15807. m.organization_id = nil
  15808. m.addorganization_id = nil
  15809. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  15810. }
  15811. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15812. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  15813. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  15814. return ok
  15815. }
  15816. // ResetOrganizationID resets all changes to the "organization_id" field.
  15817. func (m *CreditUsageMutation) ResetOrganizationID() {
  15818. m.organization_id = nil
  15819. m.addorganization_id = nil
  15820. delete(m.clearedFields, creditusage.FieldOrganizationID)
  15821. }
  15822. // SetNid sets the "nid" field.
  15823. func (m *CreditUsageMutation) SetNid(u uint64) {
  15824. m.nid = &u
  15825. m.addnid = nil
  15826. }
  15827. // Nid returns the value of the "nid" field in the mutation.
  15828. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  15829. v := m.nid
  15830. if v == nil {
  15831. return
  15832. }
  15833. return *v, true
  15834. }
  15835. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  15836. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15838. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  15839. if !m.op.Is(OpUpdateOne) {
  15840. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  15841. }
  15842. if m.id == nil || m.oldValue == nil {
  15843. return v, errors.New("OldNid requires an ID field in the mutation")
  15844. }
  15845. oldValue, err := m.oldValue(ctx)
  15846. if err != nil {
  15847. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  15848. }
  15849. return oldValue.Nid, nil
  15850. }
  15851. // AddNid adds u to the "nid" field.
  15852. func (m *CreditUsageMutation) AddNid(u int64) {
  15853. if m.addnid != nil {
  15854. *m.addnid += u
  15855. } else {
  15856. m.addnid = &u
  15857. }
  15858. }
  15859. // AddedNid returns the value that was added to the "nid" field in this mutation.
  15860. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  15861. v := m.addnid
  15862. if v == nil {
  15863. return
  15864. }
  15865. return *v, true
  15866. }
  15867. // ResetNid resets all changes to the "nid" field.
  15868. func (m *CreditUsageMutation) ResetNid() {
  15869. m.nid = nil
  15870. m.addnid = nil
  15871. }
  15872. // SetReason sets the "reason" field.
  15873. func (m *CreditUsageMutation) SetReason(s string) {
  15874. m.reason = &s
  15875. }
  15876. // Reason returns the value of the "reason" field in the mutation.
  15877. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  15878. v := m.reason
  15879. if v == nil {
  15880. return
  15881. }
  15882. return *v, true
  15883. }
  15884. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  15885. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15887. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  15888. if !m.op.Is(OpUpdateOne) {
  15889. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  15890. }
  15891. if m.id == nil || m.oldValue == nil {
  15892. return v, errors.New("OldReason requires an ID field in the mutation")
  15893. }
  15894. oldValue, err := m.oldValue(ctx)
  15895. if err != nil {
  15896. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  15897. }
  15898. return oldValue.Reason, nil
  15899. }
  15900. // ResetReason resets all changes to the "reason" field.
  15901. func (m *CreditUsageMutation) ResetReason() {
  15902. m.reason = nil
  15903. }
  15904. // SetOperator sets the "operator" field.
  15905. func (m *CreditUsageMutation) SetOperator(s string) {
  15906. m.operator = &s
  15907. }
  15908. // Operator returns the value of the "operator" field in the mutation.
  15909. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  15910. v := m.operator
  15911. if v == nil {
  15912. return
  15913. }
  15914. return *v, true
  15915. }
  15916. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  15917. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15919. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  15920. if !m.op.Is(OpUpdateOne) {
  15921. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  15922. }
  15923. if m.id == nil || m.oldValue == nil {
  15924. return v, errors.New("OldOperator requires an ID field in the mutation")
  15925. }
  15926. oldValue, err := m.oldValue(ctx)
  15927. if err != nil {
  15928. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  15929. }
  15930. return oldValue.Operator, nil
  15931. }
  15932. // ResetOperator resets all changes to the "operator" field.
  15933. func (m *CreditUsageMutation) ResetOperator() {
  15934. m.operator = nil
  15935. }
  15936. // Where appends a list predicates to the CreditUsageMutation builder.
  15937. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  15938. m.predicates = append(m.predicates, ps...)
  15939. }
  15940. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  15941. // users can use type-assertion to append predicates that do not depend on any generated package.
  15942. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  15943. p := make([]predicate.CreditUsage, len(ps))
  15944. for i := range ps {
  15945. p[i] = ps[i]
  15946. }
  15947. m.Where(p...)
  15948. }
  15949. // Op returns the operation name.
  15950. func (m *CreditUsageMutation) Op() Op {
  15951. return m.op
  15952. }
  15953. // SetOp allows setting the mutation operation.
  15954. func (m *CreditUsageMutation) SetOp(op Op) {
  15955. m.op = op
  15956. }
  15957. // Type returns the node type of this mutation (CreditUsage).
  15958. func (m *CreditUsageMutation) Type() string {
  15959. return m.typ
  15960. }
  15961. // Fields returns all fields that were changed during this mutation. Note that in
  15962. // order to get all numeric fields that were incremented/decremented, call
  15963. // AddedFields().
  15964. func (m *CreditUsageMutation) Fields() []string {
  15965. fields := make([]string, 0, 12)
  15966. if m.created_at != nil {
  15967. fields = append(fields, creditusage.FieldCreatedAt)
  15968. }
  15969. if m.updated_at != nil {
  15970. fields = append(fields, creditusage.FieldUpdatedAt)
  15971. }
  15972. if m.deleted_at != nil {
  15973. fields = append(fields, creditusage.FieldDeletedAt)
  15974. }
  15975. if m.user_id != nil {
  15976. fields = append(fields, creditusage.FieldUserID)
  15977. }
  15978. if m.number != nil {
  15979. fields = append(fields, creditusage.FieldNumber)
  15980. }
  15981. if m.status != nil {
  15982. fields = append(fields, creditusage.FieldStatus)
  15983. }
  15984. if m.ntype != nil {
  15985. fields = append(fields, creditusage.FieldNtype)
  15986. }
  15987. if m.table != nil {
  15988. fields = append(fields, creditusage.FieldTable)
  15989. }
  15990. if m.organization_id != nil {
  15991. fields = append(fields, creditusage.FieldOrganizationID)
  15992. }
  15993. if m.nid != nil {
  15994. fields = append(fields, creditusage.FieldNid)
  15995. }
  15996. if m.reason != nil {
  15997. fields = append(fields, creditusage.FieldReason)
  15998. }
  15999. if m.operator != nil {
  16000. fields = append(fields, creditusage.FieldOperator)
  16001. }
  16002. return fields
  16003. }
  16004. // Field returns the value of a field with the given name. The second boolean
  16005. // return value indicates that this field was not set, or was not defined in the
  16006. // schema.
  16007. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  16008. switch name {
  16009. case creditusage.FieldCreatedAt:
  16010. return m.CreatedAt()
  16011. case creditusage.FieldUpdatedAt:
  16012. return m.UpdatedAt()
  16013. case creditusage.FieldDeletedAt:
  16014. return m.DeletedAt()
  16015. case creditusage.FieldUserID:
  16016. return m.UserID()
  16017. case creditusage.FieldNumber:
  16018. return m.Number()
  16019. case creditusage.FieldStatus:
  16020. return m.Status()
  16021. case creditusage.FieldNtype:
  16022. return m.Ntype()
  16023. case creditusage.FieldTable:
  16024. return m.Table()
  16025. case creditusage.FieldOrganizationID:
  16026. return m.OrganizationID()
  16027. case creditusage.FieldNid:
  16028. return m.Nid()
  16029. case creditusage.FieldReason:
  16030. return m.Reason()
  16031. case creditusage.FieldOperator:
  16032. return m.Operator()
  16033. }
  16034. return nil, false
  16035. }
  16036. // OldField returns the old value of the field from the database. An error is
  16037. // returned if the mutation operation is not UpdateOne, or the query to the
  16038. // database failed.
  16039. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16040. switch name {
  16041. case creditusage.FieldCreatedAt:
  16042. return m.OldCreatedAt(ctx)
  16043. case creditusage.FieldUpdatedAt:
  16044. return m.OldUpdatedAt(ctx)
  16045. case creditusage.FieldDeletedAt:
  16046. return m.OldDeletedAt(ctx)
  16047. case creditusage.FieldUserID:
  16048. return m.OldUserID(ctx)
  16049. case creditusage.FieldNumber:
  16050. return m.OldNumber(ctx)
  16051. case creditusage.FieldStatus:
  16052. return m.OldStatus(ctx)
  16053. case creditusage.FieldNtype:
  16054. return m.OldNtype(ctx)
  16055. case creditusage.FieldTable:
  16056. return m.OldTable(ctx)
  16057. case creditusage.FieldOrganizationID:
  16058. return m.OldOrganizationID(ctx)
  16059. case creditusage.FieldNid:
  16060. return m.OldNid(ctx)
  16061. case creditusage.FieldReason:
  16062. return m.OldReason(ctx)
  16063. case creditusage.FieldOperator:
  16064. return m.OldOperator(ctx)
  16065. }
  16066. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  16067. }
  16068. // SetField sets the value of a field with the given name. It returns an error if
  16069. // the field is not defined in the schema, or if the type mismatched the field
  16070. // type.
  16071. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  16072. switch name {
  16073. case creditusage.FieldCreatedAt:
  16074. v, ok := value.(time.Time)
  16075. if !ok {
  16076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16077. }
  16078. m.SetCreatedAt(v)
  16079. return nil
  16080. case creditusage.FieldUpdatedAt:
  16081. v, ok := value.(time.Time)
  16082. if !ok {
  16083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16084. }
  16085. m.SetUpdatedAt(v)
  16086. return nil
  16087. case creditusage.FieldDeletedAt:
  16088. v, ok := value.(time.Time)
  16089. if !ok {
  16090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16091. }
  16092. m.SetDeletedAt(v)
  16093. return nil
  16094. case creditusage.FieldUserID:
  16095. v, ok := value.(string)
  16096. if !ok {
  16097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16098. }
  16099. m.SetUserID(v)
  16100. return nil
  16101. case creditusage.FieldNumber:
  16102. v, ok := value.(float32)
  16103. if !ok {
  16104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16105. }
  16106. m.SetNumber(v)
  16107. return nil
  16108. case creditusage.FieldStatus:
  16109. v, ok := value.(int)
  16110. if !ok {
  16111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16112. }
  16113. m.SetStatus(v)
  16114. return nil
  16115. case creditusage.FieldNtype:
  16116. v, ok := value.(int)
  16117. if !ok {
  16118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16119. }
  16120. m.SetNtype(v)
  16121. return nil
  16122. case creditusage.FieldTable:
  16123. v, ok := value.(string)
  16124. if !ok {
  16125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16126. }
  16127. m.SetTable(v)
  16128. return nil
  16129. case creditusage.FieldOrganizationID:
  16130. v, ok := value.(uint64)
  16131. if !ok {
  16132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16133. }
  16134. m.SetOrganizationID(v)
  16135. return nil
  16136. case creditusage.FieldNid:
  16137. v, ok := value.(uint64)
  16138. if !ok {
  16139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16140. }
  16141. m.SetNid(v)
  16142. return nil
  16143. case creditusage.FieldReason:
  16144. v, ok := value.(string)
  16145. if !ok {
  16146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16147. }
  16148. m.SetReason(v)
  16149. return nil
  16150. case creditusage.FieldOperator:
  16151. v, ok := value.(string)
  16152. if !ok {
  16153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16154. }
  16155. m.SetOperator(v)
  16156. return nil
  16157. }
  16158. return fmt.Errorf("unknown CreditUsage field %s", name)
  16159. }
  16160. // AddedFields returns all numeric fields that were incremented/decremented during
  16161. // this mutation.
  16162. func (m *CreditUsageMutation) AddedFields() []string {
  16163. var fields []string
  16164. if m.addnumber != nil {
  16165. fields = append(fields, creditusage.FieldNumber)
  16166. }
  16167. if m.addstatus != nil {
  16168. fields = append(fields, creditusage.FieldStatus)
  16169. }
  16170. if m.addntype != nil {
  16171. fields = append(fields, creditusage.FieldNtype)
  16172. }
  16173. if m.addorganization_id != nil {
  16174. fields = append(fields, creditusage.FieldOrganizationID)
  16175. }
  16176. if m.addnid != nil {
  16177. fields = append(fields, creditusage.FieldNid)
  16178. }
  16179. return fields
  16180. }
  16181. // AddedField returns the numeric value that was incremented/decremented on a field
  16182. // with the given name. The second boolean return value indicates that this field
  16183. // was not set, or was not defined in the schema.
  16184. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  16185. switch name {
  16186. case creditusage.FieldNumber:
  16187. return m.AddedNumber()
  16188. case creditusage.FieldStatus:
  16189. return m.AddedStatus()
  16190. case creditusage.FieldNtype:
  16191. return m.AddedNtype()
  16192. case creditusage.FieldOrganizationID:
  16193. return m.AddedOrganizationID()
  16194. case creditusage.FieldNid:
  16195. return m.AddedNid()
  16196. }
  16197. return nil, false
  16198. }
  16199. // AddField adds the value to the field with the given name. It returns an error if
  16200. // the field is not defined in the schema, or if the type mismatched the field
  16201. // type.
  16202. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  16203. switch name {
  16204. case creditusage.FieldNumber:
  16205. v, ok := value.(float32)
  16206. if !ok {
  16207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16208. }
  16209. m.AddNumber(v)
  16210. return nil
  16211. case creditusage.FieldStatus:
  16212. v, ok := value.(int)
  16213. if !ok {
  16214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16215. }
  16216. m.AddStatus(v)
  16217. return nil
  16218. case creditusage.FieldNtype:
  16219. v, ok := value.(int)
  16220. if !ok {
  16221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16222. }
  16223. m.AddNtype(v)
  16224. return nil
  16225. case creditusage.FieldOrganizationID:
  16226. v, ok := value.(int64)
  16227. if !ok {
  16228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16229. }
  16230. m.AddOrganizationID(v)
  16231. return nil
  16232. case creditusage.FieldNid:
  16233. v, ok := value.(int64)
  16234. if !ok {
  16235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16236. }
  16237. m.AddNid(v)
  16238. return nil
  16239. }
  16240. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  16241. }
  16242. // ClearedFields returns all nullable fields that were cleared during this
  16243. // mutation.
  16244. func (m *CreditUsageMutation) ClearedFields() []string {
  16245. var fields []string
  16246. if m.FieldCleared(creditusage.FieldDeletedAt) {
  16247. fields = append(fields, creditusage.FieldDeletedAt)
  16248. }
  16249. if m.FieldCleared(creditusage.FieldUserID) {
  16250. fields = append(fields, creditusage.FieldUserID)
  16251. }
  16252. if m.FieldCleared(creditusage.FieldStatus) {
  16253. fields = append(fields, creditusage.FieldStatus)
  16254. }
  16255. if m.FieldCleared(creditusage.FieldOrganizationID) {
  16256. fields = append(fields, creditusage.FieldOrganizationID)
  16257. }
  16258. return fields
  16259. }
  16260. // FieldCleared returns a boolean indicating if a field with the given name was
  16261. // cleared in this mutation.
  16262. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  16263. _, ok := m.clearedFields[name]
  16264. return ok
  16265. }
  16266. // ClearField clears the value of the field with the given name. It returns an
  16267. // error if the field is not defined in the schema.
  16268. func (m *CreditUsageMutation) ClearField(name string) error {
  16269. switch name {
  16270. case creditusage.FieldDeletedAt:
  16271. m.ClearDeletedAt()
  16272. return nil
  16273. case creditusage.FieldUserID:
  16274. m.ClearUserID()
  16275. return nil
  16276. case creditusage.FieldStatus:
  16277. m.ClearStatus()
  16278. return nil
  16279. case creditusage.FieldOrganizationID:
  16280. m.ClearOrganizationID()
  16281. return nil
  16282. }
  16283. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  16284. }
  16285. // ResetField resets all changes in the mutation for the field with the given name.
  16286. // It returns an error if the field is not defined in the schema.
  16287. func (m *CreditUsageMutation) ResetField(name string) error {
  16288. switch name {
  16289. case creditusage.FieldCreatedAt:
  16290. m.ResetCreatedAt()
  16291. return nil
  16292. case creditusage.FieldUpdatedAt:
  16293. m.ResetUpdatedAt()
  16294. return nil
  16295. case creditusage.FieldDeletedAt:
  16296. m.ResetDeletedAt()
  16297. return nil
  16298. case creditusage.FieldUserID:
  16299. m.ResetUserID()
  16300. return nil
  16301. case creditusage.FieldNumber:
  16302. m.ResetNumber()
  16303. return nil
  16304. case creditusage.FieldStatus:
  16305. m.ResetStatus()
  16306. return nil
  16307. case creditusage.FieldNtype:
  16308. m.ResetNtype()
  16309. return nil
  16310. case creditusage.FieldTable:
  16311. m.ResetTable()
  16312. return nil
  16313. case creditusage.FieldOrganizationID:
  16314. m.ResetOrganizationID()
  16315. return nil
  16316. case creditusage.FieldNid:
  16317. m.ResetNid()
  16318. return nil
  16319. case creditusage.FieldReason:
  16320. m.ResetReason()
  16321. return nil
  16322. case creditusage.FieldOperator:
  16323. m.ResetOperator()
  16324. return nil
  16325. }
  16326. return fmt.Errorf("unknown CreditUsage field %s", name)
  16327. }
  16328. // AddedEdges returns all edge names that were set/added in this mutation.
  16329. func (m *CreditUsageMutation) AddedEdges() []string {
  16330. edges := make([]string, 0, 0)
  16331. return edges
  16332. }
  16333. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16334. // name in this mutation.
  16335. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  16336. return nil
  16337. }
  16338. // RemovedEdges returns all edge names that were removed in this mutation.
  16339. func (m *CreditUsageMutation) RemovedEdges() []string {
  16340. edges := make([]string, 0, 0)
  16341. return edges
  16342. }
  16343. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16344. // the given name in this mutation.
  16345. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  16346. return nil
  16347. }
  16348. // ClearedEdges returns all edge names that were cleared in this mutation.
  16349. func (m *CreditUsageMutation) ClearedEdges() []string {
  16350. edges := make([]string, 0, 0)
  16351. return edges
  16352. }
  16353. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16354. // was cleared in this mutation.
  16355. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  16356. return false
  16357. }
  16358. // ClearEdge clears the value of the edge with the given name. It returns an error
  16359. // if that edge is not defined in the schema.
  16360. func (m *CreditUsageMutation) ClearEdge(name string) error {
  16361. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  16362. }
  16363. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16364. // It returns an error if the edge is not defined in the schema.
  16365. func (m *CreditUsageMutation) ResetEdge(name string) error {
  16366. return fmt.Errorf("unknown CreditUsage edge %s", name)
  16367. }
  16368. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  16369. type EmployeeMutation struct {
  16370. config
  16371. op Op
  16372. typ string
  16373. id *uint64
  16374. created_at *time.Time
  16375. updated_at *time.Time
  16376. deleted_at *time.Time
  16377. title *string
  16378. avatar *string
  16379. tags *string
  16380. hire_count *int
  16381. addhire_count *int
  16382. service_count *int
  16383. addservice_count *int
  16384. achievement_count *int
  16385. addachievement_count *int
  16386. intro *string
  16387. estimate *string
  16388. skill *string
  16389. ability_type *string
  16390. scene *string
  16391. switch_in *string
  16392. video_url *string
  16393. organization_id *uint64
  16394. addorganization_id *int64
  16395. category_id *uint64
  16396. addcategory_id *int64
  16397. api_base *string
  16398. api_key *string
  16399. ai_info *string
  16400. is_vip *int
  16401. addis_vip *int
  16402. chat_url *string
  16403. clearedFields map[string]struct{}
  16404. em_work_experiences map[uint64]struct{}
  16405. removedem_work_experiences map[uint64]struct{}
  16406. clearedem_work_experiences bool
  16407. em_tutorial map[uint64]struct{}
  16408. removedem_tutorial map[uint64]struct{}
  16409. clearedem_tutorial bool
  16410. done bool
  16411. oldValue func(context.Context) (*Employee, error)
  16412. predicates []predicate.Employee
  16413. }
  16414. var _ ent.Mutation = (*EmployeeMutation)(nil)
  16415. // employeeOption allows management of the mutation configuration using functional options.
  16416. type employeeOption func(*EmployeeMutation)
  16417. // newEmployeeMutation creates new mutation for the Employee entity.
  16418. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  16419. m := &EmployeeMutation{
  16420. config: c,
  16421. op: op,
  16422. typ: TypeEmployee,
  16423. clearedFields: make(map[string]struct{}),
  16424. }
  16425. for _, opt := range opts {
  16426. opt(m)
  16427. }
  16428. return m
  16429. }
  16430. // withEmployeeID sets the ID field of the mutation.
  16431. func withEmployeeID(id uint64) employeeOption {
  16432. return func(m *EmployeeMutation) {
  16433. var (
  16434. err error
  16435. once sync.Once
  16436. value *Employee
  16437. )
  16438. m.oldValue = func(ctx context.Context) (*Employee, error) {
  16439. once.Do(func() {
  16440. if m.done {
  16441. err = errors.New("querying old values post mutation is not allowed")
  16442. } else {
  16443. value, err = m.Client().Employee.Get(ctx, id)
  16444. }
  16445. })
  16446. return value, err
  16447. }
  16448. m.id = &id
  16449. }
  16450. }
  16451. // withEmployee sets the old Employee of the mutation.
  16452. func withEmployee(node *Employee) employeeOption {
  16453. return func(m *EmployeeMutation) {
  16454. m.oldValue = func(context.Context) (*Employee, error) {
  16455. return node, nil
  16456. }
  16457. m.id = &node.ID
  16458. }
  16459. }
  16460. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16461. // executed in a transaction (ent.Tx), a transactional client is returned.
  16462. func (m EmployeeMutation) Client() *Client {
  16463. client := &Client{config: m.config}
  16464. client.init()
  16465. return client
  16466. }
  16467. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16468. // it returns an error otherwise.
  16469. func (m EmployeeMutation) Tx() (*Tx, error) {
  16470. if _, ok := m.driver.(*txDriver); !ok {
  16471. return nil, errors.New("ent: mutation is not running in a transaction")
  16472. }
  16473. tx := &Tx{config: m.config}
  16474. tx.init()
  16475. return tx, nil
  16476. }
  16477. // SetID sets the value of the id field. Note that this
  16478. // operation is only accepted on creation of Employee entities.
  16479. func (m *EmployeeMutation) SetID(id uint64) {
  16480. m.id = &id
  16481. }
  16482. // ID returns the ID value in the mutation. Note that the ID is only available
  16483. // if it was provided to the builder or after it was returned from the database.
  16484. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  16485. if m.id == nil {
  16486. return
  16487. }
  16488. return *m.id, true
  16489. }
  16490. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16491. // That means, if the mutation is applied within a transaction with an isolation level such
  16492. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16493. // or updated by the mutation.
  16494. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16495. switch {
  16496. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16497. id, exists := m.ID()
  16498. if exists {
  16499. return []uint64{id}, nil
  16500. }
  16501. fallthrough
  16502. case m.op.Is(OpUpdate | OpDelete):
  16503. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  16504. default:
  16505. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16506. }
  16507. }
  16508. // SetCreatedAt sets the "created_at" field.
  16509. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  16510. m.created_at = &t
  16511. }
  16512. // CreatedAt returns the value of the "created_at" field in the mutation.
  16513. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  16514. v := m.created_at
  16515. if v == nil {
  16516. return
  16517. }
  16518. return *v, true
  16519. }
  16520. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  16521. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16523. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16524. if !m.op.Is(OpUpdateOne) {
  16525. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16526. }
  16527. if m.id == nil || m.oldValue == nil {
  16528. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16529. }
  16530. oldValue, err := m.oldValue(ctx)
  16531. if err != nil {
  16532. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16533. }
  16534. return oldValue.CreatedAt, nil
  16535. }
  16536. // ResetCreatedAt resets all changes to the "created_at" field.
  16537. func (m *EmployeeMutation) ResetCreatedAt() {
  16538. m.created_at = nil
  16539. }
  16540. // SetUpdatedAt sets the "updated_at" field.
  16541. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  16542. m.updated_at = &t
  16543. }
  16544. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16545. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  16546. v := m.updated_at
  16547. if v == nil {
  16548. return
  16549. }
  16550. return *v, true
  16551. }
  16552. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  16553. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16555. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16556. if !m.op.Is(OpUpdateOne) {
  16557. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16558. }
  16559. if m.id == nil || m.oldValue == nil {
  16560. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16561. }
  16562. oldValue, err := m.oldValue(ctx)
  16563. if err != nil {
  16564. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16565. }
  16566. return oldValue.UpdatedAt, nil
  16567. }
  16568. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16569. func (m *EmployeeMutation) ResetUpdatedAt() {
  16570. m.updated_at = nil
  16571. }
  16572. // SetDeletedAt sets the "deleted_at" field.
  16573. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  16574. m.deleted_at = &t
  16575. }
  16576. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16577. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  16578. v := m.deleted_at
  16579. if v == nil {
  16580. return
  16581. }
  16582. return *v, true
  16583. }
  16584. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  16585. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16587. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16588. if !m.op.Is(OpUpdateOne) {
  16589. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16590. }
  16591. if m.id == nil || m.oldValue == nil {
  16592. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16593. }
  16594. oldValue, err := m.oldValue(ctx)
  16595. if err != nil {
  16596. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16597. }
  16598. return oldValue.DeletedAt, nil
  16599. }
  16600. // ClearDeletedAt clears the value of the "deleted_at" field.
  16601. func (m *EmployeeMutation) ClearDeletedAt() {
  16602. m.deleted_at = nil
  16603. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  16604. }
  16605. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16606. func (m *EmployeeMutation) DeletedAtCleared() bool {
  16607. _, ok := m.clearedFields[employee.FieldDeletedAt]
  16608. return ok
  16609. }
  16610. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16611. func (m *EmployeeMutation) ResetDeletedAt() {
  16612. m.deleted_at = nil
  16613. delete(m.clearedFields, employee.FieldDeletedAt)
  16614. }
  16615. // SetTitle sets the "title" field.
  16616. func (m *EmployeeMutation) SetTitle(s string) {
  16617. m.title = &s
  16618. }
  16619. // Title returns the value of the "title" field in the mutation.
  16620. func (m *EmployeeMutation) Title() (r string, exists bool) {
  16621. v := m.title
  16622. if v == nil {
  16623. return
  16624. }
  16625. return *v, true
  16626. }
  16627. // OldTitle returns the old "title" field's value of the Employee entity.
  16628. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16630. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  16631. if !m.op.Is(OpUpdateOne) {
  16632. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16633. }
  16634. if m.id == nil || m.oldValue == nil {
  16635. return v, errors.New("OldTitle requires an ID field in the mutation")
  16636. }
  16637. oldValue, err := m.oldValue(ctx)
  16638. if err != nil {
  16639. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16640. }
  16641. return oldValue.Title, nil
  16642. }
  16643. // ResetTitle resets all changes to the "title" field.
  16644. func (m *EmployeeMutation) ResetTitle() {
  16645. m.title = nil
  16646. }
  16647. // SetAvatar sets the "avatar" field.
  16648. func (m *EmployeeMutation) SetAvatar(s string) {
  16649. m.avatar = &s
  16650. }
  16651. // Avatar returns the value of the "avatar" field in the mutation.
  16652. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  16653. v := m.avatar
  16654. if v == nil {
  16655. return
  16656. }
  16657. return *v, true
  16658. }
  16659. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  16660. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16662. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  16663. if !m.op.Is(OpUpdateOne) {
  16664. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  16665. }
  16666. if m.id == nil || m.oldValue == nil {
  16667. return v, errors.New("OldAvatar requires an ID field in the mutation")
  16668. }
  16669. oldValue, err := m.oldValue(ctx)
  16670. if err != nil {
  16671. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  16672. }
  16673. return oldValue.Avatar, nil
  16674. }
  16675. // ResetAvatar resets all changes to the "avatar" field.
  16676. func (m *EmployeeMutation) ResetAvatar() {
  16677. m.avatar = nil
  16678. }
  16679. // SetTags sets the "tags" field.
  16680. func (m *EmployeeMutation) SetTags(s string) {
  16681. m.tags = &s
  16682. }
  16683. // Tags returns the value of the "tags" field in the mutation.
  16684. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  16685. v := m.tags
  16686. if v == nil {
  16687. return
  16688. }
  16689. return *v, true
  16690. }
  16691. // OldTags returns the old "tags" field's value of the Employee entity.
  16692. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16694. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  16695. if !m.op.Is(OpUpdateOne) {
  16696. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  16697. }
  16698. if m.id == nil || m.oldValue == nil {
  16699. return v, errors.New("OldTags requires an ID field in the mutation")
  16700. }
  16701. oldValue, err := m.oldValue(ctx)
  16702. if err != nil {
  16703. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  16704. }
  16705. return oldValue.Tags, nil
  16706. }
  16707. // ResetTags resets all changes to the "tags" field.
  16708. func (m *EmployeeMutation) ResetTags() {
  16709. m.tags = nil
  16710. }
  16711. // SetHireCount sets the "hire_count" field.
  16712. func (m *EmployeeMutation) SetHireCount(i int) {
  16713. m.hire_count = &i
  16714. m.addhire_count = nil
  16715. }
  16716. // HireCount returns the value of the "hire_count" field in the mutation.
  16717. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  16718. v := m.hire_count
  16719. if v == nil {
  16720. return
  16721. }
  16722. return *v, true
  16723. }
  16724. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  16725. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16727. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  16728. if !m.op.Is(OpUpdateOne) {
  16729. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  16730. }
  16731. if m.id == nil || m.oldValue == nil {
  16732. return v, errors.New("OldHireCount requires an ID field in the mutation")
  16733. }
  16734. oldValue, err := m.oldValue(ctx)
  16735. if err != nil {
  16736. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  16737. }
  16738. return oldValue.HireCount, nil
  16739. }
  16740. // AddHireCount adds i to the "hire_count" field.
  16741. func (m *EmployeeMutation) AddHireCount(i int) {
  16742. if m.addhire_count != nil {
  16743. *m.addhire_count += i
  16744. } else {
  16745. m.addhire_count = &i
  16746. }
  16747. }
  16748. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  16749. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  16750. v := m.addhire_count
  16751. if v == nil {
  16752. return
  16753. }
  16754. return *v, true
  16755. }
  16756. // ResetHireCount resets all changes to the "hire_count" field.
  16757. func (m *EmployeeMutation) ResetHireCount() {
  16758. m.hire_count = nil
  16759. m.addhire_count = nil
  16760. }
  16761. // SetServiceCount sets the "service_count" field.
  16762. func (m *EmployeeMutation) SetServiceCount(i int) {
  16763. m.service_count = &i
  16764. m.addservice_count = nil
  16765. }
  16766. // ServiceCount returns the value of the "service_count" field in the mutation.
  16767. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  16768. v := m.service_count
  16769. if v == nil {
  16770. return
  16771. }
  16772. return *v, true
  16773. }
  16774. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  16775. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16777. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  16778. if !m.op.Is(OpUpdateOne) {
  16779. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  16780. }
  16781. if m.id == nil || m.oldValue == nil {
  16782. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  16783. }
  16784. oldValue, err := m.oldValue(ctx)
  16785. if err != nil {
  16786. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  16787. }
  16788. return oldValue.ServiceCount, nil
  16789. }
  16790. // AddServiceCount adds i to the "service_count" field.
  16791. func (m *EmployeeMutation) AddServiceCount(i int) {
  16792. if m.addservice_count != nil {
  16793. *m.addservice_count += i
  16794. } else {
  16795. m.addservice_count = &i
  16796. }
  16797. }
  16798. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  16799. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  16800. v := m.addservice_count
  16801. if v == nil {
  16802. return
  16803. }
  16804. return *v, true
  16805. }
  16806. // ResetServiceCount resets all changes to the "service_count" field.
  16807. func (m *EmployeeMutation) ResetServiceCount() {
  16808. m.service_count = nil
  16809. m.addservice_count = nil
  16810. }
  16811. // SetAchievementCount sets the "achievement_count" field.
  16812. func (m *EmployeeMutation) SetAchievementCount(i int) {
  16813. m.achievement_count = &i
  16814. m.addachievement_count = nil
  16815. }
  16816. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  16817. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  16818. v := m.achievement_count
  16819. if v == nil {
  16820. return
  16821. }
  16822. return *v, true
  16823. }
  16824. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  16825. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16827. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  16828. if !m.op.Is(OpUpdateOne) {
  16829. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  16830. }
  16831. if m.id == nil || m.oldValue == nil {
  16832. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  16833. }
  16834. oldValue, err := m.oldValue(ctx)
  16835. if err != nil {
  16836. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  16837. }
  16838. return oldValue.AchievementCount, nil
  16839. }
  16840. // AddAchievementCount adds i to the "achievement_count" field.
  16841. func (m *EmployeeMutation) AddAchievementCount(i int) {
  16842. if m.addachievement_count != nil {
  16843. *m.addachievement_count += i
  16844. } else {
  16845. m.addachievement_count = &i
  16846. }
  16847. }
  16848. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  16849. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  16850. v := m.addachievement_count
  16851. if v == nil {
  16852. return
  16853. }
  16854. return *v, true
  16855. }
  16856. // ResetAchievementCount resets all changes to the "achievement_count" field.
  16857. func (m *EmployeeMutation) ResetAchievementCount() {
  16858. m.achievement_count = nil
  16859. m.addachievement_count = nil
  16860. }
  16861. // SetIntro sets the "intro" field.
  16862. func (m *EmployeeMutation) SetIntro(s string) {
  16863. m.intro = &s
  16864. }
  16865. // Intro returns the value of the "intro" field in the mutation.
  16866. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  16867. v := m.intro
  16868. if v == nil {
  16869. return
  16870. }
  16871. return *v, true
  16872. }
  16873. // OldIntro returns the old "intro" field's value of the Employee entity.
  16874. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16876. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  16877. if !m.op.Is(OpUpdateOne) {
  16878. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  16879. }
  16880. if m.id == nil || m.oldValue == nil {
  16881. return v, errors.New("OldIntro requires an ID field in the mutation")
  16882. }
  16883. oldValue, err := m.oldValue(ctx)
  16884. if err != nil {
  16885. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  16886. }
  16887. return oldValue.Intro, nil
  16888. }
  16889. // ResetIntro resets all changes to the "intro" field.
  16890. func (m *EmployeeMutation) ResetIntro() {
  16891. m.intro = nil
  16892. }
  16893. // SetEstimate sets the "estimate" field.
  16894. func (m *EmployeeMutation) SetEstimate(s string) {
  16895. m.estimate = &s
  16896. }
  16897. // Estimate returns the value of the "estimate" field in the mutation.
  16898. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  16899. v := m.estimate
  16900. if v == nil {
  16901. return
  16902. }
  16903. return *v, true
  16904. }
  16905. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  16906. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16908. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  16909. if !m.op.Is(OpUpdateOne) {
  16910. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  16911. }
  16912. if m.id == nil || m.oldValue == nil {
  16913. return v, errors.New("OldEstimate requires an ID field in the mutation")
  16914. }
  16915. oldValue, err := m.oldValue(ctx)
  16916. if err != nil {
  16917. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  16918. }
  16919. return oldValue.Estimate, nil
  16920. }
  16921. // ResetEstimate resets all changes to the "estimate" field.
  16922. func (m *EmployeeMutation) ResetEstimate() {
  16923. m.estimate = nil
  16924. }
  16925. // SetSkill sets the "skill" field.
  16926. func (m *EmployeeMutation) SetSkill(s string) {
  16927. m.skill = &s
  16928. }
  16929. // Skill returns the value of the "skill" field in the mutation.
  16930. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  16931. v := m.skill
  16932. if v == nil {
  16933. return
  16934. }
  16935. return *v, true
  16936. }
  16937. // OldSkill returns the old "skill" field's value of the Employee entity.
  16938. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16940. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  16941. if !m.op.Is(OpUpdateOne) {
  16942. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  16943. }
  16944. if m.id == nil || m.oldValue == nil {
  16945. return v, errors.New("OldSkill requires an ID field in the mutation")
  16946. }
  16947. oldValue, err := m.oldValue(ctx)
  16948. if err != nil {
  16949. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  16950. }
  16951. return oldValue.Skill, nil
  16952. }
  16953. // ResetSkill resets all changes to the "skill" field.
  16954. func (m *EmployeeMutation) ResetSkill() {
  16955. m.skill = nil
  16956. }
  16957. // SetAbilityType sets the "ability_type" field.
  16958. func (m *EmployeeMutation) SetAbilityType(s string) {
  16959. m.ability_type = &s
  16960. }
  16961. // AbilityType returns the value of the "ability_type" field in the mutation.
  16962. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  16963. v := m.ability_type
  16964. if v == nil {
  16965. return
  16966. }
  16967. return *v, true
  16968. }
  16969. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  16970. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16972. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  16973. if !m.op.Is(OpUpdateOne) {
  16974. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  16975. }
  16976. if m.id == nil || m.oldValue == nil {
  16977. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  16978. }
  16979. oldValue, err := m.oldValue(ctx)
  16980. if err != nil {
  16981. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  16982. }
  16983. return oldValue.AbilityType, nil
  16984. }
  16985. // ResetAbilityType resets all changes to the "ability_type" field.
  16986. func (m *EmployeeMutation) ResetAbilityType() {
  16987. m.ability_type = nil
  16988. }
  16989. // SetScene sets the "scene" field.
  16990. func (m *EmployeeMutation) SetScene(s string) {
  16991. m.scene = &s
  16992. }
  16993. // Scene returns the value of the "scene" field in the mutation.
  16994. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  16995. v := m.scene
  16996. if v == nil {
  16997. return
  16998. }
  16999. return *v, true
  17000. }
  17001. // OldScene returns the old "scene" field's value of the Employee entity.
  17002. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17004. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  17005. if !m.op.Is(OpUpdateOne) {
  17006. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  17007. }
  17008. if m.id == nil || m.oldValue == nil {
  17009. return v, errors.New("OldScene requires an ID field in the mutation")
  17010. }
  17011. oldValue, err := m.oldValue(ctx)
  17012. if err != nil {
  17013. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  17014. }
  17015. return oldValue.Scene, nil
  17016. }
  17017. // ResetScene resets all changes to the "scene" field.
  17018. func (m *EmployeeMutation) ResetScene() {
  17019. m.scene = nil
  17020. }
  17021. // SetSwitchIn sets the "switch_in" field.
  17022. func (m *EmployeeMutation) SetSwitchIn(s string) {
  17023. m.switch_in = &s
  17024. }
  17025. // SwitchIn returns the value of the "switch_in" field in the mutation.
  17026. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  17027. v := m.switch_in
  17028. if v == nil {
  17029. return
  17030. }
  17031. return *v, true
  17032. }
  17033. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  17034. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17036. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  17037. if !m.op.Is(OpUpdateOne) {
  17038. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  17039. }
  17040. if m.id == nil || m.oldValue == nil {
  17041. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  17042. }
  17043. oldValue, err := m.oldValue(ctx)
  17044. if err != nil {
  17045. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  17046. }
  17047. return oldValue.SwitchIn, nil
  17048. }
  17049. // ResetSwitchIn resets all changes to the "switch_in" field.
  17050. func (m *EmployeeMutation) ResetSwitchIn() {
  17051. m.switch_in = nil
  17052. }
  17053. // SetVideoURL sets the "video_url" field.
  17054. func (m *EmployeeMutation) SetVideoURL(s string) {
  17055. m.video_url = &s
  17056. }
  17057. // VideoURL returns the value of the "video_url" field in the mutation.
  17058. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  17059. v := m.video_url
  17060. if v == nil {
  17061. return
  17062. }
  17063. return *v, true
  17064. }
  17065. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  17066. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17068. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  17069. if !m.op.Is(OpUpdateOne) {
  17070. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  17071. }
  17072. if m.id == nil || m.oldValue == nil {
  17073. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  17074. }
  17075. oldValue, err := m.oldValue(ctx)
  17076. if err != nil {
  17077. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  17078. }
  17079. return oldValue.VideoURL, nil
  17080. }
  17081. // ResetVideoURL resets all changes to the "video_url" field.
  17082. func (m *EmployeeMutation) ResetVideoURL() {
  17083. m.video_url = nil
  17084. }
  17085. // SetOrganizationID sets the "organization_id" field.
  17086. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  17087. m.organization_id = &u
  17088. m.addorganization_id = nil
  17089. }
  17090. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17091. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  17092. v := m.organization_id
  17093. if v == nil {
  17094. return
  17095. }
  17096. return *v, true
  17097. }
  17098. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  17099. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17101. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17102. if !m.op.Is(OpUpdateOne) {
  17103. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17104. }
  17105. if m.id == nil || m.oldValue == nil {
  17106. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17107. }
  17108. oldValue, err := m.oldValue(ctx)
  17109. if err != nil {
  17110. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17111. }
  17112. return oldValue.OrganizationID, nil
  17113. }
  17114. // AddOrganizationID adds u to the "organization_id" field.
  17115. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  17116. if m.addorganization_id != nil {
  17117. *m.addorganization_id += u
  17118. } else {
  17119. m.addorganization_id = &u
  17120. }
  17121. }
  17122. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17123. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  17124. v := m.addorganization_id
  17125. if v == nil {
  17126. return
  17127. }
  17128. return *v, true
  17129. }
  17130. // ResetOrganizationID resets all changes to the "organization_id" field.
  17131. func (m *EmployeeMutation) ResetOrganizationID() {
  17132. m.organization_id = nil
  17133. m.addorganization_id = nil
  17134. }
  17135. // SetCategoryID sets the "category_id" field.
  17136. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  17137. m.category_id = &u
  17138. m.addcategory_id = nil
  17139. }
  17140. // CategoryID returns the value of the "category_id" field in the mutation.
  17141. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  17142. v := m.category_id
  17143. if v == nil {
  17144. return
  17145. }
  17146. return *v, true
  17147. }
  17148. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  17149. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17151. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  17152. if !m.op.Is(OpUpdateOne) {
  17153. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  17154. }
  17155. if m.id == nil || m.oldValue == nil {
  17156. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  17157. }
  17158. oldValue, err := m.oldValue(ctx)
  17159. if err != nil {
  17160. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  17161. }
  17162. return oldValue.CategoryID, nil
  17163. }
  17164. // AddCategoryID adds u to the "category_id" field.
  17165. func (m *EmployeeMutation) AddCategoryID(u int64) {
  17166. if m.addcategory_id != nil {
  17167. *m.addcategory_id += u
  17168. } else {
  17169. m.addcategory_id = &u
  17170. }
  17171. }
  17172. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  17173. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  17174. v := m.addcategory_id
  17175. if v == nil {
  17176. return
  17177. }
  17178. return *v, true
  17179. }
  17180. // ResetCategoryID resets all changes to the "category_id" field.
  17181. func (m *EmployeeMutation) ResetCategoryID() {
  17182. m.category_id = nil
  17183. m.addcategory_id = nil
  17184. }
  17185. // SetAPIBase sets the "api_base" field.
  17186. func (m *EmployeeMutation) SetAPIBase(s string) {
  17187. m.api_base = &s
  17188. }
  17189. // APIBase returns the value of the "api_base" field in the mutation.
  17190. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  17191. v := m.api_base
  17192. if v == nil {
  17193. return
  17194. }
  17195. return *v, true
  17196. }
  17197. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  17198. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17200. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  17201. if !m.op.Is(OpUpdateOne) {
  17202. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  17203. }
  17204. if m.id == nil || m.oldValue == nil {
  17205. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  17206. }
  17207. oldValue, err := m.oldValue(ctx)
  17208. if err != nil {
  17209. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  17210. }
  17211. return oldValue.APIBase, nil
  17212. }
  17213. // ResetAPIBase resets all changes to the "api_base" field.
  17214. func (m *EmployeeMutation) ResetAPIBase() {
  17215. m.api_base = nil
  17216. }
  17217. // SetAPIKey sets the "api_key" field.
  17218. func (m *EmployeeMutation) SetAPIKey(s string) {
  17219. m.api_key = &s
  17220. }
  17221. // APIKey returns the value of the "api_key" field in the mutation.
  17222. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  17223. v := m.api_key
  17224. if v == nil {
  17225. return
  17226. }
  17227. return *v, true
  17228. }
  17229. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  17230. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17232. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  17233. if !m.op.Is(OpUpdateOne) {
  17234. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  17235. }
  17236. if m.id == nil || m.oldValue == nil {
  17237. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  17238. }
  17239. oldValue, err := m.oldValue(ctx)
  17240. if err != nil {
  17241. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  17242. }
  17243. return oldValue.APIKey, nil
  17244. }
  17245. // ResetAPIKey resets all changes to the "api_key" field.
  17246. func (m *EmployeeMutation) ResetAPIKey() {
  17247. m.api_key = nil
  17248. }
  17249. // SetAiInfo sets the "ai_info" field.
  17250. func (m *EmployeeMutation) SetAiInfo(s string) {
  17251. m.ai_info = &s
  17252. }
  17253. // AiInfo returns the value of the "ai_info" field in the mutation.
  17254. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  17255. v := m.ai_info
  17256. if v == nil {
  17257. return
  17258. }
  17259. return *v, true
  17260. }
  17261. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  17262. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17264. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  17265. if !m.op.Is(OpUpdateOne) {
  17266. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  17267. }
  17268. if m.id == nil || m.oldValue == nil {
  17269. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  17270. }
  17271. oldValue, err := m.oldValue(ctx)
  17272. if err != nil {
  17273. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  17274. }
  17275. return oldValue.AiInfo, nil
  17276. }
  17277. // ClearAiInfo clears the value of the "ai_info" field.
  17278. func (m *EmployeeMutation) ClearAiInfo() {
  17279. m.ai_info = nil
  17280. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  17281. }
  17282. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  17283. func (m *EmployeeMutation) AiInfoCleared() bool {
  17284. _, ok := m.clearedFields[employee.FieldAiInfo]
  17285. return ok
  17286. }
  17287. // ResetAiInfo resets all changes to the "ai_info" field.
  17288. func (m *EmployeeMutation) ResetAiInfo() {
  17289. m.ai_info = nil
  17290. delete(m.clearedFields, employee.FieldAiInfo)
  17291. }
  17292. // SetIsVip sets the "is_vip" field.
  17293. func (m *EmployeeMutation) SetIsVip(i int) {
  17294. m.is_vip = &i
  17295. m.addis_vip = nil
  17296. }
  17297. // IsVip returns the value of the "is_vip" field in the mutation.
  17298. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  17299. v := m.is_vip
  17300. if v == nil {
  17301. return
  17302. }
  17303. return *v, true
  17304. }
  17305. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  17306. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17308. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  17309. if !m.op.Is(OpUpdateOne) {
  17310. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  17311. }
  17312. if m.id == nil || m.oldValue == nil {
  17313. return v, errors.New("OldIsVip requires an ID field in the mutation")
  17314. }
  17315. oldValue, err := m.oldValue(ctx)
  17316. if err != nil {
  17317. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  17318. }
  17319. return oldValue.IsVip, nil
  17320. }
  17321. // AddIsVip adds i to the "is_vip" field.
  17322. func (m *EmployeeMutation) AddIsVip(i int) {
  17323. if m.addis_vip != nil {
  17324. *m.addis_vip += i
  17325. } else {
  17326. m.addis_vip = &i
  17327. }
  17328. }
  17329. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  17330. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  17331. v := m.addis_vip
  17332. if v == nil {
  17333. return
  17334. }
  17335. return *v, true
  17336. }
  17337. // ResetIsVip resets all changes to the "is_vip" field.
  17338. func (m *EmployeeMutation) ResetIsVip() {
  17339. m.is_vip = nil
  17340. m.addis_vip = nil
  17341. }
  17342. // SetChatURL sets the "chat_url" field.
  17343. func (m *EmployeeMutation) SetChatURL(s string) {
  17344. m.chat_url = &s
  17345. }
  17346. // ChatURL returns the value of the "chat_url" field in the mutation.
  17347. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  17348. v := m.chat_url
  17349. if v == nil {
  17350. return
  17351. }
  17352. return *v, true
  17353. }
  17354. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  17355. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17357. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  17358. if !m.op.Is(OpUpdateOne) {
  17359. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  17360. }
  17361. if m.id == nil || m.oldValue == nil {
  17362. return v, errors.New("OldChatURL requires an ID field in the mutation")
  17363. }
  17364. oldValue, err := m.oldValue(ctx)
  17365. if err != nil {
  17366. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  17367. }
  17368. return oldValue.ChatURL, nil
  17369. }
  17370. // ResetChatURL resets all changes to the "chat_url" field.
  17371. func (m *EmployeeMutation) ResetChatURL() {
  17372. m.chat_url = nil
  17373. }
  17374. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  17375. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  17376. if m.em_work_experiences == nil {
  17377. m.em_work_experiences = make(map[uint64]struct{})
  17378. }
  17379. for i := range ids {
  17380. m.em_work_experiences[ids[i]] = struct{}{}
  17381. }
  17382. }
  17383. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  17384. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  17385. m.clearedem_work_experiences = true
  17386. }
  17387. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  17388. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  17389. return m.clearedem_work_experiences
  17390. }
  17391. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  17392. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  17393. if m.removedem_work_experiences == nil {
  17394. m.removedem_work_experiences = make(map[uint64]struct{})
  17395. }
  17396. for i := range ids {
  17397. delete(m.em_work_experiences, ids[i])
  17398. m.removedem_work_experiences[ids[i]] = struct{}{}
  17399. }
  17400. }
  17401. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  17402. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  17403. for id := range m.removedem_work_experiences {
  17404. ids = append(ids, id)
  17405. }
  17406. return
  17407. }
  17408. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  17409. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  17410. for id := range m.em_work_experiences {
  17411. ids = append(ids, id)
  17412. }
  17413. return
  17414. }
  17415. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  17416. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  17417. m.em_work_experiences = nil
  17418. m.clearedem_work_experiences = false
  17419. m.removedem_work_experiences = nil
  17420. }
  17421. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  17422. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  17423. if m.em_tutorial == nil {
  17424. m.em_tutorial = make(map[uint64]struct{})
  17425. }
  17426. for i := range ids {
  17427. m.em_tutorial[ids[i]] = struct{}{}
  17428. }
  17429. }
  17430. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  17431. func (m *EmployeeMutation) ClearEmTutorial() {
  17432. m.clearedem_tutorial = true
  17433. }
  17434. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  17435. func (m *EmployeeMutation) EmTutorialCleared() bool {
  17436. return m.clearedem_tutorial
  17437. }
  17438. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  17439. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  17440. if m.removedem_tutorial == nil {
  17441. m.removedem_tutorial = make(map[uint64]struct{})
  17442. }
  17443. for i := range ids {
  17444. delete(m.em_tutorial, ids[i])
  17445. m.removedem_tutorial[ids[i]] = struct{}{}
  17446. }
  17447. }
  17448. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  17449. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  17450. for id := range m.removedem_tutorial {
  17451. ids = append(ids, id)
  17452. }
  17453. return
  17454. }
  17455. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  17456. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  17457. for id := range m.em_tutorial {
  17458. ids = append(ids, id)
  17459. }
  17460. return
  17461. }
  17462. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  17463. func (m *EmployeeMutation) ResetEmTutorial() {
  17464. m.em_tutorial = nil
  17465. m.clearedem_tutorial = false
  17466. m.removedem_tutorial = nil
  17467. }
  17468. // Where appends a list predicates to the EmployeeMutation builder.
  17469. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  17470. m.predicates = append(m.predicates, ps...)
  17471. }
  17472. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  17473. // users can use type-assertion to append predicates that do not depend on any generated package.
  17474. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  17475. p := make([]predicate.Employee, len(ps))
  17476. for i := range ps {
  17477. p[i] = ps[i]
  17478. }
  17479. m.Where(p...)
  17480. }
  17481. // Op returns the operation name.
  17482. func (m *EmployeeMutation) Op() Op {
  17483. return m.op
  17484. }
  17485. // SetOp allows setting the mutation operation.
  17486. func (m *EmployeeMutation) SetOp(op Op) {
  17487. m.op = op
  17488. }
  17489. // Type returns the node type of this mutation (Employee).
  17490. func (m *EmployeeMutation) Type() string {
  17491. return m.typ
  17492. }
  17493. // Fields returns all fields that were changed during this mutation. Note that in
  17494. // order to get all numeric fields that were incremented/decremented, call
  17495. // AddedFields().
  17496. func (m *EmployeeMutation) Fields() []string {
  17497. fields := make([]string, 0, 23)
  17498. if m.created_at != nil {
  17499. fields = append(fields, employee.FieldCreatedAt)
  17500. }
  17501. if m.updated_at != nil {
  17502. fields = append(fields, employee.FieldUpdatedAt)
  17503. }
  17504. if m.deleted_at != nil {
  17505. fields = append(fields, employee.FieldDeletedAt)
  17506. }
  17507. if m.title != nil {
  17508. fields = append(fields, employee.FieldTitle)
  17509. }
  17510. if m.avatar != nil {
  17511. fields = append(fields, employee.FieldAvatar)
  17512. }
  17513. if m.tags != nil {
  17514. fields = append(fields, employee.FieldTags)
  17515. }
  17516. if m.hire_count != nil {
  17517. fields = append(fields, employee.FieldHireCount)
  17518. }
  17519. if m.service_count != nil {
  17520. fields = append(fields, employee.FieldServiceCount)
  17521. }
  17522. if m.achievement_count != nil {
  17523. fields = append(fields, employee.FieldAchievementCount)
  17524. }
  17525. if m.intro != nil {
  17526. fields = append(fields, employee.FieldIntro)
  17527. }
  17528. if m.estimate != nil {
  17529. fields = append(fields, employee.FieldEstimate)
  17530. }
  17531. if m.skill != nil {
  17532. fields = append(fields, employee.FieldSkill)
  17533. }
  17534. if m.ability_type != nil {
  17535. fields = append(fields, employee.FieldAbilityType)
  17536. }
  17537. if m.scene != nil {
  17538. fields = append(fields, employee.FieldScene)
  17539. }
  17540. if m.switch_in != nil {
  17541. fields = append(fields, employee.FieldSwitchIn)
  17542. }
  17543. if m.video_url != nil {
  17544. fields = append(fields, employee.FieldVideoURL)
  17545. }
  17546. if m.organization_id != nil {
  17547. fields = append(fields, employee.FieldOrganizationID)
  17548. }
  17549. if m.category_id != nil {
  17550. fields = append(fields, employee.FieldCategoryID)
  17551. }
  17552. if m.api_base != nil {
  17553. fields = append(fields, employee.FieldAPIBase)
  17554. }
  17555. if m.api_key != nil {
  17556. fields = append(fields, employee.FieldAPIKey)
  17557. }
  17558. if m.ai_info != nil {
  17559. fields = append(fields, employee.FieldAiInfo)
  17560. }
  17561. if m.is_vip != nil {
  17562. fields = append(fields, employee.FieldIsVip)
  17563. }
  17564. if m.chat_url != nil {
  17565. fields = append(fields, employee.FieldChatURL)
  17566. }
  17567. return fields
  17568. }
  17569. // Field returns the value of a field with the given name. The second boolean
  17570. // return value indicates that this field was not set, or was not defined in the
  17571. // schema.
  17572. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  17573. switch name {
  17574. case employee.FieldCreatedAt:
  17575. return m.CreatedAt()
  17576. case employee.FieldUpdatedAt:
  17577. return m.UpdatedAt()
  17578. case employee.FieldDeletedAt:
  17579. return m.DeletedAt()
  17580. case employee.FieldTitle:
  17581. return m.Title()
  17582. case employee.FieldAvatar:
  17583. return m.Avatar()
  17584. case employee.FieldTags:
  17585. return m.Tags()
  17586. case employee.FieldHireCount:
  17587. return m.HireCount()
  17588. case employee.FieldServiceCount:
  17589. return m.ServiceCount()
  17590. case employee.FieldAchievementCount:
  17591. return m.AchievementCount()
  17592. case employee.FieldIntro:
  17593. return m.Intro()
  17594. case employee.FieldEstimate:
  17595. return m.Estimate()
  17596. case employee.FieldSkill:
  17597. return m.Skill()
  17598. case employee.FieldAbilityType:
  17599. return m.AbilityType()
  17600. case employee.FieldScene:
  17601. return m.Scene()
  17602. case employee.FieldSwitchIn:
  17603. return m.SwitchIn()
  17604. case employee.FieldVideoURL:
  17605. return m.VideoURL()
  17606. case employee.FieldOrganizationID:
  17607. return m.OrganizationID()
  17608. case employee.FieldCategoryID:
  17609. return m.CategoryID()
  17610. case employee.FieldAPIBase:
  17611. return m.APIBase()
  17612. case employee.FieldAPIKey:
  17613. return m.APIKey()
  17614. case employee.FieldAiInfo:
  17615. return m.AiInfo()
  17616. case employee.FieldIsVip:
  17617. return m.IsVip()
  17618. case employee.FieldChatURL:
  17619. return m.ChatURL()
  17620. }
  17621. return nil, false
  17622. }
  17623. // OldField returns the old value of the field from the database. An error is
  17624. // returned if the mutation operation is not UpdateOne, or the query to the
  17625. // database failed.
  17626. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17627. switch name {
  17628. case employee.FieldCreatedAt:
  17629. return m.OldCreatedAt(ctx)
  17630. case employee.FieldUpdatedAt:
  17631. return m.OldUpdatedAt(ctx)
  17632. case employee.FieldDeletedAt:
  17633. return m.OldDeletedAt(ctx)
  17634. case employee.FieldTitle:
  17635. return m.OldTitle(ctx)
  17636. case employee.FieldAvatar:
  17637. return m.OldAvatar(ctx)
  17638. case employee.FieldTags:
  17639. return m.OldTags(ctx)
  17640. case employee.FieldHireCount:
  17641. return m.OldHireCount(ctx)
  17642. case employee.FieldServiceCount:
  17643. return m.OldServiceCount(ctx)
  17644. case employee.FieldAchievementCount:
  17645. return m.OldAchievementCount(ctx)
  17646. case employee.FieldIntro:
  17647. return m.OldIntro(ctx)
  17648. case employee.FieldEstimate:
  17649. return m.OldEstimate(ctx)
  17650. case employee.FieldSkill:
  17651. return m.OldSkill(ctx)
  17652. case employee.FieldAbilityType:
  17653. return m.OldAbilityType(ctx)
  17654. case employee.FieldScene:
  17655. return m.OldScene(ctx)
  17656. case employee.FieldSwitchIn:
  17657. return m.OldSwitchIn(ctx)
  17658. case employee.FieldVideoURL:
  17659. return m.OldVideoURL(ctx)
  17660. case employee.FieldOrganizationID:
  17661. return m.OldOrganizationID(ctx)
  17662. case employee.FieldCategoryID:
  17663. return m.OldCategoryID(ctx)
  17664. case employee.FieldAPIBase:
  17665. return m.OldAPIBase(ctx)
  17666. case employee.FieldAPIKey:
  17667. return m.OldAPIKey(ctx)
  17668. case employee.FieldAiInfo:
  17669. return m.OldAiInfo(ctx)
  17670. case employee.FieldIsVip:
  17671. return m.OldIsVip(ctx)
  17672. case employee.FieldChatURL:
  17673. return m.OldChatURL(ctx)
  17674. }
  17675. return nil, fmt.Errorf("unknown Employee field %s", name)
  17676. }
  17677. // SetField sets the value of a field with the given name. It returns an error if
  17678. // the field is not defined in the schema, or if the type mismatched the field
  17679. // type.
  17680. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  17681. switch name {
  17682. case employee.FieldCreatedAt:
  17683. v, ok := value.(time.Time)
  17684. if !ok {
  17685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17686. }
  17687. m.SetCreatedAt(v)
  17688. return nil
  17689. case employee.FieldUpdatedAt:
  17690. v, ok := value.(time.Time)
  17691. if !ok {
  17692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17693. }
  17694. m.SetUpdatedAt(v)
  17695. return nil
  17696. case employee.FieldDeletedAt:
  17697. v, ok := value.(time.Time)
  17698. if !ok {
  17699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17700. }
  17701. m.SetDeletedAt(v)
  17702. return nil
  17703. case employee.FieldTitle:
  17704. v, ok := value.(string)
  17705. if !ok {
  17706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17707. }
  17708. m.SetTitle(v)
  17709. return nil
  17710. case employee.FieldAvatar:
  17711. v, ok := value.(string)
  17712. if !ok {
  17713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17714. }
  17715. m.SetAvatar(v)
  17716. return nil
  17717. case employee.FieldTags:
  17718. v, ok := value.(string)
  17719. if !ok {
  17720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17721. }
  17722. m.SetTags(v)
  17723. return nil
  17724. case employee.FieldHireCount:
  17725. v, ok := value.(int)
  17726. if !ok {
  17727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17728. }
  17729. m.SetHireCount(v)
  17730. return nil
  17731. case employee.FieldServiceCount:
  17732. v, ok := value.(int)
  17733. if !ok {
  17734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17735. }
  17736. m.SetServiceCount(v)
  17737. return nil
  17738. case employee.FieldAchievementCount:
  17739. v, ok := value.(int)
  17740. if !ok {
  17741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17742. }
  17743. m.SetAchievementCount(v)
  17744. return nil
  17745. case employee.FieldIntro:
  17746. v, ok := value.(string)
  17747. if !ok {
  17748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17749. }
  17750. m.SetIntro(v)
  17751. return nil
  17752. case employee.FieldEstimate:
  17753. v, ok := value.(string)
  17754. if !ok {
  17755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17756. }
  17757. m.SetEstimate(v)
  17758. return nil
  17759. case employee.FieldSkill:
  17760. v, ok := value.(string)
  17761. if !ok {
  17762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17763. }
  17764. m.SetSkill(v)
  17765. return nil
  17766. case employee.FieldAbilityType:
  17767. v, ok := value.(string)
  17768. if !ok {
  17769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17770. }
  17771. m.SetAbilityType(v)
  17772. return nil
  17773. case employee.FieldScene:
  17774. v, ok := value.(string)
  17775. if !ok {
  17776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17777. }
  17778. m.SetScene(v)
  17779. return nil
  17780. case employee.FieldSwitchIn:
  17781. v, ok := value.(string)
  17782. if !ok {
  17783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17784. }
  17785. m.SetSwitchIn(v)
  17786. return nil
  17787. case employee.FieldVideoURL:
  17788. v, ok := value.(string)
  17789. if !ok {
  17790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17791. }
  17792. m.SetVideoURL(v)
  17793. return nil
  17794. case employee.FieldOrganizationID:
  17795. v, ok := value.(uint64)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.SetOrganizationID(v)
  17800. return nil
  17801. case employee.FieldCategoryID:
  17802. v, ok := value.(uint64)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.SetCategoryID(v)
  17807. return nil
  17808. case employee.FieldAPIBase:
  17809. v, ok := value.(string)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.SetAPIBase(v)
  17814. return nil
  17815. case employee.FieldAPIKey:
  17816. v, ok := value.(string)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.SetAPIKey(v)
  17821. return nil
  17822. case employee.FieldAiInfo:
  17823. v, ok := value.(string)
  17824. if !ok {
  17825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17826. }
  17827. m.SetAiInfo(v)
  17828. return nil
  17829. case employee.FieldIsVip:
  17830. v, ok := value.(int)
  17831. if !ok {
  17832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17833. }
  17834. m.SetIsVip(v)
  17835. return nil
  17836. case employee.FieldChatURL:
  17837. v, ok := value.(string)
  17838. if !ok {
  17839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17840. }
  17841. m.SetChatURL(v)
  17842. return nil
  17843. }
  17844. return fmt.Errorf("unknown Employee field %s", name)
  17845. }
  17846. // AddedFields returns all numeric fields that were incremented/decremented during
  17847. // this mutation.
  17848. func (m *EmployeeMutation) AddedFields() []string {
  17849. var fields []string
  17850. if m.addhire_count != nil {
  17851. fields = append(fields, employee.FieldHireCount)
  17852. }
  17853. if m.addservice_count != nil {
  17854. fields = append(fields, employee.FieldServiceCount)
  17855. }
  17856. if m.addachievement_count != nil {
  17857. fields = append(fields, employee.FieldAchievementCount)
  17858. }
  17859. if m.addorganization_id != nil {
  17860. fields = append(fields, employee.FieldOrganizationID)
  17861. }
  17862. if m.addcategory_id != nil {
  17863. fields = append(fields, employee.FieldCategoryID)
  17864. }
  17865. if m.addis_vip != nil {
  17866. fields = append(fields, employee.FieldIsVip)
  17867. }
  17868. return fields
  17869. }
  17870. // AddedField returns the numeric value that was incremented/decremented on a field
  17871. // with the given name. The second boolean return value indicates that this field
  17872. // was not set, or was not defined in the schema.
  17873. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  17874. switch name {
  17875. case employee.FieldHireCount:
  17876. return m.AddedHireCount()
  17877. case employee.FieldServiceCount:
  17878. return m.AddedServiceCount()
  17879. case employee.FieldAchievementCount:
  17880. return m.AddedAchievementCount()
  17881. case employee.FieldOrganizationID:
  17882. return m.AddedOrganizationID()
  17883. case employee.FieldCategoryID:
  17884. return m.AddedCategoryID()
  17885. case employee.FieldIsVip:
  17886. return m.AddedIsVip()
  17887. }
  17888. return nil, false
  17889. }
  17890. // AddField adds the value to the field with the given name. It returns an error if
  17891. // the field is not defined in the schema, or if the type mismatched the field
  17892. // type.
  17893. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  17894. switch name {
  17895. case employee.FieldHireCount:
  17896. v, ok := value.(int)
  17897. if !ok {
  17898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17899. }
  17900. m.AddHireCount(v)
  17901. return nil
  17902. case employee.FieldServiceCount:
  17903. v, ok := value.(int)
  17904. if !ok {
  17905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17906. }
  17907. m.AddServiceCount(v)
  17908. return nil
  17909. case employee.FieldAchievementCount:
  17910. v, ok := value.(int)
  17911. if !ok {
  17912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17913. }
  17914. m.AddAchievementCount(v)
  17915. return nil
  17916. case employee.FieldOrganizationID:
  17917. v, ok := value.(int64)
  17918. if !ok {
  17919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17920. }
  17921. m.AddOrganizationID(v)
  17922. return nil
  17923. case employee.FieldCategoryID:
  17924. v, ok := value.(int64)
  17925. if !ok {
  17926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17927. }
  17928. m.AddCategoryID(v)
  17929. return nil
  17930. case employee.FieldIsVip:
  17931. v, ok := value.(int)
  17932. if !ok {
  17933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17934. }
  17935. m.AddIsVip(v)
  17936. return nil
  17937. }
  17938. return fmt.Errorf("unknown Employee numeric field %s", name)
  17939. }
  17940. // ClearedFields returns all nullable fields that were cleared during this
  17941. // mutation.
  17942. func (m *EmployeeMutation) ClearedFields() []string {
  17943. var fields []string
  17944. if m.FieldCleared(employee.FieldDeletedAt) {
  17945. fields = append(fields, employee.FieldDeletedAt)
  17946. }
  17947. if m.FieldCleared(employee.FieldAiInfo) {
  17948. fields = append(fields, employee.FieldAiInfo)
  17949. }
  17950. return fields
  17951. }
  17952. // FieldCleared returns a boolean indicating if a field with the given name was
  17953. // cleared in this mutation.
  17954. func (m *EmployeeMutation) FieldCleared(name string) bool {
  17955. _, ok := m.clearedFields[name]
  17956. return ok
  17957. }
  17958. // ClearField clears the value of the field with the given name. It returns an
  17959. // error if the field is not defined in the schema.
  17960. func (m *EmployeeMutation) ClearField(name string) error {
  17961. switch name {
  17962. case employee.FieldDeletedAt:
  17963. m.ClearDeletedAt()
  17964. return nil
  17965. case employee.FieldAiInfo:
  17966. m.ClearAiInfo()
  17967. return nil
  17968. }
  17969. return fmt.Errorf("unknown Employee nullable field %s", name)
  17970. }
  17971. // ResetField resets all changes in the mutation for the field with the given name.
  17972. // It returns an error if the field is not defined in the schema.
  17973. func (m *EmployeeMutation) ResetField(name string) error {
  17974. switch name {
  17975. case employee.FieldCreatedAt:
  17976. m.ResetCreatedAt()
  17977. return nil
  17978. case employee.FieldUpdatedAt:
  17979. m.ResetUpdatedAt()
  17980. return nil
  17981. case employee.FieldDeletedAt:
  17982. m.ResetDeletedAt()
  17983. return nil
  17984. case employee.FieldTitle:
  17985. m.ResetTitle()
  17986. return nil
  17987. case employee.FieldAvatar:
  17988. m.ResetAvatar()
  17989. return nil
  17990. case employee.FieldTags:
  17991. m.ResetTags()
  17992. return nil
  17993. case employee.FieldHireCount:
  17994. m.ResetHireCount()
  17995. return nil
  17996. case employee.FieldServiceCount:
  17997. m.ResetServiceCount()
  17998. return nil
  17999. case employee.FieldAchievementCount:
  18000. m.ResetAchievementCount()
  18001. return nil
  18002. case employee.FieldIntro:
  18003. m.ResetIntro()
  18004. return nil
  18005. case employee.FieldEstimate:
  18006. m.ResetEstimate()
  18007. return nil
  18008. case employee.FieldSkill:
  18009. m.ResetSkill()
  18010. return nil
  18011. case employee.FieldAbilityType:
  18012. m.ResetAbilityType()
  18013. return nil
  18014. case employee.FieldScene:
  18015. m.ResetScene()
  18016. return nil
  18017. case employee.FieldSwitchIn:
  18018. m.ResetSwitchIn()
  18019. return nil
  18020. case employee.FieldVideoURL:
  18021. m.ResetVideoURL()
  18022. return nil
  18023. case employee.FieldOrganizationID:
  18024. m.ResetOrganizationID()
  18025. return nil
  18026. case employee.FieldCategoryID:
  18027. m.ResetCategoryID()
  18028. return nil
  18029. case employee.FieldAPIBase:
  18030. m.ResetAPIBase()
  18031. return nil
  18032. case employee.FieldAPIKey:
  18033. m.ResetAPIKey()
  18034. return nil
  18035. case employee.FieldAiInfo:
  18036. m.ResetAiInfo()
  18037. return nil
  18038. case employee.FieldIsVip:
  18039. m.ResetIsVip()
  18040. return nil
  18041. case employee.FieldChatURL:
  18042. m.ResetChatURL()
  18043. return nil
  18044. }
  18045. return fmt.Errorf("unknown Employee field %s", name)
  18046. }
  18047. // AddedEdges returns all edge names that were set/added in this mutation.
  18048. func (m *EmployeeMutation) AddedEdges() []string {
  18049. edges := make([]string, 0, 2)
  18050. if m.em_work_experiences != nil {
  18051. edges = append(edges, employee.EdgeEmWorkExperiences)
  18052. }
  18053. if m.em_tutorial != nil {
  18054. edges = append(edges, employee.EdgeEmTutorial)
  18055. }
  18056. return edges
  18057. }
  18058. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18059. // name in this mutation.
  18060. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  18061. switch name {
  18062. case employee.EdgeEmWorkExperiences:
  18063. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  18064. for id := range m.em_work_experiences {
  18065. ids = append(ids, id)
  18066. }
  18067. return ids
  18068. case employee.EdgeEmTutorial:
  18069. ids := make([]ent.Value, 0, len(m.em_tutorial))
  18070. for id := range m.em_tutorial {
  18071. ids = append(ids, id)
  18072. }
  18073. return ids
  18074. }
  18075. return nil
  18076. }
  18077. // RemovedEdges returns all edge names that were removed in this mutation.
  18078. func (m *EmployeeMutation) RemovedEdges() []string {
  18079. edges := make([]string, 0, 2)
  18080. if m.removedem_work_experiences != nil {
  18081. edges = append(edges, employee.EdgeEmWorkExperiences)
  18082. }
  18083. if m.removedem_tutorial != nil {
  18084. edges = append(edges, employee.EdgeEmTutorial)
  18085. }
  18086. return edges
  18087. }
  18088. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18089. // the given name in this mutation.
  18090. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  18091. switch name {
  18092. case employee.EdgeEmWorkExperiences:
  18093. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  18094. for id := range m.removedem_work_experiences {
  18095. ids = append(ids, id)
  18096. }
  18097. return ids
  18098. case employee.EdgeEmTutorial:
  18099. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  18100. for id := range m.removedem_tutorial {
  18101. ids = append(ids, id)
  18102. }
  18103. return ids
  18104. }
  18105. return nil
  18106. }
  18107. // ClearedEdges returns all edge names that were cleared in this mutation.
  18108. func (m *EmployeeMutation) ClearedEdges() []string {
  18109. edges := make([]string, 0, 2)
  18110. if m.clearedem_work_experiences {
  18111. edges = append(edges, employee.EdgeEmWorkExperiences)
  18112. }
  18113. if m.clearedem_tutorial {
  18114. edges = append(edges, employee.EdgeEmTutorial)
  18115. }
  18116. return edges
  18117. }
  18118. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18119. // was cleared in this mutation.
  18120. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  18121. switch name {
  18122. case employee.EdgeEmWorkExperiences:
  18123. return m.clearedem_work_experiences
  18124. case employee.EdgeEmTutorial:
  18125. return m.clearedem_tutorial
  18126. }
  18127. return false
  18128. }
  18129. // ClearEdge clears the value of the edge with the given name. It returns an error
  18130. // if that edge is not defined in the schema.
  18131. func (m *EmployeeMutation) ClearEdge(name string) error {
  18132. switch name {
  18133. }
  18134. return fmt.Errorf("unknown Employee unique edge %s", name)
  18135. }
  18136. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18137. // It returns an error if the edge is not defined in the schema.
  18138. func (m *EmployeeMutation) ResetEdge(name string) error {
  18139. switch name {
  18140. case employee.EdgeEmWorkExperiences:
  18141. m.ResetEmWorkExperiences()
  18142. return nil
  18143. case employee.EdgeEmTutorial:
  18144. m.ResetEmTutorial()
  18145. return nil
  18146. }
  18147. return fmt.Errorf("unknown Employee edge %s", name)
  18148. }
  18149. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  18150. type EmployeeConfigMutation struct {
  18151. config
  18152. op Op
  18153. typ string
  18154. id *uint64
  18155. created_at *time.Time
  18156. updated_at *time.Time
  18157. deleted_at *time.Time
  18158. stype *string
  18159. title *string
  18160. photo *string
  18161. organization_id *uint64
  18162. addorganization_id *int64
  18163. clearedFields map[string]struct{}
  18164. done bool
  18165. oldValue func(context.Context) (*EmployeeConfig, error)
  18166. predicates []predicate.EmployeeConfig
  18167. }
  18168. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  18169. // employeeconfigOption allows management of the mutation configuration using functional options.
  18170. type employeeconfigOption func(*EmployeeConfigMutation)
  18171. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  18172. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  18173. m := &EmployeeConfigMutation{
  18174. config: c,
  18175. op: op,
  18176. typ: TypeEmployeeConfig,
  18177. clearedFields: make(map[string]struct{}),
  18178. }
  18179. for _, opt := range opts {
  18180. opt(m)
  18181. }
  18182. return m
  18183. }
  18184. // withEmployeeConfigID sets the ID field of the mutation.
  18185. func withEmployeeConfigID(id uint64) employeeconfigOption {
  18186. return func(m *EmployeeConfigMutation) {
  18187. var (
  18188. err error
  18189. once sync.Once
  18190. value *EmployeeConfig
  18191. )
  18192. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  18193. once.Do(func() {
  18194. if m.done {
  18195. err = errors.New("querying old values post mutation is not allowed")
  18196. } else {
  18197. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  18198. }
  18199. })
  18200. return value, err
  18201. }
  18202. m.id = &id
  18203. }
  18204. }
  18205. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  18206. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  18207. return func(m *EmployeeConfigMutation) {
  18208. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  18209. return node, nil
  18210. }
  18211. m.id = &node.ID
  18212. }
  18213. }
  18214. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18215. // executed in a transaction (ent.Tx), a transactional client is returned.
  18216. func (m EmployeeConfigMutation) Client() *Client {
  18217. client := &Client{config: m.config}
  18218. client.init()
  18219. return client
  18220. }
  18221. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18222. // it returns an error otherwise.
  18223. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  18224. if _, ok := m.driver.(*txDriver); !ok {
  18225. return nil, errors.New("ent: mutation is not running in a transaction")
  18226. }
  18227. tx := &Tx{config: m.config}
  18228. tx.init()
  18229. return tx, nil
  18230. }
  18231. // SetID sets the value of the id field. Note that this
  18232. // operation is only accepted on creation of EmployeeConfig entities.
  18233. func (m *EmployeeConfigMutation) SetID(id uint64) {
  18234. m.id = &id
  18235. }
  18236. // ID returns the ID value in the mutation. Note that the ID is only available
  18237. // if it was provided to the builder or after it was returned from the database.
  18238. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  18239. if m.id == nil {
  18240. return
  18241. }
  18242. return *m.id, true
  18243. }
  18244. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18245. // That means, if the mutation is applied within a transaction with an isolation level such
  18246. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18247. // or updated by the mutation.
  18248. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  18249. switch {
  18250. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18251. id, exists := m.ID()
  18252. if exists {
  18253. return []uint64{id}, nil
  18254. }
  18255. fallthrough
  18256. case m.op.Is(OpUpdate | OpDelete):
  18257. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  18258. default:
  18259. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18260. }
  18261. }
  18262. // SetCreatedAt sets the "created_at" field.
  18263. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  18264. m.created_at = &t
  18265. }
  18266. // CreatedAt returns the value of the "created_at" field in the mutation.
  18267. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  18268. v := m.created_at
  18269. if v == nil {
  18270. return
  18271. }
  18272. return *v, true
  18273. }
  18274. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  18275. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18277. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18278. if !m.op.Is(OpUpdateOne) {
  18279. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18280. }
  18281. if m.id == nil || m.oldValue == nil {
  18282. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18283. }
  18284. oldValue, err := m.oldValue(ctx)
  18285. if err != nil {
  18286. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18287. }
  18288. return oldValue.CreatedAt, nil
  18289. }
  18290. // ResetCreatedAt resets all changes to the "created_at" field.
  18291. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  18292. m.created_at = nil
  18293. }
  18294. // SetUpdatedAt sets the "updated_at" field.
  18295. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  18296. m.updated_at = &t
  18297. }
  18298. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18299. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  18300. v := m.updated_at
  18301. if v == nil {
  18302. return
  18303. }
  18304. return *v, true
  18305. }
  18306. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  18307. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18309. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18310. if !m.op.Is(OpUpdateOne) {
  18311. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18312. }
  18313. if m.id == nil || m.oldValue == nil {
  18314. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18315. }
  18316. oldValue, err := m.oldValue(ctx)
  18317. if err != nil {
  18318. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18319. }
  18320. return oldValue.UpdatedAt, nil
  18321. }
  18322. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18323. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  18324. m.updated_at = nil
  18325. }
  18326. // SetDeletedAt sets the "deleted_at" field.
  18327. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  18328. m.deleted_at = &t
  18329. }
  18330. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18331. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  18332. v := m.deleted_at
  18333. if v == nil {
  18334. return
  18335. }
  18336. return *v, true
  18337. }
  18338. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  18339. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18341. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18342. if !m.op.Is(OpUpdateOne) {
  18343. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18344. }
  18345. if m.id == nil || m.oldValue == nil {
  18346. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18347. }
  18348. oldValue, err := m.oldValue(ctx)
  18349. if err != nil {
  18350. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18351. }
  18352. return oldValue.DeletedAt, nil
  18353. }
  18354. // ClearDeletedAt clears the value of the "deleted_at" field.
  18355. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  18356. m.deleted_at = nil
  18357. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  18358. }
  18359. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18360. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  18361. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  18362. return ok
  18363. }
  18364. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18365. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  18366. m.deleted_at = nil
  18367. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  18368. }
  18369. // SetStype sets the "stype" field.
  18370. func (m *EmployeeConfigMutation) SetStype(s string) {
  18371. m.stype = &s
  18372. }
  18373. // Stype returns the value of the "stype" field in the mutation.
  18374. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  18375. v := m.stype
  18376. if v == nil {
  18377. return
  18378. }
  18379. return *v, true
  18380. }
  18381. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  18382. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18384. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  18385. if !m.op.Is(OpUpdateOne) {
  18386. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  18387. }
  18388. if m.id == nil || m.oldValue == nil {
  18389. return v, errors.New("OldStype requires an ID field in the mutation")
  18390. }
  18391. oldValue, err := m.oldValue(ctx)
  18392. if err != nil {
  18393. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  18394. }
  18395. return oldValue.Stype, nil
  18396. }
  18397. // ResetStype resets all changes to the "stype" field.
  18398. func (m *EmployeeConfigMutation) ResetStype() {
  18399. m.stype = nil
  18400. }
  18401. // SetTitle sets the "title" field.
  18402. func (m *EmployeeConfigMutation) SetTitle(s string) {
  18403. m.title = &s
  18404. }
  18405. // Title returns the value of the "title" field in the mutation.
  18406. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  18407. v := m.title
  18408. if v == nil {
  18409. return
  18410. }
  18411. return *v, true
  18412. }
  18413. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  18414. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18416. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  18417. if !m.op.Is(OpUpdateOne) {
  18418. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18419. }
  18420. if m.id == nil || m.oldValue == nil {
  18421. return v, errors.New("OldTitle requires an ID field in the mutation")
  18422. }
  18423. oldValue, err := m.oldValue(ctx)
  18424. if err != nil {
  18425. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18426. }
  18427. return oldValue.Title, nil
  18428. }
  18429. // ResetTitle resets all changes to the "title" field.
  18430. func (m *EmployeeConfigMutation) ResetTitle() {
  18431. m.title = nil
  18432. }
  18433. // SetPhoto sets the "photo" field.
  18434. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  18435. m.photo = &s
  18436. }
  18437. // Photo returns the value of the "photo" field in the mutation.
  18438. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  18439. v := m.photo
  18440. if v == nil {
  18441. return
  18442. }
  18443. return *v, true
  18444. }
  18445. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  18446. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18448. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  18449. if !m.op.Is(OpUpdateOne) {
  18450. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  18451. }
  18452. if m.id == nil || m.oldValue == nil {
  18453. return v, errors.New("OldPhoto requires an ID field in the mutation")
  18454. }
  18455. oldValue, err := m.oldValue(ctx)
  18456. if err != nil {
  18457. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  18458. }
  18459. return oldValue.Photo, nil
  18460. }
  18461. // ResetPhoto resets all changes to the "photo" field.
  18462. func (m *EmployeeConfigMutation) ResetPhoto() {
  18463. m.photo = nil
  18464. }
  18465. // SetOrganizationID sets the "organization_id" field.
  18466. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  18467. m.organization_id = &u
  18468. m.addorganization_id = nil
  18469. }
  18470. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18471. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  18472. v := m.organization_id
  18473. if v == nil {
  18474. return
  18475. }
  18476. return *v, true
  18477. }
  18478. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  18479. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18481. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18482. if !m.op.Is(OpUpdateOne) {
  18483. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18484. }
  18485. if m.id == nil || m.oldValue == nil {
  18486. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18487. }
  18488. oldValue, err := m.oldValue(ctx)
  18489. if err != nil {
  18490. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18491. }
  18492. return oldValue.OrganizationID, nil
  18493. }
  18494. // AddOrganizationID adds u to the "organization_id" field.
  18495. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  18496. if m.addorganization_id != nil {
  18497. *m.addorganization_id += u
  18498. } else {
  18499. m.addorganization_id = &u
  18500. }
  18501. }
  18502. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18503. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  18504. v := m.addorganization_id
  18505. if v == nil {
  18506. return
  18507. }
  18508. return *v, true
  18509. }
  18510. // ClearOrganizationID clears the value of the "organization_id" field.
  18511. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  18512. m.organization_id = nil
  18513. m.addorganization_id = nil
  18514. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  18515. }
  18516. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18517. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  18518. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  18519. return ok
  18520. }
  18521. // ResetOrganizationID resets all changes to the "organization_id" field.
  18522. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  18523. m.organization_id = nil
  18524. m.addorganization_id = nil
  18525. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  18526. }
  18527. // Where appends a list predicates to the EmployeeConfigMutation builder.
  18528. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  18529. m.predicates = append(m.predicates, ps...)
  18530. }
  18531. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  18532. // users can use type-assertion to append predicates that do not depend on any generated package.
  18533. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  18534. p := make([]predicate.EmployeeConfig, len(ps))
  18535. for i := range ps {
  18536. p[i] = ps[i]
  18537. }
  18538. m.Where(p...)
  18539. }
  18540. // Op returns the operation name.
  18541. func (m *EmployeeConfigMutation) Op() Op {
  18542. return m.op
  18543. }
  18544. // SetOp allows setting the mutation operation.
  18545. func (m *EmployeeConfigMutation) SetOp(op Op) {
  18546. m.op = op
  18547. }
  18548. // Type returns the node type of this mutation (EmployeeConfig).
  18549. func (m *EmployeeConfigMutation) Type() string {
  18550. return m.typ
  18551. }
  18552. // Fields returns all fields that were changed during this mutation. Note that in
  18553. // order to get all numeric fields that were incremented/decremented, call
  18554. // AddedFields().
  18555. func (m *EmployeeConfigMutation) Fields() []string {
  18556. fields := make([]string, 0, 7)
  18557. if m.created_at != nil {
  18558. fields = append(fields, employeeconfig.FieldCreatedAt)
  18559. }
  18560. if m.updated_at != nil {
  18561. fields = append(fields, employeeconfig.FieldUpdatedAt)
  18562. }
  18563. if m.deleted_at != nil {
  18564. fields = append(fields, employeeconfig.FieldDeletedAt)
  18565. }
  18566. if m.stype != nil {
  18567. fields = append(fields, employeeconfig.FieldStype)
  18568. }
  18569. if m.title != nil {
  18570. fields = append(fields, employeeconfig.FieldTitle)
  18571. }
  18572. if m.photo != nil {
  18573. fields = append(fields, employeeconfig.FieldPhoto)
  18574. }
  18575. if m.organization_id != nil {
  18576. fields = append(fields, employeeconfig.FieldOrganizationID)
  18577. }
  18578. return fields
  18579. }
  18580. // Field returns the value of a field with the given name. The second boolean
  18581. // return value indicates that this field was not set, or was not defined in the
  18582. // schema.
  18583. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  18584. switch name {
  18585. case employeeconfig.FieldCreatedAt:
  18586. return m.CreatedAt()
  18587. case employeeconfig.FieldUpdatedAt:
  18588. return m.UpdatedAt()
  18589. case employeeconfig.FieldDeletedAt:
  18590. return m.DeletedAt()
  18591. case employeeconfig.FieldStype:
  18592. return m.Stype()
  18593. case employeeconfig.FieldTitle:
  18594. return m.Title()
  18595. case employeeconfig.FieldPhoto:
  18596. return m.Photo()
  18597. case employeeconfig.FieldOrganizationID:
  18598. return m.OrganizationID()
  18599. }
  18600. return nil, false
  18601. }
  18602. // OldField returns the old value of the field from the database. An error is
  18603. // returned if the mutation operation is not UpdateOne, or the query to the
  18604. // database failed.
  18605. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18606. switch name {
  18607. case employeeconfig.FieldCreatedAt:
  18608. return m.OldCreatedAt(ctx)
  18609. case employeeconfig.FieldUpdatedAt:
  18610. return m.OldUpdatedAt(ctx)
  18611. case employeeconfig.FieldDeletedAt:
  18612. return m.OldDeletedAt(ctx)
  18613. case employeeconfig.FieldStype:
  18614. return m.OldStype(ctx)
  18615. case employeeconfig.FieldTitle:
  18616. return m.OldTitle(ctx)
  18617. case employeeconfig.FieldPhoto:
  18618. return m.OldPhoto(ctx)
  18619. case employeeconfig.FieldOrganizationID:
  18620. return m.OldOrganizationID(ctx)
  18621. }
  18622. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  18623. }
  18624. // SetField sets the value of a field with the given name. It returns an error if
  18625. // the field is not defined in the schema, or if the type mismatched the field
  18626. // type.
  18627. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  18628. switch name {
  18629. case employeeconfig.FieldCreatedAt:
  18630. v, ok := value.(time.Time)
  18631. if !ok {
  18632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18633. }
  18634. m.SetCreatedAt(v)
  18635. return nil
  18636. case employeeconfig.FieldUpdatedAt:
  18637. v, ok := value.(time.Time)
  18638. if !ok {
  18639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18640. }
  18641. m.SetUpdatedAt(v)
  18642. return nil
  18643. case employeeconfig.FieldDeletedAt:
  18644. v, ok := value.(time.Time)
  18645. if !ok {
  18646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18647. }
  18648. m.SetDeletedAt(v)
  18649. return nil
  18650. case employeeconfig.FieldStype:
  18651. v, ok := value.(string)
  18652. if !ok {
  18653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18654. }
  18655. m.SetStype(v)
  18656. return nil
  18657. case employeeconfig.FieldTitle:
  18658. v, ok := value.(string)
  18659. if !ok {
  18660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18661. }
  18662. m.SetTitle(v)
  18663. return nil
  18664. case employeeconfig.FieldPhoto:
  18665. v, ok := value.(string)
  18666. if !ok {
  18667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18668. }
  18669. m.SetPhoto(v)
  18670. return nil
  18671. case employeeconfig.FieldOrganizationID:
  18672. v, ok := value.(uint64)
  18673. if !ok {
  18674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18675. }
  18676. m.SetOrganizationID(v)
  18677. return nil
  18678. }
  18679. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  18680. }
  18681. // AddedFields returns all numeric fields that were incremented/decremented during
  18682. // this mutation.
  18683. func (m *EmployeeConfigMutation) AddedFields() []string {
  18684. var fields []string
  18685. if m.addorganization_id != nil {
  18686. fields = append(fields, employeeconfig.FieldOrganizationID)
  18687. }
  18688. return fields
  18689. }
  18690. // AddedField returns the numeric value that was incremented/decremented on a field
  18691. // with the given name. The second boolean return value indicates that this field
  18692. // was not set, or was not defined in the schema.
  18693. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  18694. switch name {
  18695. case employeeconfig.FieldOrganizationID:
  18696. return m.AddedOrganizationID()
  18697. }
  18698. return nil, false
  18699. }
  18700. // AddField adds the value to the field with the given name. It returns an error if
  18701. // the field is not defined in the schema, or if the type mismatched the field
  18702. // type.
  18703. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  18704. switch name {
  18705. case employeeconfig.FieldOrganizationID:
  18706. v, ok := value.(int64)
  18707. if !ok {
  18708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18709. }
  18710. m.AddOrganizationID(v)
  18711. return nil
  18712. }
  18713. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  18714. }
  18715. // ClearedFields returns all nullable fields that were cleared during this
  18716. // mutation.
  18717. func (m *EmployeeConfigMutation) ClearedFields() []string {
  18718. var fields []string
  18719. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  18720. fields = append(fields, employeeconfig.FieldDeletedAt)
  18721. }
  18722. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  18723. fields = append(fields, employeeconfig.FieldOrganizationID)
  18724. }
  18725. return fields
  18726. }
  18727. // FieldCleared returns a boolean indicating if a field with the given name was
  18728. // cleared in this mutation.
  18729. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  18730. _, ok := m.clearedFields[name]
  18731. return ok
  18732. }
  18733. // ClearField clears the value of the field with the given name. It returns an
  18734. // error if the field is not defined in the schema.
  18735. func (m *EmployeeConfigMutation) ClearField(name string) error {
  18736. switch name {
  18737. case employeeconfig.FieldDeletedAt:
  18738. m.ClearDeletedAt()
  18739. return nil
  18740. case employeeconfig.FieldOrganizationID:
  18741. m.ClearOrganizationID()
  18742. return nil
  18743. }
  18744. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  18745. }
  18746. // ResetField resets all changes in the mutation for the field with the given name.
  18747. // It returns an error if the field is not defined in the schema.
  18748. func (m *EmployeeConfigMutation) ResetField(name string) error {
  18749. switch name {
  18750. case employeeconfig.FieldCreatedAt:
  18751. m.ResetCreatedAt()
  18752. return nil
  18753. case employeeconfig.FieldUpdatedAt:
  18754. m.ResetUpdatedAt()
  18755. return nil
  18756. case employeeconfig.FieldDeletedAt:
  18757. m.ResetDeletedAt()
  18758. return nil
  18759. case employeeconfig.FieldStype:
  18760. m.ResetStype()
  18761. return nil
  18762. case employeeconfig.FieldTitle:
  18763. m.ResetTitle()
  18764. return nil
  18765. case employeeconfig.FieldPhoto:
  18766. m.ResetPhoto()
  18767. return nil
  18768. case employeeconfig.FieldOrganizationID:
  18769. m.ResetOrganizationID()
  18770. return nil
  18771. }
  18772. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  18773. }
  18774. // AddedEdges returns all edge names that were set/added in this mutation.
  18775. func (m *EmployeeConfigMutation) AddedEdges() []string {
  18776. edges := make([]string, 0, 0)
  18777. return edges
  18778. }
  18779. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18780. // name in this mutation.
  18781. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  18782. return nil
  18783. }
  18784. // RemovedEdges returns all edge names that were removed in this mutation.
  18785. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  18786. edges := make([]string, 0, 0)
  18787. return edges
  18788. }
  18789. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18790. // the given name in this mutation.
  18791. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  18792. return nil
  18793. }
  18794. // ClearedEdges returns all edge names that were cleared in this mutation.
  18795. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  18796. edges := make([]string, 0, 0)
  18797. return edges
  18798. }
  18799. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18800. // was cleared in this mutation.
  18801. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  18802. return false
  18803. }
  18804. // ClearEdge clears the value of the edge with the given name. It returns an error
  18805. // if that edge is not defined in the schema.
  18806. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  18807. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  18808. }
  18809. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18810. // It returns an error if the edge is not defined in the schema.
  18811. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  18812. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  18813. }
  18814. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  18815. type LabelMutation struct {
  18816. config
  18817. op Op
  18818. typ string
  18819. id *uint64
  18820. created_at *time.Time
  18821. updated_at *time.Time
  18822. status *uint8
  18823. addstatus *int8
  18824. _type *int
  18825. add_type *int
  18826. name *string
  18827. from *int
  18828. addfrom *int
  18829. mode *int
  18830. addmode *int
  18831. conditions *string
  18832. organization_id *uint64
  18833. addorganization_id *int64
  18834. clearedFields map[string]struct{}
  18835. label_relationships map[uint64]struct{}
  18836. removedlabel_relationships map[uint64]struct{}
  18837. clearedlabel_relationships bool
  18838. done bool
  18839. oldValue func(context.Context) (*Label, error)
  18840. predicates []predicate.Label
  18841. }
  18842. var _ ent.Mutation = (*LabelMutation)(nil)
  18843. // labelOption allows management of the mutation configuration using functional options.
  18844. type labelOption func(*LabelMutation)
  18845. // newLabelMutation creates new mutation for the Label entity.
  18846. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  18847. m := &LabelMutation{
  18848. config: c,
  18849. op: op,
  18850. typ: TypeLabel,
  18851. clearedFields: make(map[string]struct{}),
  18852. }
  18853. for _, opt := range opts {
  18854. opt(m)
  18855. }
  18856. return m
  18857. }
  18858. // withLabelID sets the ID field of the mutation.
  18859. func withLabelID(id uint64) labelOption {
  18860. return func(m *LabelMutation) {
  18861. var (
  18862. err error
  18863. once sync.Once
  18864. value *Label
  18865. )
  18866. m.oldValue = func(ctx context.Context) (*Label, error) {
  18867. once.Do(func() {
  18868. if m.done {
  18869. err = errors.New("querying old values post mutation is not allowed")
  18870. } else {
  18871. value, err = m.Client().Label.Get(ctx, id)
  18872. }
  18873. })
  18874. return value, err
  18875. }
  18876. m.id = &id
  18877. }
  18878. }
  18879. // withLabel sets the old Label of the mutation.
  18880. func withLabel(node *Label) labelOption {
  18881. return func(m *LabelMutation) {
  18882. m.oldValue = func(context.Context) (*Label, error) {
  18883. return node, nil
  18884. }
  18885. m.id = &node.ID
  18886. }
  18887. }
  18888. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18889. // executed in a transaction (ent.Tx), a transactional client is returned.
  18890. func (m LabelMutation) Client() *Client {
  18891. client := &Client{config: m.config}
  18892. client.init()
  18893. return client
  18894. }
  18895. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18896. // it returns an error otherwise.
  18897. func (m LabelMutation) Tx() (*Tx, error) {
  18898. if _, ok := m.driver.(*txDriver); !ok {
  18899. return nil, errors.New("ent: mutation is not running in a transaction")
  18900. }
  18901. tx := &Tx{config: m.config}
  18902. tx.init()
  18903. return tx, nil
  18904. }
  18905. // SetID sets the value of the id field. Note that this
  18906. // operation is only accepted on creation of Label entities.
  18907. func (m *LabelMutation) SetID(id uint64) {
  18908. m.id = &id
  18909. }
  18910. // ID returns the ID value in the mutation. Note that the ID is only available
  18911. // if it was provided to the builder or after it was returned from the database.
  18912. func (m *LabelMutation) ID() (id uint64, exists bool) {
  18913. if m.id == nil {
  18914. return
  18915. }
  18916. return *m.id, true
  18917. }
  18918. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18919. // That means, if the mutation is applied within a transaction with an isolation level such
  18920. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18921. // or updated by the mutation.
  18922. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  18923. switch {
  18924. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18925. id, exists := m.ID()
  18926. if exists {
  18927. return []uint64{id}, nil
  18928. }
  18929. fallthrough
  18930. case m.op.Is(OpUpdate | OpDelete):
  18931. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  18932. default:
  18933. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18934. }
  18935. }
  18936. // SetCreatedAt sets the "created_at" field.
  18937. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  18938. m.created_at = &t
  18939. }
  18940. // CreatedAt returns the value of the "created_at" field in the mutation.
  18941. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  18942. v := m.created_at
  18943. if v == nil {
  18944. return
  18945. }
  18946. return *v, true
  18947. }
  18948. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  18949. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18951. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18952. if !m.op.Is(OpUpdateOne) {
  18953. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18954. }
  18955. if m.id == nil || m.oldValue == nil {
  18956. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18957. }
  18958. oldValue, err := m.oldValue(ctx)
  18959. if err != nil {
  18960. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18961. }
  18962. return oldValue.CreatedAt, nil
  18963. }
  18964. // ResetCreatedAt resets all changes to the "created_at" field.
  18965. func (m *LabelMutation) ResetCreatedAt() {
  18966. m.created_at = nil
  18967. }
  18968. // SetUpdatedAt sets the "updated_at" field.
  18969. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  18970. m.updated_at = &t
  18971. }
  18972. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18973. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  18974. v := m.updated_at
  18975. if v == nil {
  18976. return
  18977. }
  18978. return *v, true
  18979. }
  18980. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  18981. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18983. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18984. if !m.op.Is(OpUpdateOne) {
  18985. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18986. }
  18987. if m.id == nil || m.oldValue == nil {
  18988. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18989. }
  18990. oldValue, err := m.oldValue(ctx)
  18991. if err != nil {
  18992. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18993. }
  18994. return oldValue.UpdatedAt, nil
  18995. }
  18996. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18997. func (m *LabelMutation) ResetUpdatedAt() {
  18998. m.updated_at = nil
  18999. }
  19000. // SetStatus sets the "status" field.
  19001. func (m *LabelMutation) SetStatus(u uint8) {
  19002. m.status = &u
  19003. m.addstatus = nil
  19004. }
  19005. // Status returns the value of the "status" field in the mutation.
  19006. func (m *LabelMutation) Status() (r uint8, exists bool) {
  19007. v := m.status
  19008. if v == nil {
  19009. return
  19010. }
  19011. return *v, true
  19012. }
  19013. // OldStatus returns the old "status" field's value of the Label entity.
  19014. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19016. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19017. if !m.op.Is(OpUpdateOne) {
  19018. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19019. }
  19020. if m.id == nil || m.oldValue == nil {
  19021. return v, errors.New("OldStatus requires an ID field in the mutation")
  19022. }
  19023. oldValue, err := m.oldValue(ctx)
  19024. if err != nil {
  19025. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19026. }
  19027. return oldValue.Status, nil
  19028. }
  19029. // AddStatus adds u to the "status" field.
  19030. func (m *LabelMutation) AddStatus(u int8) {
  19031. if m.addstatus != nil {
  19032. *m.addstatus += u
  19033. } else {
  19034. m.addstatus = &u
  19035. }
  19036. }
  19037. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19038. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  19039. v := m.addstatus
  19040. if v == nil {
  19041. return
  19042. }
  19043. return *v, true
  19044. }
  19045. // ClearStatus clears the value of the "status" field.
  19046. func (m *LabelMutation) ClearStatus() {
  19047. m.status = nil
  19048. m.addstatus = nil
  19049. m.clearedFields[label.FieldStatus] = struct{}{}
  19050. }
  19051. // StatusCleared returns if the "status" field was cleared in this mutation.
  19052. func (m *LabelMutation) StatusCleared() bool {
  19053. _, ok := m.clearedFields[label.FieldStatus]
  19054. return ok
  19055. }
  19056. // ResetStatus resets all changes to the "status" field.
  19057. func (m *LabelMutation) ResetStatus() {
  19058. m.status = nil
  19059. m.addstatus = nil
  19060. delete(m.clearedFields, label.FieldStatus)
  19061. }
  19062. // SetType sets the "type" field.
  19063. func (m *LabelMutation) SetType(i int) {
  19064. m._type = &i
  19065. m.add_type = nil
  19066. }
  19067. // GetType returns the value of the "type" field in the mutation.
  19068. func (m *LabelMutation) GetType() (r int, exists bool) {
  19069. v := m._type
  19070. if v == nil {
  19071. return
  19072. }
  19073. return *v, true
  19074. }
  19075. // OldType returns the old "type" field's value of the Label entity.
  19076. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19078. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  19079. if !m.op.Is(OpUpdateOne) {
  19080. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19081. }
  19082. if m.id == nil || m.oldValue == nil {
  19083. return v, errors.New("OldType requires an ID field in the mutation")
  19084. }
  19085. oldValue, err := m.oldValue(ctx)
  19086. if err != nil {
  19087. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19088. }
  19089. return oldValue.Type, nil
  19090. }
  19091. // AddType adds i to the "type" field.
  19092. func (m *LabelMutation) AddType(i int) {
  19093. if m.add_type != nil {
  19094. *m.add_type += i
  19095. } else {
  19096. m.add_type = &i
  19097. }
  19098. }
  19099. // AddedType returns the value that was added to the "type" field in this mutation.
  19100. func (m *LabelMutation) AddedType() (r int, exists bool) {
  19101. v := m.add_type
  19102. if v == nil {
  19103. return
  19104. }
  19105. return *v, true
  19106. }
  19107. // ResetType resets all changes to the "type" field.
  19108. func (m *LabelMutation) ResetType() {
  19109. m._type = nil
  19110. m.add_type = nil
  19111. }
  19112. // SetName sets the "name" field.
  19113. func (m *LabelMutation) SetName(s string) {
  19114. m.name = &s
  19115. }
  19116. // Name returns the value of the "name" field in the mutation.
  19117. func (m *LabelMutation) Name() (r string, exists bool) {
  19118. v := m.name
  19119. if v == nil {
  19120. return
  19121. }
  19122. return *v, true
  19123. }
  19124. // OldName returns the old "name" field's value of the Label entity.
  19125. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19127. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  19128. if !m.op.Is(OpUpdateOne) {
  19129. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19130. }
  19131. if m.id == nil || m.oldValue == nil {
  19132. return v, errors.New("OldName requires an ID field in the mutation")
  19133. }
  19134. oldValue, err := m.oldValue(ctx)
  19135. if err != nil {
  19136. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19137. }
  19138. return oldValue.Name, nil
  19139. }
  19140. // ResetName resets all changes to the "name" field.
  19141. func (m *LabelMutation) ResetName() {
  19142. m.name = nil
  19143. }
  19144. // SetFrom sets the "from" field.
  19145. func (m *LabelMutation) SetFrom(i int) {
  19146. m.from = &i
  19147. m.addfrom = nil
  19148. }
  19149. // From returns the value of the "from" field in the mutation.
  19150. func (m *LabelMutation) From() (r int, exists bool) {
  19151. v := m.from
  19152. if v == nil {
  19153. return
  19154. }
  19155. return *v, true
  19156. }
  19157. // OldFrom returns the old "from" field's value of the Label entity.
  19158. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19160. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  19161. if !m.op.Is(OpUpdateOne) {
  19162. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  19163. }
  19164. if m.id == nil || m.oldValue == nil {
  19165. return v, errors.New("OldFrom requires an ID field in the mutation")
  19166. }
  19167. oldValue, err := m.oldValue(ctx)
  19168. if err != nil {
  19169. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  19170. }
  19171. return oldValue.From, nil
  19172. }
  19173. // AddFrom adds i to the "from" field.
  19174. func (m *LabelMutation) AddFrom(i int) {
  19175. if m.addfrom != nil {
  19176. *m.addfrom += i
  19177. } else {
  19178. m.addfrom = &i
  19179. }
  19180. }
  19181. // AddedFrom returns the value that was added to the "from" field in this mutation.
  19182. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  19183. v := m.addfrom
  19184. if v == nil {
  19185. return
  19186. }
  19187. return *v, true
  19188. }
  19189. // ResetFrom resets all changes to the "from" field.
  19190. func (m *LabelMutation) ResetFrom() {
  19191. m.from = nil
  19192. m.addfrom = nil
  19193. }
  19194. // SetMode sets the "mode" field.
  19195. func (m *LabelMutation) SetMode(i int) {
  19196. m.mode = &i
  19197. m.addmode = nil
  19198. }
  19199. // Mode returns the value of the "mode" field in the mutation.
  19200. func (m *LabelMutation) Mode() (r int, exists bool) {
  19201. v := m.mode
  19202. if v == nil {
  19203. return
  19204. }
  19205. return *v, true
  19206. }
  19207. // OldMode returns the old "mode" field's value of the Label entity.
  19208. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19210. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  19211. if !m.op.Is(OpUpdateOne) {
  19212. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  19213. }
  19214. if m.id == nil || m.oldValue == nil {
  19215. return v, errors.New("OldMode requires an ID field in the mutation")
  19216. }
  19217. oldValue, err := m.oldValue(ctx)
  19218. if err != nil {
  19219. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  19220. }
  19221. return oldValue.Mode, nil
  19222. }
  19223. // AddMode adds i to the "mode" field.
  19224. func (m *LabelMutation) AddMode(i int) {
  19225. if m.addmode != nil {
  19226. *m.addmode += i
  19227. } else {
  19228. m.addmode = &i
  19229. }
  19230. }
  19231. // AddedMode returns the value that was added to the "mode" field in this mutation.
  19232. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  19233. v := m.addmode
  19234. if v == nil {
  19235. return
  19236. }
  19237. return *v, true
  19238. }
  19239. // ResetMode resets all changes to the "mode" field.
  19240. func (m *LabelMutation) ResetMode() {
  19241. m.mode = nil
  19242. m.addmode = nil
  19243. }
  19244. // SetConditions sets the "conditions" field.
  19245. func (m *LabelMutation) SetConditions(s string) {
  19246. m.conditions = &s
  19247. }
  19248. // Conditions returns the value of the "conditions" field in the mutation.
  19249. func (m *LabelMutation) Conditions() (r string, exists bool) {
  19250. v := m.conditions
  19251. if v == nil {
  19252. return
  19253. }
  19254. return *v, true
  19255. }
  19256. // OldConditions returns the old "conditions" field's value of the Label entity.
  19257. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19259. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  19260. if !m.op.Is(OpUpdateOne) {
  19261. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19262. }
  19263. if m.id == nil || m.oldValue == nil {
  19264. return v, errors.New("OldConditions requires an ID field in the mutation")
  19265. }
  19266. oldValue, err := m.oldValue(ctx)
  19267. if err != nil {
  19268. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19269. }
  19270. return oldValue.Conditions, nil
  19271. }
  19272. // ClearConditions clears the value of the "conditions" field.
  19273. func (m *LabelMutation) ClearConditions() {
  19274. m.conditions = nil
  19275. m.clearedFields[label.FieldConditions] = struct{}{}
  19276. }
  19277. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  19278. func (m *LabelMutation) ConditionsCleared() bool {
  19279. _, ok := m.clearedFields[label.FieldConditions]
  19280. return ok
  19281. }
  19282. // ResetConditions resets all changes to the "conditions" field.
  19283. func (m *LabelMutation) ResetConditions() {
  19284. m.conditions = nil
  19285. delete(m.clearedFields, label.FieldConditions)
  19286. }
  19287. // SetOrganizationID sets the "organization_id" field.
  19288. func (m *LabelMutation) SetOrganizationID(u uint64) {
  19289. m.organization_id = &u
  19290. m.addorganization_id = nil
  19291. }
  19292. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19293. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  19294. v := m.organization_id
  19295. if v == nil {
  19296. return
  19297. }
  19298. return *v, true
  19299. }
  19300. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  19301. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19303. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19304. if !m.op.Is(OpUpdateOne) {
  19305. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19306. }
  19307. if m.id == nil || m.oldValue == nil {
  19308. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19309. }
  19310. oldValue, err := m.oldValue(ctx)
  19311. if err != nil {
  19312. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19313. }
  19314. return oldValue.OrganizationID, nil
  19315. }
  19316. // AddOrganizationID adds u to the "organization_id" field.
  19317. func (m *LabelMutation) AddOrganizationID(u int64) {
  19318. if m.addorganization_id != nil {
  19319. *m.addorganization_id += u
  19320. } else {
  19321. m.addorganization_id = &u
  19322. }
  19323. }
  19324. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19325. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  19326. v := m.addorganization_id
  19327. if v == nil {
  19328. return
  19329. }
  19330. return *v, true
  19331. }
  19332. // ClearOrganizationID clears the value of the "organization_id" field.
  19333. func (m *LabelMutation) ClearOrganizationID() {
  19334. m.organization_id = nil
  19335. m.addorganization_id = nil
  19336. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  19337. }
  19338. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19339. func (m *LabelMutation) OrganizationIDCleared() bool {
  19340. _, ok := m.clearedFields[label.FieldOrganizationID]
  19341. return ok
  19342. }
  19343. // ResetOrganizationID resets all changes to the "organization_id" field.
  19344. func (m *LabelMutation) ResetOrganizationID() {
  19345. m.organization_id = nil
  19346. m.addorganization_id = nil
  19347. delete(m.clearedFields, label.FieldOrganizationID)
  19348. }
  19349. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  19350. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  19351. if m.label_relationships == nil {
  19352. m.label_relationships = make(map[uint64]struct{})
  19353. }
  19354. for i := range ids {
  19355. m.label_relationships[ids[i]] = struct{}{}
  19356. }
  19357. }
  19358. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  19359. func (m *LabelMutation) ClearLabelRelationships() {
  19360. m.clearedlabel_relationships = true
  19361. }
  19362. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  19363. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  19364. return m.clearedlabel_relationships
  19365. }
  19366. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  19367. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  19368. if m.removedlabel_relationships == nil {
  19369. m.removedlabel_relationships = make(map[uint64]struct{})
  19370. }
  19371. for i := range ids {
  19372. delete(m.label_relationships, ids[i])
  19373. m.removedlabel_relationships[ids[i]] = struct{}{}
  19374. }
  19375. }
  19376. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  19377. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  19378. for id := range m.removedlabel_relationships {
  19379. ids = append(ids, id)
  19380. }
  19381. return
  19382. }
  19383. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  19384. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  19385. for id := range m.label_relationships {
  19386. ids = append(ids, id)
  19387. }
  19388. return
  19389. }
  19390. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  19391. func (m *LabelMutation) ResetLabelRelationships() {
  19392. m.label_relationships = nil
  19393. m.clearedlabel_relationships = false
  19394. m.removedlabel_relationships = nil
  19395. }
  19396. // Where appends a list predicates to the LabelMutation builder.
  19397. func (m *LabelMutation) Where(ps ...predicate.Label) {
  19398. m.predicates = append(m.predicates, ps...)
  19399. }
  19400. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  19401. // users can use type-assertion to append predicates that do not depend on any generated package.
  19402. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  19403. p := make([]predicate.Label, len(ps))
  19404. for i := range ps {
  19405. p[i] = ps[i]
  19406. }
  19407. m.Where(p...)
  19408. }
  19409. // Op returns the operation name.
  19410. func (m *LabelMutation) Op() Op {
  19411. return m.op
  19412. }
  19413. // SetOp allows setting the mutation operation.
  19414. func (m *LabelMutation) SetOp(op Op) {
  19415. m.op = op
  19416. }
  19417. // Type returns the node type of this mutation (Label).
  19418. func (m *LabelMutation) Type() string {
  19419. return m.typ
  19420. }
  19421. // Fields returns all fields that were changed during this mutation. Note that in
  19422. // order to get all numeric fields that were incremented/decremented, call
  19423. // AddedFields().
  19424. func (m *LabelMutation) Fields() []string {
  19425. fields := make([]string, 0, 9)
  19426. if m.created_at != nil {
  19427. fields = append(fields, label.FieldCreatedAt)
  19428. }
  19429. if m.updated_at != nil {
  19430. fields = append(fields, label.FieldUpdatedAt)
  19431. }
  19432. if m.status != nil {
  19433. fields = append(fields, label.FieldStatus)
  19434. }
  19435. if m._type != nil {
  19436. fields = append(fields, label.FieldType)
  19437. }
  19438. if m.name != nil {
  19439. fields = append(fields, label.FieldName)
  19440. }
  19441. if m.from != nil {
  19442. fields = append(fields, label.FieldFrom)
  19443. }
  19444. if m.mode != nil {
  19445. fields = append(fields, label.FieldMode)
  19446. }
  19447. if m.conditions != nil {
  19448. fields = append(fields, label.FieldConditions)
  19449. }
  19450. if m.organization_id != nil {
  19451. fields = append(fields, label.FieldOrganizationID)
  19452. }
  19453. return fields
  19454. }
  19455. // Field returns the value of a field with the given name. The second boolean
  19456. // return value indicates that this field was not set, or was not defined in the
  19457. // schema.
  19458. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  19459. switch name {
  19460. case label.FieldCreatedAt:
  19461. return m.CreatedAt()
  19462. case label.FieldUpdatedAt:
  19463. return m.UpdatedAt()
  19464. case label.FieldStatus:
  19465. return m.Status()
  19466. case label.FieldType:
  19467. return m.GetType()
  19468. case label.FieldName:
  19469. return m.Name()
  19470. case label.FieldFrom:
  19471. return m.From()
  19472. case label.FieldMode:
  19473. return m.Mode()
  19474. case label.FieldConditions:
  19475. return m.Conditions()
  19476. case label.FieldOrganizationID:
  19477. return m.OrganizationID()
  19478. }
  19479. return nil, false
  19480. }
  19481. // OldField returns the old value of the field from the database. An error is
  19482. // returned if the mutation operation is not UpdateOne, or the query to the
  19483. // database failed.
  19484. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19485. switch name {
  19486. case label.FieldCreatedAt:
  19487. return m.OldCreatedAt(ctx)
  19488. case label.FieldUpdatedAt:
  19489. return m.OldUpdatedAt(ctx)
  19490. case label.FieldStatus:
  19491. return m.OldStatus(ctx)
  19492. case label.FieldType:
  19493. return m.OldType(ctx)
  19494. case label.FieldName:
  19495. return m.OldName(ctx)
  19496. case label.FieldFrom:
  19497. return m.OldFrom(ctx)
  19498. case label.FieldMode:
  19499. return m.OldMode(ctx)
  19500. case label.FieldConditions:
  19501. return m.OldConditions(ctx)
  19502. case label.FieldOrganizationID:
  19503. return m.OldOrganizationID(ctx)
  19504. }
  19505. return nil, fmt.Errorf("unknown Label field %s", name)
  19506. }
  19507. // SetField sets the value of a field with the given name. It returns an error if
  19508. // the field is not defined in the schema, or if the type mismatched the field
  19509. // type.
  19510. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  19511. switch name {
  19512. case label.FieldCreatedAt:
  19513. v, ok := value.(time.Time)
  19514. if !ok {
  19515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19516. }
  19517. m.SetCreatedAt(v)
  19518. return nil
  19519. case label.FieldUpdatedAt:
  19520. v, ok := value.(time.Time)
  19521. if !ok {
  19522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19523. }
  19524. m.SetUpdatedAt(v)
  19525. return nil
  19526. case label.FieldStatus:
  19527. v, ok := value.(uint8)
  19528. if !ok {
  19529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19530. }
  19531. m.SetStatus(v)
  19532. return nil
  19533. case label.FieldType:
  19534. v, ok := value.(int)
  19535. if !ok {
  19536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19537. }
  19538. m.SetType(v)
  19539. return nil
  19540. case label.FieldName:
  19541. v, ok := value.(string)
  19542. if !ok {
  19543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19544. }
  19545. m.SetName(v)
  19546. return nil
  19547. case label.FieldFrom:
  19548. v, ok := value.(int)
  19549. if !ok {
  19550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19551. }
  19552. m.SetFrom(v)
  19553. return nil
  19554. case label.FieldMode:
  19555. v, ok := value.(int)
  19556. if !ok {
  19557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19558. }
  19559. m.SetMode(v)
  19560. return nil
  19561. case label.FieldConditions:
  19562. v, ok := value.(string)
  19563. if !ok {
  19564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19565. }
  19566. m.SetConditions(v)
  19567. return nil
  19568. case label.FieldOrganizationID:
  19569. v, ok := value.(uint64)
  19570. if !ok {
  19571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19572. }
  19573. m.SetOrganizationID(v)
  19574. return nil
  19575. }
  19576. return fmt.Errorf("unknown Label field %s", name)
  19577. }
  19578. // AddedFields returns all numeric fields that were incremented/decremented during
  19579. // this mutation.
  19580. func (m *LabelMutation) AddedFields() []string {
  19581. var fields []string
  19582. if m.addstatus != nil {
  19583. fields = append(fields, label.FieldStatus)
  19584. }
  19585. if m.add_type != nil {
  19586. fields = append(fields, label.FieldType)
  19587. }
  19588. if m.addfrom != nil {
  19589. fields = append(fields, label.FieldFrom)
  19590. }
  19591. if m.addmode != nil {
  19592. fields = append(fields, label.FieldMode)
  19593. }
  19594. if m.addorganization_id != nil {
  19595. fields = append(fields, label.FieldOrganizationID)
  19596. }
  19597. return fields
  19598. }
  19599. // AddedField returns the numeric value that was incremented/decremented on a field
  19600. // with the given name. The second boolean return value indicates that this field
  19601. // was not set, or was not defined in the schema.
  19602. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  19603. switch name {
  19604. case label.FieldStatus:
  19605. return m.AddedStatus()
  19606. case label.FieldType:
  19607. return m.AddedType()
  19608. case label.FieldFrom:
  19609. return m.AddedFrom()
  19610. case label.FieldMode:
  19611. return m.AddedMode()
  19612. case label.FieldOrganizationID:
  19613. return m.AddedOrganizationID()
  19614. }
  19615. return nil, false
  19616. }
  19617. // AddField adds the value to the field with the given name. It returns an error if
  19618. // the field is not defined in the schema, or if the type mismatched the field
  19619. // type.
  19620. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  19621. switch name {
  19622. case label.FieldStatus:
  19623. v, ok := value.(int8)
  19624. if !ok {
  19625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19626. }
  19627. m.AddStatus(v)
  19628. return nil
  19629. case label.FieldType:
  19630. v, ok := value.(int)
  19631. if !ok {
  19632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19633. }
  19634. m.AddType(v)
  19635. return nil
  19636. case label.FieldFrom:
  19637. v, ok := value.(int)
  19638. if !ok {
  19639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19640. }
  19641. m.AddFrom(v)
  19642. return nil
  19643. case label.FieldMode:
  19644. v, ok := value.(int)
  19645. if !ok {
  19646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19647. }
  19648. m.AddMode(v)
  19649. return nil
  19650. case label.FieldOrganizationID:
  19651. v, ok := value.(int64)
  19652. if !ok {
  19653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19654. }
  19655. m.AddOrganizationID(v)
  19656. return nil
  19657. }
  19658. return fmt.Errorf("unknown Label numeric field %s", name)
  19659. }
  19660. // ClearedFields returns all nullable fields that were cleared during this
  19661. // mutation.
  19662. func (m *LabelMutation) ClearedFields() []string {
  19663. var fields []string
  19664. if m.FieldCleared(label.FieldStatus) {
  19665. fields = append(fields, label.FieldStatus)
  19666. }
  19667. if m.FieldCleared(label.FieldConditions) {
  19668. fields = append(fields, label.FieldConditions)
  19669. }
  19670. if m.FieldCleared(label.FieldOrganizationID) {
  19671. fields = append(fields, label.FieldOrganizationID)
  19672. }
  19673. return fields
  19674. }
  19675. // FieldCleared returns a boolean indicating if a field with the given name was
  19676. // cleared in this mutation.
  19677. func (m *LabelMutation) FieldCleared(name string) bool {
  19678. _, ok := m.clearedFields[name]
  19679. return ok
  19680. }
  19681. // ClearField clears the value of the field with the given name. It returns an
  19682. // error if the field is not defined in the schema.
  19683. func (m *LabelMutation) ClearField(name string) error {
  19684. switch name {
  19685. case label.FieldStatus:
  19686. m.ClearStatus()
  19687. return nil
  19688. case label.FieldConditions:
  19689. m.ClearConditions()
  19690. return nil
  19691. case label.FieldOrganizationID:
  19692. m.ClearOrganizationID()
  19693. return nil
  19694. }
  19695. return fmt.Errorf("unknown Label nullable field %s", name)
  19696. }
  19697. // ResetField resets all changes in the mutation for the field with the given name.
  19698. // It returns an error if the field is not defined in the schema.
  19699. func (m *LabelMutation) ResetField(name string) error {
  19700. switch name {
  19701. case label.FieldCreatedAt:
  19702. m.ResetCreatedAt()
  19703. return nil
  19704. case label.FieldUpdatedAt:
  19705. m.ResetUpdatedAt()
  19706. return nil
  19707. case label.FieldStatus:
  19708. m.ResetStatus()
  19709. return nil
  19710. case label.FieldType:
  19711. m.ResetType()
  19712. return nil
  19713. case label.FieldName:
  19714. m.ResetName()
  19715. return nil
  19716. case label.FieldFrom:
  19717. m.ResetFrom()
  19718. return nil
  19719. case label.FieldMode:
  19720. m.ResetMode()
  19721. return nil
  19722. case label.FieldConditions:
  19723. m.ResetConditions()
  19724. return nil
  19725. case label.FieldOrganizationID:
  19726. m.ResetOrganizationID()
  19727. return nil
  19728. }
  19729. return fmt.Errorf("unknown Label field %s", name)
  19730. }
  19731. // AddedEdges returns all edge names that were set/added in this mutation.
  19732. func (m *LabelMutation) AddedEdges() []string {
  19733. edges := make([]string, 0, 1)
  19734. if m.label_relationships != nil {
  19735. edges = append(edges, label.EdgeLabelRelationships)
  19736. }
  19737. return edges
  19738. }
  19739. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19740. // name in this mutation.
  19741. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  19742. switch name {
  19743. case label.EdgeLabelRelationships:
  19744. ids := make([]ent.Value, 0, len(m.label_relationships))
  19745. for id := range m.label_relationships {
  19746. ids = append(ids, id)
  19747. }
  19748. return ids
  19749. }
  19750. return nil
  19751. }
  19752. // RemovedEdges returns all edge names that were removed in this mutation.
  19753. func (m *LabelMutation) RemovedEdges() []string {
  19754. edges := make([]string, 0, 1)
  19755. if m.removedlabel_relationships != nil {
  19756. edges = append(edges, label.EdgeLabelRelationships)
  19757. }
  19758. return edges
  19759. }
  19760. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19761. // the given name in this mutation.
  19762. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  19763. switch name {
  19764. case label.EdgeLabelRelationships:
  19765. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  19766. for id := range m.removedlabel_relationships {
  19767. ids = append(ids, id)
  19768. }
  19769. return ids
  19770. }
  19771. return nil
  19772. }
  19773. // ClearedEdges returns all edge names that were cleared in this mutation.
  19774. func (m *LabelMutation) ClearedEdges() []string {
  19775. edges := make([]string, 0, 1)
  19776. if m.clearedlabel_relationships {
  19777. edges = append(edges, label.EdgeLabelRelationships)
  19778. }
  19779. return edges
  19780. }
  19781. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19782. // was cleared in this mutation.
  19783. func (m *LabelMutation) EdgeCleared(name string) bool {
  19784. switch name {
  19785. case label.EdgeLabelRelationships:
  19786. return m.clearedlabel_relationships
  19787. }
  19788. return false
  19789. }
  19790. // ClearEdge clears the value of the edge with the given name. It returns an error
  19791. // if that edge is not defined in the schema.
  19792. func (m *LabelMutation) ClearEdge(name string) error {
  19793. switch name {
  19794. }
  19795. return fmt.Errorf("unknown Label unique edge %s", name)
  19796. }
  19797. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19798. // It returns an error if the edge is not defined in the schema.
  19799. func (m *LabelMutation) ResetEdge(name string) error {
  19800. switch name {
  19801. case label.EdgeLabelRelationships:
  19802. m.ResetLabelRelationships()
  19803. return nil
  19804. }
  19805. return fmt.Errorf("unknown Label edge %s", name)
  19806. }
  19807. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  19808. type LabelRelationshipMutation struct {
  19809. config
  19810. op Op
  19811. typ string
  19812. id *uint64
  19813. created_at *time.Time
  19814. updated_at *time.Time
  19815. status *uint8
  19816. addstatus *int8
  19817. organization_id *uint64
  19818. addorganization_id *int64
  19819. clearedFields map[string]struct{}
  19820. contacts *uint64
  19821. clearedcontacts bool
  19822. labels *uint64
  19823. clearedlabels bool
  19824. done bool
  19825. oldValue func(context.Context) (*LabelRelationship, error)
  19826. predicates []predicate.LabelRelationship
  19827. }
  19828. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  19829. // labelrelationshipOption allows management of the mutation configuration using functional options.
  19830. type labelrelationshipOption func(*LabelRelationshipMutation)
  19831. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  19832. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  19833. m := &LabelRelationshipMutation{
  19834. config: c,
  19835. op: op,
  19836. typ: TypeLabelRelationship,
  19837. clearedFields: make(map[string]struct{}),
  19838. }
  19839. for _, opt := range opts {
  19840. opt(m)
  19841. }
  19842. return m
  19843. }
  19844. // withLabelRelationshipID sets the ID field of the mutation.
  19845. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  19846. return func(m *LabelRelationshipMutation) {
  19847. var (
  19848. err error
  19849. once sync.Once
  19850. value *LabelRelationship
  19851. )
  19852. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  19853. once.Do(func() {
  19854. if m.done {
  19855. err = errors.New("querying old values post mutation is not allowed")
  19856. } else {
  19857. value, err = m.Client().LabelRelationship.Get(ctx, id)
  19858. }
  19859. })
  19860. return value, err
  19861. }
  19862. m.id = &id
  19863. }
  19864. }
  19865. // withLabelRelationship sets the old LabelRelationship of the mutation.
  19866. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  19867. return func(m *LabelRelationshipMutation) {
  19868. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  19869. return node, nil
  19870. }
  19871. m.id = &node.ID
  19872. }
  19873. }
  19874. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19875. // executed in a transaction (ent.Tx), a transactional client is returned.
  19876. func (m LabelRelationshipMutation) Client() *Client {
  19877. client := &Client{config: m.config}
  19878. client.init()
  19879. return client
  19880. }
  19881. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19882. // it returns an error otherwise.
  19883. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  19884. if _, ok := m.driver.(*txDriver); !ok {
  19885. return nil, errors.New("ent: mutation is not running in a transaction")
  19886. }
  19887. tx := &Tx{config: m.config}
  19888. tx.init()
  19889. return tx, nil
  19890. }
  19891. // SetID sets the value of the id field. Note that this
  19892. // operation is only accepted on creation of LabelRelationship entities.
  19893. func (m *LabelRelationshipMutation) SetID(id uint64) {
  19894. m.id = &id
  19895. }
  19896. // ID returns the ID value in the mutation. Note that the ID is only available
  19897. // if it was provided to the builder or after it was returned from the database.
  19898. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  19899. if m.id == nil {
  19900. return
  19901. }
  19902. return *m.id, true
  19903. }
  19904. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19905. // That means, if the mutation is applied within a transaction with an isolation level such
  19906. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19907. // or updated by the mutation.
  19908. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  19909. switch {
  19910. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19911. id, exists := m.ID()
  19912. if exists {
  19913. return []uint64{id}, nil
  19914. }
  19915. fallthrough
  19916. case m.op.Is(OpUpdate | OpDelete):
  19917. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  19918. default:
  19919. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19920. }
  19921. }
  19922. // SetCreatedAt sets the "created_at" field.
  19923. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  19924. m.created_at = &t
  19925. }
  19926. // CreatedAt returns the value of the "created_at" field in the mutation.
  19927. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  19928. v := m.created_at
  19929. if v == nil {
  19930. return
  19931. }
  19932. return *v, true
  19933. }
  19934. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  19935. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19937. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19938. if !m.op.Is(OpUpdateOne) {
  19939. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19940. }
  19941. if m.id == nil || m.oldValue == nil {
  19942. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19943. }
  19944. oldValue, err := m.oldValue(ctx)
  19945. if err != nil {
  19946. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19947. }
  19948. return oldValue.CreatedAt, nil
  19949. }
  19950. // ResetCreatedAt resets all changes to the "created_at" field.
  19951. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  19952. m.created_at = nil
  19953. }
  19954. // SetUpdatedAt sets the "updated_at" field.
  19955. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  19956. m.updated_at = &t
  19957. }
  19958. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19959. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  19960. v := m.updated_at
  19961. if v == nil {
  19962. return
  19963. }
  19964. return *v, true
  19965. }
  19966. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  19967. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19969. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19970. if !m.op.Is(OpUpdateOne) {
  19971. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19972. }
  19973. if m.id == nil || m.oldValue == nil {
  19974. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19975. }
  19976. oldValue, err := m.oldValue(ctx)
  19977. if err != nil {
  19978. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19979. }
  19980. return oldValue.UpdatedAt, nil
  19981. }
  19982. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19983. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  19984. m.updated_at = nil
  19985. }
  19986. // SetStatus sets the "status" field.
  19987. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  19988. m.status = &u
  19989. m.addstatus = nil
  19990. }
  19991. // Status returns the value of the "status" field in the mutation.
  19992. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  19993. v := m.status
  19994. if v == nil {
  19995. return
  19996. }
  19997. return *v, true
  19998. }
  19999. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  20000. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20002. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20003. if !m.op.Is(OpUpdateOne) {
  20004. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20005. }
  20006. if m.id == nil || m.oldValue == nil {
  20007. return v, errors.New("OldStatus requires an ID field in the mutation")
  20008. }
  20009. oldValue, err := m.oldValue(ctx)
  20010. if err != nil {
  20011. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20012. }
  20013. return oldValue.Status, nil
  20014. }
  20015. // AddStatus adds u to the "status" field.
  20016. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  20017. if m.addstatus != nil {
  20018. *m.addstatus += u
  20019. } else {
  20020. m.addstatus = &u
  20021. }
  20022. }
  20023. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20024. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  20025. v := m.addstatus
  20026. if v == nil {
  20027. return
  20028. }
  20029. return *v, true
  20030. }
  20031. // ClearStatus clears the value of the "status" field.
  20032. func (m *LabelRelationshipMutation) ClearStatus() {
  20033. m.status = nil
  20034. m.addstatus = nil
  20035. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  20036. }
  20037. // StatusCleared returns if the "status" field was cleared in this mutation.
  20038. func (m *LabelRelationshipMutation) StatusCleared() bool {
  20039. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  20040. return ok
  20041. }
  20042. // ResetStatus resets all changes to the "status" field.
  20043. func (m *LabelRelationshipMutation) ResetStatus() {
  20044. m.status = nil
  20045. m.addstatus = nil
  20046. delete(m.clearedFields, labelrelationship.FieldStatus)
  20047. }
  20048. // SetLabelID sets the "label_id" field.
  20049. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  20050. m.labels = &u
  20051. }
  20052. // LabelID returns the value of the "label_id" field in the mutation.
  20053. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  20054. v := m.labels
  20055. if v == nil {
  20056. return
  20057. }
  20058. return *v, true
  20059. }
  20060. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  20061. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20063. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  20064. if !m.op.Is(OpUpdateOne) {
  20065. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  20066. }
  20067. if m.id == nil || m.oldValue == nil {
  20068. return v, errors.New("OldLabelID requires an ID field in the mutation")
  20069. }
  20070. oldValue, err := m.oldValue(ctx)
  20071. if err != nil {
  20072. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  20073. }
  20074. return oldValue.LabelID, nil
  20075. }
  20076. // ResetLabelID resets all changes to the "label_id" field.
  20077. func (m *LabelRelationshipMutation) ResetLabelID() {
  20078. m.labels = nil
  20079. }
  20080. // SetContactID sets the "contact_id" field.
  20081. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  20082. m.contacts = &u
  20083. }
  20084. // ContactID returns the value of the "contact_id" field in the mutation.
  20085. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  20086. v := m.contacts
  20087. if v == nil {
  20088. return
  20089. }
  20090. return *v, true
  20091. }
  20092. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  20093. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20095. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20096. if !m.op.Is(OpUpdateOne) {
  20097. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20098. }
  20099. if m.id == nil || m.oldValue == nil {
  20100. return v, errors.New("OldContactID requires an ID field in the mutation")
  20101. }
  20102. oldValue, err := m.oldValue(ctx)
  20103. if err != nil {
  20104. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20105. }
  20106. return oldValue.ContactID, nil
  20107. }
  20108. // ResetContactID resets all changes to the "contact_id" field.
  20109. func (m *LabelRelationshipMutation) ResetContactID() {
  20110. m.contacts = nil
  20111. }
  20112. // SetOrganizationID sets the "organization_id" field.
  20113. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  20114. m.organization_id = &u
  20115. m.addorganization_id = nil
  20116. }
  20117. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20118. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  20119. v := m.organization_id
  20120. if v == nil {
  20121. return
  20122. }
  20123. return *v, true
  20124. }
  20125. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  20126. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20128. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20129. if !m.op.Is(OpUpdateOne) {
  20130. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20131. }
  20132. if m.id == nil || m.oldValue == nil {
  20133. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20134. }
  20135. oldValue, err := m.oldValue(ctx)
  20136. if err != nil {
  20137. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20138. }
  20139. return oldValue.OrganizationID, nil
  20140. }
  20141. // AddOrganizationID adds u to the "organization_id" field.
  20142. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  20143. if m.addorganization_id != nil {
  20144. *m.addorganization_id += u
  20145. } else {
  20146. m.addorganization_id = &u
  20147. }
  20148. }
  20149. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20150. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  20151. v := m.addorganization_id
  20152. if v == nil {
  20153. return
  20154. }
  20155. return *v, true
  20156. }
  20157. // ClearOrganizationID clears the value of the "organization_id" field.
  20158. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  20159. m.organization_id = nil
  20160. m.addorganization_id = nil
  20161. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  20162. }
  20163. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20164. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  20165. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  20166. return ok
  20167. }
  20168. // ResetOrganizationID resets all changes to the "organization_id" field.
  20169. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  20170. m.organization_id = nil
  20171. m.addorganization_id = nil
  20172. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  20173. }
  20174. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  20175. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  20176. m.contacts = &id
  20177. }
  20178. // ClearContacts clears the "contacts" edge to the Contact entity.
  20179. func (m *LabelRelationshipMutation) ClearContacts() {
  20180. m.clearedcontacts = true
  20181. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  20182. }
  20183. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  20184. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  20185. return m.clearedcontacts
  20186. }
  20187. // ContactsID returns the "contacts" edge ID in the mutation.
  20188. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  20189. if m.contacts != nil {
  20190. return *m.contacts, true
  20191. }
  20192. return
  20193. }
  20194. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  20195. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20196. // ContactsID instead. It exists only for internal usage by the builders.
  20197. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  20198. if id := m.contacts; id != nil {
  20199. ids = append(ids, *id)
  20200. }
  20201. return
  20202. }
  20203. // ResetContacts resets all changes to the "contacts" edge.
  20204. func (m *LabelRelationshipMutation) ResetContacts() {
  20205. m.contacts = nil
  20206. m.clearedcontacts = false
  20207. }
  20208. // SetLabelsID sets the "labels" edge to the Label entity by id.
  20209. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  20210. m.labels = &id
  20211. }
  20212. // ClearLabels clears the "labels" edge to the Label entity.
  20213. func (m *LabelRelationshipMutation) ClearLabels() {
  20214. m.clearedlabels = true
  20215. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  20216. }
  20217. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  20218. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  20219. return m.clearedlabels
  20220. }
  20221. // LabelsID returns the "labels" edge ID in the mutation.
  20222. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  20223. if m.labels != nil {
  20224. return *m.labels, true
  20225. }
  20226. return
  20227. }
  20228. // LabelsIDs returns the "labels" edge IDs in the mutation.
  20229. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20230. // LabelsID instead. It exists only for internal usage by the builders.
  20231. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  20232. if id := m.labels; id != nil {
  20233. ids = append(ids, *id)
  20234. }
  20235. return
  20236. }
  20237. // ResetLabels resets all changes to the "labels" edge.
  20238. func (m *LabelRelationshipMutation) ResetLabels() {
  20239. m.labels = nil
  20240. m.clearedlabels = false
  20241. }
  20242. // Where appends a list predicates to the LabelRelationshipMutation builder.
  20243. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  20244. m.predicates = append(m.predicates, ps...)
  20245. }
  20246. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  20247. // users can use type-assertion to append predicates that do not depend on any generated package.
  20248. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  20249. p := make([]predicate.LabelRelationship, len(ps))
  20250. for i := range ps {
  20251. p[i] = ps[i]
  20252. }
  20253. m.Where(p...)
  20254. }
  20255. // Op returns the operation name.
  20256. func (m *LabelRelationshipMutation) Op() Op {
  20257. return m.op
  20258. }
  20259. // SetOp allows setting the mutation operation.
  20260. func (m *LabelRelationshipMutation) SetOp(op Op) {
  20261. m.op = op
  20262. }
  20263. // Type returns the node type of this mutation (LabelRelationship).
  20264. func (m *LabelRelationshipMutation) Type() string {
  20265. return m.typ
  20266. }
  20267. // Fields returns all fields that were changed during this mutation. Note that in
  20268. // order to get all numeric fields that were incremented/decremented, call
  20269. // AddedFields().
  20270. func (m *LabelRelationshipMutation) Fields() []string {
  20271. fields := make([]string, 0, 6)
  20272. if m.created_at != nil {
  20273. fields = append(fields, labelrelationship.FieldCreatedAt)
  20274. }
  20275. if m.updated_at != nil {
  20276. fields = append(fields, labelrelationship.FieldUpdatedAt)
  20277. }
  20278. if m.status != nil {
  20279. fields = append(fields, labelrelationship.FieldStatus)
  20280. }
  20281. if m.labels != nil {
  20282. fields = append(fields, labelrelationship.FieldLabelID)
  20283. }
  20284. if m.contacts != nil {
  20285. fields = append(fields, labelrelationship.FieldContactID)
  20286. }
  20287. if m.organization_id != nil {
  20288. fields = append(fields, labelrelationship.FieldOrganizationID)
  20289. }
  20290. return fields
  20291. }
  20292. // Field returns the value of a field with the given name. The second boolean
  20293. // return value indicates that this field was not set, or was not defined in the
  20294. // schema.
  20295. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  20296. switch name {
  20297. case labelrelationship.FieldCreatedAt:
  20298. return m.CreatedAt()
  20299. case labelrelationship.FieldUpdatedAt:
  20300. return m.UpdatedAt()
  20301. case labelrelationship.FieldStatus:
  20302. return m.Status()
  20303. case labelrelationship.FieldLabelID:
  20304. return m.LabelID()
  20305. case labelrelationship.FieldContactID:
  20306. return m.ContactID()
  20307. case labelrelationship.FieldOrganizationID:
  20308. return m.OrganizationID()
  20309. }
  20310. return nil, false
  20311. }
  20312. // OldField returns the old value of the field from the database. An error is
  20313. // returned if the mutation operation is not UpdateOne, or the query to the
  20314. // database failed.
  20315. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20316. switch name {
  20317. case labelrelationship.FieldCreatedAt:
  20318. return m.OldCreatedAt(ctx)
  20319. case labelrelationship.FieldUpdatedAt:
  20320. return m.OldUpdatedAt(ctx)
  20321. case labelrelationship.FieldStatus:
  20322. return m.OldStatus(ctx)
  20323. case labelrelationship.FieldLabelID:
  20324. return m.OldLabelID(ctx)
  20325. case labelrelationship.FieldContactID:
  20326. return m.OldContactID(ctx)
  20327. case labelrelationship.FieldOrganizationID:
  20328. return m.OldOrganizationID(ctx)
  20329. }
  20330. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  20331. }
  20332. // SetField sets the value of a field with the given name. It returns an error if
  20333. // the field is not defined in the schema, or if the type mismatched the field
  20334. // type.
  20335. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  20336. switch name {
  20337. case labelrelationship.FieldCreatedAt:
  20338. v, ok := value.(time.Time)
  20339. if !ok {
  20340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20341. }
  20342. m.SetCreatedAt(v)
  20343. return nil
  20344. case labelrelationship.FieldUpdatedAt:
  20345. v, ok := value.(time.Time)
  20346. if !ok {
  20347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20348. }
  20349. m.SetUpdatedAt(v)
  20350. return nil
  20351. case labelrelationship.FieldStatus:
  20352. v, ok := value.(uint8)
  20353. if !ok {
  20354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20355. }
  20356. m.SetStatus(v)
  20357. return nil
  20358. case labelrelationship.FieldLabelID:
  20359. v, ok := value.(uint64)
  20360. if !ok {
  20361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20362. }
  20363. m.SetLabelID(v)
  20364. return nil
  20365. case labelrelationship.FieldContactID:
  20366. v, ok := value.(uint64)
  20367. if !ok {
  20368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20369. }
  20370. m.SetContactID(v)
  20371. return nil
  20372. case labelrelationship.FieldOrganizationID:
  20373. v, ok := value.(uint64)
  20374. if !ok {
  20375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20376. }
  20377. m.SetOrganizationID(v)
  20378. return nil
  20379. }
  20380. return fmt.Errorf("unknown LabelRelationship field %s", name)
  20381. }
  20382. // AddedFields returns all numeric fields that were incremented/decremented during
  20383. // this mutation.
  20384. func (m *LabelRelationshipMutation) AddedFields() []string {
  20385. var fields []string
  20386. if m.addstatus != nil {
  20387. fields = append(fields, labelrelationship.FieldStatus)
  20388. }
  20389. if m.addorganization_id != nil {
  20390. fields = append(fields, labelrelationship.FieldOrganizationID)
  20391. }
  20392. return fields
  20393. }
  20394. // AddedField returns the numeric value that was incremented/decremented on a field
  20395. // with the given name. The second boolean return value indicates that this field
  20396. // was not set, or was not defined in the schema.
  20397. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  20398. switch name {
  20399. case labelrelationship.FieldStatus:
  20400. return m.AddedStatus()
  20401. case labelrelationship.FieldOrganizationID:
  20402. return m.AddedOrganizationID()
  20403. }
  20404. return nil, false
  20405. }
  20406. // AddField adds the value to the field with the given name. It returns an error if
  20407. // the field is not defined in the schema, or if the type mismatched the field
  20408. // type.
  20409. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  20410. switch name {
  20411. case labelrelationship.FieldStatus:
  20412. v, ok := value.(int8)
  20413. if !ok {
  20414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20415. }
  20416. m.AddStatus(v)
  20417. return nil
  20418. case labelrelationship.FieldOrganizationID:
  20419. v, ok := value.(int64)
  20420. if !ok {
  20421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20422. }
  20423. m.AddOrganizationID(v)
  20424. return nil
  20425. }
  20426. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  20427. }
  20428. // ClearedFields returns all nullable fields that were cleared during this
  20429. // mutation.
  20430. func (m *LabelRelationshipMutation) ClearedFields() []string {
  20431. var fields []string
  20432. if m.FieldCleared(labelrelationship.FieldStatus) {
  20433. fields = append(fields, labelrelationship.FieldStatus)
  20434. }
  20435. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  20436. fields = append(fields, labelrelationship.FieldOrganizationID)
  20437. }
  20438. return fields
  20439. }
  20440. // FieldCleared returns a boolean indicating if a field with the given name was
  20441. // cleared in this mutation.
  20442. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  20443. _, ok := m.clearedFields[name]
  20444. return ok
  20445. }
  20446. // ClearField clears the value of the field with the given name. It returns an
  20447. // error if the field is not defined in the schema.
  20448. func (m *LabelRelationshipMutation) ClearField(name string) error {
  20449. switch name {
  20450. case labelrelationship.FieldStatus:
  20451. m.ClearStatus()
  20452. return nil
  20453. case labelrelationship.FieldOrganizationID:
  20454. m.ClearOrganizationID()
  20455. return nil
  20456. }
  20457. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  20458. }
  20459. // ResetField resets all changes in the mutation for the field with the given name.
  20460. // It returns an error if the field is not defined in the schema.
  20461. func (m *LabelRelationshipMutation) ResetField(name string) error {
  20462. switch name {
  20463. case labelrelationship.FieldCreatedAt:
  20464. m.ResetCreatedAt()
  20465. return nil
  20466. case labelrelationship.FieldUpdatedAt:
  20467. m.ResetUpdatedAt()
  20468. return nil
  20469. case labelrelationship.FieldStatus:
  20470. m.ResetStatus()
  20471. return nil
  20472. case labelrelationship.FieldLabelID:
  20473. m.ResetLabelID()
  20474. return nil
  20475. case labelrelationship.FieldContactID:
  20476. m.ResetContactID()
  20477. return nil
  20478. case labelrelationship.FieldOrganizationID:
  20479. m.ResetOrganizationID()
  20480. return nil
  20481. }
  20482. return fmt.Errorf("unknown LabelRelationship field %s", name)
  20483. }
  20484. // AddedEdges returns all edge names that were set/added in this mutation.
  20485. func (m *LabelRelationshipMutation) AddedEdges() []string {
  20486. edges := make([]string, 0, 2)
  20487. if m.contacts != nil {
  20488. edges = append(edges, labelrelationship.EdgeContacts)
  20489. }
  20490. if m.labels != nil {
  20491. edges = append(edges, labelrelationship.EdgeLabels)
  20492. }
  20493. return edges
  20494. }
  20495. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20496. // name in this mutation.
  20497. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  20498. switch name {
  20499. case labelrelationship.EdgeContacts:
  20500. if id := m.contacts; id != nil {
  20501. return []ent.Value{*id}
  20502. }
  20503. case labelrelationship.EdgeLabels:
  20504. if id := m.labels; id != nil {
  20505. return []ent.Value{*id}
  20506. }
  20507. }
  20508. return nil
  20509. }
  20510. // RemovedEdges returns all edge names that were removed in this mutation.
  20511. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  20512. edges := make([]string, 0, 2)
  20513. return edges
  20514. }
  20515. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20516. // the given name in this mutation.
  20517. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  20518. return nil
  20519. }
  20520. // ClearedEdges returns all edge names that were cleared in this mutation.
  20521. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  20522. edges := make([]string, 0, 2)
  20523. if m.clearedcontacts {
  20524. edges = append(edges, labelrelationship.EdgeContacts)
  20525. }
  20526. if m.clearedlabels {
  20527. edges = append(edges, labelrelationship.EdgeLabels)
  20528. }
  20529. return edges
  20530. }
  20531. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20532. // was cleared in this mutation.
  20533. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  20534. switch name {
  20535. case labelrelationship.EdgeContacts:
  20536. return m.clearedcontacts
  20537. case labelrelationship.EdgeLabels:
  20538. return m.clearedlabels
  20539. }
  20540. return false
  20541. }
  20542. // ClearEdge clears the value of the edge with the given name. It returns an error
  20543. // if that edge is not defined in the schema.
  20544. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  20545. switch name {
  20546. case labelrelationship.EdgeContacts:
  20547. m.ClearContacts()
  20548. return nil
  20549. case labelrelationship.EdgeLabels:
  20550. m.ClearLabels()
  20551. return nil
  20552. }
  20553. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  20554. }
  20555. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20556. // It returns an error if the edge is not defined in the schema.
  20557. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  20558. switch name {
  20559. case labelrelationship.EdgeContacts:
  20560. m.ResetContacts()
  20561. return nil
  20562. case labelrelationship.EdgeLabels:
  20563. m.ResetLabels()
  20564. return nil
  20565. }
  20566. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  20567. }
  20568. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  20569. type LabelTaggingMutation struct {
  20570. config
  20571. op Op
  20572. typ string
  20573. id *uint64
  20574. created_at *time.Time
  20575. updated_at *time.Time
  20576. status *uint8
  20577. addstatus *int8
  20578. deleted_at *time.Time
  20579. organization_id *uint64
  20580. addorganization_id *int64
  20581. _type *int
  20582. add_type *int
  20583. conditions *string
  20584. action_label_add *[]uint64
  20585. appendaction_label_add []uint64
  20586. action_label_del *[]uint64
  20587. appendaction_label_del []uint64
  20588. clearedFields map[string]struct{}
  20589. done bool
  20590. oldValue func(context.Context) (*LabelTagging, error)
  20591. predicates []predicate.LabelTagging
  20592. }
  20593. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  20594. // labeltaggingOption allows management of the mutation configuration using functional options.
  20595. type labeltaggingOption func(*LabelTaggingMutation)
  20596. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  20597. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  20598. m := &LabelTaggingMutation{
  20599. config: c,
  20600. op: op,
  20601. typ: TypeLabelTagging,
  20602. clearedFields: make(map[string]struct{}),
  20603. }
  20604. for _, opt := range opts {
  20605. opt(m)
  20606. }
  20607. return m
  20608. }
  20609. // withLabelTaggingID sets the ID field of the mutation.
  20610. func withLabelTaggingID(id uint64) labeltaggingOption {
  20611. return func(m *LabelTaggingMutation) {
  20612. var (
  20613. err error
  20614. once sync.Once
  20615. value *LabelTagging
  20616. )
  20617. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  20618. once.Do(func() {
  20619. if m.done {
  20620. err = errors.New("querying old values post mutation is not allowed")
  20621. } else {
  20622. value, err = m.Client().LabelTagging.Get(ctx, id)
  20623. }
  20624. })
  20625. return value, err
  20626. }
  20627. m.id = &id
  20628. }
  20629. }
  20630. // withLabelTagging sets the old LabelTagging of the mutation.
  20631. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  20632. return func(m *LabelTaggingMutation) {
  20633. m.oldValue = func(context.Context) (*LabelTagging, error) {
  20634. return node, nil
  20635. }
  20636. m.id = &node.ID
  20637. }
  20638. }
  20639. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20640. // executed in a transaction (ent.Tx), a transactional client is returned.
  20641. func (m LabelTaggingMutation) Client() *Client {
  20642. client := &Client{config: m.config}
  20643. client.init()
  20644. return client
  20645. }
  20646. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20647. // it returns an error otherwise.
  20648. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  20649. if _, ok := m.driver.(*txDriver); !ok {
  20650. return nil, errors.New("ent: mutation is not running in a transaction")
  20651. }
  20652. tx := &Tx{config: m.config}
  20653. tx.init()
  20654. return tx, nil
  20655. }
  20656. // SetID sets the value of the id field. Note that this
  20657. // operation is only accepted on creation of LabelTagging entities.
  20658. func (m *LabelTaggingMutation) SetID(id uint64) {
  20659. m.id = &id
  20660. }
  20661. // ID returns the ID value in the mutation. Note that the ID is only available
  20662. // if it was provided to the builder or after it was returned from the database.
  20663. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  20664. if m.id == nil {
  20665. return
  20666. }
  20667. return *m.id, true
  20668. }
  20669. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20670. // That means, if the mutation is applied within a transaction with an isolation level such
  20671. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20672. // or updated by the mutation.
  20673. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  20674. switch {
  20675. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20676. id, exists := m.ID()
  20677. if exists {
  20678. return []uint64{id}, nil
  20679. }
  20680. fallthrough
  20681. case m.op.Is(OpUpdate | OpDelete):
  20682. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  20683. default:
  20684. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20685. }
  20686. }
  20687. // SetCreatedAt sets the "created_at" field.
  20688. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  20689. m.created_at = &t
  20690. }
  20691. // CreatedAt returns the value of the "created_at" field in the mutation.
  20692. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  20693. v := m.created_at
  20694. if v == nil {
  20695. return
  20696. }
  20697. return *v, true
  20698. }
  20699. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  20700. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20702. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20703. if !m.op.Is(OpUpdateOne) {
  20704. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20705. }
  20706. if m.id == nil || m.oldValue == nil {
  20707. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20708. }
  20709. oldValue, err := m.oldValue(ctx)
  20710. if err != nil {
  20711. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20712. }
  20713. return oldValue.CreatedAt, nil
  20714. }
  20715. // ResetCreatedAt resets all changes to the "created_at" field.
  20716. func (m *LabelTaggingMutation) ResetCreatedAt() {
  20717. m.created_at = nil
  20718. }
  20719. // SetUpdatedAt sets the "updated_at" field.
  20720. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  20721. m.updated_at = &t
  20722. }
  20723. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20724. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  20725. v := m.updated_at
  20726. if v == nil {
  20727. return
  20728. }
  20729. return *v, true
  20730. }
  20731. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  20732. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20734. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20735. if !m.op.Is(OpUpdateOne) {
  20736. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20737. }
  20738. if m.id == nil || m.oldValue == nil {
  20739. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20740. }
  20741. oldValue, err := m.oldValue(ctx)
  20742. if err != nil {
  20743. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20744. }
  20745. return oldValue.UpdatedAt, nil
  20746. }
  20747. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20748. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  20749. m.updated_at = nil
  20750. }
  20751. // SetStatus sets the "status" field.
  20752. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  20753. m.status = &u
  20754. m.addstatus = nil
  20755. }
  20756. // Status returns the value of the "status" field in the mutation.
  20757. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  20758. v := m.status
  20759. if v == nil {
  20760. return
  20761. }
  20762. return *v, true
  20763. }
  20764. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  20765. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20767. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20768. if !m.op.Is(OpUpdateOne) {
  20769. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20770. }
  20771. if m.id == nil || m.oldValue == nil {
  20772. return v, errors.New("OldStatus requires an ID field in the mutation")
  20773. }
  20774. oldValue, err := m.oldValue(ctx)
  20775. if err != nil {
  20776. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20777. }
  20778. return oldValue.Status, nil
  20779. }
  20780. // AddStatus adds u to the "status" field.
  20781. func (m *LabelTaggingMutation) AddStatus(u int8) {
  20782. if m.addstatus != nil {
  20783. *m.addstatus += u
  20784. } else {
  20785. m.addstatus = &u
  20786. }
  20787. }
  20788. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20789. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  20790. v := m.addstatus
  20791. if v == nil {
  20792. return
  20793. }
  20794. return *v, true
  20795. }
  20796. // ClearStatus clears the value of the "status" field.
  20797. func (m *LabelTaggingMutation) ClearStatus() {
  20798. m.status = nil
  20799. m.addstatus = nil
  20800. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  20801. }
  20802. // StatusCleared returns if the "status" field was cleared in this mutation.
  20803. func (m *LabelTaggingMutation) StatusCleared() bool {
  20804. _, ok := m.clearedFields[labeltagging.FieldStatus]
  20805. return ok
  20806. }
  20807. // ResetStatus resets all changes to the "status" field.
  20808. func (m *LabelTaggingMutation) ResetStatus() {
  20809. m.status = nil
  20810. m.addstatus = nil
  20811. delete(m.clearedFields, labeltagging.FieldStatus)
  20812. }
  20813. // SetDeletedAt sets the "deleted_at" field.
  20814. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  20815. m.deleted_at = &t
  20816. }
  20817. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20818. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  20819. v := m.deleted_at
  20820. if v == nil {
  20821. return
  20822. }
  20823. return *v, true
  20824. }
  20825. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  20826. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20828. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20829. if !m.op.Is(OpUpdateOne) {
  20830. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20831. }
  20832. if m.id == nil || m.oldValue == nil {
  20833. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20834. }
  20835. oldValue, err := m.oldValue(ctx)
  20836. if err != nil {
  20837. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20838. }
  20839. return oldValue.DeletedAt, nil
  20840. }
  20841. // ClearDeletedAt clears the value of the "deleted_at" field.
  20842. func (m *LabelTaggingMutation) ClearDeletedAt() {
  20843. m.deleted_at = nil
  20844. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  20845. }
  20846. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20847. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  20848. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  20849. return ok
  20850. }
  20851. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20852. func (m *LabelTaggingMutation) ResetDeletedAt() {
  20853. m.deleted_at = nil
  20854. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  20855. }
  20856. // SetOrganizationID sets the "organization_id" field.
  20857. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  20858. m.organization_id = &u
  20859. m.addorganization_id = nil
  20860. }
  20861. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20862. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  20863. v := m.organization_id
  20864. if v == nil {
  20865. return
  20866. }
  20867. return *v, true
  20868. }
  20869. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  20870. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20872. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20873. if !m.op.Is(OpUpdateOne) {
  20874. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20875. }
  20876. if m.id == nil || m.oldValue == nil {
  20877. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20878. }
  20879. oldValue, err := m.oldValue(ctx)
  20880. if err != nil {
  20881. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20882. }
  20883. return oldValue.OrganizationID, nil
  20884. }
  20885. // AddOrganizationID adds u to the "organization_id" field.
  20886. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  20887. if m.addorganization_id != nil {
  20888. *m.addorganization_id += u
  20889. } else {
  20890. m.addorganization_id = &u
  20891. }
  20892. }
  20893. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20894. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  20895. v := m.addorganization_id
  20896. if v == nil {
  20897. return
  20898. }
  20899. return *v, true
  20900. }
  20901. // ResetOrganizationID resets all changes to the "organization_id" field.
  20902. func (m *LabelTaggingMutation) ResetOrganizationID() {
  20903. m.organization_id = nil
  20904. m.addorganization_id = nil
  20905. }
  20906. // SetType sets the "type" field.
  20907. func (m *LabelTaggingMutation) SetType(i int) {
  20908. m._type = &i
  20909. m.add_type = nil
  20910. }
  20911. // GetType returns the value of the "type" field in the mutation.
  20912. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  20913. v := m._type
  20914. if v == nil {
  20915. return
  20916. }
  20917. return *v, true
  20918. }
  20919. // OldType returns the old "type" field's value of the LabelTagging entity.
  20920. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20922. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  20923. if !m.op.Is(OpUpdateOne) {
  20924. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20925. }
  20926. if m.id == nil || m.oldValue == nil {
  20927. return v, errors.New("OldType requires an ID field in the mutation")
  20928. }
  20929. oldValue, err := m.oldValue(ctx)
  20930. if err != nil {
  20931. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20932. }
  20933. return oldValue.Type, nil
  20934. }
  20935. // AddType adds i to the "type" field.
  20936. func (m *LabelTaggingMutation) AddType(i int) {
  20937. if m.add_type != nil {
  20938. *m.add_type += i
  20939. } else {
  20940. m.add_type = &i
  20941. }
  20942. }
  20943. // AddedType returns the value that was added to the "type" field in this mutation.
  20944. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  20945. v := m.add_type
  20946. if v == nil {
  20947. return
  20948. }
  20949. return *v, true
  20950. }
  20951. // ResetType resets all changes to the "type" field.
  20952. func (m *LabelTaggingMutation) ResetType() {
  20953. m._type = nil
  20954. m.add_type = nil
  20955. }
  20956. // SetConditions sets the "conditions" field.
  20957. func (m *LabelTaggingMutation) SetConditions(s string) {
  20958. m.conditions = &s
  20959. }
  20960. // Conditions returns the value of the "conditions" field in the mutation.
  20961. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  20962. v := m.conditions
  20963. if v == nil {
  20964. return
  20965. }
  20966. return *v, true
  20967. }
  20968. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  20969. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20971. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  20972. if !m.op.Is(OpUpdateOne) {
  20973. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20974. }
  20975. if m.id == nil || m.oldValue == nil {
  20976. return v, errors.New("OldConditions requires an ID field in the mutation")
  20977. }
  20978. oldValue, err := m.oldValue(ctx)
  20979. if err != nil {
  20980. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20981. }
  20982. return oldValue.Conditions, nil
  20983. }
  20984. // ResetConditions resets all changes to the "conditions" field.
  20985. func (m *LabelTaggingMutation) ResetConditions() {
  20986. m.conditions = nil
  20987. }
  20988. // SetActionLabelAdd sets the "action_label_add" field.
  20989. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  20990. m.action_label_add = &u
  20991. m.appendaction_label_add = nil
  20992. }
  20993. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  20994. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  20995. v := m.action_label_add
  20996. if v == nil {
  20997. return
  20998. }
  20999. return *v, true
  21000. }
  21001. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  21002. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21004. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21005. if !m.op.Is(OpUpdateOne) {
  21006. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21007. }
  21008. if m.id == nil || m.oldValue == nil {
  21009. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21010. }
  21011. oldValue, err := m.oldValue(ctx)
  21012. if err != nil {
  21013. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21014. }
  21015. return oldValue.ActionLabelAdd, nil
  21016. }
  21017. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21018. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  21019. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21020. }
  21021. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21022. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21023. if len(m.appendaction_label_add) == 0 {
  21024. return nil, false
  21025. }
  21026. return m.appendaction_label_add, true
  21027. }
  21028. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21029. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  21030. m.action_label_add = nil
  21031. m.appendaction_label_add = nil
  21032. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  21033. }
  21034. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21035. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  21036. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  21037. return ok
  21038. }
  21039. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21040. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  21041. m.action_label_add = nil
  21042. m.appendaction_label_add = nil
  21043. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  21044. }
  21045. // SetActionLabelDel sets the "action_label_del" field.
  21046. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  21047. m.action_label_del = &u
  21048. m.appendaction_label_del = nil
  21049. }
  21050. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21051. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  21052. v := m.action_label_del
  21053. if v == nil {
  21054. return
  21055. }
  21056. return *v, true
  21057. }
  21058. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  21059. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21061. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21062. if !m.op.Is(OpUpdateOne) {
  21063. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21064. }
  21065. if m.id == nil || m.oldValue == nil {
  21066. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21067. }
  21068. oldValue, err := m.oldValue(ctx)
  21069. if err != nil {
  21070. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21071. }
  21072. return oldValue.ActionLabelDel, nil
  21073. }
  21074. // AppendActionLabelDel adds u to the "action_label_del" field.
  21075. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  21076. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21077. }
  21078. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21079. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21080. if len(m.appendaction_label_del) == 0 {
  21081. return nil, false
  21082. }
  21083. return m.appendaction_label_del, true
  21084. }
  21085. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21086. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  21087. m.action_label_del = nil
  21088. m.appendaction_label_del = nil
  21089. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  21090. }
  21091. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21092. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  21093. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  21094. return ok
  21095. }
  21096. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21097. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  21098. m.action_label_del = nil
  21099. m.appendaction_label_del = nil
  21100. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  21101. }
  21102. // Where appends a list predicates to the LabelTaggingMutation builder.
  21103. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  21104. m.predicates = append(m.predicates, ps...)
  21105. }
  21106. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  21107. // users can use type-assertion to append predicates that do not depend on any generated package.
  21108. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  21109. p := make([]predicate.LabelTagging, len(ps))
  21110. for i := range ps {
  21111. p[i] = ps[i]
  21112. }
  21113. m.Where(p...)
  21114. }
  21115. // Op returns the operation name.
  21116. func (m *LabelTaggingMutation) Op() Op {
  21117. return m.op
  21118. }
  21119. // SetOp allows setting the mutation operation.
  21120. func (m *LabelTaggingMutation) SetOp(op Op) {
  21121. m.op = op
  21122. }
  21123. // Type returns the node type of this mutation (LabelTagging).
  21124. func (m *LabelTaggingMutation) Type() string {
  21125. return m.typ
  21126. }
  21127. // Fields returns all fields that were changed during this mutation. Note that in
  21128. // order to get all numeric fields that were incremented/decremented, call
  21129. // AddedFields().
  21130. func (m *LabelTaggingMutation) Fields() []string {
  21131. fields := make([]string, 0, 9)
  21132. if m.created_at != nil {
  21133. fields = append(fields, labeltagging.FieldCreatedAt)
  21134. }
  21135. if m.updated_at != nil {
  21136. fields = append(fields, labeltagging.FieldUpdatedAt)
  21137. }
  21138. if m.status != nil {
  21139. fields = append(fields, labeltagging.FieldStatus)
  21140. }
  21141. if m.deleted_at != nil {
  21142. fields = append(fields, labeltagging.FieldDeletedAt)
  21143. }
  21144. if m.organization_id != nil {
  21145. fields = append(fields, labeltagging.FieldOrganizationID)
  21146. }
  21147. if m._type != nil {
  21148. fields = append(fields, labeltagging.FieldType)
  21149. }
  21150. if m.conditions != nil {
  21151. fields = append(fields, labeltagging.FieldConditions)
  21152. }
  21153. if m.action_label_add != nil {
  21154. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21155. }
  21156. if m.action_label_del != nil {
  21157. fields = append(fields, labeltagging.FieldActionLabelDel)
  21158. }
  21159. return fields
  21160. }
  21161. // Field returns the value of a field with the given name. The second boolean
  21162. // return value indicates that this field was not set, or was not defined in the
  21163. // schema.
  21164. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  21165. switch name {
  21166. case labeltagging.FieldCreatedAt:
  21167. return m.CreatedAt()
  21168. case labeltagging.FieldUpdatedAt:
  21169. return m.UpdatedAt()
  21170. case labeltagging.FieldStatus:
  21171. return m.Status()
  21172. case labeltagging.FieldDeletedAt:
  21173. return m.DeletedAt()
  21174. case labeltagging.FieldOrganizationID:
  21175. return m.OrganizationID()
  21176. case labeltagging.FieldType:
  21177. return m.GetType()
  21178. case labeltagging.FieldConditions:
  21179. return m.Conditions()
  21180. case labeltagging.FieldActionLabelAdd:
  21181. return m.ActionLabelAdd()
  21182. case labeltagging.FieldActionLabelDel:
  21183. return m.ActionLabelDel()
  21184. }
  21185. return nil, false
  21186. }
  21187. // OldField returns the old value of the field from the database. An error is
  21188. // returned if the mutation operation is not UpdateOne, or the query to the
  21189. // database failed.
  21190. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21191. switch name {
  21192. case labeltagging.FieldCreatedAt:
  21193. return m.OldCreatedAt(ctx)
  21194. case labeltagging.FieldUpdatedAt:
  21195. return m.OldUpdatedAt(ctx)
  21196. case labeltagging.FieldStatus:
  21197. return m.OldStatus(ctx)
  21198. case labeltagging.FieldDeletedAt:
  21199. return m.OldDeletedAt(ctx)
  21200. case labeltagging.FieldOrganizationID:
  21201. return m.OldOrganizationID(ctx)
  21202. case labeltagging.FieldType:
  21203. return m.OldType(ctx)
  21204. case labeltagging.FieldConditions:
  21205. return m.OldConditions(ctx)
  21206. case labeltagging.FieldActionLabelAdd:
  21207. return m.OldActionLabelAdd(ctx)
  21208. case labeltagging.FieldActionLabelDel:
  21209. return m.OldActionLabelDel(ctx)
  21210. }
  21211. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  21212. }
  21213. // SetField sets the value of a field with the given name. It returns an error if
  21214. // the field is not defined in the schema, or if the type mismatched the field
  21215. // type.
  21216. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  21217. switch name {
  21218. case labeltagging.FieldCreatedAt:
  21219. v, ok := value.(time.Time)
  21220. if !ok {
  21221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21222. }
  21223. m.SetCreatedAt(v)
  21224. return nil
  21225. case labeltagging.FieldUpdatedAt:
  21226. v, ok := value.(time.Time)
  21227. if !ok {
  21228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21229. }
  21230. m.SetUpdatedAt(v)
  21231. return nil
  21232. case labeltagging.FieldStatus:
  21233. v, ok := value.(uint8)
  21234. if !ok {
  21235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21236. }
  21237. m.SetStatus(v)
  21238. return nil
  21239. case labeltagging.FieldDeletedAt:
  21240. v, ok := value.(time.Time)
  21241. if !ok {
  21242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21243. }
  21244. m.SetDeletedAt(v)
  21245. return nil
  21246. case labeltagging.FieldOrganizationID:
  21247. v, ok := value.(uint64)
  21248. if !ok {
  21249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21250. }
  21251. m.SetOrganizationID(v)
  21252. return nil
  21253. case labeltagging.FieldType:
  21254. v, ok := value.(int)
  21255. if !ok {
  21256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21257. }
  21258. m.SetType(v)
  21259. return nil
  21260. case labeltagging.FieldConditions:
  21261. v, ok := value.(string)
  21262. if !ok {
  21263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21264. }
  21265. m.SetConditions(v)
  21266. return nil
  21267. case labeltagging.FieldActionLabelAdd:
  21268. v, ok := value.([]uint64)
  21269. if !ok {
  21270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21271. }
  21272. m.SetActionLabelAdd(v)
  21273. return nil
  21274. case labeltagging.FieldActionLabelDel:
  21275. v, ok := value.([]uint64)
  21276. if !ok {
  21277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21278. }
  21279. m.SetActionLabelDel(v)
  21280. return nil
  21281. }
  21282. return fmt.Errorf("unknown LabelTagging field %s", name)
  21283. }
  21284. // AddedFields returns all numeric fields that were incremented/decremented during
  21285. // this mutation.
  21286. func (m *LabelTaggingMutation) AddedFields() []string {
  21287. var fields []string
  21288. if m.addstatus != nil {
  21289. fields = append(fields, labeltagging.FieldStatus)
  21290. }
  21291. if m.addorganization_id != nil {
  21292. fields = append(fields, labeltagging.FieldOrganizationID)
  21293. }
  21294. if m.add_type != nil {
  21295. fields = append(fields, labeltagging.FieldType)
  21296. }
  21297. return fields
  21298. }
  21299. // AddedField returns the numeric value that was incremented/decremented on a field
  21300. // with the given name. The second boolean return value indicates that this field
  21301. // was not set, or was not defined in the schema.
  21302. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  21303. switch name {
  21304. case labeltagging.FieldStatus:
  21305. return m.AddedStatus()
  21306. case labeltagging.FieldOrganizationID:
  21307. return m.AddedOrganizationID()
  21308. case labeltagging.FieldType:
  21309. return m.AddedType()
  21310. }
  21311. return nil, false
  21312. }
  21313. // AddField adds the value to the field with the given name. It returns an error if
  21314. // the field is not defined in the schema, or if the type mismatched the field
  21315. // type.
  21316. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  21317. switch name {
  21318. case labeltagging.FieldStatus:
  21319. v, ok := value.(int8)
  21320. if !ok {
  21321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21322. }
  21323. m.AddStatus(v)
  21324. return nil
  21325. case labeltagging.FieldOrganizationID:
  21326. v, ok := value.(int64)
  21327. if !ok {
  21328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21329. }
  21330. m.AddOrganizationID(v)
  21331. return nil
  21332. case labeltagging.FieldType:
  21333. v, ok := value.(int)
  21334. if !ok {
  21335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21336. }
  21337. m.AddType(v)
  21338. return nil
  21339. }
  21340. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  21341. }
  21342. // ClearedFields returns all nullable fields that were cleared during this
  21343. // mutation.
  21344. func (m *LabelTaggingMutation) ClearedFields() []string {
  21345. var fields []string
  21346. if m.FieldCleared(labeltagging.FieldStatus) {
  21347. fields = append(fields, labeltagging.FieldStatus)
  21348. }
  21349. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  21350. fields = append(fields, labeltagging.FieldDeletedAt)
  21351. }
  21352. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  21353. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21354. }
  21355. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  21356. fields = append(fields, labeltagging.FieldActionLabelDel)
  21357. }
  21358. return fields
  21359. }
  21360. // FieldCleared returns a boolean indicating if a field with the given name was
  21361. // cleared in this mutation.
  21362. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  21363. _, ok := m.clearedFields[name]
  21364. return ok
  21365. }
  21366. // ClearField clears the value of the field with the given name. It returns an
  21367. // error if the field is not defined in the schema.
  21368. func (m *LabelTaggingMutation) ClearField(name string) error {
  21369. switch name {
  21370. case labeltagging.FieldStatus:
  21371. m.ClearStatus()
  21372. return nil
  21373. case labeltagging.FieldDeletedAt:
  21374. m.ClearDeletedAt()
  21375. return nil
  21376. case labeltagging.FieldActionLabelAdd:
  21377. m.ClearActionLabelAdd()
  21378. return nil
  21379. case labeltagging.FieldActionLabelDel:
  21380. m.ClearActionLabelDel()
  21381. return nil
  21382. }
  21383. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  21384. }
  21385. // ResetField resets all changes in the mutation for the field with the given name.
  21386. // It returns an error if the field is not defined in the schema.
  21387. func (m *LabelTaggingMutation) ResetField(name string) error {
  21388. switch name {
  21389. case labeltagging.FieldCreatedAt:
  21390. m.ResetCreatedAt()
  21391. return nil
  21392. case labeltagging.FieldUpdatedAt:
  21393. m.ResetUpdatedAt()
  21394. return nil
  21395. case labeltagging.FieldStatus:
  21396. m.ResetStatus()
  21397. return nil
  21398. case labeltagging.FieldDeletedAt:
  21399. m.ResetDeletedAt()
  21400. return nil
  21401. case labeltagging.FieldOrganizationID:
  21402. m.ResetOrganizationID()
  21403. return nil
  21404. case labeltagging.FieldType:
  21405. m.ResetType()
  21406. return nil
  21407. case labeltagging.FieldConditions:
  21408. m.ResetConditions()
  21409. return nil
  21410. case labeltagging.FieldActionLabelAdd:
  21411. m.ResetActionLabelAdd()
  21412. return nil
  21413. case labeltagging.FieldActionLabelDel:
  21414. m.ResetActionLabelDel()
  21415. return nil
  21416. }
  21417. return fmt.Errorf("unknown LabelTagging field %s", name)
  21418. }
  21419. // AddedEdges returns all edge names that were set/added in this mutation.
  21420. func (m *LabelTaggingMutation) AddedEdges() []string {
  21421. edges := make([]string, 0, 0)
  21422. return edges
  21423. }
  21424. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21425. // name in this mutation.
  21426. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  21427. return nil
  21428. }
  21429. // RemovedEdges returns all edge names that were removed in this mutation.
  21430. func (m *LabelTaggingMutation) RemovedEdges() []string {
  21431. edges := make([]string, 0, 0)
  21432. return edges
  21433. }
  21434. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21435. // the given name in this mutation.
  21436. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  21437. return nil
  21438. }
  21439. // ClearedEdges returns all edge names that were cleared in this mutation.
  21440. func (m *LabelTaggingMutation) ClearedEdges() []string {
  21441. edges := make([]string, 0, 0)
  21442. return edges
  21443. }
  21444. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21445. // was cleared in this mutation.
  21446. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  21447. return false
  21448. }
  21449. // ClearEdge clears the value of the edge with the given name. It returns an error
  21450. // if that edge is not defined in the schema.
  21451. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  21452. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  21453. }
  21454. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21455. // It returns an error if the edge is not defined in the schema.
  21456. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  21457. return fmt.Errorf("unknown LabelTagging edge %s", name)
  21458. }
  21459. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  21460. type MessageMutation struct {
  21461. config
  21462. op Op
  21463. typ string
  21464. id *int
  21465. wx_wxid *string
  21466. wxid *string
  21467. content *string
  21468. clearedFields map[string]struct{}
  21469. done bool
  21470. oldValue func(context.Context) (*Message, error)
  21471. predicates []predicate.Message
  21472. }
  21473. var _ ent.Mutation = (*MessageMutation)(nil)
  21474. // messageOption allows management of the mutation configuration using functional options.
  21475. type messageOption func(*MessageMutation)
  21476. // newMessageMutation creates new mutation for the Message entity.
  21477. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  21478. m := &MessageMutation{
  21479. config: c,
  21480. op: op,
  21481. typ: TypeMessage,
  21482. clearedFields: make(map[string]struct{}),
  21483. }
  21484. for _, opt := range opts {
  21485. opt(m)
  21486. }
  21487. return m
  21488. }
  21489. // withMessageID sets the ID field of the mutation.
  21490. func withMessageID(id int) messageOption {
  21491. return func(m *MessageMutation) {
  21492. var (
  21493. err error
  21494. once sync.Once
  21495. value *Message
  21496. )
  21497. m.oldValue = func(ctx context.Context) (*Message, error) {
  21498. once.Do(func() {
  21499. if m.done {
  21500. err = errors.New("querying old values post mutation is not allowed")
  21501. } else {
  21502. value, err = m.Client().Message.Get(ctx, id)
  21503. }
  21504. })
  21505. return value, err
  21506. }
  21507. m.id = &id
  21508. }
  21509. }
  21510. // withMessage sets the old Message of the mutation.
  21511. func withMessage(node *Message) messageOption {
  21512. return func(m *MessageMutation) {
  21513. m.oldValue = func(context.Context) (*Message, error) {
  21514. return node, nil
  21515. }
  21516. m.id = &node.ID
  21517. }
  21518. }
  21519. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21520. // executed in a transaction (ent.Tx), a transactional client is returned.
  21521. func (m MessageMutation) Client() *Client {
  21522. client := &Client{config: m.config}
  21523. client.init()
  21524. return client
  21525. }
  21526. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21527. // it returns an error otherwise.
  21528. func (m MessageMutation) Tx() (*Tx, error) {
  21529. if _, ok := m.driver.(*txDriver); !ok {
  21530. return nil, errors.New("ent: mutation is not running in a transaction")
  21531. }
  21532. tx := &Tx{config: m.config}
  21533. tx.init()
  21534. return tx, nil
  21535. }
  21536. // ID returns the ID value in the mutation. Note that the ID is only available
  21537. // if it was provided to the builder or after it was returned from the database.
  21538. func (m *MessageMutation) ID() (id int, exists bool) {
  21539. if m.id == nil {
  21540. return
  21541. }
  21542. return *m.id, true
  21543. }
  21544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21545. // That means, if the mutation is applied within a transaction with an isolation level such
  21546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21547. // or updated by the mutation.
  21548. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  21549. switch {
  21550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21551. id, exists := m.ID()
  21552. if exists {
  21553. return []int{id}, nil
  21554. }
  21555. fallthrough
  21556. case m.op.Is(OpUpdate | OpDelete):
  21557. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  21558. default:
  21559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21560. }
  21561. }
  21562. // SetWxWxid sets the "wx_wxid" field.
  21563. func (m *MessageMutation) SetWxWxid(s string) {
  21564. m.wx_wxid = &s
  21565. }
  21566. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  21567. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  21568. v := m.wx_wxid
  21569. if v == nil {
  21570. return
  21571. }
  21572. return *v, true
  21573. }
  21574. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  21575. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  21576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21577. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  21578. if !m.op.Is(OpUpdateOne) {
  21579. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  21580. }
  21581. if m.id == nil || m.oldValue == nil {
  21582. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  21583. }
  21584. oldValue, err := m.oldValue(ctx)
  21585. if err != nil {
  21586. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  21587. }
  21588. return oldValue.WxWxid, nil
  21589. }
  21590. // ClearWxWxid clears the value of the "wx_wxid" field.
  21591. func (m *MessageMutation) ClearWxWxid() {
  21592. m.wx_wxid = nil
  21593. m.clearedFields[message.FieldWxWxid] = struct{}{}
  21594. }
  21595. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  21596. func (m *MessageMutation) WxWxidCleared() bool {
  21597. _, ok := m.clearedFields[message.FieldWxWxid]
  21598. return ok
  21599. }
  21600. // ResetWxWxid resets all changes to the "wx_wxid" field.
  21601. func (m *MessageMutation) ResetWxWxid() {
  21602. m.wx_wxid = nil
  21603. delete(m.clearedFields, message.FieldWxWxid)
  21604. }
  21605. // SetWxid sets the "wxid" field.
  21606. func (m *MessageMutation) SetWxid(s string) {
  21607. m.wxid = &s
  21608. }
  21609. // Wxid returns the value of the "wxid" field in the mutation.
  21610. func (m *MessageMutation) Wxid() (r string, exists bool) {
  21611. v := m.wxid
  21612. if v == nil {
  21613. return
  21614. }
  21615. return *v, true
  21616. }
  21617. // OldWxid returns the old "wxid" field's value of the Message entity.
  21618. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  21619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21620. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  21621. if !m.op.Is(OpUpdateOne) {
  21622. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  21623. }
  21624. if m.id == nil || m.oldValue == nil {
  21625. return v, errors.New("OldWxid requires an ID field in the mutation")
  21626. }
  21627. oldValue, err := m.oldValue(ctx)
  21628. if err != nil {
  21629. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  21630. }
  21631. return oldValue.Wxid, nil
  21632. }
  21633. // ResetWxid resets all changes to the "wxid" field.
  21634. func (m *MessageMutation) ResetWxid() {
  21635. m.wxid = nil
  21636. }
  21637. // SetContent sets the "content" field.
  21638. func (m *MessageMutation) SetContent(s string) {
  21639. m.content = &s
  21640. }
  21641. // Content returns the value of the "content" field in the mutation.
  21642. func (m *MessageMutation) Content() (r string, exists bool) {
  21643. v := m.content
  21644. if v == nil {
  21645. return
  21646. }
  21647. return *v, true
  21648. }
  21649. // OldContent returns the old "content" field's value of the Message entity.
  21650. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  21651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21652. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  21653. if !m.op.Is(OpUpdateOne) {
  21654. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21655. }
  21656. if m.id == nil || m.oldValue == nil {
  21657. return v, errors.New("OldContent requires an ID field in the mutation")
  21658. }
  21659. oldValue, err := m.oldValue(ctx)
  21660. if err != nil {
  21661. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21662. }
  21663. return oldValue.Content, nil
  21664. }
  21665. // ResetContent resets all changes to the "content" field.
  21666. func (m *MessageMutation) ResetContent() {
  21667. m.content = nil
  21668. }
  21669. // Where appends a list predicates to the MessageMutation builder.
  21670. func (m *MessageMutation) Where(ps ...predicate.Message) {
  21671. m.predicates = append(m.predicates, ps...)
  21672. }
  21673. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  21674. // users can use type-assertion to append predicates that do not depend on any generated package.
  21675. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  21676. p := make([]predicate.Message, len(ps))
  21677. for i := range ps {
  21678. p[i] = ps[i]
  21679. }
  21680. m.Where(p...)
  21681. }
  21682. // Op returns the operation name.
  21683. func (m *MessageMutation) Op() Op {
  21684. return m.op
  21685. }
  21686. // SetOp allows setting the mutation operation.
  21687. func (m *MessageMutation) SetOp(op Op) {
  21688. m.op = op
  21689. }
  21690. // Type returns the node type of this mutation (Message).
  21691. func (m *MessageMutation) Type() string {
  21692. return m.typ
  21693. }
  21694. // Fields returns all fields that were changed during this mutation. Note that in
  21695. // order to get all numeric fields that were incremented/decremented, call
  21696. // AddedFields().
  21697. func (m *MessageMutation) Fields() []string {
  21698. fields := make([]string, 0, 3)
  21699. if m.wx_wxid != nil {
  21700. fields = append(fields, message.FieldWxWxid)
  21701. }
  21702. if m.wxid != nil {
  21703. fields = append(fields, message.FieldWxid)
  21704. }
  21705. if m.content != nil {
  21706. fields = append(fields, message.FieldContent)
  21707. }
  21708. return fields
  21709. }
  21710. // Field returns the value of a field with the given name. The second boolean
  21711. // return value indicates that this field was not set, or was not defined in the
  21712. // schema.
  21713. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  21714. switch name {
  21715. case message.FieldWxWxid:
  21716. return m.WxWxid()
  21717. case message.FieldWxid:
  21718. return m.Wxid()
  21719. case message.FieldContent:
  21720. return m.Content()
  21721. }
  21722. return nil, false
  21723. }
  21724. // OldField returns the old value of the field from the database. An error is
  21725. // returned if the mutation operation is not UpdateOne, or the query to the
  21726. // database failed.
  21727. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21728. switch name {
  21729. case message.FieldWxWxid:
  21730. return m.OldWxWxid(ctx)
  21731. case message.FieldWxid:
  21732. return m.OldWxid(ctx)
  21733. case message.FieldContent:
  21734. return m.OldContent(ctx)
  21735. }
  21736. return nil, fmt.Errorf("unknown Message field %s", name)
  21737. }
  21738. // SetField sets the value of a field with the given name. It returns an error if
  21739. // the field is not defined in the schema, or if the type mismatched the field
  21740. // type.
  21741. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  21742. switch name {
  21743. case message.FieldWxWxid:
  21744. v, ok := value.(string)
  21745. if !ok {
  21746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21747. }
  21748. m.SetWxWxid(v)
  21749. return nil
  21750. case message.FieldWxid:
  21751. v, ok := value.(string)
  21752. if !ok {
  21753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21754. }
  21755. m.SetWxid(v)
  21756. return nil
  21757. case message.FieldContent:
  21758. v, ok := value.(string)
  21759. if !ok {
  21760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21761. }
  21762. m.SetContent(v)
  21763. return nil
  21764. }
  21765. return fmt.Errorf("unknown Message field %s", name)
  21766. }
  21767. // AddedFields returns all numeric fields that were incremented/decremented during
  21768. // this mutation.
  21769. func (m *MessageMutation) AddedFields() []string {
  21770. return nil
  21771. }
  21772. // AddedField returns the numeric value that was incremented/decremented on a field
  21773. // with the given name. The second boolean return value indicates that this field
  21774. // was not set, or was not defined in the schema.
  21775. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  21776. return nil, false
  21777. }
  21778. // AddField adds the value to the field with the given name. It returns an error if
  21779. // the field is not defined in the schema, or if the type mismatched the field
  21780. // type.
  21781. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  21782. switch name {
  21783. }
  21784. return fmt.Errorf("unknown Message numeric field %s", name)
  21785. }
  21786. // ClearedFields returns all nullable fields that were cleared during this
  21787. // mutation.
  21788. func (m *MessageMutation) ClearedFields() []string {
  21789. var fields []string
  21790. if m.FieldCleared(message.FieldWxWxid) {
  21791. fields = append(fields, message.FieldWxWxid)
  21792. }
  21793. return fields
  21794. }
  21795. // FieldCleared returns a boolean indicating if a field with the given name was
  21796. // cleared in this mutation.
  21797. func (m *MessageMutation) FieldCleared(name string) bool {
  21798. _, ok := m.clearedFields[name]
  21799. return ok
  21800. }
  21801. // ClearField clears the value of the field with the given name. It returns an
  21802. // error if the field is not defined in the schema.
  21803. func (m *MessageMutation) ClearField(name string) error {
  21804. switch name {
  21805. case message.FieldWxWxid:
  21806. m.ClearWxWxid()
  21807. return nil
  21808. }
  21809. return fmt.Errorf("unknown Message nullable field %s", name)
  21810. }
  21811. // ResetField resets all changes in the mutation for the field with the given name.
  21812. // It returns an error if the field is not defined in the schema.
  21813. func (m *MessageMutation) ResetField(name string) error {
  21814. switch name {
  21815. case message.FieldWxWxid:
  21816. m.ResetWxWxid()
  21817. return nil
  21818. case message.FieldWxid:
  21819. m.ResetWxid()
  21820. return nil
  21821. case message.FieldContent:
  21822. m.ResetContent()
  21823. return nil
  21824. }
  21825. return fmt.Errorf("unknown Message field %s", name)
  21826. }
  21827. // AddedEdges returns all edge names that were set/added in this mutation.
  21828. func (m *MessageMutation) AddedEdges() []string {
  21829. edges := make([]string, 0, 0)
  21830. return edges
  21831. }
  21832. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21833. // name in this mutation.
  21834. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  21835. return nil
  21836. }
  21837. // RemovedEdges returns all edge names that were removed in this mutation.
  21838. func (m *MessageMutation) RemovedEdges() []string {
  21839. edges := make([]string, 0, 0)
  21840. return edges
  21841. }
  21842. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21843. // the given name in this mutation.
  21844. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  21845. return nil
  21846. }
  21847. // ClearedEdges returns all edge names that were cleared in this mutation.
  21848. func (m *MessageMutation) ClearedEdges() []string {
  21849. edges := make([]string, 0, 0)
  21850. return edges
  21851. }
  21852. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21853. // was cleared in this mutation.
  21854. func (m *MessageMutation) EdgeCleared(name string) bool {
  21855. return false
  21856. }
  21857. // ClearEdge clears the value of the edge with the given name. It returns an error
  21858. // if that edge is not defined in the schema.
  21859. func (m *MessageMutation) ClearEdge(name string) error {
  21860. return fmt.Errorf("unknown Message unique edge %s", name)
  21861. }
  21862. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21863. // It returns an error if the edge is not defined in the schema.
  21864. func (m *MessageMutation) ResetEdge(name string) error {
  21865. return fmt.Errorf("unknown Message edge %s", name)
  21866. }
  21867. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  21868. type MessageRecordsMutation struct {
  21869. config
  21870. op Op
  21871. typ string
  21872. id *uint64
  21873. created_at *time.Time
  21874. updated_at *time.Time
  21875. status *uint8
  21876. addstatus *int8
  21877. bot_wxid *string
  21878. contact_type *int
  21879. addcontact_type *int
  21880. contact_wxid *string
  21881. content_type *int
  21882. addcontent_type *int
  21883. content *string
  21884. meta *custom_types.Meta
  21885. error_detail *string
  21886. send_time *time.Time
  21887. source_type *int
  21888. addsource_type *int
  21889. organization_id *uint64
  21890. addorganization_id *int64
  21891. clearedFields map[string]struct{}
  21892. sop_stage *uint64
  21893. clearedsop_stage bool
  21894. sop_node *uint64
  21895. clearedsop_node bool
  21896. message_contact *uint64
  21897. clearedmessage_contact bool
  21898. done bool
  21899. oldValue func(context.Context) (*MessageRecords, error)
  21900. predicates []predicate.MessageRecords
  21901. }
  21902. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  21903. // messagerecordsOption allows management of the mutation configuration using functional options.
  21904. type messagerecordsOption func(*MessageRecordsMutation)
  21905. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  21906. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  21907. m := &MessageRecordsMutation{
  21908. config: c,
  21909. op: op,
  21910. typ: TypeMessageRecords,
  21911. clearedFields: make(map[string]struct{}),
  21912. }
  21913. for _, opt := range opts {
  21914. opt(m)
  21915. }
  21916. return m
  21917. }
  21918. // withMessageRecordsID sets the ID field of the mutation.
  21919. func withMessageRecordsID(id uint64) messagerecordsOption {
  21920. return func(m *MessageRecordsMutation) {
  21921. var (
  21922. err error
  21923. once sync.Once
  21924. value *MessageRecords
  21925. )
  21926. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  21927. once.Do(func() {
  21928. if m.done {
  21929. err = errors.New("querying old values post mutation is not allowed")
  21930. } else {
  21931. value, err = m.Client().MessageRecords.Get(ctx, id)
  21932. }
  21933. })
  21934. return value, err
  21935. }
  21936. m.id = &id
  21937. }
  21938. }
  21939. // withMessageRecords sets the old MessageRecords of the mutation.
  21940. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  21941. return func(m *MessageRecordsMutation) {
  21942. m.oldValue = func(context.Context) (*MessageRecords, error) {
  21943. return node, nil
  21944. }
  21945. m.id = &node.ID
  21946. }
  21947. }
  21948. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21949. // executed in a transaction (ent.Tx), a transactional client is returned.
  21950. func (m MessageRecordsMutation) Client() *Client {
  21951. client := &Client{config: m.config}
  21952. client.init()
  21953. return client
  21954. }
  21955. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21956. // it returns an error otherwise.
  21957. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  21958. if _, ok := m.driver.(*txDriver); !ok {
  21959. return nil, errors.New("ent: mutation is not running in a transaction")
  21960. }
  21961. tx := &Tx{config: m.config}
  21962. tx.init()
  21963. return tx, nil
  21964. }
  21965. // SetID sets the value of the id field. Note that this
  21966. // operation is only accepted on creation of MessageRecords entities.
  21967. func (m *MessageRecordsMutation) SetID(id uint64) {
  21968. m.id = &id
  21969. }
  21970. // ID returns the ID value in the mutation. Note that the ID is only available
  21971. // if it was provided to the builder or after it was returned from the database.
  21972. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  21973. if m.id == nil {
  21974. return
  21975. }
  21976. return *m.id, true
  21977. }
  21978. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21979. // That means, if the mutation is applied within a transaction with an isolation level such
  21980. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21981. // or updated by the mutation.
  21982. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  21983. switch {
  21984. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21985. id, exists := m.ID()
  21986. if exists {
  21987. return []uint64{id}, nil
  21988. }
  21989. fallthrough
  21990. case m.op.Is(OpUpdate | OpDelete):
  21991. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  21992. default:
  21993. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21994. }
  21995. }
  21996. // SetCreatedAt sets the "created_at" field.
  21997. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  21998. m.created_at = &t
  21999. }
  22000. // CreatedAt returns the value of the "created_at" field in the mutation.
  22001. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  22002. v := m.created_at
  22003. if v == nil {
  22004. return
  22005. }
  22006. return *v, true
  22007. }
  22008. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  22009. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22011. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22012. if !m.op.Is(OpUpdateOne) {
  22013. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22014. }
  22015. if m.id == nil || m.oldValue == nil {
  22016. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22017. }
  22018. oldValue, err := m.oldValue(ctx)
  22019. if err != nil {
  22020. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22021. }
  22022. return oldValue.CreatedAt, nil
  22023. }
  22024. // ResetCreatedAt resets all changes to the "created_at" field.
  22025. func (m *MessageRecordsMutation) ResetCreatedAt() {
  22026. m.created_at = nil
  22027. }
  22028. // SetUpdatedAt sets the "updated_at" field.
  22029. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  22030. m.updated_at = &t
  22031. }
  22032. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22033. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  22034. v := m.updated_at
  22035. if v == nil {
  22036. return
  22037. }
  22038. return *v, true
  22039. }
  22040. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  22041. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22043. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22044. if !m.op.Is(OpUpdateOne) {
  22045. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22046. }
  22047. if m.id == nil || m.oldValue == nil {
  22048. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22049. }
  22050. oldValue, err := m.oldValue(ctx)
  22051. if err != nil {
  22052. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22053. }
  22054. return oldValue.UpdatedAt, nil
  22055. }
  22056. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22057. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  22058. m.updated_at = nil
  22059. }
  22060. // SetStatus sets the "status" field.
  22061. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  22062. m.status = &u
  22063. m.addstatus = nil
  22064. }
  22065. // Status returns the value of the "status" field in the mutation.
  22066. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  22067. v := m.status
  22068. if v == nil {
  22069. return
  22070. }
  22071. return *v, true
  22072. }
  22073. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  22074. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22076. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22077. if !m.op.Is(OpUpdateOne) {
  22078. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22079. }
  22080. if m.id == nil || m.oldValue == nil {
  22081. return v, errors.New("OldStatus requires an ID field in the mutation")
  22082. }
  22083. oldValue, err := m.oldValue(ctx)
  22084. if err != nil {
  22085. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22086. }
  22087. return oldValue.Status, nil
  22088. }
  22089. // AddStatus adds u to the "status" field.
  22090. func (m *MessageRecordsMutation) AddStatus(u int8) {
  22091. if m.addstatus != nil {
  22092. *m.addstatus += u
  22093. } else {
  22094. m.addstatus = &u
  22095. }
  22096. }
  22097. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22098. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  22099. v := m.addstatus
  22100. if v == nil {
  22101. return
  22102. }
  22103. return *v, true
  22104. }
  22105. // ClearStatus clears the value of the "status" field.
  22106. func (m *MessageRecordsMutation) ClearStatus() {
  22107. m.status = nil
  22108. m.addstatus = nil
  22109. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  22110. }
  22111. // StatusCleared returns if the "status" field was cleared in this mutation.
  22112. func (m *MessageRecordsMutation) StatusCleared() bool {
  22113. _, ok := m.clearedFields[messagerecords.FieldStatus]
  22114. return ok
  22115. }
  22116. // ResetStatus resets all changes to the "status" field.
  22117. func (m *MessageRecordsMutation) ResetStatus() {
  22118. m.status = nil
  22119. m.addstatus = nil
  22120. delete(m.clearedFields, messagerecords.FieldStatus)
  22121. }
  22122. // SetBotWxid sets the "bot_wxid" field.
  22123. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  22124. m.bot_wxid = &s
  22125. }
  22126. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  22127. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  22128. v := m.bot_wxid
  22129. if v == nil {
  22130. return
  22131. }
  22132. return *v, true
  22133. }
  22134. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  22135. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22137. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  22138. if !m.op.Is(OpUpdateOne) {
  22139. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  22140. }
  22141. if m.id == nil || m.oldValue == nil {
  22142. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  22143. }
  22144. oldValue, err := m.oldValue(ctx)
  22145. if err != nil {
  22146. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  22147. }
  22148. return oldValue.BotWxid, nil
  22149. }
  22150. // ResetBotWxid resets all changes to the "bot_wxid" field.
  22151. func (m *MessageRecordsMutation) ResetBotWxid() {
  22152. m.bot_wxid = nil
  22153. }
  22154. // SetContactID sets the "contact_id" field.
  22155. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  22156. m.message_contact = &u
  22157. }
  22158. // ContactID returns the value of the "contact_id" field in the mutation.
  22159. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  22160. v := m.message_contact
  22161. if v == nil {
  22162. return
  22163. }
  22164. return *v, true
  22165. }
  22166. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  22167. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22169. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22170. if !m.op.Is(OpUpdateOne) {
  22171. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22172. }
  22173. if m.id == nil || m.oldValue == nil {
  22174. return v, errors.New("OldContactID requires an ID field in the mutation")
  22175. }
  22176. oldValue, err := m.oldValue(ctx)
  22177. if err != nil {
  22178. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22179. }
  22180. return oldValue.ContactID, nil
  22181. }
  22182. // ClearContactID clears the value of the "contact_id" field.
  22183. func (m *MessageRecordsMutation) ClearContactID() {
  22184. m.message_contact = nil
  22185. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  22186. }
  22187. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  22188. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  22189. _, ok := m.clearedFields[messagerecords.FieldContactID]
  22190. return ok
  22191. }
  22192. // ResetContactID resets all changes to the "contact_id" field.
  22193. func (m *MessageRecordsMutation) ResetContactID() {
  22194. m.message_contact = nil
  22195. delete(m.clearedFields, messagerecords.FieldContactID)
  22196. }
  22197. // SetContactType sets the "contact_type" field.
  22198. func (m *MessageRecordsMutation) SetContactType(i int) {
  22199. m.contact_type = &i
  22200. m.addcontact_type = nil
  22201. }
  22202. // ContactType returns the value of the "contact_type" field in the mutation.
  22203. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  22204. v := m.contact_type
  22205. if v == nil {
  22206. return
  22207. }
  22208. return *v, true
  22209. }
  22210. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  22211. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22213. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  22214. if !m.op.Is(OpUpdateOne) {
  22215. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  22216. }
  22217. if m.id == nil || m.oldValue == nil {
  22218. return v, errors.New("OldContactType requires an ID field in the mutation")
  22219. }
  22220. oldValue, err := m.oldValue(ctx)
  22221. if err != nil {
  22222. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  22223. }
  22224. return oldValue.ContactType, nil
  22225. }
  22226. // AddContactType adds i to the "contact_type" field.
  22227. func (m *MessageRecordsMutation) AddContactType(i int) {
  22228. if m.addcontact_type != nil {
  22229. *m.addcontact_type += i
  22230. } else {
  22231. m.addcontact_type = &i
  22232. }
  22233. }
  22234. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  22235. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  22236. v := m.addcontact_type
  22237. if v == nil {
  22238. return
  22239. }
  22240. return *v, true
  22241. }
  22242. // ResetContactType resets all changes to the "contact_type" field.
  22243. func (m *MessageRecordsMutation) ResetContactType() {
  22244. m.contact_type = nil
  22245. m.addcontact_type = nil
  22246. }
  22247. // SetContactWxid sets the "contact_wxid" field.
  22248. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  22249. m.contact_wxid = &s
  22250. }
  22251. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  22252. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  22253. v := m.contact_wxid
  22254. if v == nil {
  22255. return
  22256. }
  22257. return *v, true
  22258. }
  22259. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  22260. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22262. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  22263. if !m.op.Is(OpUpdateOne) {
  22264. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  22265. }
  22266. if m.id == nil || m.oldValue == nil {
  22267. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  22268. }
  22269. oldValue, err := m.oldValue(ctx)
  22270. if err != nil {
  22271. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  22272. }
  22273. return oldValue.ContactWxid, nil
  22274. }
  22275. // ResetContactWxid resets all changes to the "contact_wxid" field.
  22276. func (m *MessageRecordsMutation) ResetContactWxid() {
  22277. m.contact_wxid = nil
  22278. }
  22279. // SetContentType sets the "content_type" field.
  22280. func (m *MessageRecordsMutation) SetContentType(i int) {
  22281. m.content_type = &i
  22282. m.addcontent_type = nil
  22283. }
  22284. // ContentType returns the value of the "content_type" field in the mutation.
  22285. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  22286. v := m.content_type
  22287. if v == nil {
  22288. return
  22289. }
  22290. return *v, true
  22291. }
  22292. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  22293. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22295. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  22296. if !m.op.Is(OpUpdateOne) {
  22297. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  22298. }
  22299. if m.id == nil || m.oldValue == nil {
  22300. return v, errors.New("OldContentType requires an ID field in the mutation")
  22301. }
  22302. oldValue, err := m.oldValue(ctx)
  22303. if err != nil {
  22304. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  22305. }
  22306. return oldValue.ContentType, nil
  22307. }
  22308. // AddContentType adds i to the "content_type" field.
  22309. func (m *MessageRecordsMutation) AddContentType(i int) {
  22310. if m.addcontent_type != nil {
  22311. *m.addcontent_type += i
  22312. } else {
  22313. m.addcontent_type = &i
  22314. }
  22315. }
  22316. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  22317. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  22318. v := m.addcontent_type
  22319. if v == nil {
  22320. return
  22321. }
  22322. return *v, true
  22323. }
  22324. // ResetContentType resets all changes to the "content_type" field.
  22325. func (m *MessageRecordsMutation) ResetContentType() {
  22326. m.content_type = nil
  22327. m.addcontent_type = nil
  22328. }
  22329. // SetContent sets the "content" field.
  22330. func (m *MessageRecordsMutation) SetContent(s string) {
  22331. m.content = &s
  22332. }
  22333. // Content returns the value of the "content" field in the mutation.
  22334. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  22335. v := m.content
  22336. if v == nil {
  22337. return
  22338. }
  22339. return *v, true
  22340. }
  22341. // OldContent returns the old "content" field's value of the MessageRecords entity.
  22342. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22344. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  22345. if !m.op.Is(OpUpdateOne) {
  22346. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22347. }
  22348. if m.id == nil || m.oldValue == nil {
  22349. return v, errors.New("OldContent requires an ID field in the mutation")
  22350. }
  22351. oldValue, err := m.oldValue(ctx)
  22352. if err != nil {
  22353. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22354. }
  22355. return oldValue.Content, nil
  22356. }
  22357. // ResetContent resets all changes to the "content" field.
  22358. func (m *MessageRecordsMutation) ResetContent() {
  22359. m.content = nil
  22360. }
  22361. // SetMeta sets the "meta" field.
  22362. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  22363. m.meta = &ct
  22364. }
  22365. // Meta returns the value of the "meta" field in the mutation.
  22366. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  22367. v := m.meta
  22368. if v == nil {
  22369. return
  22370. }
  22371. return *v, true
  22372. }
  22373. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  22374. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22376. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  22377. if !m.op.Is(OpUpdateOne) {
  22378. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  22379. }
  22380. if m.id == nil || m.oldValue == nil {
  22381. return v, errors.New("OldMeta requires an ID field in the mutation")
  22382. }
  22383. oldValue, err := m.oldValue(ctx)
  22384. if err != nil {
  22385. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  22386. }
  22387. return oldValue.Meta, nil
  22388. }
  22389. // ClearMeta clears the value of the "meta" field.
  22390. func (m *MessageRecordsMutation) ClearMeta() {
  22391. m.meta = nil
  22392. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  22393. }
  22394. // MetaCleared returns if the "meta" field was cleared in this mutation.
  22395. func (m *MessageRecordsMutation) MetaCleared() bool {
  22396. _, ok := m.clearedFields[messagerecords.FieldMeta]
  22397. return ok
  22398. }
  22399. // ResetMeta resets all changes to the "meta" field.
  22400. func (m *MessageRecordsMutation) ResetMeta() {
  22401. m.meta = nil
  22402. delete(m.clearedFields, messagerecords.FieldMeta)
  22403. }
  22404. // SetErrorDetail sets the "error_detail" field.
  22405. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  22406. m.error_detail = &s
  22407. }
  22408. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  22409. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  22410. v := m.error_detail
  22411. if v == nil {
  22412. return
  22413. }
  22414. return *v, true
  22415. }
  22416. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  22417. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22419. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  22420. if !m.op.Is(OpUpdateOne) {
  22421. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  22422. }
  22423. if m.id == nil || m.oldValue == nil {
  22424. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  22425. }
  22426. oldValue, err := m.oldValue(ctx)
  22427. if err != nil {
  22428. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  22429. }
  22430. return oldValue.ErrorDetail, nil
  22431. }
  22432. // ResetErrorDetail resets all changes to the "error_detail" field.
  22433. func (m *MessageRecordsMutation) ResetErrorDetail() {
  22434. m.error_detail = nil
  22435. }
  22436. // SetSendTime sets the "send_time" field.
  22437. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  22438. m.send_time = &t
  22439. }
  22440. // SendTime returns the value of the "send_time" field in the mutation.
  22441. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  22442. v := m.send_time
  22443. if v == nil {
  22444. return
  22445. }
  22446. return *v, true
  22447. }
  22448. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  22449. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22451. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  22452. if !m.op.Is(OpUpdateOne) {
  22453. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  22454. }
  22455. if m.id == nil || m.oldValue == nil {
  22456. return v, errors.New("OldSendTime requires an ID field in the mutation")
  22457. }
  22458. oldValue, err := m.oldValue(ctx)
  22459. if err != nil {
  22460. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  22461. }
  22462. return oldValue.SendTime, nil
  22463. }
  22464. // ClearSendTime clears the value of the "send_time" field.
  22465. func (m *MessageRecordsMutation) ClearSendTime() {
  22466. m.send_time = nil
  22467. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  22468. }
  22469. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  22470. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  22471. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  22472. return ok
  22473. }
  22474. // ResetSendTime resets all changes to the "send_time" field.
  22475. func (m *MessageRecordsMutation) ResetSendTime() {
  22476. m.send_time = nil
  22477. delete(m.clearedFields, messagerecords.FieldSendTime)
  22478. }
  22479. // SetSourceType sets the "source_type" field.
  22480. func (m *MessageRecordsMutation) SetSourceType(i int) {
  22481. m.source_type = &i
  22482. m.addsource_type = nil
  22483. }
  22484. // SourceType returns the value of the "source_type" field in the mutation.
  22485. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  22486. v := m.source_type
  22487. if v == nil {
  22488. return
  22489. }
  22490. return *v, true
  22491. }
  22492. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  22493. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22495. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  22496. if !m.op.Is(OpUpdateOne) {
  22497. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  22498. }
  22499. if m.id == nil || m.oldValue == nil {
  22500. return v, errors.New("OldSourceType requires an ID field in the mutation")
  22501. }
  22502. oldValue, err := m.oldValue(ctx)
  22503. if err != nil {
  22504. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  22505. }
  22506. return oldValue.SourceType, nil
  22507. }
  22508. // AddSourceType adds i to the "source_type" field.
  22509. func (m *MessageRecordsMutation) AddSourceType(i int) {
  22510. if m.addsource_type != nil {
  22511. *m.addsource_type += i
  22512. } else {
  22513. m.addsource_type = &i
  22514. }
  22515. }
  22516. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  22517. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  22518. v := m.addsource_type
  22519. if v == nil {
  22520. return
  22521. }
  22522. return *v, true
  22523. }
  22524. // ResetSourceType resets all changes to the "source_type" field.
  22525. func (m *MessageRecordsMutation) ResetSourceType() {
  22526. m.source_type = nil
  22527. m.addsource_type = nil
  22528. }
  22529. // SetSourceID sets the "source_id" field.
  22530. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  22531. m.sop_stage = &u
  22532. }
  22533. // SourceID returns the value of the "source_id" field in the mutation.
  22534. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  22535. v := m.sop_stage
  22536. if v == nil {
  22537. return
  22538. }
  22539. return *v, true
  22540. }
  22541. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  22542. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22544. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  22545. if !m.op.Is(OpUpdateOne) {
  22546. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  22547. }
  22548. if m.id == nil || m.oldValue == nil {
  22549. return v, errors.New("OldSourceID requires an ID field in the mutation")
  22550. }
  22551. oldValue, err := m.oldValue(ctx)
  22552. if err != nil {
  22553. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  22554. }
  22555. return oldValue.SourceID, nil
  22556. }
  22557. // ClearSourceID clears the value of the "source_id" field.
  22558. func (m *MessageRecordsMutation) ClearSourceID() {
  22559. m.sop_stage = nil
  22560. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  22561. }
  22562. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  22563. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  22564. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  22565. return ok
  22566. }
  22567. // ResetSourceID resets all changes to the "source_id" field.
  22568. func (m *MessageRecordsMutation) ResetSourceID() {
  22569. m.sop_stage = nil
  22570. delete(m.clearedFields, messagerecords.FieldSourceID)
  22571. }
  22572. // SetSubSourceID sets the "sub_source_id" field.
  22573. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  22574. m.sop_node = &u
  22575. }
  22576. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  22577. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  22578. v := m.sop_node
  22579. if v == nil {
  22580. return
  22581. }
  22582. return *v, true
  22583. }
  22584. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  22585. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22587. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  22588. if !m.op.Is(OpUpdateOne) {
  22589. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  22590. }
  22591. if m.id == nil || m.oldValue == nil {
  22592. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  22593. }
  22594. oldValue, err := m.oldValue(ctx)
  22595. if err != nil {
  22596. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  22597. }
  22598. return oldValue.SubSourceID, nil
  22599. }
  22600. // ClearSubSourceID clears the value of the "sub_source_id" field.
  22601. func (m *MessageRecordsMutation) ClearSubSourceID() {
  22602. m.sop_node = nil
  22603. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  22604. }
  22605. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  22606. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  22607. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  22608. return ok
  22609. }
  22610. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  22611. func (m *MessageRecordsMutation) ResetSubSourceID() {
  22612. m.sop_node = nil
  22613. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  22614. }
  22615. // SetOrganizationID sets the "organization_id" field.
  22616. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  22617. m.organization_id = &u
  22618. m.addorganization_id = nil
  22619. }
  22620. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22621. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  22622. v := m.organization_id
  22623. if v == nil {
  22624. return
  22625. }
  22626. return *v, true
  22627. }
  22628. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  22629. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22631. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22632. if !m.op.Is(OpUpdateOne) {
  22633. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22634. }
  22635. if m.id == nil || m.oldValue == nil {
  22636. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22637. }
  22638. oldValue, err := m.oldValue(ctx)
  22639. if err != nil {
  22640. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22641. }
  22642. return oldValue.OrganizationID, nil
  22643. }
  22644. // AddOrganizationID adds u to the "organization_id" field.
  22645. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  22646. if m.addorganization_id != nil {
  22647. *m.addorganization_id += u
  22648. } else {
  22649. m.addorganization_id = &u
  22650. }
  22651. }
  22652. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22653. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  22654. v := m.addorganization_id
  22655. if v == nil {
  22656. return
  22657. }
  22658. return *v, true
  22659. }
  22660. // ClearOrganizationID clears the value of the "organization_id" field.
  22661. func (m *MessageRecordsMutation) ClearOrganizationID() {
  22662. m.organization_id = nil
  22663. m.addorganization_id = nil
  22664. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  22665. }
  22666. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22667. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  22668. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  22669. return ok
  22670. }
  22671. // ResetOrganizationID resets all changes to the "organization_id" field.
  22672. func (m *MessageRecordsMutation) ResetOrganizationID() {
  22673. m.organization_id = nil
  22674. m.addorganization_id = nil
  22675. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  22676. }
  22677. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22678. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  22679. m.sop_stage = &id
  22680. }
  22681. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22682. func (m *MessageRecordsMutation) ClearSopStage() {
  22683. m.clearedsop_stage = true
  22684. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  22685. }
  22686. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22687. func (m *MessageRecordsMutation) SopStageCleared() bool {
  22688. return m.SourceIDCleared() || m.clearedsop_stage
  22689. }
  22690. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22691. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  22692. if m.sop_stage != nil {
  22693. return *m.sop_stage, true
  22694. }
  22695. return
  22696. }
  22697. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22698. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22699. // SopStageID instead. It exists only for internal usage by the builders.
  22700. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  22701. if id := m.sop_stage; id != nil {
  22702. ids = append(ids, *id)
  22703. }
  22704. return
  22705. }
  22706. // ResetSopStage resets all changes to the "sop_stage" edge.
  22707. func (m *MessageRecordsMutation) ResetSopStage() {
  22708. m.sop_stage = nil
  22709. m.clearedsop_stage = false
  22710. }
  22711. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  22712. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  22713. m.sop_node = &id
  22714. }
  22715. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  22716. func (m *MessageRecordsMutation) ClearSopNode() {
  22717. m.clearedsop_node = true
  22718. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  22719. }
  22720. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  22721. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  22722. return m.SubSourceIDCleared() || m.clearedsop_node
  22723. }
  22724. // SopNodeID returns the "sop_node" edge ID in the mutation.
  22725. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  22726. if m.sop_node != nil {
  22727. return *m.sop_node, true
  22728. }
  22729. return
  22730. }
  22731. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  22732. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22733. // SopNodeID instead. It exists only for internal usage by the builders.
  22734. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  22735. if id := m.sop_node; id != nil {
  22736. ids = append(ids, *id)
  22737. }
  22738. return
  22739. }
  22740. // ResetSopNode resets all changes to the "sop_node" edge.
  22741. func (m *MessageRecordsMutation) ResetSopNode() {
  22742. m.sop_node = nil
  22743. m.clearedsop_node = false
  22744. }
  22745. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  22746. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  22747. m.message_contact = &id
  22748. }
  22749. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  22750. func (m *MessageRecordsMutation) ClearMessageContact() {
  22751. m.clearedmessage_contact = true
  22752. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  22753. }
  22754. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  22755. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  22756. return m.ContactIDCleared() || m.clearedmessage_contact
  22757. }
  22758. // MessageContactID returns the "message_contact" edge ID in the mutation.
  22759. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  22760. if m.message_contact != nil {
  22761. return *m.message_contact, true
  22762. }
  22763. return
  22764. }
  22765. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  22766. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22767. // MessageContactID instead. It exists only for internal usage by the builders.
  22768. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  22769. if id := m.message_contact; id != nil {
  22770. ids = append(ids, *id)
  22771. }
  22772. return
  22773. }
  22774. // ResetMessageContact resets all changes to the "message_contact" edge.
  22775. func (m *MessageRecordsMutation) ResetMessageContact() {
  22776. m.message_contact = nil
  22777. m.clearedmessage_contact = false
  22778. }
  22779. // Where appends a list predicates to the MessageRecordsMutation builder.
  22780. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  22781. m.predicates = append(m.predicates, ps...)
  22782. }
  22783. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  22784. // users can use type-assertion to append predicates that do not depend on any generated package.
  22785. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  22786. p := make([]predicate.MessageRecords, len(ps))
  22787. for i := range ps {
  22788. p[i] = ps[i]
  22789. }
  22790. m.Where(p...)
  22791. }
  22792. // Op returns the operation name.
  22793. func (m *MessageRecordsMutation) Op() Op {
  22794. return m.op
  22795. }
  22796. // SetOp allows setting the mutation operation.
  22797. func (m *MessageRecordsMutation) SetOp(op Op) {
  22798. m.op = op
  22799. }
  22800. // Type returns the node type of this mutation (MessageRecords).
  22801. func (m *MessageRecordsMutation) Type() string {
  22802. return m.typ
  22803. }
  22804. // Fields returns all fields that were changed during this mutation. Note that in
  22805. // order to get all numeric fields that were incremented/decremented, call
  22806. // AddedFields().
  22807. func (m *MessageRecordsMutation) Fields() []string {
  22808. fields := make([]string, 0, 16)
  22809. if m.created_at != nil {
  22810. fields = append(fields, messagerecords.FieldCreatedAt)
  22811. }
  22812. if m.updated_at != nil {
  22813. fields = append(fields, messagerecords.FieldUpdatedAt)
  22814. }
  22815. if m.status != nil {
  22816. fields = append(fields, messagerecords.FieldStatus)
  22817. }
  22818. if m.bot_wxid != nil {
  22819. fields = append(fields, messagerecords.FieldBotWxid)
  22820. }
  22821. if m.message_contact != nil {
  22822. fields = append(fields, messagerecords.FieldContactID)
  22823. }
  22824. if m.contact_type != nil {
  22825. fields = append(fields, messagerecords.FieldContactType)
  22826. }
  22827. if m.contact_wxid != nil {
  22828. fields = append(fields, messagerecords.FieldContactWxid)
  22829. }
  22830. if m.content_type != nil {
  22831. fields = append(fields, messagerecords.FieldContentType)
  22832. }
  22833. if m.content != nil {
  22834. fields = append(fields, messagerecords.FieldContent)
  22835. }
  22836. if m.meta != nil {
  22837. fields = append(fields, messagerecords.FieldMeta)
  22838. }
  22839. if m.error_detail != nil {
  22840. fields = append(fields, messagerecords.FieldErrorDetail)
  22841. }
  22842. if m.send_time != nil {
  22843. fields = append(fields, messagerecords.FieldSendTime)
  22844. }
  22845. if m.source_type != nil {
  22846. fields = append(fields, messagerecords.FieldSourceType)
  22847. }
  22848. if m.sop_stage != nil {
  22849. fields = append(fields, messagerecords.FieldSourceID)
  22850. }
  22851. if m.sop_node != nil {
  22852. fields = append(fields, messagerecords.FieldSubSourceID)
  22853. }
  22854. if m.organization_id != nil {
  22855. fields = append(fields, messagerecords.FieldOrganizationID)
  22856. }
  22857. return fields
  22858. }
  22859. // Field returns the value of a field with the given name. The second boolean
  22860. // return value indicates that this field was not set, or was not defined in the
  22861. // schema.
  22862. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  22863. switch name {
  22864. case messagerecords.FieldCreatedAt:
  22865. return m.CreatedAt()
  22866. case messagerecords.FieldUpdatedAt:
  22867. return m.UpdatedAt()
  22868. case messagerecords.FieldStatus:
  22869. return m.Status()
  22870. case messagerecords.FieldBotWxid:
  22871. return m.BotWxid()
  22872. case messagerecords.FieldContactID:
  22873. return m.ContactID()
  22874. case messagerecords.FieldContactType:
  22875. return m.ContactType()
  22876. case messagerecords.FieldContactWxid:
  22877. return m.ContactWxid()
  22878. case messagerecords.FieldContentType:
  22879. return m.ContentType()
  22880. case messagerecords.FieldContent:
  22881. return m.Content()
  22882. case messagerecords.FieldMeta:
  22883. return m.Meta()
  22884. case messagerecords.FieldErrorDetail:
  22885. return m.ErrorDetail()
  22886. case messagerecords.FieldSendTime:
  22887. return m.SendTime()
  22888. case messagerecords.FieldSourceType:
  22889. return m.SourceType()
  22890. case messagerecords.FieldSourceID:
  22891. return m.SourceID()
  22892. case messagerecords.FieldSubSourceID:
  22893. return m.SubSourceID()
  22894. case messagerecords.FieldOrganizationID:
  22895. return m.OrganizationID()
  22896. }
  22897. return nil, false
  22898. }
  22899. // OldField returns the old value of the field from the database. An error is
  22900. // returned if the mutation operation is not UpdateOne, or the query to the
  22901. // database failed.
  22902. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22903. switch name {
  22904. case messagerecords.FieldCreatedAt:
  22905. return m.OldCreatedAt(ctx)
  22906. case messagerecords.FieldUpdatedAt:
  22907. return m.OldUpdatedAt(ctx)
  22908. case messagerecords.FieldStatus:
  22909. return m.OldStatus(ctx)
  22910. case messagerecords.FieldBotWxid:
  22911. return m.OldBotWxid(ctx)
  22912. case messagerecords.FieldContactID:
  22913. return m.OldContactID(ctx)
  22914. case messagerecords.FieldContactType:
  22915. return m.OldContactType(ctx)
  22916. case messagerecords.FieldContactWxid:
  22917. return m.OldContactWxid(ctx)
  22918. case messagerecords.FieldContentType:
  22919. return m.OldContentType(ctx)
  22920. case messagerecords.FieldContent:
  22921. return m.OldContent(ctx)
  22922. case messagerecords.FieldMeta:
  22923. return m.OldMeta(ctx)
  22924. case messagerecords.FieldErrorDetail:
  22925. return m.OldErrorDetail(ctx)
  22926. case messagerecords.FieldSendTime:
  22927. return m.OldSendTime(ctx)
  22928. case messagerecords.FieldSourceType:
  22929. return m.OldSourceType(ctx)
  22930. case messagerecords.FieldSourceID:
  22931. return m.OldSourceID(ctx)
  22932. case messagerecords.FieldSubSourceID:
  22933. return m.OldSubSourceID(ctx)
  22934. case messagerecords.FieldOrganizationID:
  22935. return m.OldOrganizationID(ctx)
  22936. }
  22937. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  22938. }
  22939. // SetField sets the value of a field with the given name. It returns an error if
  22940. // the field is not defined in the schema, or if the type mismatched the field
  22941. // type.
  22942. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  22943. switch name {
  22944. case messagerecords.FieldCreatedAt:
  22945. v, ok := value.(time.Time)
  22946. if !ok {
  22947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22948. }
  22949. m.SetCreatedAt(v)
  22950. return nil
  22951. case messagerecords.FieldUpdatedAt:
  22952. v, ok := value.(time.Time)
  22953. if !ok {
  22954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22955. }
  22956. m.SetUpdatedAt(v)
  22957. return nil
  22958. case messagerecords.FieldStatus:
  22959. v, ok := value.(uint8)
  22960. if !ok {
  22961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22962. }
  22963. m.SetStatus(v)
  22964. return nil
  22965. case messagerecords.FieldBotWxid:
  22966. v, ok := value.(string)
  22967. if !ok {
  22968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22969. }
  22970. m.SetBotWxid(v)
  22971. return nil
  22972. case messagerecords.FieldContactID:
  22973. v, ok := value.(uint64)
  22974. if !ok {
  22975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22976. }
  22977. m.SetContactID(v)
  22978. return nil
  22979. case messagerecords.FieldContactType:
  22980. v, ok := value.(int)
  22981. if !ok {
  22982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22983. }
  22984. m.SetContactType(v)
  22985. return nil
  22986. case messagerecords.FieldContactWxid:
  22987. v, ok := value.(string)
  22988. if !ok {
  22989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22990. }
  22991. m.SetContactWxid(v)
  22992. return nil
  22993. case messagerecords.FieldContentType:
  22994. v, ok := value.(int)
  22995. if !ok {
  22996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22997. }
  22998. m.SetContentType(v)
  22999. return nil
  23000. case messagerecords.FieldContent:
  23001. v, ok := value.(string)
  23002. if !ok {
  23003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23004. }
  23005. m.SetContent(v)
  23006. return nil
  23007. case messagerecords.FieldMeta:
  23008. v, ok := value.(custom_types.Meta)
  23009. if !ok {
  23010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23011. }
  23012. m.SetMeta(v)
  23013. return nil
  23014. case messagerecords.FieldErrorDetail:
  23015. v, ok := value.(string)
  23016. if !ok {
  23017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23018. }
  23019. m.SetErrorDetail(v)
  23020. return nil
  23021. case messagerecords.FieldSendTime:
  23022. v, ok := value.(time.Time)
  23023. if !ok {
  23024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23025. }
  23026. m.SetSendTime(v)
  23027. return nil
  23028. case messagerecords.FieldSourceType:
  23029. v, ok := value.(int)
  23030. if !ok {
  23031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23032. }
  23033. m.SetSourceType(v)
  23034. return nil
  23035. case messagerecords.FieldSourceID:
  23036. v, ok := value.(uint64)
  23037. if !ok {
  23038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23039. }
  23040. m.SetSourceID(v)
  23041. return nil
  23042. case messagerecords.FieldSubSourceID:
  23043. v, ok := value.(uint64)
  23044. if !ok {
  23045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23046. }
  23047. m.SetSubSourceID(v)
  23048. return nil
  23049. case messagerecords.FieldOrganizationID:
  23050. v, ok := value.(uint64)
  23051. if !ok {
  23052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23053. }
  23054. m.SetOrganizationID(v)
  23055. return nil
  23056. }
  23057. return fmt.Errorf("unknown MessageRecords field %s", name)
  23058. }
  23059. // AddedFields returns all numeric fields that were incremented/decremented during
  23060. // this mutation.
  23061. func (m *MessageRecordsMutation) AddedFields() []string {
  23062. var fields []string
  23063. if m.addstatus != nil {
  23064. fields = append(fields, messagerecords.FieldStatus)
  23065. }
  23066. if m.addcontact_type != nil {
  23067. fields = append(fields, messagerecords.FieldContactType)
  23068. }
  23069. if m.addcontent_type != nil {
  23070. fields = append(fields, messagerecords.FieldContentType)
  23071. }
  23072. if m.addsource_type != nil {
  23073. fields = append(fields, messagerecords.FieldSourceType)
  23074. }
  23075. if m.addorganization_id != nil {
  23076. fields = append(fields, messagerecords.FieldOrganizationID)
  23077. }
  23078. return fields
  23079. }
  23080. // AddedField returns the numeric value that was incremented/decremented on a field
  23081. // with the given name. The second boolean return value indicates that this field
  23082. // was not set, or was not defined in the schema.
  23083. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  23084. switch name {
  23085. case messagerecords.FieldStatus:
  23086. return m.AddedStatus()
  23087. case messagerecords.FieldContactType:
  23088. return m.AddedContactType()
  23089. case messagerecords.FieldContentType:
  23090. return m.AddedContentType()
  23091. case messagerecords.FieldSourceType:
  23092. return m.AddedSourceType()
  23093. case messagerecords.FieldOrganizationID:
  23094. return m.AddedOrganizationID()
  23095. }
  23096. return nil, false
  23097. }
  23098. // AddField adds the value to the field with the given name. It returns an error if
  23099. // the field is not defined in the schema, or if the type mismatched the field
  23100. // type.
  23101. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  23102. switch name {
  23103. case messagerecords.FieldStatus:
  23104. v, ok := value.(int8)
  23105. if !ok {
  23106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23107. }
  23108. m.AddStatus(v)
  23109. return nil
  23110. case messagerecords.FieldContactType:
  23111. v, ok := value.(int)
  23112. if !ok {
  23113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23114. }
  23115. m.AddContactType(v)
  23116. return nil
  23117. case messagerecords.FieldContentType:
  23118. v, ok := value.(int)
  23119. if !ok {
  23120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23121. }
  23122. m.AddContentType(v)
  23123. return nil
  23124. case messagerecords.FieldSourceType:
  23125. v, ok := value.(int)
  23126. if !ok {
  23127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23128. }
  23129. m.AddSourceType(v)
  23130. return nil
  23131. case messagerecords.FieldOrganizationID:
  23132. v, ok := value.(int64)
  23133. if !ok {
  23134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23135. }
  23136. m.AddOrganizationID(v)
  23137. return nil
  23138. }
  23139. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  23140. }
  23141. // ClearedFields returns all nullable fields that were cleared during this
  23142. // mutation.
  23143. func (m *MessageRecordsMutation) ClearedFields() []string {
  23144. var fields []string
  23145. if m.FieldCleared(messagerecords.FieldStatus) {
  23146. fields = append(fields, messagerecords.FieldStatus)
  23147. }
  23148. if m.FieldCleared(messagerecords.FieldContactID) {
  23149. fields = append(fields, messagerecords.FieldContactID)
  23150. }
  23151. if m.FieldCleared(messagerecords.FieldMeta) {
  23152. fields = append(fields, messagerecords.FieldMeta)
  23153. }
  23154. if m.FieldCleared(messagerecords.FieldSendTime) {
  23155. fields = append(fields, messagerecords.FieldSendTime)
  23156. }
  23157. if m.FieldCleared(messagerecords.FieldSourceID) {
  23158. fields = append(fields, messagerecords.FieldSourceID)
  23159. }
  23160. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  23161. fields = append(fields, messagerecords.FieldSubSourceID)
  23162. }
  23163. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  23164. fields = append(fields, messagerecords.FieldOrganizationID)
  23165. }
  23166. return fields
  23167. }
  23168. // FieldCleared returns a boolean indicating if a field with the given name was
  23169. // cleared in this mutation.
  23170. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  23171. _, ok := m.clearedFields[name]
  23172. return ok
  23173. }
  23174. // ClearField clears the value of the field with the given name. It returns an
  23175. // error if the field is not defined in the schema.
  23176. func (m *MessageRecordsMutation) ClearField(name string) error {
  23177. switch name {
  23178. case messagerecords.FieldStatus:
  23179. m.ClearStatus()
  23180. return nil
  23181. case messagerecords.FieldContactID:
  23182. m.ClearContactID()
  23183. return nil
  23184. case messagerecords.FieldMeta:
  23185. m.ClearMeta()
  23186. return nil
  23187. case messagerecords.FieldSendTime:
  23188. m.ClearSendTime()
  23189. return nil
  23190. case messagerecords.FieldSourceID:
  23191. m.ClearSourceID()
  23192. return nil
  23193. case messagerecords.FieldSubSourceID:
  23194. m.ClearSubSourceID()
  23195. return nil
  23196. case messagerecords.FieldOrganizationID:
  23197. m.ClearOrganizationID()
  23198. return nil
  23199. }
  23200. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  23201. }
  23202. // ResetField resets all changes in the mutation for the field with the given name.
  23203. // It returns an error if the field is not defined in the schema.
  23204. func (m *MessageRecordsMutation) ResetField(name string) error {
  23205. switch name {
  23206. case messagerecords.FieldCreatedAt:
  23207. m.ResetCreatedAt()
  23208. return nil
  23209. case messagerecords.FieldUpdatedAt:
  23210. m.ResetUpdatedAt()
  23211. return nil
  23212. case messagerecords.FieldStatus:
  23213. m.ResetStatus()
  23214. return nil
  23215. case messagerecords.FieldBotWxid:
  23216. m.ResetBotWxid()
  23217. return nil
  23218. case messagerecords.FieldContactID:
  23219. m.ResetContactID()
  23220. return nil
  23221. case messagerecords.FieldContactType:
  23222. m.ResetContactType()
  23223. return nil
  23224. case messagerecords.FieldContactWxid:
  23225. m.ResetContactWxid()
  23226. return nil
  23227. case messagerecords.FieldContentType:
  23228. m.ResetContentType()
  23229. return nil
  23230. case messagerecords.FieldContent:
  23231. m.ResetContent()
  23232. return nil
  23233. case messagerecords.FieldMeta:
  23234. m.ResetMeta()
  23235. return nil
  23236. case messagerecords.FieldErrorDetail:
  23237. m.ResetErrorDetail()
  23238. return nil
  23239. case messagerecords.FieldSendTime:
  23240. m.ResetSendTime()
  23241. return nil
  23242. case messagerecords.FieldSourceType:
  23243. m.ResetSourceType()
  23244. return nil
  23245. case messagerecords.FieldSourceID:
  23246. m.ResetSourceID()
  23247. return nil
  23248. case messagerecords.FieldSubSourceID:
  23249. m.ResetSubSourceID()
  23250. return nil
  23251. case messagerecords.FieldOrganizationID:
  23252. m.ResetOrganizationID()
  23253. return nil
  23254. }
  23255. return fmt.Errorf("unknown MessageRecords field %s", name)
  23256. }
  23257. // AddedEdges returns all edge names that were set/added in this mutation.
  23258. func (m *MessageRecordsMutation) AddedEdges() []string {
  23259. edges := make([]string, 0, 3)
  23260. if m.sop_stage != nil {
  23261. edges = append(edges, messagerecords.EdgeSopStage)
  23262. }
  23263. if m.sop_node != nil {
  23264. edges = append(edges, messagerecords.EdgeSopNode)
  23265. }
  23266. if m.message_contact != nil {
  23267. edges = append(edges, messagerecords.EdgeMessageContact)
  23268. }
  23269. return edges
  23270. }
  23271. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23272. // name in this mutation.
  23273. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  23274. switch name {
  23275. case messagerecords.EdgeSopStage:
  23276. if id := m.sop_stage; id != nil {
  23277. return []ent.Value{*id}
  23278. }
  23279. case messagerecords.EdgeSopNode:
  23280. if id := m.sop_node; id != nil {
  23281. return []ent.Value{*id}
  23282. }
  23283. case messagerecords.EdgeMessageContact:
  23284. if id := m.message_contact; id != nil {
  23285. return []ent.Value{*id}
  23286. }
  23287. }
  23288. return nil
  23289. }
  23290. // RemovedEdges returns all edge names that were removed in this mutation.
  23291. func (m *MessageRecordsMutation) RemovedEdges() []string {
  23292. edges := make([]string, 0, 3)
  23293. return edges
  23294. }
  23295. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23296. // the given name in this mutation.
  23297. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  23298. return nil
  23299. }
  23300. // ClearedEdges returns all edge names that were cleared in this mutation.
  23301. func (m *MessageRecordsMutation) ClearedEdges() []string {
  23302. edges := make([]string, 0, 3)
  23303. if m.clearedsop_stage {
  23304. edges = append(edges, messagerecords.EdgeSopStage)
  23305. }
  23306. if m.clearedsop_node {
  23307. edges = append(edges, messagerecords.EdgeSopNode)
  23308. }
  23309. if m.clearedmessage_contact {
  23310. edges = append(edges, messagerecords.EdgeMessageContact)
  23311. }
  23312. return edges
  23313. }
  23314. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23315. // was cleared in this mutation.
  23316. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  23317. switch name {
  23318. case messagerecords.EdgeSopStage:
  23319. return m.clearedsop_stage
  23320. case messagerecords.EdgeSopNode:
  23321. return m.clearedsop_node
  23322. case messagerecords.EdgeMessageContact:
  23323. return m.clearedmessage_contact
  23324. }
  23325. return false
  23326. }
  23327. // ClearEdge clears the value of the edge with the given name. It returns an error
  23328. // if that edge is not defined in the schema.
  23329. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  23330. switch name {
  23331. case messagerecords.EdgeSopStage:
  23332. m.ClearSopStage()
  23333. return nil
  23334. case messagerecords.EdgeSopNode:
  23335. m.ClearSopNode()
  23336. return nil
  23337. case messagerecords.EdgeMessageContact:
  23338. m.ClearMessageContact()
  23339. return nil
  23340. }
  23341. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  23342. }
  23343. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23344. // It returns an error if the edge is not defined in the schema.
  23345. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  23346. switch name {
  23347. case messagerecords.EdgeSopStage:
  23348. m.ResetSopStage()
  23349. return nil
  23350. case messagerecords.EdgeSopNode:
  23351. m.ResetSopNode()
  23352. return nil
  23353. case messagerecords.EdgeMessageContact:
  23354. m.ResetMessageContact()
  23355. return nil
  23356. }
  23357. return fmt.Errorf("unknown MessageRecords edge %s", name)
  23358. }
  23359. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  23360. type MsgMutation struct {
  23361. config
  23362. op Op
  23363. typ string
  23364. id *uint64
  23365. created_at *time.Time
  23366. updated_at *time.Time
  23367. deleted_at *time.Time
  23368. status *uint8
  23369. addstatus *int8
  23370. fromwxid *string
  23371. toid *string
  23372. msgtype *int32
  23373. addmsgtype *int32
  23374. msg *string
  23375. batch_no *string
  23376. cc *string
  23377. phone *string
  23378. clearedFields map[string]struct{}
  23379. done bool
  23380. oldValue func(context.Context) (*Msg, error)
  23381. predicates []predicate.Msg
  23382. }
  23383. var _ ent.Mutation = (*MsgMutation)(nil)
  23384. // msgOption allows management of the mutation configuration using functional options.
  23385. type msgOption func(*MsgMutation)
  23386. // newMsgMutation creates new mutation for the Msg entity.
  23387. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  23388. m := &MsgMutation{
  23389. config: c,
  23390. op: op,
  23391. typ: TypeMsg,
  23392. clearedFields: make(map[string]struct{}),
  23393. }
  23394. for _, opt := range opts {
  23395. opt(m)
  23396. }
  23397. return m
  23398. }
  23399. // withMsgID sets the ID field of the mutation.
  23400. func withMsgID(id uint64) msgOption {
  23401. return func(m *MsgMutation) {
  23402. var (
  23403. err error
  23404. once sync.Once
  23405. value *Msg
  23406. )
  23407. m.oldValue = func(ctx context.Context) (*Msg, error) {
  23408. once.Do(func() {
  23409. if m.done {
  23410. err = errors.New("querying old values post mutation is not allowed")
  23411. } else {
  23412. value, err = m.Client().Msg.Get(ctx, id)
  23413. }
  23414. })
  23415. return value, err
  23416. }
  23417. m.id = &id
  23418. }
  23419. }
  23420. // withMsg sets the old Msg of the mutation.
  23421. func withMsg(node *Msg) msgOption {
  23422. return func(m *MsgMutation) {
  23423. m.oldValue = func(context.Context) (*Msg, error) {
  23424. return node, nil
  23425. }
  23426. m.id = &node.ID
  23427. }
  23428. }
  23429. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23430. // executed in a transaction (ent.Tx), a transactional client is returned.
  23431. func (m MsgMutation) Client() *Client {
  23432. client := &Client{config: m.config}
  23433. client.init()
  23434. return client
  23435. }
  23436. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23437. // it returns an error otherwise.
  23438. func (m MsgMutation) Tx() (*Tx, error) {
  23439. if _, ok := m.driver.(*txDriver); !ok {
  23440. return nil, errors.New("ent: mutation is not running in a transaction")
  23441. }
  23442. tx := &Tx{config: m.config}
  23443. tx.init()
  23444. return tx, nil
  23445. }
  23446. // SetID sets the value of the id field. Note that this
  23447. // operation is only accepted on creation of Msg entities.
  23448. func (m *MsgMutation) SetID(id uint64) {
  23449. m.id = &id
  23450. }
  23451. // ID returns the ID value in the mutation. Note that the ID is only available
  23452. // if it was provided to the builder or after it was returned from the database.
  23453. func (m *MsgMutation) ID() (id uint64, exists bool) {
  23454. if m.id == nil {
  23455. return
  23456. }
  23457. return *m.id, true
  23458. }
  23459. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23460. // That means, if the mutation is applied within a transaction with an isolation level such
  23461. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23462. // or updated by the mutation.
  23463. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  23464. switch {
  23465. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23466. id, exists := m.ID()
  23467. if exists {
  23468. return []uint64{id}, nil
  23469. }
  23470. fallthrough
  23471. case m.op.Is(OpUpdate | OpDelete):
  23472. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  23473. default:
  23474. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23475. }
  23476. }
  23477. // SetCreatedAt sets the "created_at" field.
  23478. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  23479. m.created_at = &t
  23480. }
  23481. // CreatedAt returns the value of the "created_at" field in the mutation.
  23482. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  23483. v := m.created_at
  23484. if v == nil {
  23485. return
  23486. }
  23487. return *v, true
  23488. }
  23489. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  23490. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23492. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23493. if !m.op.Is(OpUpdateOne) {
  23494. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23495. }
  23496. if m.id == nil || m.oldValue == nil {
  23497. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23498. }
  23499. oldValue, err := m.oldValue(ctx)
  23500. if err != nil {
  23501. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23502. }
  23503. return oldValue.CreatedAt, nil
  23504. }
  23505. // ResetCreatedAt resets all changes to the "created_at" field.
  23506. func (m *MsgMutation) ResetCreatedAt() {
  23507. m.created_at = nil
  23508. }
  23509. // SetUpdatedAt sets the "updated_at" field.
  23510. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  23511. m.updated_at = &t
  23512. }
  23513. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23514. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  23515. v := m.updated_at
  23516. if v == nil {
  23517. return
  23518. }
  23519. return *v, true
  23520. }
  23521. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  23522. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23524. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23525. if !m.op.Is(OpUpdateOne) {
  23526. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23527. }
  23528. if m.id == nil || m.oldValue == nil {
  23529. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23530. }
  23531. oldValue, err := m.oldValue(ctx)
  23532. if err != nil {
  23533. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23534. }
  23535. return oldValue.UpdatedAt, nil
  23536. }
  23537. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23538. func (m *MsgMutation) ResetUpdatedAt() {
  23539. m.updated_at = nil
  23540. }
  23541. // SetDeletedAt sets the "deleted_at" field.
  23542. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  23543. m.deleted_at = &t
  23544. }
  23545. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23546. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  23547. v := m.deleted_at
  23548. if v == nil {
  23549. return
  23550. }
  23551. return *v, true
  23552. }
  23553. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  23554. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23556. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23557. if !m.op.Is(OpUpdateOne) {
  23558. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23559. }
  23560. if m.id == nil || m.oldValue == nil {
  23561. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23562. }
  23563. oldValue, err := m.oldValue(ctx)
  23564. if err != nil {
  23565. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23566. }
  23567. return oldValue.DeletedAt, nil
  23568. }
  23569. // ClearDeletedAt clears the value of the "deleted_at" field.
  23570. func (m *MsgMutation) ClearDeletedAt() {
  23571. m.deleted_at = nil
  23572. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  23573. }
  23574. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23575. func (m *MsgMutation) DeletedAtCleared() bool {
  23576. _, ok := m.clearedFields[msg.FieldDeletedAt]
  23577. return ok
  23578. }
  23579. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23580. func (m *MsgMutation) ResetDeletedAt() {
  23581. m.deleted_at = nil
  23582. delete(m.clearedFields, msg.FieldDeletedAt)
  23583. }
  23584. // SetStatus sets the "status" field.
  23585. func (m *MsgMutation) SetStatus(u uint8) {
  23586. m.status = &u
  23587. m.addstatus = nil
  23588. }
  23589. // Status returns the value of the "status" field in the mutation.
  23590. func (m *MsgMutation) Status() (r uint8, exists bool) {
  23591. v := m.status
  23592. if v == nil {
  23593. return
  23594. }
  23595. return *v, true
  23596. }
  23597. // OldStatus returns the old "status" field's value of the Msg entity.
  23598. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23600. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23601. if !m.op.Is(OpUpdateOne) {
  23602. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23603. }
  23604. if m.id == nil || m.oldValue == nil {
  23605. return v, errors.New("OldStatus requires an ID field in the mutation")
  23606. }
  23607. oldValue, err := m.oldValue(ctx)
  23608. if err != nil {
  23609. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23610. }
  23611. return oldValue.Status, nil
  23612. }
  23613. // AddStatus adds u to the "status" field.
  23614. func (m *MsgMutation) AddStatus(u int8) {
  23615. if m.addstatus != nil {
  23616. *m.addstatus += u
  23617. } else {
  23618. m.addstatus = &u
  23619. }
  23620. }
  23621. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23622. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  23623. v := m.addstatus
  23624. if v == nil {
  23625. return
  23626. }
  23627. return *v, true
  23628. }
  23629. // ClearStatus clears the value of the "status" field.
  23630. func (m *MsgMutation) ClearStatus() {
  23631. m.status = nil
  23632. m.addstatus = nil
  23633. m.clearedFields[msg.FieldStatus] = struct{}{}
  23634. }
  23635. // StatusCleared returns if the "status" field was cleared in this mutation.
  23636. func (m *MsgMutation) StatusCleared() bool {
  23637. _, ok := m.clearedFields[msg.FieldStatus]
  23638. return ok
  23639. }
  23640. // ResetStatus resets all changes to the "status" field.
  23641. func (m *MsgMutation) ResetStatus() {
  23642. m.status = nil
  23643. m.addstatus = nil
  23644. delete(m.clearedFields, msg.FieldStatus)
  23645. }
  23646. // SetFromwxid sets the "fromwxid" field.
  23647. func (m *MsgMutation) SetFromwxid(s string) {
  23648. m.fromwxid = &s
  23649. }
  23650. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  23651. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  23652. v := m.fromwxid
  23653. if v == nil {
  23654. return
  23655. }
  23656. return *v, true
  23657. }
  23658. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  23659. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23661. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  23662. if !m.op.Is(OpUpdateOne) {
  23663. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  23664. }
  23665. if m.id == nil || m.oldValue == nil {
  23666. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  23667. }
  23668. oldValue, err := m.oldValue(ctx)
  23669. if err != nil {
  23670. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  23671. }
  23672. return oldValue.Fromwxid, nil
  23673. }
  23674. // ClearFromwxid clears the value of the "fromwxid" field.
  23675. func (m *MsgMutation) ClearFromwxid() {
  23676. m.fromwxid = nil
  23677. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  23678. }
  23679. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  23680. func (m *MsgMutation) FromwxidCleared() bool {
  23681. _, ok := m.clearedFields[msg.FieldFromwxid]
  23682. return ok
  23683. }
  23684. // ResetFromwxid resets all changes to the "fromwxid" field.
  23685. func (m *MsgMutation) ResetFromwxid() {
  23686. m.fromwxid = nil
  23687. delete(m.clearedFields, msg.FieldFromwxid)
  23688. }
  23689. // SetToid sets the "toid" field.
  23690. func (m *MsgMutation) SetToid(s string) {
  23691. m.toid = &s
  23692. }
  23693. // Toid returns the value of the "toid" field in the mutation.
  23694. func (m *MsgMutation) Toid() (r string, exists bool) {
  23695. v := m.toid
  23696. if v == nil {
  23697. return
  23698. }
  23699. return *v, true
  23700. }
  23701. // OldToid returns the old "toid" field's value of the Msg entity.
  23702. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23704. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  23705. if !m.op.Is(OpUpdateOne) {
  23706. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  23707. }
  23708. if m.id == nil || m.oldValue == nil {
  23709. return v, errors.New("OldToid requires an ID field in the mutation")
  23710. }
  23711. oldValue, err := m.oldValue(ctx)
  23712. if err != nil {
  23713. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  23714. }
  23715. return oldValue.Toid, nil
  23716. }
  23717. // ClearToid clears the value of the "toid" field.
  23718. func (m *MsgMutation) ClearToid() {
  23719. m.toid = nil
  23720. m.clearedFields[msg.FieldToid] = struct{}{}
  23721. }
  23722. // ToidCleared returns if the "toid" field was cleared in this mutation.
  23723. func (m *MsgMutation) ToidCleared() bool {
  23724. _, ok := m.clearedFields[msg.FieldToid]
  23725. return ok
  23726. }
  23727. // ResetToid resets all changes to the "toid" field.
  23728. func (m *MsgMutation) ResetToid() {
  23729. m.toid = nil
  23730. delete(m.clearedFields, msg.FieldToid)
  23731. }
  23732. // SetMsgtype sets the "msgtype" field.
  23733. func (m *MsgMutation) SetMsgtype(i int32) {
  23734. m.msgtype = &i
  23735. m.addmsgtype = nil
  23736. }
  23737. // Msgtype returns the value of the "msgtype" field in the mutation.
  23738. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  23739. v := m.msgtype
  23740. if v == nil {
  23741. return
  23742. }
  23743. return *v, true
  23744. }
  23745. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  23746. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23748. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  23749. if !m.op.Is(OpUpdateOne) {
  23750. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  23751. }
  23752. if m.id == nil || m.oldValue == nil {
  23753. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  23754. }
  23755. oldValue, err := m.oldValue(ctx)
  23756. if err != nil {
  23757. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  23758. }
  23759. return oldValue.Msgtype, nil
  23760. }
  23761. // AddMsgtype adds i to the "msgtype" field.
  23762. func (m *MsgMutation) AddMsgtype(i int32) {
  23763. if m.addmsgtype != nil {
  23764. *m.addmsgtype += i
  23765. } else {
  23766. m.addmsgtype = &i
  23767. }
  23768. }
  23769. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  23770. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  23771. v := m.addmsgtype
  23772. if v == nil {
  23773. return
  23774. }
  23775. return *v, true
  23776. }
  23777. // ClearMsgtype clears the value of the "msgtype" field.
  23778. func (m *MsgMutation) ClearMsgtype() {
  23779. m.msgtype = nil
  23780. m.addmsgtype = nil
  23781. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  23782. }
  23783. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  23784. func (m *MsgMutation) MsgtypeCleared() bool {
  23785. _, ok := m.clearedFields[msg.FieldMsgtype]
  23786. return ok
  23787. }
  23788. // ResetMsgtype resets all changes to the "msgtype" field.
  23789. func (m *MsgMutation) ResetMsgtype() {
  23790. m.msgtype = nil
  23791. m.addmsgtype = nil
  23792. delete(m.clearedFields, msg.FieldMsgtype)
  23793. }
  23794. // SetMsg sets the "msg" field.
  23795. func (m *MsgMutation) SetMsg(s string) {
  23796. m.msg = &s
  23797. }
  23798. // Msg returns the value of the "msg" field in the mutation.
  23799. func (m *MsgMutation) Msg() (r string, exists bool) {
  23800. v := m.msg
  23801. if v == nil {
  23802. return
  23803. }
  23804. return *v, true
  23805. }
  23806. // OldMsg returns the old "msg" field's value of the Msg entity.
  23807. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23809. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  23810. if !m.op.Is(OpUpdateOne) {
  23811. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  23812. }
  23813. if m.id == nil || m.oldValue == nil {
  23814. return v, errors.New("OldMsg requires an ID field in the mutation")
  23815. }
  23816. oldValue, err := m.oldValue(ctx)
  23817. if err != nil {
  23818. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  23819. }
  23820. return oldValue.Msg, nil
  23821. }
  23822. // ClearMsg clears the value of the "msg" field.
  23823. func (m *MsgMutation) ClearMsg() {
  23824. m.msg = nil
  23825. m.clearedFields[msg.FieldMsg] = struct{}{}
  23826. }
  23827. // MsgCleared returns if the "msg" field was cleared in this mutation.
  23828. func (m *MsgMutation) MsgCleared() bool {
  23829. _, ok := m.clearedFields[msg.FieldMsg]
  23830. return ok
  23831. }
  23832. // ResetMsg resets all changes to the "msg" field.
  23833. func (m *MsgMutation) ResetMsg() {
  23834. m.msg = nil
  23835. delete(m.clearedFields, msg.FieldMsg)
  23836. }
  23837. // SetBatchNo sets the "batch_no" field.
  23838. func (m *MsgMutation) SetBatchNo(s string) {
  23839. m.batch_no = &s
  23840. }
  23841. // BatchNo returns the value of the "batch_no" field in the mutation.
  23842. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  23843. v := m.batch_no
  23844. if v == nil {
  23845. return
  23846. }
  23847. return *v, true
  23848. }
  23849. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  23850. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23852. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  23853. if !m.op.Is(OpUpdateOne) {
  23854. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  23855. }
  23856. if m.id == nil || m.oldValue == nil {
  23857. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  23858. }
  23859. oldValue, err := m.oldValue(ctx)
  23860. if err != nil {
  23861. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  23862. }
  23863. return oldValue.BatchNo, nil
  23864. }
  23865. // ClearBatchNo clears the value of the "batch_no" field.
  23866. func (m *MsgMutation) ClearBatchNo() {
  23867. m.batch_no = nil
  23868. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  23869. }
  23870. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  23871. func (m *MsgMutation) BatchNoCleared() bool {
  23872. _, ok := m.clearedFields[msg.FieldBatchNo]
  23873. return ok
  23874. }
  23875. // ResetBatchNo resets all changes to the "batch_no" field.
  23876. func (m *MsgMutation) ResetBatchNo() {
  23877. m.batch_no = nil
  23878. delete(m.clearedFields, msg.FieldBatchNo)
  23879. }
  23880. // SetCc sets the "cc" field.
  23881. func (m *MsgMutation) SetCc(s string) {
  23882. m.cc = &s
  23883. }
  23884. // Cc returns the value of the "cc" field in the mutation.
  23885. func (m *MsgMutation) Cc() (r string, exists bool) {
  23886. v := m.cc
  23887. if v == nil {
  23888. return
  23889. }
  23890. return *v, true
  23891. }
  23892. // OldCc returns the old "cc" field's value of the Msg entity.
  23893. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23895. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  23896. if !m.op.Is(OpUpdateOne) {
  23897. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  23898. }
  23899. if m.id == nil || m.oldValue == nil {
  23900. return v, errors.New("OldCc requires an ID field in the mutation")
  23901. }
  23902. oldValue, err := m.oldValue(ctx)
  23903. if err != nil {
  23904. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  23905. }
  23906. return oldValue.Cc, nil
  23907. }
  23908. // ResetCc resets all changes to the "cc" field.
  23909. func (m *MsgMutation) ResetCc() {
  23910. m.cc = nil
  23911. }
  23912. // SetPhone sets the "phone" field.
  23913. func (m *MsgMutation) SetPhone(s string) {
  23914. m.phone = &s
  23915. }
  23916. // Phone returns the value of the "phone" field in the mutation.
  23917. func (m *MsgMutation) Phone() (r string, exists bool) {
  23918. v := m.phone
  23919. if v == nil {
  23920. return
  23921. }
  23922. return *v, true
  23923. }
  23924. // OldPhone returns the old "phone" field's value of the Msg entity.
  23925. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23927. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  23928. if !m.op.Is(OpUpdateOne) {
  23929. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  23930. }
  23931. if m.id == nil || m.oldValue == nil {
  23932. return v, errors.New("OldPhone requires an ID field in the mutation")
  23933. }
  23934. oldValue, err := m.oldValue(ctx)
  23935. if err != nil {
  23936. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  23937. }
  23938. return oldValue.Phone, nil
  23939. }
  23940. // ResetPhone resets all changes to the "phone" field.
  23941. func (m *MsgMutation) ResetPhone() {
  23942. m.phone = nil
  23943. }
  23944. // Where appends a list predicates to the MsgMutation builder.
  23945. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  23946. m.predicates = append(m.predicates, ps...)
  23947. }
  23948. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  23949. // users can use type-assertion to append predicates that do not depend on any generated package.
  23950. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  23951. p := make([]predicate.Msg, len(ps))
  23952. for i := range ps {
  23953. p[i] = ps[i]
  23954. }
  23955. m.Where(p...)
  23956. }
  23957. // Op returns the operation name.
  23958. func (m *MsgMutation) Op() Op {
  23959. return m.op
  23960. }
  23961. // SetOp allows setting the mutation operation.
  23962. func (m *MsgMutation) SetOp(op Op) {
  23963. m.op = op
  23964. }
  23965. // Type returns the node type of this mutation (Msg).
  23966. func (m *MsgMutation) Type() string {
  23967. return m.typ
  23968. }
  23969. // Fields returns all fields that were changed during this mutation. Note that in
  23970. // order to get all numeric fields that were incremented/decremented, call
  23971. // AddedFields().
  23972. func (m *MsgMutation) Fields() []string {
  23973. fields := make([]string, 0, 11)
  23974. if m.created_at != nil {
  23975. fields = append(fields, msg.FieldCreatedAt)
  23976. }
  23977. if m.updated_at != nil {
  23978. fields = append(fields, msg.FieldUpdatedAt)
  23979. }
  23980. if m.deleted_at != nil {
  23981. fields = append(fields, msg.FieldDeletedAt)
  23982. }
  23983. if m.status != nil {
  23984. fields = append(fields, msg.FieldStatus)
  23985. }
  23986. if m.fromwxid != nil {
  23987. fields = append(fields, msg.FieldFromwxid)
  23988. }
  23989. if m.toid != nil {
  23990. fields = append(fields, msg.FieldToid)
  23991. }
  23992. if m.msgtype != nil {
  23993. fields = append(fields, msg.FieldMsgtype)
  23994. }
  23995. if m.msg != nil {
  23996. fields = append(fields, msg.FieldMsg)
  23997. }
  23998. if m.batch_no != nil {
  23999. fields = append(fields, msg.FieldBatchNo)
  24000. }
  24001. if m.cc != nil {
  24002. fields = append(fields, msg.FieldCc)
  24003. }
  24004. if m.phone != nil {
  24005. fields = append(fields, msg.FieldPhone)
  24006. }
  24007. return fields
  24008. }
  24009. // Field returns the value of a field with the given name. The second boolean
  24010. // return value indicates that this field was not set, or was not defined in the
  24011. // schema.
  24012. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  24013. switch name {
  24014. case msg.FieldCreatedAt:
  24015. return m.CreatedAt()
  24016. case msg.FieldUpdatedAt:
  24017. return m.UpdatedAt()
  24018. case msg.FieldDeletedAt:
  24019. return m.DeletedAt()
  24020. case msg.FieldStatus:
  24021. return m.Status()
  24022. case msg.FieldFromwxid:
  24023. return m.Fromwxid()
  24024. case msg.FieldToid:
  24025. return m.Toid()
  24026. case msg.FieldMsgtype:
  24027. return m.Msgtype()
  24028. case msg.FieldMsg:
  24029. return m.Msg()
  24030. case msg.FieldBatchNo:
  24031. return m.BatchNo()
  24032. case msg.FieldCc:
  24033. return m.Cc()
  24034. case msg.FieldPhone:
  24035. return m.Phone()
  24036. }
  24037. return nil, false
  24038. }
  24039. // OldField returns the old value of the field from the database. An error is
  24040. // returned if the mutation operation is not UpdateOne, or the query to the
  24041. // database failed.
  24042. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24043. switch name {
  24044. case msg.FieldCreatedAt:
  24045. return m.OldCreatedAt(ctx)
  24046. case msg.FieldUpdatedAt:
  24047. return m.OldUpdatedAt(ctx)
  24048. case msg.FieldDeletedAt:
  24049. return m.OldDeletedAt(ctx)
  24050. case msg.FieldStatus:
  24051. return m.OldStatus(ctx)
  24052. case msg.FieldFromwxid:
  24053. return m.OldFromwxid(ctx)
  24054. case msg.FieldToid:
  24055. return m.OldToid(ctx)
  24056. case msg.FieldMsgtype:
  24057. return m.OldMsgtype(ctx)
  24058. case msg.FieldMsg:
  24059. return m.OldMsg(ctx)
  24060. case msg.FieldBatchNo:
  24061. return m.OldBatchNo(ctx)
  24062. case msg.FieldCc:
  24063. return m.OldCc(ctx)
  24064. case msg.FieldPhone:
  24065. return m.OldPhone(ctx)
  24066. }
  24067. return nil, fmt.Errorf("unknown Msg field %s", name)
  24068. }
  24069. // SetField sets the value of a field with the given name. It returns an error if
  24070. // the field is not defined in the schema, or if the type mismatched the field
  24071. // type.
  24072. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  24073. switch name {
  24074. case msg.FieldCreatedAt:
  24075. v, ok := value.(time.Time)
  24076. if !ok {
  24077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24078. }
  24079. m.SetCreatedAt(v)
  24080. return nil
  24081. case msg.FieldUpdatedAt:
  24082. v, ok := value.(time.Time)
  24083. if !ok {
  24084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24085. }
  24086. m.SetUpdatedAt(v)
  24087. return nil
  24088. case msg.FieldDeletedAt:
  24089. v, ok := value.(time.Time)
  24090. if !ok {
  24091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24092. }
  24093. m.SetDeletedAt(v)
  24094. return nil
  24095. case msg.FieldStatus:
  24096. v, ok := value.(uint8)
  24097. if !ok {
  24098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24099. }
  24100. m.SetStatus(v)
  24101. return nil
  24102. case msg.FieldFromwxid:
  24103. v, ok := value.(string)
  24104. if !ok {
  24105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24106. }
  24107. m.SetFromwxid(v)
  24108. return nil
  24109. case msg.FieldToid:
  24110. v, ok := value.(string)
  24111. if !ok {
  24112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24113. }
  24114. m.SetToid(v)
  24115. return nil
  24116. case msg.FieldMsgtype:
  24117. v, ok := value.(int32)
  24118. if !ok {
  24119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24120. }
  24121. m.SetMsgtype(v)
  24122. return nil
  24123. case msg.FieldMsg:
  24124. v, ok := value.(string)
  24125. if !ok {
  24126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24127. }
  24128. m.SetMsg(v)
  24129. return nil
  24130. case msg.FieldBatchNo:
  24131. v, ok := value.(string)
  24132. if !ok {
  24133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24134. }
  24135. m.SetBatchNo(v)
  24136. return nil
  24137. case msg.FieldCc:
  24138. v, ok := value.(string)
  24139. if !ok {
  24140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24141. }
  24142. m.SetCc(v)
  24143. return nil
  24144. case msg.FieldPhone:
  24145. v, ok := value.(string)
  24146. if !ok {
  24147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24148. }
  24149. m.SetPhone(v)
  24150. return nil
  24151. }
  24152. return fmt.Errorf("unknown Msg field %s", name)
  24153. }
  24154. // AddedFields returns all numeric fields that were incremented/decremented during
  24155. // this mutation.
  24156. func (m *MsgMutation) AddedFields() []string {
  24157. var fields []string
  24158. if m.addstatus != nil {
  24159. fields = append(fields, msg.FieldStatus)
  24160. }
  24161. if m.addmsgtype != nil {
  24162. fields = append(fields, msg.FieldMsgtype)
  24163. }
  24164. return fields
  24165. }
  24166. // AddedField returns the numeric value that was incremented/decremented on a field
  24167. // with the given name. The second boolean return value indicates that this field
  24168. // was not set, or was not defined in the schema.
  24169. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  24170. switch name {
  24171. case msg.FieldStatus:
  24172. return m.AddedStatus()
  24173. case msg.FieldMsgtype:
  24174. return m.AddedMsgtype()
  24175. }
  24176. return nil, false
  24177. }
  24178. // AddField adds the value to the field with the given name. It returns an error if
  24179. // the field is not defined in the schema, or if the type mismatched the field
  24180. // type.
  24181. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  24182. switch name {
  24183. case msg.FieldStatus:
  24184. v, ok := value.(int8)
  24185. if !ok {
  24186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24187. }
  24188. m.AddStatus(v)
  24189. return nil
  24190. case msg.FieldMsgtype:
  24191. v, ok := value.(int32)
  24192. if !ok {
  24193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24194. }
  24195. m.AddMsgtype(v)
  24196. return nil
  24197. }
  24198. return fmt.Errorf("unknown Msg numeric field %s", name)
  24199. }
  24200. // ClearedFields returns all nullable fields that were cleared during this
  24201. // mutation.
  24202. func (m *MsgMutation) ClearedFields() []string {
  24203. var fields []string
  24204. if m.FieldCleared(msg.FieldDeletedAt) {
  24205. fields = append(fields, msg.FieldDeletedAt)
  24206. }
  24207. if m.FieldCleared(msg.FieldStatus) {
  24208. fields = append(fields, msg.FieldStatus)
  24209. }
  24210. if m.FieldCleared(msg.FieldFromwxid) {
  24211. fields = append(fields, msg.FieldFromwxid)
  24212. }
  24213. if m.FieldCleared(msg.FieldToid) {
  24214. fields = append(fields, msg.FieldToid)
  24215. }
  24216. if m.FieldCleared(msg.FieldMsgtype) {
  24217. fields = append(fields, msg.FieldMsgtype)
  24218. }
  24219. if m.FieldCleared(msg.FieldMsg) {
  24220. fields = append(fields, msg.FieldMsg)
  24221. }
  24222. if m.FieldCleared(msg.FieldBatchNo) {
  24223. fields = append(fields, msg.FieldBatchNo)
  24224. }
  24225. return fields
  24226. }
  24227. // FieldCleared returns a boolean indicating if a field with the given name was
  24228. // cleared in this mutation.
  24229. func (m *MsgMutation) FieldCleared(name string) bool {
  24230. _, ok := m.clearedFields[name]
  24231. return ok
  24232. }
  24233. // ClearField clears the value of the field with the given name. It returns an
  24234. // error if the field is not defined in the schema.
  24235. func (m *MsgMutation) ClearField(name string) error {
  24236. switch name {
  24237. case msg.FieldDeletedAt:
  24238. m.ClearDeletedAt()
  24239. return nil
  24240. case msg.FieldStatus:
  24241. m.ClearStatus()
  24242. return nil
  24243. case msg.FieldFromwxid:
  24244. m.ClearFromwxid()
  24245. return nil
  24246. case msg.FieldToid:
  24247. m.ClearToid()
  24248. return nil
  24249. case msg.FieldMsgtype:
  24250. m.ClearMsgtype()
  24251. return nil
  24252. case msg.FieldMsg:
  24253. m.ClearMsg()
  24254. return nil
  24255. case msg.FieldBatchNo:
  24256. m.ClearBatchNo()
  24257. return nil
  24258. }
  24259. return fmt.Errorf("unknown Msg nullable field %s", name)
  24260. }
  24261. // ResetField resets all changes in the mutation for the field with the given name.
  24262. // It returns an error if the field is not defined in the schema.
  24263. func (m *MsgMutation) ResetField(name string) error {
  24264. switch name {
  24265. case msg.FieldCreatedAt:
  24266. m.ResetCreatedAt()
  24267. return nil
  24268. case msg.FieldUpdatedAt:
  24269. m.ResetUpdatedAt()
  24270. return nil
  24271. case msg.FieldDeletedAt:
  24272. m.ResetDeletedAt()
  24273. return nil
  24274. case msg.FieldStatus:
  24275. m.ResetStatus()
  24276. return nil
  24277. case msg.FieldFromwxid:
  24278. m.ResetFromwxid()
  24279. return nil
  24280. case msg.FieldToid:
  24281. m.ResetToid()
  24282. return nil
  24283. case msg.FieldMsgtype:
  24284. m.ResetMsgtype()
  24285. return nil
  24286. case msg.FieldMsg:
  24287. m.ResetMsg()
  24288. return nil
  24289. case msg.FieldBatchNo:
  24290. m.ResetBatchNo()
  24291. return nil
  24292. case msg.FieldCc:
  24293. m.ResetCc()
  24294. return nil
  24295. case msg.FieldPhone:
  24296. m.ResetPhone()
  24297. return nil
  24298. }
  24299. return fmt.Errorf("unknown Msg field %s", name)
  24300. }
  24301. // AddedEdges returns all edge names that were set/added in this mutation.
  24302. func (m *MsgMutation) AddedEdges() []string {
  24303. edges := make([]string, 0, 0)
  24304. return edges
  24305. }
  24306. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24307. // name in this mutation.
  24308. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  24309. return nil
  24310. }
  24311. // RemovedEdges returns all edge names that were removed in this mutation.
  24312. func (m *MsgMutation) RemovedEdges() []string {
  24313. edges := make([]string, 0, 0)
  24314. return edges
  24315. }
  24316. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24317. // the given name in this mutation.
  24318. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  24319. return nil
  24320. }
  24321. // ClearedEdges returns all edge names that were cleared in this mutation.
  24322. func (m *MsgMutation) ClearedEdges() []string {
  24323. edges := make([]string, 0, 0)
  24324. return edges
  24325. }
  24326. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24327. // was cleared in this mutation.
  24328. func (m *MsgMutation) EdgeCleared(name string) bool {
  24329. return false
  24330. }
  24331. // ClearEdge clears the value of the edge with the given name. It returns an error
  24332. // if that edge is not defined in the schema.
  24333. func (m *MsgMutation) ClearEdge(name string) error {
  24334. return fmt.Errorf("unknown Msg unique edge %s", name)
  24335. }
  24336. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24337. // It returns an error if the edge is not defined in the schema.
  24338. func (m *MsgMutation) ResetEdge(name string) error {
  24339. return fmt.Errorf("unknown Msg edge %s", name)
  24340. }
  24341. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  24342. type PayRechargeMutation struct {
  24343. config
  24344. op Op
  24345. typ string
  24346. id *uint64
  24347. created_at *time.Time
  24348. updated_at *time.Time
  24349. deleted_at *time.Time
  24350. user_id *string
  24351. number *float32
  24352. addnumber *float32
  24353. status *int
  24354. addstatus *int
  24355. money *float32
  24356. addmoney *float32
  24357. out_trade_no *string
  24358. organization_id *uint64
  24359. addorganization_id *int64
  24360. clearedFields map[string]struct{}
  24361. done bool
  24362. oldValue func(context.Context) (*PayRecharge, error)
  24363. predicates []predicate.PayRecharge
  24364. }
  24365. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  24366. // payrechargeOption allows management of the mutation configuration using functional options.
  24367. type payrechargeOption func(*PayRechargeMutation)
  24368. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  24369. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  24370. m := &PayRechargeMutation{
  24371. config: c,
  24372. op: op,
  24373. typ: TypePayRecharge,
  24374. clearedFields: make(map[string]struct{}),
  24375. }
  24376. for _, opt := range opts {
  24377. opt(m)
  24378. }
  24379. return m
  24380. }
  24381. // withPayRechargeID sets the ID field of the mutation.
  24382. func withPayRechargeID(id uint64) payrechargeOption {
  24383. return func(m *PayRechargeMutation) {
  24384. var (
  24385. err error
  24386. once sync.Once
  24387. value *PayRecharge
  24388. )
  24389. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  24390. once.Do(func() {
  24391. if m.done {
  24392. err = errors.New("querying old values post mutation is not allowed")
  24393. } else {
  24394. value, err = m.Client().PayRecharge.Get(ctx, id)
  24395. }
  24396. })
  24397. return value, err
  24398. }
  24399. m.id = &id
  24400. }
  24401. }
  24402. // withPayRecharge sets the old PayRecharge of the mutation.
  24403. func withPayRecharge(node *PayRecharge) payrechargeOption {
  24404. return func(m *PayRechargeMutation) {
  24405. m.oldValue = func(context.Context) (*PayRecharge, error) {
  24406. return node, nil
  24407. }
  24408. m.id = &node.ID
  24409. }
  24410. }
  24411. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24412. // executed in a transaction (ent.Tx), a transactional client is returned.
  24413. func (m PayRechargeMutation) Client() *Client {
  24414. client := &Client{config: m.config}
  24415. client.init()
  24416. return client
  24417. }
  24418. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24419. // it returns an error otherwise.
  24420. func (m PayRechargeMutation) Tx() (*Tx, error) {
  24421. if _, ok := m.driver.(*txDriver); !ok {
  24422. return nil, errors.New("ent: mutation is not running in a transaction")
  24423. }
  24424. tx := &Tx{config: m.config}
  24425. tx.init()
  24426. return tx, nil
  24427. }
  24428. // SetID sets the value of the id field. Note that this
  24429. // operation is only accepted on creation of PayRecharge entities.
  24430. func (m *PayRechargeMutation) SetID(id uint64) {
  24431. m.id = &id
  24432. }
  24433. // ID returns the ID value in the mutation. Note that the ID is only available
  24434. // if it was provided to the builder or after it was returned from the database.
  24435. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  24436. if m.id == nil {
  24437. return
  24438. }
  24439. return *m.id, true
  24440. }
  24441. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24442. // That means, if the mutation is applied within a transaction with an isolation level such
  24443. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24444. // or updated by the mutation.
  24445. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24446. switch {
  24447. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24448. id, exists := m.ID()
  24449. if exists {
  24450. return []uint64{id}, nil
  24451. }
  24452. fallthrough
  24453. case m.op.Is(OpUpdate | OpDelete):
  24454. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  24455. default:
  24456. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24457. }
  24458. }
  24459. // SetCreatedAt sets the "created_at" field.
  24460. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  24461. m.created_at = &t
  24462. }
  24463. // CreatedAt returns the value of the "created_at" field in the mutation.
  24464. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  24465. v := m.created_at
  24466. if v == nil {
  24467. return
  24468. }
  24469. return *v, true
  24470. }
  24471. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  24472. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24474. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24475. if !m.op.Is(OpUpdateOne) {
  24476. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24477. }
  24478. if m.id == nil || m.oldValue == nil {
  24479. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24480. }
  24481. oldValue, err := m.oldValue(ctx)
  24482. if err != nil {
  24483. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24484. }
  24485. return oldValue.CreatedAt, nil
  24486. }
  24487. // ResetCreatedAt resets all changes to the "created_at" field.
  24488. func (m *PayRechargeMutation) ResetCreatedAt() {
  24489. m.created_at = nil
  24490. }
  24491. // SetUpdatedAt sets the "updated_at" field.
  24492. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  24493. m.updated_at = &t
  24494. }
  24495. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24496. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  24497. v := m.updated_at
  24498. if v == nil {
  24499. return
  24500. }
  24501. return *v, true
  24502. }
  24503. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  24504. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24506. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24507. if !m.op.Is(OpUpdateOne) {
  24508. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24509. }
  24510. if m.id == nil || m.oldValue == nil {
  24511. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24512. }
  24513. oldValue, err := m.oldValue(ctx)
  24514. if err != nil {
  24515. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24516. }
  24517. return oldValue.UpdatedAt, nil
  24518. }
  24519. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24520. func (m *PayRechargeMutation) ResetUpdatedAt() {
  24521. m.updated_at = nil
  24522. }
  24523. // SetDeletedAt sets the "deleted_at" field.
  24524. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  24525. m.deleted_at = &t
  24526. }
  24527. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24528. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  24529. v := m.deleted_at
  24530. if v == nil {
  24531. return
  24532. }
  24533. return *v, true
  24534. }
  24535. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  24536. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24538. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24539. if !m.op.Is(OpUpdateOne) {
  24540. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24541. }
  24542. if m.id == nil || m.oldValue == nil {
  24543. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24544. }
  24545. oldValue, err := m.oldValue(ctx)
  24546. if err != nil {
  24547. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24548. }
  24549. return oldValue.DeletedAt, nil
  24550. }
  24551. // ClearDeletedAt clears the value of the "deleted_at" field.
  24552. func (m *PayRechargeMutation) ClearDeletedAt() {
  24553. m.deleted_at = nil
  24554. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  24555. }
  24556. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24557. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  24558. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  24559. return ok
  24560. }
  24561. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24562. func (m *PayRechargeMutation) ResetDeletedAt() {
  24563. m.deleted_at = nil
  24564. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  24565. }
  24566. // SetUserID sets the "user_id" field.
  24567. func (m *PayRechargeMutation) SetUserID(s string) {
  24568. m.user_id = &s
  24569. }
  24570. // UserID returns the value of the "user_id" field in the mutation.
  24571. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  24572. v := m.user_id
  24573. if v == nil {
  24574. return
  24575. }
  24576. return *v, true
  24577. }
  24578. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  24579. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24581. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  24582. if !m.op.Is(OpUpdateOne) {
  24583. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  24584. }
  24585. if m.id == nil || m.oldValue == nil {
  24586. return v, errors.New("OldUserID requires an ID field in the mutation")
  24587. }
  24588. oldValue, err := m.oldValue(ctx)
  24589. if err != nil {
  24590. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  24591. }
  24592. return oldValue.UserID, nil
  24593. }
  24594. // ResetUserID resets all changes to the "user_id" field.
  24595. func (m *PayRechargeMutation) ResetUserID() {
  24596. m.user_id = nil
  24597. }
  24598. // SetNumber sets the "number" field.
  24599. func (m *PayRechargeMutation) SetNumber(f float32) {
  24600. m.number = &f
  24601. m.addnumber = nil
  24602. }
  24603. // Number returns the value of the "number" field in the mutation.
  24604. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  24605. v := m.number
  24606. if v == nil {
  24607. return
  24608. }
  24609. return *v, true
  24610. }
  24611. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  24612. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24614. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  24615. if !m.op.Is(OpUpdateOne) {
  24616. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  24617. }
  24618. if m.id == nil || m.oldValue == nil {
  24619. return v, errors.New("OldNumber requires an ID field in the mutation")
  24620. }
  24621. oldValue, err := m.oldValue(ctx)
  24622. if err != nil {
  24623. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  24624. }
  24625. return oldValue.Number, nil
  24626. }
  24627. // AddNumber adds f to the "number" field.
  24628. func (m *PayRechargeMutation) AddNumber(f float32) {
  24629. if m.addnumber != nil {
  24630. *m.addnumber += f
  24631. } else {
  24632. m.addnumber = &f
  24633. }
  24634. }
  24635. // AddedNumber returns the value that was added to the "number" field in this mutation.
  24636. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  24637. v := m.addnumber
  24638. if v == nil {
  24639. return
  24640. }
  24641. return *v, true
  24642. }
  24643. // ResetNumber resets all changes to the "number" field.
  24644. func (m *PayRechargeMutation) ResetNumber() {
  24645. m.number = nil
  24646. m.addnumber = nil
  24647. }
  24648. // SetStatus sets the "status" field.
  24649. func (m *PayRechargeMutation) SetStatus(i int) {
  24650. m.status = &i
  24651. m.addstatus = nil
  24652. }
  24653. // Status returns the value of the "status" field in the mutation.
  24654. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  24655. v := m.status
  24656. if v == nil {
  24657. return
  24658. }
  24659. return *v, true
  24660. }
  24661. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  24662. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24664. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  24665. if !m.op.Is(OpUpdateOne) {
  24666. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24667. }
  24668. if m.id == nil || m.oldValue == nil {
  24669. return v, errors.New("OldStatus requires an ID field in the mutation")
  24670. }
  24671. oldValue, err := m.oldValue(ctx)
  24672. if err != nil {
  24673. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24674. }
  24675. return oldValue.Status, nil
  24676. }
  24677. // AddStatus adds i to the "status" field.
  24678. func (m *PayRechargeMutation) AddStatus(i int) {
  24679. if m.addstatus != nil {
  24680. *m.addstatus += i
  24681. } else {
  24682. m.addstatus = &i
  24683. }
  24684. }
  24685. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24686. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  24687. v := m.addstatus
  24688. if v == nil {
  24689. return
  24690. }
  24691. return *v, true
  24692. }
  24693. // ClearStatus clears the value of the "status" field.
  24694. func (m *PayRechargeMutation) ClearStatus() {
  24695. m.status = nil
  24696. m.addstatus = nil
  24697. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  24698. }
  24699. // StatusCleared returns if the "status" field was cleared in this mutation.
  24700. func (m *PayRechargeMutation) StatusCleared() bool {
  24701. _, ok := m.clearedFields[payrecharge.FieldStatus]
  24702. return ok
  24703. }
  24704. // ResetStatus resets all changes to the "status" field.
  24705. func (m *PayRechargeMutation) ResetStatus() {
  24706. m.status = nil
  24707. m.addstatus = nil
  24708. delete(m.clearedFields, payrecharge.FieldStatus)
  24709. }
  24710. // SetMoney sets the "money" field.
  24711. func (m *PayRechargeMutation) SetMoney(f float32) {
  24712. m.money = &f
  24713. m.addmoney = nil
  24714. }
  24715. // Money returns the value of the "money" field in the mutation.
  24716. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  24717. v := m.money
  24718. if v == nil {
  24719. return
  24720. }
  24721. return *v, true
  24722. }
  24723. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  24724. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24726. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  24727. if !m.op.Is(OpUpdateOne) {
  24728. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  24729. }
  24730. if m.id == nil || m.oldValue == nil {
  24731. return v, errors.New("OldMoney requires an ID field in the mutation")
  24732. }
  24733. oldValue, err := m.oldValue(ctx)
  24734. if err != nil {
  24735. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  24736. }
  24737. return oldValue.Money, nil
  24738. }
  24739. // AddMoney adds f to the "money" field.
  24740. func (m *PayRechargeMutation) AddMoney(f float32) {
  24741. if m.addmoney != nil {
  24742. *m.addmoney += f
  24743. } else {
  24744. m.addmoney = &f
  24745. }
  24746. }
  24747. // AddedMoney returns the value that was added to the "money" field in this mutation.
  24748. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  24749. v := m.addmoney
  24750. if v == nil {
  24751. return
  24752. }
  24753. return *v, true
  24754. }
  24755. // ClearMoney clears the value of the "money" field.
  24756. func (m *PayRechargeMutation) ClearMoney() {
  24757. m.money = nil
  24758. m.addmoney = nil
  24759. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  24760. }
  24761. // MoneyCleared returns if the "money" field was cleared in this mutation.
  24762. func (m *PayRechargeMutation) MoneyCleared() bool {
  24763. _, ok := m.clearedFields[payrecharge.FieldMoney]
  24764. return ok
  24765. }
  24766. // ResetMoney resets all changes to the "money" field.
  24767. func (m *PayRechargeMutation) ResetMoney() {
  24768. m.money = nil
  24769. m.addmoney = nil
  24770. delete(m.clearedFields, payrecharge.FieldMoney)
  24771. }
  24772. // SetOutTradeNo sets the "out_trade_no" field.
  24773. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  24774. m.out_trade_no = &s
  24775. }
  24776. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  24777. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  24778. v := m.out_trade_no
  24779. if v == nil {
  24780. return
  24781. }
  24782. return *v, true
  24783. }
  24784. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  24785. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24787. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  24788. if !m.op.Is(OpUpdateOne) {
  24789. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  24790. }
  24791. if m.id == nil || m.oldValue == nil {
  24792. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  24793. }
  24794. oldValue, err := m.oldValue(ctx)
  24795. if err != nil {
  24796. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  24797. }
  24798. return oldValue.OutTradeNo, nil
  24799. }
  24800. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  24801. func (m *PayRechargeMutation) ClearOutTradeNo() {
  24802. m.out_trade_no = nil
  24803. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  24804. }
  24805. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  24806. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  24807. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  24808. return ok
  24809. }
  24810. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  24811. func (m *PayRechargeMutation) ResetOutTradeNo() {
  24812. m.out_trade_no = nil
  24813. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  24814. }
  24815. // SetOrganizationID sets the "organization_id" field.
  24816. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  24817. m.organization_id = &u
  24818. m.addorganization_id = nil
  24819. }
  24820. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24821. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  24822. v := m.organization_id
  24823. if v == nil {
  24824. return
  24825. }
  24826. return *v, true
  24827. }
  24828. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  24829. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24831. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24832. if !m.op.Is(OpUpdateOne) {
  24833. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24834. }
  24835. if m.id == nil || m.oldValue == nil {
  24836. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24837. }
  24838. oldValue, err := m.oldValue(ctx)
  24839. if err != nil {
  24840. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24841. }
  24842. return oldValue.OrganizationID, nil
  24843. }
  24844. // AddOrganizationID adds u to the "organization_id" field.
  24845. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  24846. if m.addorganization_id != nil {
  24847. *m.addorganization_id += u
  24848. } else {
  24849. m.addorganization_id = &u
  24850. }
  24851. }
  24852. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24853. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  24854. v := m.addorganization_id
  24855. if v == nil {
  24856. return
  24857. }
  24858. return *v, true
  24859. }
  24860. // ResetOrganizationID resets all changes to the "organization_id" field.
  24861. func (m *PayRechargeMutation) ResetOrganizationID() {
  24862. m.organization_id = nil
  24863. m.addorganization_id = nil
  24864. }
  24865. // Where appends a list predicates to the PayRechargeMutation builder.
  24866. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  24867. m.predicates = append(m.predicates, ps...)
  24868. }
  24869. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  24870. // users can use type-assertion to append predicates that do not depend on any generated package.
  24871. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  24872. p := make([]predicate.PayRecharge, len(ps))
  24873. for i := range ps {
  24874. p[i] = ps[i]
  24875. }
  24876. m.Where(p...)
  24877. }
  24878. // Op returns the operation name.
  24879. func (m *PayRechargeMutation) Op() Op {
  24880. return m.op
  24881. }
  24882. // SetOp allows setting the mutation operation.
  24883. func (m *PayRechargeMutation) SetOp(op Op) {
  24884. m.op = op
  24885. }
  24886. // Type returns the node type of this mutation (PayRecharge).
  24887. func (m *PayRechargeMutation) Type() string {
  24888. return m.typ
  24889. }
  24890. // Fields returns all fields that were changed during this mutation. Note that in
  24891. // order to get all numeric fields that were incremented/decremented, call
  24892. // AddedFields().
  24893. func (m *PayRechargeMutation) Fields() []string {
  24894. fields := make([]string, 0, 9)
  24895. if m.created_at != nil {
  24896. fields = append(fields, payrecharge.FieldCreatedAt)
  24897. }
  24898. if m.updated_at != nil {
  24899. fields = append(fields, payrecharge.FieldUpdatedAt)
  24900. }
  24901. if m.deleted_at != nil {
  24902. fields = append(fields, payrecharge.FieldDeletedAt)
  24903. }
  24904. if m.user_id != nil {
  24905. fields = append(fields, payrecharge.FieldUserID)
  24906. }
  24907. if m.number != nil {
  24908. fields = append(fields, payrecharge.FieldNumber)
  24909. }
  24910. if m.status != nil {
  24911. fields = append(fields, payrecharge.FieldStatus)
  24912. }
  24913. if m.money != nil {
  24914. fields = append(fields, payrecharge.FieldMoney)
  24915. }
  24916. if m.out_trade_no != nil {
  24917. fields = append(fields, payrecharge.FieldOutTradeNo)
  24918. }
  24919. if m.organization_id != nil {
  24920. fields = append(fields, payrecharge.FieldOrganizationID)
  24921. }
  24922. return fields
  24923. }
  24924. // Field returns the value of a field with the given name. The second boolean
  24925. // return value indicates that this field was not set, or was not defined in the
  24926. // schema.
  24927. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  24928. switch name {
  24929. case payrecharge.FieldCreatedAt:
  24930. return m.CreatedAt()
  24931. case payrecharge.FieldUpdatedAt:
  24932. return m.UpdatedAt()
  24933. case payrecharge.FieldDeletedAt:
  24934. return m.DeletedAt()
  24935. case payrecharge.FieldUserID:
  24936. return m.UserID()
  24937. case payrecharge.FieldNumber:
  24938. return m.Number()
  24939. case payrecharge.FieldStatus:
  24940. return m.Status()
  24941. case payrecharge.FieldMoney:
  24942. return m.Money()
  24943. case payrecharge.FieldOutTradeNo:
  24944. return m.OutTradeNo()
  24945. case payrecharge.FieldOrganizationID:
  24946. return m.OrganizationID()
  24947. }
  24948. return nil, false
  24949. }
  24950. // OldField returns the old value of the field from the database. An error is
  24951. // returned if the mutation operation is not UpdateOne, or the query to the
  24952. // database failed.
  24953. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24954. switch name {
  24955. case payrecharge.FieldCreatedAt:
  24956. return m.OldCreatedAt(ctx)
  24957. case payrecharge.FieldUpdatedAt:
  24958. return m.OldUpdatedAt(ctx)
  24959. case payrecharge.FieldDeletedAt:
  24960. return m.OldDeletedAt(ctx)
  24961. case payrecharge.FieldUserID:
  24962. return m.OldUserID(ctx)
  24963. case payrecharge.FieldNumber:
  24964. return m.OldNumber(ctx)
  24965. case payrecharge.FieldStatus:
  24966. return m.OldStatus(ctx)
  24967. case payrecharge.FieldMoney:
  24968. return m.OldMoney(ctx)
  24969. case payrecharge.FieldOutTradeNo:
  24970. return m.OldOutTradeNo(ctx)
  24971. case payrecharge.FieldOrganizationID:
  24972. return m.OldOrganizationID(ctx)
  24973. }
  24974. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  24975. }
  24976. // SetField sets the value of a field with the given name. It returns an error if
  24977. // the field is not defined in the schema, or if the type mismatched the field
  24978. // type.
  24979. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  24980. switch name {
  24981. case payrecharge.FieldCreatedAt:
  24982. v, ok := value.(time.Time)
  24983. if !ok {
  24984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24985. }
  24986. m.SetCreatedAt(v)
  24987. return nil
  24988. case payrecharge.FieldUpdatedAt:
  24989. v, ok := value.(time.Time)
  24990. if !ok {
  24991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24992. }
  24993. m.SetUpdatedAt(v)
  24994. return nil
  24995. case payrecharge.FieldDeletedAt:
  24996. v, ok := value.(time.Time)
  24997. if !ok {
  24998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24999. }
  25000. m.SetDeletedAt(v)
  25001. return nil
  25002. case payrecharge.FieldUserID:
  25003. v, ok := value.(string)
  25004. if !ok {
  25005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25006. }
  25007. m.SetUserID(v)
  25008. return nil
  25009. case payrecharge.FieldNumber:
  25010. v, ok := value.(float32)
  25011. if !ok {
  25012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25013. }
  25014. m.SetNumber(v)
  25015. return nil
  25016. case payrecharge.FieldStatus:
  25017. v, ok := value.(int)
  25018. if !ok {
  25019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25020. }
  25021. m.SetStatus(v)
  25022. return nil
  25023. case payrecharge.FieldMoney:
  25024. v, ok := value.(float32)
  25025. if !ok {
  25026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25027. }
  25028. m.SetMoney(v)
  25029. return nil
  25030. case payrecharge.FieldOutTradeNo:
  25031. v, ok := value.(string)
  25032. if !ok {
  25033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25034. }
  25035. m.SetOutTradeNo(v)
  25036. return nil
  25037. case payrecharge.FieldOrganizationID:
  25038. v, ok := value.(uint64)
  25039. if !ok {
  25040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25041. }
  25042. m.SetOrganizationID(v)
  25043. return nil
  25044. }
  25045. return fmt.Errorf("unknown PayRecharge field %s", name)
  25046. }
  25047. // AddedFields returns all numeric fields that were incremented/decremented during
  25048. // this mutation.
  25049. func (m *PayRechargeMutation) AddedFields() []string {
  25050. var fields []string
  25051. if m.addnumber != nil {
  25052. fields = append(fields, payrecharge.FieldNumber)
  25053. }
  25054. if m.addstatus != nil {
  25055. fields = append(fields, payrecharge.FieldStatus)
  25056. }
  25057. if m.addmoney != nil {
  25058. fields = append(fields, payrecharge.FieldMoney)
  25059. }
  25060. if m.addorganization_id != nil {
  25061. fields = append(fields, payrecharge.FieldOrganizationID)
  25062. }
  25063. return fields
  25064. }
  25065. // AddedField returns the numeric value that was incremented/decremented on a field
  25066. // with the given name. The second boolean return value indicates that this field
  25067. // was not set, or was not defined in the schema.
  25068. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  25069. switch name {
  25070. case payrecharge.FieldNumber:
  25071. return m.AddedNumber()
  25072. case payrecharge.FieldStatus:
  25073. return m.AddedStatus()
  25074. case payrecharge.FieldMoney:
  25075. return m.AddedMoney()
  25076. case payrecharge.FieldOrganizationID:
  25077. return m.AddedOrganizationID()
  25078. }
  25079. return nil, false
  25080. }
  25081. // AddField adds the value to the field with the given name. It returns an error if
  25082. // the field is not defined in the schema, or if the type mismatched the field
  25083. // type.
  25084. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  25085. switch name {
  25086. case payrecharge.FieldNumber:
  25087. v, ok := value.(float32)
  25088. if !ok {
  25089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25090. }
  25091. m.AddNumber(v)
  25092. return nil
  25093. case payrecharge.FieldStatus:
  25094. v, ok := value.(int)
  25095. if !ok {
  25096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25097. }
  25098. m.AddStatus(v)
  25099. return nil
  25100. case payrecharge.FieldMoney:
  25101. v, ok := value.(float32)
  25102. if !ok {
  25103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25104. }
  25105. m.AddMoney(v)
  25106. return nil
  25107. case payrecharge.FieldOrganizationID:
  25108. v, ok := value.(int64)
  25109. if !ok {
  25110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25111. }
  25112. m.AddOrganizationID(v)
  25113. return nil
  25114. }
  25115. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  25116. }
  25117. // ClearedFields returns all nullable fields that were cleared during this
  25118. // mutation.
  25119. func (m *PayRechargeMutation) ClearedFields() []string {
  25120. var fields []string
  25121. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  25122. fields = append(fields, payrecharge.FieldDeletedAt)
  25123. }
  25124. if m.FieldCleared(payrecharge.FieldStatus) {
  25125. fields = append(fields, payrecharge.FieldStatus)
  25126. }
  25127. if m.FieldCleared(payrecharge.FieldMoney) {
  25128. fields = append(fields, payrecharge.FieldMoney)
  25129. }
  25130. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  25131. fields = append(fields, payrecharge.FieldOutTradeNo)
  25132. }
  25133. return fields
  25134. }
  25135. // FieldCleared returns a boolean indicating if a field with the given name was
  25136. // cleared in this mutation.
  25137. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  25138. _, ok := m.clearedFields[name]
  25139. return ok
  25140. }
  25141. // ClearField clears the value of the field with the given name. It returns an
  25142. // error if the field is not defined in the schema.
  25143. func (m *PayRechargeMutation) ClearField(name string) error {
  25144. switch name {
  25145. case payrecharge.FieldDeletedAt:
  25146. m.ClearDeletedAt()
  25147. return nil
  25148. case payrecharge.FieldStatus:
  25149. m.ClearStatus()
  25150. return nil
  25151. case payrecharge.FieldMoney:
  25152. m.ClearMoney()
  25153. return nil
  25154. case payrecharge.FieldOutTradeNo:
  25155. m.ClearOutTradeNo()
  25156. return nil
  25157. }
  25158. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  25159. }
  25160. // ResetField resets all changes in the mutation for the field with the given name.
  25161. // It returns an error if the field is not defined in the schema.
  25162. func (m *PayRechargeMutation) ResetField(name string) error {
  25163. switch name {
  25164. case payrecharge.FieldCreatedAt:
  25165. m.ResetCreatedAt()
  25166. return nil
  25167. case payrecharge.FieldUpdatedAt:
  25168. m.ResetUpdatedAt()
  25169. return nil
  25170. case payrecharge.FieldDeletedAt:
  25171. m.ResetDeletedAt()
  25172. return nil
  25173. case payrecharge.FieldUserID:
  25174. m.ResetUserID()
  25175. return nil
  25176. case payrecharge.FieldNumber:
  25177. m.ResetNumber()
  25178. return nil
  25179. case payrecharge.FieldStatus:
  25180. m.ResetStatus()
  25181. return nil
  25182. case payrecharge.FieldMoney:
  25183. m.ResetMoney()
  25184. return nil
  25185. case payrecharge.FieldOutTradeNo:
  25186. m.ResetOutTradeNo()
  25187. return nil
  25188. case payrecharge.FieldOrganizationID:
  25189. m.ResetOrganizationID()
  25190. return nil
  25191. }
  25192. return fmt.Errorf("unknown PayRecharge field %s", name)
  25193. }
  25194. // AddedEdges returns all edge names that were set/added in this mutation.
  25195. func (m *PayRechargeMutation) AddedEdges() []string {
  25196. edges := make([]string, 0, 0)
  25197. return edges
  25198. }
  25199. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25200. // name in this mutation.
  25201. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  25202. return nil
  25203. }
  25204. // RemovedEdges returns all edge names that were removed in this mutation.
  25205. func (m *PayRechargeMutation) RemovedEdges() []string {
  25206. edges := make([]string, 0, 0)
  25207. return edges
  25208. }
  25209. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25210. // the given name in this mutation.
  25211. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  25212. return nil
  25213. }
  25214. // ClearedEdges returns all edge names that were cleared in this mutation.
  25215. func (m *PayRechargeMutation) ClearedEdges() []string {
  25216. edges := make([]string, 0, 0)
  25217. return edges
  25218. }
  25219. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25220. // was cleared in this mutation.
  25221. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  25222. return false
  25223. }
  25224. // ClearEdge clears the value of the edge with the given name. It returns an error
  25225. // if that edge is not defined in the schema.
  25226. func (m *PayRechargeMutation) ClearEdge(name string) error {
  25227. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  25228. }
  25229. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25230. // It returns an error if the edge is not defined in the schema.
  25231. func (m *PayRechargeMutation) ResetEdge(name string) error {
  25232. return fmt.Errorf("unknown PayRecharge edge %s", name)
  25233. }
  25234. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  25235. type ServerMutation struct {
  25236. config
  25237. op Op
  25238. typ string
  25239. id *uint64
  25240. created_at *time.Time
  25241. updated_at *time.Time
  25242. status *uint8
  25243. addstatus *int8
  25244. deleted_at *time.Time
  25245. name *string
  25246. public_ip *string
  25247. private_ip *string
  25248. admin_port *string
  25249. clearedFields map[string]struct{}
  25250. wxs map[uint64]struct{}
  25251. removedwxs map[uint64]struct{}
  25252. clearedwxs bool
  25253. done bool
  25254. oldValue func(context.Context) (*Server, error)
  25255. predicates []predicate.Server
  25256. }
  25257. var _ ent.Mutation = (*ServerMutation)(nil)
  25258. // serverOption allows management of the mutation configuration using functional options.
  25259. type serverOption func(*ServerMutation)
  25260. // newServerMutation creates new mutation for the Server entity.
  25261. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  25262. m := &ServerMutation{
  25263. config: c,
  25264. op: op,
  25265. typ: TypeServer,
  25266. clearedFields: make(map[string]struct{}),
  25267. }
  25268. for _, opt := range opts {
  25269. opt(m)
  25270. }
  25271. return m
  25272. }
  25273. // withServerID sets the ID field of the mutation.
  25274. func withServerID(id uint64) serverOption {
  25275. return func(m *ServerMutation) {
  25276. var (
  25277. err error
  25278. once sync.Once
  25279. value *Server
  25280. )
  25281. m.oldValue = func(ctx context.Context) (*Server, error) {
  25282. once.Do(func() {
  25283. if m.done {
  25284. err = errors.New("querying old values post mutation is not allowed")
  25285. } else {
  25286. value, err = m.Client().Server.Get(ctx, id)
  25287. }
  25288. })
  25289. return value, err
  25290. }
  25291. m.id = &id
  25292. }
  25293. }
  25294. // withServer sets the old Server of the mutation.
  25295. func withServer(node *Server) serverOption {
  25296. return func(m *ServerMutation) {
  25297. m.oldValue = func(context.Context) (*Server, error) {
  25298. return node, nil
  25299. }
  25300. m.id = &node.ID
  25301. }
  25302. }
  25303. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25304. // executed in a transaction (ent.Tx), a transactional client is returned.
  25305. func (m ServerMutation) Client() *Client {
  25306. client := &Client{config: m.config}
  25307. client.init()
  25308. return client
  25309. }
  25310. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25311. // it returns an error otherwise.
  25312. func (m ServerMutation) Tx() (*Tx, error) {
  25313. if _, ok := m.driver.(*txDriver); !ok {
  25314. return nil, errors.New("ent: mutation is not running in a transaction")
  25315. }
  25316. tx := &Tx{config: m.config}
  25317. tx.init()
  25318. return tx, nil
  25319. }
  25320. // SetID sets the value of the id field. Note that this
  25321. // operation is only accepted on creation of Server entities.
  25322. func (m *ServerMutation) SetID(id uint64) {
  25323. m.id = &id
  25324. }
  25325. // ID returns the ID value in the mutation. Note that the ID is only available
  25326. // if it was provided to the builder or after it was returned from the database.
  25327. func (m *ServerMutation) ID() (id uint64, exists bool) {
  25328. if m.id == nil {
  25329. return
  25330. }
  25331. return *m.id, true
  25332. }
  25333. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25334. // That means, if the mutation is applied within a transaction with an isolation level such
  25335. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25336. // or updated by the mutation.
  25337. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  25338. switch {
  25339. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25340. id, exists := m.ID()
  25341. if exists {
  25342. return []uint64{id}, nil
  25343. }
  25344. fallthrough
  25345. case m.op.Is(OpUpdate | OpDelete):
  25346. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  25347. default:
  25348. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25349. }
  25350. }
  25351. // SetCreatedAt sets the "created_at" field.
  25352. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  25353. m.created_at = &t
  25354. }
  25355. // CreatedAt returns the value of the "created_at" field in the mutation.
  25356. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  25357. v := m.created_at
  25358. if v == nil {
  25359. return
  25360. }
  25361. return *v, true
  25362. }
  25363. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  25364. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25366. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25367. if !m.op.Is(OpUpdateOne) {
  25368. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25369. }
  25370. if m.id == nil || m.oldValue == nil {
  25371. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25372. }
  25373. oldValue, err := m.oldValue(ctx)
  25374. if err != nil {
  25375. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25376. }
  25377. return oldValue.CreatedAt, nil
  25378. }
  25379. // ResetCreatedAt resets all changes to the "created_at" field.
  25380. func (m *ServerMutation) ResetCreatedAt() {
  25381. m.created_at = nil
  25382. }
  25383. // SetUpdatedAt sets the "updated_at" field.
  25384. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  25385. m.updated_at = &t
  25386. }
  25387. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25388. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  25389. v := m.updated_at
  25390. if v == nil {
  25391. return
  25392. }
  25393. return *v, true
  25394. }
  25395. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  25396. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25398. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25399. if !m.op.Is(OpUpdateOne) {
  25400. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25401. }
  25402. if m.id == nil || m.oldValue == nil {
  25403. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25404. }
  25405. oldValue, err := m.oldValue(ctx)
  25406. if err != nil {
  25407. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25408. }
  25409. return oldValue.UpdatedAt, nil
  25410. }
  25411. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25412. func (m *ServerMutation) ResetUpdatedAt() {
  25413. m.updated_at = nil
  25414. }
  25415. // SetStatus sets the "status" field.
  25416. func (m *ServerMutation) SetStatus(u uint8) {
  25417. m.status = &u
  25418. m.addstatus = nil
  25419. }
  25420. // Status returns the value of the "status" field in the mutation.
  25421. func (m *ServerMutation) Status() (r uint8, exists bool) {
  25422. v := m.status
  25423. if v == nil {
  25424. return
  25425. }
  25426. return *v, true
  25427. }
  25428. // OldStatus returns the old "status" field's value of the Server entity.
  25429. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25431. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25432. if !m.op.Is(OpUpdateOne) {
  25433. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25434. }
  25435. if m.id == nil || m.oldValue == nil {
  25436. return v, errors.New("OldStatus requires an ID field in the mutation")
  25437. }
  25438. oldValue, err := m.oldValue(ctx)
  25439. if err != nil {
  25440. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25441. }
  25442. return oldValue.Status, nil
  25443. }
  25444. // AddStatus adds u to the "status" field.
  25445. func (m *ServerMutation) AddStatus(u int8) {
  25446. if m.addstatus != nil {
  25447. *m.addstatus += u
  25448. } else {
  25449. m.addstatus = &u
  25450. }
  25451. }
  25452. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25453. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  25454. v := m.addstatus
  25455. if v == nil {
  25456. return
  25457. }
  25458. return *v, true
  25459. }
  25460. // ClearStatus clears the value of the "status" field.
  25461. func (m *ServerMutation) ClearStatus() {
  25462. m.status = nil
  25463. m.addstatus = nil
  25464. m.clearedFields[server.FieldStatus] = struct{}{}
  25465. }
  25466. // StatusCleared returns if the "status" field was cleared in this mutation.
  25467. func (m *ServerMutation) StatusCleared() bool {
  25468. _, ok := m.clearedFields[server.FieldStatus]
  25469. return ok
  25470. }
  25471. // ResetStatus resets all changes to the "status" field.
  25472. func (m *ServerMutation) ResetStatus() {
  25473. m.status = nil
  25474. m.addstatus = nil
  25475. delete(m.clearedFields, server.FieldStatus)
  25476. }
  25477. // SetDeletedAt sets the "deleted_at" field.
  25478. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  25479. m.deleted_at = &t
  25480. }
  25481. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25482. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  25483. v := m.deleted_at
  25484. if v == nil {
  25485. return
  25486. }
  25487. return *v, true
  25488. }
  25489. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  25490. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25492. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25493. if !m.op.Is(OpUpdateOne) {
  25494. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25495. }
  25496. if m.id == nil || m.oldValue == nil {
  25497. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25498. }
  25499. oldValue, err := m.oldValue(ctx)
  25500. if err != nil {
  25501. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25502. }
  25503. return oldValue.DeletedAt, nil
  25504. }
  25505. // ClearDeletedAt clears the value of the "deleted_at" field.
  25506. func (m *ServerMutation) ClearDeletedAt() {
  25507. m.deleted_at = nil
  25508. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  25509. }
  25510. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25511. func (m *ServerMutation) DeletedAtCleared() bool {
  25512. _, ok := m.clearedFields[server.FieldDeletedAt]
  25513. return ok
  25514. }
  25515. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25516. func (m *ServerMutation) ResetDeletedAt() {
  25517. m.deleted_at = nil
  25518. delete(m.clearedFields, server.FieldDeletedAt)
  25519. }
  25520. // SetName sets the "name" field.
  25521. func (m *ServerMutation) SetName(s string) {
  25522. m.name = &s
  25523. }
  25524. // Name returns the value of the "name" field in the mutation.
  25525. func (m *ServerMutation) Name() (r string, exists bool) {
  25526. v := m.name
  25527. if v == nil {
  25528. return
  25529. }
  25530. return *v, true
  25531. }
  25532. // OldName returns the old "name" field's value of the Server entity.
  25533. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25535. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  25536. if !m.op.Is(OpUpdateOne) {
  25537. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25538. }
  25539. if m.id == nil || m.oldValue == nil {
  25540. return v, errors.New("OldName requires an ID field in the mutation")
  25541. }
  25542. oldValue, err := m.oldValue(ctx)
  25543. if err != nil {
  25544. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25545. }
  25546. return oldValue.Name, nil
  25547. }
  25548. // ResetName resets all changes to the "name" field.
  25549. func (m *ServerMutation) ResetName() {
  25550. m.name = nil
  25551. }
  25552. // SetPublicIP sets the "public_ip" field.
  25553. func (m *ServerMutation) SetPublicIP(s string) {
  25554. m.public_ip = &s
  25555. }
  25556. // PublicIP returns the value of the "public_ip" field in the mutation.
  25557. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  25558. v := m.public_ip
  25559. if v == nil {
  25560. return
  25561. }
  25562. return *v, true
  25563. }
  25564. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  25565. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25567. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  25568. if !m.op.Is(OpUpdateOne) {
  25569. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  25570. }
  25571. if m.id == nil || m.oldValue == nil {
  25572. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  25573. }
  25574. oldValue, err := m.oldValue(ctx)
  25575. if err != nil {
  25576. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  25577. }
  25578. return oldValue.PublicIP, nil
  25579. }
  25580. // ResetPublicIP resets all changes to the "public_ip" field.
  25581. func (m *ServerMutation) ResetPublicIP() {
  25582. m.public_ip = nil
  25583. }
  25584. // SetPrivateIP sets the "private_ip" field.
  25585. func (m *ServerMutation) SetPrivateIP(s string) {
  25586. m.private_ip = &s
  25587. }
  25588. // PrivateIP returns the value of the "private_ip" field in the mutation.
  25589. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  25590. v := m.private_ip
  25591. if v == nil {
  25592. return
  25593. }
  25594. return *v, true
  25595. }
  25596. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  25597. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25599. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  25600. if !m.op.Is(OpUpdateOne) {
  25601. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  25602. }
  25603. if m.id == nil || m.oldValue == nil {
  25604. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  25605. }
  25606. oldValue, err := m.oldValue(ctx)
  25607. if err != nil {
  25608. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  25609. }
  25610. return oldValue.PrivateIP, nil
  25611. }
  25612. // ResetPrivateIP resets all changes to the "private_ip" field.
  25613. func (m *ServerMutation) ResetPrivateIP() {
  25614. m.private_ip = nil
  25615. }
  25616. // SetAdminPort sets the "admin_port" field.
  25617. func (m *ServerMutation) SetAdminPort(s string) {
  25618. m.admin_port = &s
  25619. }
  25620. // AdminPort returns the value of the "admin_port" field in the mutation.
  25621. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  25622. v := m.admin_port
  25623. if v == nil {
  25624. return
  25625. }
  25626. return *v, true
  25627. }
  25628. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  25629. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25631. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  25632. if !m.op.Is(OpUpdateOne) {
  25633. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  25634. }
  25635. if m.id == nil || m.oldValue == nil {
  25636. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  25637. }
  25638. oldValue, err := m.oldValue(ctx)
  25639. if err != nil {
  25640. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  25641. }
  25642. return oldValue.AdminPort, nil
  25643. }
  25644. // ResetAdminPort resets all changes to the "admin_port" field.
  25645. func (m *ServerMutation) ResetAdminPort() {
  25646. m.admin_port = nil
  25647. }
  25648. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  25649. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  25650. if m.wxs == nil {
  25651. m.wxs = make(map[uint64]struct{})
  25652. }
  25653. for i := range ids {
  25654. m.wxs[ids[i]] = struct{}{}
  25655. }
  25656. }
  25657. // ClearWxs clears the "wxs" edge to the Wx entity.
  25658. func (m *ServerMutation) ClearWxs() {
  25659. m.clearedwxs = true
  25660. }
  25661. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  25662. func (m *ServerMutation) WxsCleared() bool {
  25663. return m.clearedwxs
  25664. }
  25665. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  25666. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  25667. if m.removedwxs == nil {
  25668. m.removedwxs = make(map[uint64]struct{})
  25669. }
  25670. for i := range ids {
  25671. delete(m.wxs, ids[i])
  25672. m.removedwxs[ids[i]] = struct{}{}
  25673. }
  25674. }
  25675. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  25676. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  25677. for id := range m.removedwxs {
  25678. ids = append(ids, id)
  25679. }
  25680. return
  25681. }
  25682. // WxsIDs returns the "wxs" edge IDs in the mutation.
  25683. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  25684. for id := range m.wxs {
  25685. ids = append(ids, id)
  25686. }
  25687. return
  25688. }
  25689. // ResetWxs resets all changes to the "wxs" edge.
  25690. func (m *ServerMutation) ResetWxs() {
  25691. m.wxs = nil
  25692. m.clearedwxs = false
  25693. m.removedwxs = nil
  25694. }
  25695. // Where appends a list predicates to the ServerMutation builder.
  25696. func (m *ServerMutation) Where(ps ...predicate.Server) {
  25697. m.predicates = append(m.predicates, ps...)
  25698. }
  25699. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  25700. // users can use type-assertion to append predicates that do not depend on any generated package.
  25701. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  25702. p := make([]predicate.Server, len(ps))
  25703. for i := range ps {
  25704. p[i] = ps[i]
  25705. }
  25706. m.Where(p...)
  25707. }
  25708. // Op returns the operation name.
  25709. func (m *ServerMutation) Op() Op {
  25710. return m.op
  25711. }
  25712. // SetOp allows setting the mutation operation.
  25713. func (m *ServerMutation) SetOp(op Op) {
  25714. m.op = op
  25715. }
  25716. // Type returns the node type of this mutation (Server).
  25717. func (m *ServerMutation) Type() string {
  25718. return m.typ
  25719. }
  25720. // Fields returns all fields that were changed during this mutation. Note that in
  25721. // order to get all numeric fields that were incremented/decremented, call
  25722. // AddedFields().
  25723. func (m *ServerMutation) Fields() []string {
  25724. fields := make([]string, 0, 8)
  25725. if m.created_at != nil {
  25726. fields = append(fields, server.FieldCreatedAt)
  25727. }
  25728. if m.updated_at != nil {
  25729. fields = append(fields, server.FieldUpdatedAt)
  25730. }
  25731. if m.status != nil {
  25732. fields = append(fields, server.FieldStatus)
  25733. }
  25734. if m.deleted_at != nil {
  25735. fields = append(fields, server.FieldDeletedAt)
  25736. }
  25737. if m.name != nil {
  25738. fields = append(fields, server.FieldName)
  25739. }
  25740. if m.public_ip != nil {
  25741. fields = append(fields, server.FieldPublicIP)
  25742. }
  25743. if m.private_ip != nil {
  25744. fields = append(fields, server.FieldPrivateIP)
  25745. }
  25746. if m.admin_port != nil {
  25747. fields = append(fields, server.FieldAdminPort)
  25748. }
  25749. return fields
  25750. }
  25751. // Field returns the value of a field with the given name. The second boolean
  25752. // return value indicates that this field was not set, or was not defined in the
  25753. // schema.
  25754. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  25755. switch name {
  25756. case server.FieldCreatedAt:
  25757. return m.CreatedAt()
  25758. case server.FieldUpdatedAt:
  25759. return m.UpdatedAt()
  25760. case server.FieldStatus:
  25761. return m.Status()
  25762. case server.FieldDeletedAt:
  25763. return m.DeletedAt()
  25764. case server.FieldName:
  25765. return m.Name()
  25766. case server.FieldPublicIP:
  25767. return m.PublicIP()
  25768. case server.FieldPrivateIP:
  25769. return m.PrivateIP()
  25770. case server.FieldAdminPort:
  25771. return m.AdminPort()
  25772. }
  25773. return nil, false
  25774. }
  25775. // OldField returns the old value of the field from the database. An error is
  25776. // returned if the mutation operation is not UpdateOne, or the query to the
  25777. // database failed.
  25778. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25779. switch name {
  25780. case server.FieldCreatedAt:
  25781. return m.OldCreatedAt(ctx)
  25782. case server.FieldUpdatedAt:
  25783. return m.OldUpdatedAt(ctx)
  25784. case server.FieldStatus:
  25785. return m.OldStatus(ctx)
  25786. case server.FieldDeletedAt:
  25787. return m.OldDeletedAt(ctx)
  25788. case server.FieldName:
  25789. return m.OldName(ctx)
  25790. case server.FieldPublicIP:
  25791. return m.OldPublicIP(ctx)
  25792. case server.FieldPrivateIP:
  25793. return m.OldPrivateIP(ctx)
  25794. case server.FieldAdminPort:
  25795. return m.OldAdminPort(ctx)
  25796. }
  25797. return nil, fmt.Errorf("unknown Server field %s", name)
  25798. }
  25799. // SetField sets the value of a field with the given name. It returns an error if
  25800. // the field is not defined in the schema, or if the type mismatched the field
  25801. // type.
  25802. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  25803. switch name {
  25804. case server.FieldCreatedAt:
  25805. v, ok := value.(time.Time)
  25806. if !ok {
  25807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25808. }
  25809. m.SetCreatedAt(v)
  25810. return nil
  25811. case server.FieldUpdatedAt:
  25812. v, ok := value.(time.Time)
  25813. if !ok {
  25814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25815. }
  25816. m.SetUpdatedAt(v)
  25817. return nil
  25818. case server.FieldStatus:
  25819. v, ok := value.(uint8)
  25820. if !ok {
  25821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25822. }
  25823. m.SetStatus(v)
  25824. return nil
  25825. case server.FieldDeletedAt:
  25826. v, ok := value.(time.Time)
  25827. if !ok {
  25828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25829. }
  25830. m.SetDeletedAt(v)
  25831. return nil
  25832. case server.FieldName:
  25833. v, ok := value.(string)
  25834. if !ok {
  25835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25836. }
  25837. m.SetName(v)
  25838. return nil
  25839. case server.FieldPublicIP:
  25840. v, ok := value.(string)
  25841. if !ok {
  25842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25843. }
  25844. m.SetPublicIP(v)
  25845. return nil
  25846. case server.FieldPrivateIP:
  25847. v, ok := value.(string)
  25848. if !ok {
  25849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25850. }
  25851. m.SetPrivateIP(v)
  25852. return nil
  25853. case server.FieldAdminPort:
  25854. v, ok := value.(string)
  25855. if !ok {
  25856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25857. }
  25858. m.SetAdminPort(v)
  25859. return nil
  25860. }
  25861. return fmt.Errorf("unknown Server field %s", name)
  25862. }
  25863. // AddedFields returns all numeric fields that were incremented/decremented during
  25864. // this mutation.
  25865. func (m *ServerMutation) AddedFields() []string {
  25866. var fields []string
  25867. if m.addstatus != nil {
  25868. fields = append(fields, server.FieldStatus)
  25869. }
  25870. return fields
  25871. }
  25872. // AddedField returns the numeric value that was incremented/decremented on a field
  25873. // with the given name. The second boolean return value indicates that this field
  25874. // was not set, or was not defined in the schema.
  25875. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  25876. switch name {
  25877. case server.FieldStatus:
  25878. return m.AddedStatus()
  25879. }
  25880. return nil, false
  25881. }
  25882. // AddField adds the value to the field with the given name. It returns an error if
  25883. // the field is not defined in the schema, or if the type mismatched the field
  25884. // type.
  25885. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  25886. switch name {
  25887. case server.FieldStatus:
  25888. v, ok := value.(int8)
  25889. if !ok {
  25890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25891. }
  25892. m.AddStatus(v)
  25893. return nil
  25894. }
  25895. return fmt.Errorf("unknown Server numeric field %s", name)
  25896. }
  25897. // ClearedFields returns all nullable fields that were cleared during this
  25898. // mutation.
  25899. func (m *ServerMutation) ClearedFields() []string {
  25900. var fields []string
  25901. if m.FieldCleared(server.FieldStatus) {
  25902. fields = append(fields, server.FieldStatus)
  25903. }
  25904. if m.FieldCleared(server.FieldDeletedAt) {
  25905. fields = append(fields, server.FieldDeletedAt)
  25906. }
  25907. return fields
  25908. }
  25909. // FieldCleared returns a boolean indicating if a field with the given name was
  25910. // cleared in this mutation.
  25911. func (m *ServerMutation) FieldCleared(name string) bool {
  25912. _, ok := m.clearedFields[name]
  25913. return ok
  25914. }
  25915. // ClearField clears the value of the field with the given name. It returns an
  25916. // error if the field is not defined in the schema.
  25917. func (m *ServerMutation) ClearField(name string) error {
  25918. switch name {
  25919. case server.FieldStatus:
  25920. m.ClearStatus()
  25921. return nil
  25922. case server.FieldDeletedAt:
  25923. m.ClearDeletedAt()
  25924. return nil
  25925. }
  25926. return fmt.Errorf("unknown Server nullable field %s", name)
  25927. }
  25928. // ResetField resets all changes in the mutation for the field with the given name.
  25929. // It returns an error if the field is not defined in the schema.
  25930. func (m *ServerMutation) ResetField(name string) error {
  25931. switch name {
  25932. case server.FieldCreatedAt:
  25933. m.ResetCreatedAt()
  25934. return nil
  25935. case server.FieldUpdatedAt:
  25936. m.ResetUpdatedAt()
  25937. return nil
  25938. case server.FieldStatus:
  25939. m.ResetStatus()
  25940. return nil
  25941. case server.FieldDeletedAt:
  25942. m.ResetDeletedAt()
  25943. return nil
  25944. case server.FieldName:
  25945. m.ResetName()
  25946. return nil
  25947. case server.FieldPublicIP:
  25948. m.ResetPublicIP()
  25949. return nil
  25950. case server.FieldPrivateIP:
  25951. m.ResetPrivateIP()
  25952. return nil
  25953. case server.FieldAdminPort:
  25954. m.ResetAdminPort()
  25955. return nil
  25956. }
  25957. return fmt.Errorf("unknown Server field %s", name)
  25958. }
  25959. // AddedEdges returns all edge names that were set/added in this mutation.
  25960. func (m *ServerMutation) AddedEdges() []string {
  25961. edges := make([]string, 0, 1)
  25962. if m.wxs != nil {
  25963. edges = append(edges, server.EdgeWxs)
  25964. }
  25965. return edges
  25966. }
  25967. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25968. // name in this mutation.
  25969. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  25970. switch name {
  25971. case server.EdgeWxs:
  25972. ids := make([]ent.Value, 0, len(m.wxs))
  25973. for id := range m.wxs {
  25974. ids = append(ids, id)
  25975. }
  25976. return ids
  25977. }
  25978. return nil
  25979. }
  25980. // RemovedEdges returns all edge names that were removed in this mutation.
  25981. func (m *ServerMutation) RemovedEdges() []string {
  25982. edges := make([]string, 0, 1)
  25983. if m.removedwxs != nil {
  25984. edges = append(edges, server.EdgeWxs)
  25985. }
  25986. return edges
  25987. }
  25988. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25989. // the given name in this mutation.
  25990. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  25991. switch name {
  25992. case server.EdgeWxs:
  25993. ids := make([]ent.Value, 0, len(m.removedwxs))
  25994. for id := range m.removedwxs {
  25995. ids = append(ids, id)
  25996. }
  25997. return ids
  25998. }
  25999. return nil
  26000. }
  26001. // ClearedEdges returns all edge names that were cleared in this mutation.
  26002. func (m *ServerMutation) ClearedEdges() []string {
  26003. edges := make([]string, 0, 1)
  26004. if m.clearedwxs {
  26005. edges = append(edges, server.EdgeWxs)
  26006. }
  26007. return edges
  26008. }
  26009. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26010. // was cleared in this mutation.
  26011. func (m *ServerMutation) EdgeCleared(name string) bool {
  26012. switch name {
  26013. case server.EdgeWxs:
  26014. return m.clearedwxs
  26015. }
  26016. return false
  26017. }
  26018. // ClearEdge clears the value of the edge with the given name. It returns an error
  26019. // if that edge is not defined in the schema.
  26020. func (m *ServerMutation) ClearEdge(name string) error {
  26021. switch name {
  26022. }
  26023. return fmt.Errorf("unknown Server unique edge %s", name)
  26024. }
  26025. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26026. // It returns an error if the edge is not defined in the schema.
  26027. func (m *ServerMutation) ResetEdge(name string) error {
  26028. switch name {
  26029. case server.EdgeWxs:
  26030. m.ResetWxs()
  26031. return nil
  26032. }
  26033. return fmt.Errorf("unknown Server edge %s", name)
  26034. }
  26035. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  26036. type SopNodeMutation struct {
  26037. config
  26038. op Op
  26039. typ string
  26040. id *uint64
  26041. created_at *time.Time
  26042. updated_at *time.Time
  26043. status *uint8
  26044. addstatus *int8
  26045. deleted_at *time.Time
  26046. parent_id *uint64
  26047. addparent_id *int64
  26048. name *string
  26049. condition_type *int
  26050. addcondition_type *int
  26051. condition_list *[]string
  26052. appendcondition_list []string
  26053. no_reply_condition *uint64
  26054. addno_reply_condition *int64
  26055. no_reply_unit *string
  26056. action_message *[]custom_types.Action
  26057. appendaction_message []custom_types.Action
  26058. action_label_add *[]uint64
  26059. appendaction_label_add []uint64
  26060. action_label_del *[]uint64
  26061. appendaction_label_del []uint64
  26062. action_forward **custom_types.ActionForward
  26063. clearedFields map[string]struct{}
  26064. sop_stage *uint64
  26065. clearedsop_stage bool
  26066. node_messages map[uint64]struct{}
  26067. removednode_messages map[uint64]struct{}
  26068. clearednode_messages bool
  26069. done bool
  26070. oldValue func(context.Context) (*SopNode, error)
  26071. predicates []predicate.SopNode
  26072. }
  26073. var _ ent.Mutation = (*SopNodeMutation)(nil)
  26074. // sopnodeOption allows management of the mutation configuration using functional options.
  26075. type sopnodeOption func(*SopNodeMutation)
  26076. // newSopNodeMutation creates new mutation for the SopNode entity.
  26077. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  26078. m := &SopNodeMutation{
  26079. config: c,
  26080. op: op,
  26081. typ: TypeSopNode,
  26082. clearedFields: make(map[string]struct{}),
  26083. }
  26084. for _, opt := range opts {
  26085. opt(m)
  26086. }
  26087. return m
  26088. }
  26089. // withSopNodeID sets the ID field of the mutation.
  26090. func withSopNodeID(id uint64) sopnodeOption {
  26091. return func(m *SopNodeMutation) {
  26092. var (
  26093. err error
  26094. once sync.Once
  26095. value *SopNode
  26096. )
  26097. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  26098. once.Do(func() {
  26099. if m.done {
  26100. err = errors.New("querying old values post mutation is not allowed")
  26101. } else {
  26102. value, err = m.Client().SopNode.Get(ctx, id)
  26103. }
  26104. })
  26105. return value, err
  26106. }
  26107. m.id = &id
  26108. }
  26109. }
  26110. // withSopNode sets the old SopNode of the mutation.
  26111. func withSopNode(node *SopNode) sopnodeOption {
  26112. return func(m *SopNodeMutation) {
  26113. m.oldValue = func(context.Context) (*SopNode, error) {
  26114. return node, nil
  26115. }
  26116. m.id = &node.ID
  26117. }
  26118. }
  26119. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26120. // executed in a transaction (ent.Tx), a transactional client is returned.
  26121. func (m SopNodeMutation) Client() *Client {
  26122. client := &Client{config: m.config}
  26123. client.init()
  26124. return client
  26125. }
  26126. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26127. // it returns an error otherwise.
  26128. func (m SopNodeMutation) Tx() (*Tx, error) {
  26129. if _, ok := m.driver.(*txDriver); !ok {
  26130. return nil, errors.New("ent: mutation is not running in a transaction")
  26131. }
  26132. tx := &Tx{config: m.config}
  26133. tx.init()
  26134. return tx, nil
  26135. }
  26136. // SetID sets the value of the id field. Note that this
  26137. // operation is only accepted on creation of SopNode entities.
  26138. func (m *SopNodeMutation) SetID(id uint64) {
  26139. m.id = &id
  26140. }
  26141. // ID returns the ID value in the mutation. Note that the ID is only available
  26142. // if it was provided to the builder or after it was returned from the database.
  26143. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  26144. if m.id == nil {
  26145. return
  26146. }
  26147. return *m.id, true
  26148. }
  26149. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26150. // That means, if the mutation is applied within a transaction with an isolation level such
  26151. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26152. // or updated by the mutation.
  26153. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26154. switch {
  26155. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26156. id, exists := m.ID()
  26157. if exists {
  26158. return []uint64{id}, nil
  26159. }
  26160. fallthrough
  26161. case m.op.Is(OpUpdate | OpDelete):
  26162. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  26163. default:
  26164. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26165. }
  26166. }
  26167. // SetCreatedAt sets the "created_at" field.
  26168. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  26169. m.created_at = &t
  26170. }
  26171. // CreatedAt returns the value of the "created_at" field in the mutation.
  26172. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  26173. v := m.created_at
  26174. if v == nil {
  26175. return
  26176. }
  26177. return *v, true
  26178. }
  26179. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  26180. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26182. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26183. if !m.op.Is(OpUpdateOne) {
  26184. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26185. }
  26186. if m.id == nil || m.oldValue == nil {
  26187. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26188. }
  26189. oldValue, err := m.oldValue(ctx)
  26190. if err != nil {
  26191. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26192. }
  26193. return oldValue.CreatedAt, nil
  26194. }
  26195. // ResetCreatedAt resets all changes to the "created_at" field.
  26196. func (m *SopNodeMutation) ResetCreatedAt() {
  26197. m.created_at = nil
  26198. }
  26199. // SetUpdatedAt sets the "updated_at" field.
  26200. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  26201. m.updated_at = &t
  26202. }
  26203. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26204. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  26205. v := m.updated_at
  26206. if v == nil {
  26207. return
  26208. }
  26209. return *v, true
  26210. }
  26211. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  26212. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26214. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26215. if !m.op.Is(OpUpdateOne) {
  26216. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26217. }
  26218. if m.id == nil || m.oldValue == nil {
  26219. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26220. }
  26221. oldValue, err := m.oldValue(ctx)
  26222. if err != nil {
  26223. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26224. }
  26225. return oldValue.UpdatedAt, nil
  26226. }
  26227. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26228. func (m *SopNodeMutation) ResetUpdatedAt() {
  26229. m.updated_at = nil
  26230. }
  26231. // SetStatus sets the "status" field.
  26232. func (m *SopNodeMutation) SetStatus(u uint8) {
  26233. m.status = &u
  26234. m.addstatus = nil
  26235. }
  26236. // Status returns the value of the "status" field in the mutation.
  26237. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  26238. v := m.status
  26239. if v == nil {
  26240. return
  26241. }
  26242. return *v, true
  26243. }
  26244. // OldStatus returns the old "status" field's value of the SopNode entity.
  26245. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26247. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26248. if !m.op.Is(OpUpdateOne) {
  26249. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26250. }
  26251. if m.id == nil || m.oldValue == nil {
  26252. return v, errors.New("OldStatus requires an ID field in the mutation")
  26253. }
  26254. oldValue, err := m.oldValue(ctx)
  26255. if err != nil {
  26256. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26257. }
  26258. return oldValue.Status, nil
  26259. }
  26260. // AddStatus adds u to the "status" field.
  26261. func (m *SopNodeMutation) AddStatus(u int8) {
  26262. if m.addstatus != nil {
  26263. *m.addstatus += u
  26264. } else {
  26265. m.addstatus = &u
  26266. }
  26267. }
  26268. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26269. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  26270. v := m.addstatus
  26271. if v == nil {
  26272. return
  26273. }
  26274. return *v, true
  26275. }
  26276. // ClearStatus clears the value of the "status" field.
  26277. func (m *SopNodeMutation) ClearStatus() {
  26278. m.status = nil
  26279. m.addstatus = nil
  26280. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  26281. }
  26282. // StatusCleared returns if the "status" field was cleared in this mutation.
  26283. func (m *SopNodeMutation) StatusCleared() bool {
  26284. _, ok := m.clearedFields[sopnode.FieldStatus]
  26285. return ok
  26286. }
  26287. // ResetStatus resets all changes to the "status" field.
  26288. func (m *SopNodeMutation) ResetStatus() {
  26289. m.status = nil
  26290. m.addstatus = nil
  26291. delete(m.clearedFields, sopnode.FieldStatus)
  26292. }
  26293. // SetDeletedAt sets the "deleted_at" field.
  26294. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  26295. m.deleted_at = &t
  26296. }
  26297. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26298. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  26299. v := m.deleted_at
  26300. if v == nil {
  26301. return
  26302. }
  26303. return *v, true
  26304. }
  26305. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  26306. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26308. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26309. if !m.op.Is(OpUpdateOne) {
  26310. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26311. }
  26312. if m.id == nil || m.oldValue == nil {
  26313. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26314. }
  26315. oldValue, err := m.oldValue(ctx)
  26316. if err != nil {
  26317. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26318. }
  26319. return oldValue.DeletedAt, nil
  26320. }
  26321. // ClearDeletedAt clears the value of the "deleted_at" field.
  26322. func (m *SopNodeMutation) ClearDeletedAt() {
  26323. m.deleted_at = nil
  26324. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  26325. }
  26326. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26327. func (m *SopNodeMutation) DeletedAtCleared() bool {
  26328. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  26329. return ok
  26330. }
  26331. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26332. func (m *SopNodeMutation) ResetDeletedAt() {
  26333. m.deleted_at = nil
  26334. delete(m.clearedFields, sopnode.FieldDeletedAt)
  26335. }
  26336. // SetStageID sets the "stage_id" field.
  26337. func (m *SopNodeMutation) SetStageID(u uint64) {
  26338. m.sop_stage = &u
  26339. }
  26340. // StageID returns the value of the "stage_id" field in the mutation.
  26341. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  26342. v := m.sop_stage
  26343. if v == nil {
  26344. return
  26345. }
  26346. return *v, true
  26347. }
  26348. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  26349. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26351. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  26352. if !m.op.Is(OpUpdateOne) {
  26353. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  26354. }
  26355. if m.id == nil || m.oldValue == nil {
  26356. return v, errors.New("OldStageID requires an ID field in the mutation")
  26357. }
  26358. oldValue, err := m.oldValue(ctx)
  26359. if err != nil {
  26360. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  26361. }
  26362. return oldValue.StageID, nil
  26363. }
  26364. // ResetStageID resets all changes to the "stage_id" field.
  26365. func (m *SopNodeMutation) ResetStageID() {
  26366. m.sop_stage = nil
  26367. }
  26368. // SetParentID sets the "parent_id" field.
  26369. func (m *SopNodeMutation) SetParentID(u uint64) {
  26370. m.parent_id = &u
  26371. m.addparent_id = nil
  26372. }
  26373. // ParentID returns the value of the "parent_id" field in the mutation.
  26374. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  26375. v := m.parent_id
  26376. if v == nil {
  26377. return
  26378. }
  26379. return *v, true
  26380. }
  26381. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  26382. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26384. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  26385. if !m.op.Is(OpUpdateOne) {
  26386. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  26387. }
  26388. if m.id == nil || m.oldValue == nil {
  26389. return v, errors.New("OldParentID requires an ID field in the mutation")
  26390. }
  26391. oldValue, err := m.oldValue(ctx)
  26392. if err != nil {
  26393. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  26394. }
  26395. return oldValue.ParentID, nil
  26396. }
  26397. // AddParentID adds u to the "parent_id" field.
  26398. func (m *SopNodeMutation) AddParentID(u int64) {
  26399. if m.addparent_id != nil {
  26400. *m.addparent_id += u
  26401. } else {
  26402. m.addparent_id = &u
  26403. }
  26404. }
  26405. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  26406. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  26407. v := m.addparent_id
  26408. if v == nil {
  26409. return
  26410. }
  26411. return *v, true
  26412. }
  26413. // ResetParentID resets all changes to the "parent_id" field.
  26414. func (m *SopNodeMutation) ResetParentID() {
  26415. m.parent_id = nil
  26416. m.addparent_id = nil
  26417. }
  26418. // SetName sets the "name" field.
  26419. func (m *SopNodeMutation) SetName(s string) {
  26420. m.name = &s
  26421. }
  26422. // Name returns the value of the "name" field in the mutation.
  26423. func (m *SopNodeMutation) Name() (r string, exists bool) {
  26424. v := m.name
  26425. if v == nil {
  26426. return
  26427. }
  26428. return *v, true
  26429. }
  26430. // OldName returns the old "name" field's value of the SopNode entity.
  26431. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26433. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  26434. if !m.op.Is(OpUpdateOne) {
  26435. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26436. }
  26437. if m.id == nil || m.oldValue == nil {
  26438. return v, errors.New("OldName requires an ID field in the mutation")
  26439. }
  26440. oldValue, err := m.oldValue(ctx)
  26441. if err != nil {
  26442. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26443. }
  26444. return oldValue.Name, nil
  26445. }
  26446. // ResetName resets all changes to the "name" field.
  26447. func (m *SopNodeMutation) ResetName() {
  26448. m.name = nil
  26449. }
  26450. // SetConditionType sets the "condition_type" field.
  26451. func (m *SopNodeMutation) SetConditionType(i int) {
  26452. m.condition_type = &i
  26453. m.addcondition_type = nil
  26454. }
  26455. // ConditionType returns the value of the "condition_type" field in the mutation.
  26456. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  26457. v := m.condition_type
  26458. if v == nil {
  26459. return
  26460. }
  26461. return *v, true
  26462. }
  26463. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  26464. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26466. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26467. if !m.op.Is(OpUpdateOne) {
  26468. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26469. }
  26470. if m.id == nil || m.oldValue == nil {
  26471. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26472. }
  26473. oldValue, err := m.oldValue(ctx)
  26474. if err != nil {
  26475. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26476. }
  26477. return oldValue.ConditionType, nil
  26478. }
  26479. // AddConditionType adds i to the "condition_type" field.
  26480. func (m *SopNodeMutation) AddConditionType(i int) {
  26481. if m.addcondition_type != nil {
  26482. *m.addcondition_type += i
  26483. } else {
  26484. m.addcondition_type = &i
  26485. }
  26486. }
  26487. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26488. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  26489. v := m.addcondition_type
  26490. if v == nil {
  26491. return
  26492. }
  26493. return *v, true
  26494. }
  26495. // ResetConditionType resets all changes to the "condition_type" field.
  26496. func (m *SopNodeMutation) ResetConditionType() {
  26497. m.condition_type = nil
  26498. m.addcondition_type = nil
  26499. }
  26500. // SetConditionList sets the "condition_list" field.
  26501. func (m *SopNodeMutation) SetConditionList(s []string) {
  26502. m.condition_list = &s
  26503. m.appendcondition_list = nil
  26504. }
  26505. // ConditionList returns the value of the "condition_list" field in the mutation.
  26506. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  26507. v := m.condition_list
  26508. if v == nil {
  26509. return
  26510. }
  26511. return *v, true
  26512. }
  26513. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  26514. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26516. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  26517. if !m.op.Is(OpUpdateOne) {
  26518. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  26519. }
  26520. if m.id == nil || m.oldValue == nil {
  26521. return v, errors.New("OldConditionList requires an ID field in the mutation")
  26522. }
  26523. oldValue, err := m.oldValue(ctx)
  26524. if err != nil {
  26525. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  26526. }
  26527. return oldValue.ConditionList, nil
  26528. }
  26529. // AppendConditionList adds s to the "condition_list" field.
  26530. func (m *SopNodeMutation) AppendConditionList(s []string) {
  26531. m.appendcondition_list = append(m.appendcondition_list, s...)
  26532. }
  26533. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  26534. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  26535. if len(m.appendcondition_list) == 0 {
  26536. return nil, false
  26537. }
  26538. return m.appendcondition_list, true
  26539. }
  26540. // ClearConditionList clears the value of the "condition_list" field.
  26541. func (m *SopNodeMutation) ClearConditionList() {
  26542. m.condition_list = nil
  26543. m.appendcondition_list = nil
  26544. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  26545. }
  26546. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  26547. func (m *SopNodeMutation) ConditionListCleared() bool {
  26548. _, ok := m.clearedFields[sopnode.FieldConditionList]
  26549. return ok
  26550. }
  26551. // ResetConditionList resets all changes to the "condition_list" field.
  26552. func (m *SopNodeMutation) ResetConditionList() {
  26553. m.condition_list = nil
  26554. m.appendcondition_list = nil
  26555. delete(m.clearedFields, sopnode.FieldConditionList)
  26556. }
  26557. // SetNoReplyCondition sets the "no_reply_condition" field.
  26558. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  26559. m.no_reply_condition = &u
  26560. m.addno_reply_condition = nil
  26561. }
  26562. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  26563. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  26564. v := m.no_reply_condition
  26565. if v == nil {
  26566. return
  26567. }
  26568. return *v, true
  26569. }
  26570. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  26571. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26573. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  26574. if !m.op.Is(OpUpdateOne) {
  26575. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  26576. }
  26577. if m.id == nil || m.oldValue == nil {
  26578. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  26579. }
  26580. oldValue, err := m.oldValue(ctx)
  26581. if err != nil {
  26582. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  26583. }
  26584. return oldValue.NoReplyCondition, nil
  26585. }
  26586. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  26587. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  26588. if m.addno_reply_condition != nil {
  26589. *m.addno_reply_condition += u
  26590. } else {
  26591. m.addno_reply_condition = &u
  26592. }
  26593. }
  26594. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  26595. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  26596. v := m.addno_reply_condition
  26597. if v == nil {
  26598. return
  26599. }
  26600. return *v, true
  26601. }
  26602. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  26603. func (m *SopNodeMutation) ResetNoReplyCondition() {
  26604. m.no_reply_condition = nil
  26605. m.addno_reply_condition = nil
  26606. }
  26607. // SetNoReplyUnit sets the "no_reply_unit" field.
  26608. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  26609. m.no_reply_unit = &s
  26610. }
  26611. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  26612. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  26613. v := m.no_reply_unit
  26614. if v == nil {
  26615. return
  26616. }
  26617. return *v, true
  26618. }
  26619. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  26620. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26622. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  26623. if !m.op.Is(OpUpdateOne) {
  26624. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  26625. }
  26626. if m.id == nil || m.oldValue == nil {
  26627. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  26628. }
  26629. oldValue, err := m.oldValue(ctx)
  26630. if err != nil {
  26631. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  26632. }
  26633. return oldValue.NoReplyUnit, nil
  26634. }
  26635. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  26636. func (m *SopNodeMutation) ResetNoReplyUnit() {
  26637. m.no_reply_unit = nil
  26638. }
  26639. // SetActionMessage sets the "action_message" field.
  26640. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  26641. m.action_message = &ct
  26642. m.appendaction_message = nil
  26643. }
  26644. // ActionMessage returns the value of the "action_message" field in the mutation.
  26645. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  26646. v := m.action_message
  26647. if v == nil {
  26648. return
  26649. }
  26650. return *v, true
  26651. }
  26652. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  26653. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26655. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  26656. if !m.op.Is(OpUpdateOne) {
  26657. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  26658. }
  26659. if m.id == nil || m.oldValue == nil {
  26660. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  26661. }
  26662. oldValue, err := m.oldValue(ctx)
  26663. if err != nil {
  26664. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  26665. }
  26666. return oldValue.ActionMessage, nil
  26667. }
  26668. // AppendActionMessage adds ct to the "action_message" field.
  26669. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  26670. m.appendaction_message = append(m.appendaction_message, ct...)
  26671. }
  26672. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  26673. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  26674. if len(m.appendaction_message) == 0 {
  26675. return nil, false
  26676. }
  26677. return m.appendaction_message, true
  26678. }
  26679. // ClearActionMessage clears the value of the "action_message" field.
  26680. func (m *SopNodeMutation) ClearActionMessage() {
  26681. m.action_message = nil
  26682. m.appendaction_message = nil
  26683. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  26684. }
  26685. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  26686. func (m *SopNodeMutation) ActionMessageCleared() bool {
  26687. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  26688. return ok
  26689. }
  26690. // ResetActionMessage resets all changes to the "action_message" field.
  26691. func (m *SopNodeMutation) ResetActionMessage() {
  26692. m.action_message = nil
  26693. m.appendaction_message = nil
  26694. delete(m.clearedFields, sopnode.FieldActionMessage)
  26695. }
  26696. // SetActionLabelAdd sets the "action_label_add" field.
  26697. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  26698. m.action_label_add = &u
  26699. m.appendaction_label_add = nil
  26700. }
  26701. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  26702. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  26703. v := m.action_label_add
  26704. if v == nil {
  26705. return
  26706. }
  26707. return *v, true
  26708. }
  26709. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  26710. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26712. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  26713. if !m.op.Is(OpUpdateOne) {
  26714. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  26715. }
  26716. if m.id == nil || m.oldValue == nil {
  26717. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  26718. }
  26719. oldValue, err := m.oldValue(ctx)
  26720. if err != nil {
  26721. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  26722. }
  26723. return oldValue.ActionLabelAdd, nil
  26724. }
  26725. // AppendActionLabelAdd adds u to the "action_label_add" field.
  26726. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  26727. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  26728. }
  26729. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  26730. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  26731. if len(m.appendaction_label_add) == 0 {
  26732. return nil, false
  26733. }
  26734. return m.appendaction_label_add, true
  26735. }
  26736. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  26737. func (m *SopNodeMutation) ClearActionLabelAdd() {
  26738. m.action_label_add = nil
  26739. m.appendaction_label_add = nil
  26740. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  26741. }
  26742. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  26743. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  26744. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  26745. return ok
  26746. }
  26747. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  26748. func (m *SopNodeMutation) ResetActionLabelAdd() {
  26749. m.action_label_add = nil
  26750. m.appendaction_label_add = nil
  26751. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  26752. }
  26753. // SetActionLabelDel sets the "action_label_del" field.
  26754. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  26755. m.action_label_del = &u
  26756. m.appendaction_label_del = nil
  26757. }
  26758. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  26759. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  26760. v := m.action_label_del
  26761. if v == nil {
  26762. return
  26763. }
  26764. return *v, true
  26765. }
  26766. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  26767. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26769. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  26770. if !m.op.Is(OpUpdateOne) {
  26771. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  26772. }
  26773. if m.id == nil || m.oldValue == nil {
  26774. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  26775. }
  26776. oldValue, err := m.oldValue(ctx)
  26777. if err != nil {
  26778. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  26779. }
  26780. return oldValue.ActionLabelDel, nil
  26781. }
  26782. // AppendActionLabelDel adds u to the "action_label_del" field.
  26783. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  26784. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  26785. }
  26786. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  26787. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  26788. if len(m.appendaction_label_del) == 0 {
  26789. return nil, false
  26790. }
  26791. return m.appendaction_label_del, true
  26792. }
  26793. // ClearActionLabelDel clears the value of the "action_label_del" field.
  26794. func (m *SopNodeMutation) ClearActionLabelDel() {
  26795. m.action_label_del = nil
  26796. m.appendaction_label_del = nil
  26797. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  26798. }
  26799. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  26800. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  26801. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  26802. return ok
  26803. }
  26804. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  26805. func (m *SopNodeMutation) ResetActionLabelDel() {
  26806. m.action_label_del = nil
  26807. m.appendaction_label_del = nil
  26808. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  26809. }
  26810. // SetActionForward sets the "action_forward" field.
  26811. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  26812. m.action_forward = &ctf
  26813. }
  26814. // ActionForward returns the value of the "action_forward" field in the mutation.
  26815. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  26816. v := m.action_forward
  26817. if v == nil {
  26818. return
  26819. }
  26820. return *v, true
  26821. }
  26822. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  26823. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26825. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  26826. if !m.op.Is(OpUpdateOne) {
  26827. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  26828. }
  26829. if m.id == nil || m.oldValue == nil {
  26830. return v, errors.New("OldActionForward requires an ID field in the mutation")
  26831. }
  26832. oldValue, err := m.oldValue(ctx)
  26833. if err != nil {
  26834. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  26835. }
  26836. return oldValue.ActionForward, nil
  26837. }
  26838. // ClearActionForward clears the value of the "action_forward" field.
  26839. func (m *SopNodeMutation) ClearActionForward() {
  26840. m.action_forward = nil
  26841. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  26842. }
  26843. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  26844. func (m *SopNodeMutation) ActionForwardCleared() bool {
  26845. _, ok := m.clearedFields[sopnode.FieldActionForward]
  26846. return ok
  26847. }
  26848. // ResetActionForward resets all changes to the "action_forward" field.
  26849. func (m *SopNodeMutation) ResetActionForward() {
  26850. m.action_forward = nil
  26851. delete(m.clearedFields, sopnode.FieldActionForward)
  26852. }
  26853. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  26854. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  26855. m.sop_stage = &id
  26856. }
  26857. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  26858. func (m *SopNodeMutation) ClearSopStage() {
  26859. m.clearedsop_stage = true
  26860. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  26861. }
  26862. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  26863. func (m *SopNodeMutation) SopStageCleared() bool {
  26864. return m.clearedsop_stage
  26865. }
  26866. // SopStageID returns the "sop_stage" edge ID in the mutation.
  26867. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  26868. if m.sop_stage != nil {
  26869. return *m.sop_stage, true
  26870. }
  26871. return
  26872. }
  26873. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  26874. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26875. // SopStageID instead. It exists only for internal usage by the builders.
  26876. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  26877. if id := m.sop_stage; id != nil {
  26878. ids = append(ids, *id)
  26879. }
  26880. return
  26881. }
  26882. // ResetSopStage resets all changes to the "sop_stage" edge.
  26883. func (m *SopNodeMutation) ResetSopStage() {
  26884. m.sop_stage = nil
  26885. m.clearedsop_stage = false
  26886. }
  26887. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  26888. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  26889. if m.node_messages == nil {
  26890. m.node_messages = make(map[uint64]struct{})
  26891. }
  26892. for i := range ids {
  26893. m.node_messages[ids[i]] = struct{}{}
  26894. }
  26895. }
  26896. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  26897. func (m *SopNodeMutation) ClearNodeMessages() {
  26898. m.clearednode_messages = true
  26899. }
  26900. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  26901. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  26902. return m.clearednode_messages
  26903. }
  26904. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  26905. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  26906. if m.removednode_messages == nil {
  26907. m.removednode_messages = make(map[uint64]struct{})
  26908. }
  26909. for i := range ids {
  26910. delete(m.node_messages, ids[i])
  26911. m.removednode_messages[ids[i]] = struct{}{}
  26912. }
  26913. }
  26914. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  26915. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  26916. for id := range m.removednode_messages {
  26917. ids = append(ids, id)
  26918. }
  26919. return
  26920. }
  26921. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  26922. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  26923. for id := range m.node_messages {
  26924. ids = append(ids, id)
  26925. }
  26926. return
  26927. }
  26928. // ResetNodeMessages resets all changes to the "node_messages" edge.
  26929. func (m *SopNodeMutation) ResetNodeMessages() {
  26930. m.node_messages = nil
  26931. m.clearednode_messages = false
  26932. m.removednode_messages = nil
  26933. }
  26934. // Where appends a list predicates to the SopNodeMutation builder.
  26935. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  26936. m.predicates = append(m.predicates, ps...)
  26937. }
  26938. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  26939. // users can use type-assertion to append predicates that do not depend on any generated package.
  26940. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  26941. p := make([]predicate.SopNode, len(ps))
  26942. for i := range ps {
  26943. p[i] = ps[i]
  26944. }
  26945. m.Where(p...)
  26946. }
  26947. // Op returns the operation name.
  26948. func (m *SopNodeMutation) Op() Op {
  26949. return m.op
  26950. }
  26951. // SetOp allows setting the mutation operation.
  26952. func (m *SopNodeMutation) SetOp(op Op) {
  26953. m.op = op
  26954. }
  26955. // Type returns the node type of this mutation (SopNode).
  26956. func (m *SopNodeMutation) Type() string {
  26957. return m.typ
  26958. }
  26959. // Fields returns all fields that were changed during this mutation. Note that in
  26960. // order to get all numeric fields that were incremented/decremented, call
  26961. // AddedFields().
  26962. func (m *SopNodeMutation) Fields() []string {
  26963. fields := make([]string, 0, 15)
  26964. if m.created_at != nil {
  26965. fields = append(fields, sopnode.FieldCreatedAt)
  26966. }
  26967. if m.updated_at != nil {
  26968. fields = append(fields, sopnode.FieldUpdatedAt)
  26969. }
  26970. if m.status != nil {
  26971. fields = append(fields, sopnode.FieldStatus)
  26972. }
  26973. if m.deleted_at != nil {
  26974. fields = append(fields, sopnode.FieldDeletedAt)
  26975. }
  26976. if m.sop_stage != nil {
  26977. fields = append(fields, sopnode.FieldStageID)
  26978. }
  26979. if m.parent_id != nil {
  26980. fields = append(fields, sopnode.FieldParentID)
  26981. }
  26982. if m.name != nil {
  26983. fields = append(fields, sopnode.FieldName)
  26984. }
  26985. if m.condition_type != nil {
  26986. fields = append(fields, sopnode.FieldConditionType)
  26987. }
  26988. if m.condition_list != nil {
  26989. fields = append(fields, sopnode.FieldConditionList)
  26990. }
  26991. if m.no_reply_condition != nil {
  26992. fields = append(fields, sopnode.FieldNoReplyCondition)
  26993. }
  26994. if m.no_reply_unit != nil {
  26995. fields = append(fields, sopnode.FieldNoReplyUnit)
  26996. }
  26997. if m.action_message != nil {
  26998. fields = append(fields, sopnode.FieldActionMessage)
  26999. }
  27000. if m.action_label_add != nil {
  27001. fields = append(fields, sopnode.FieldActionLabelAdd)
  27002. }
  27003. if m.action_label_del != nil {
  27004. fields = append(fields, sopnode.FieldActionLabelDel)
  27005. }
  27006. if m.action_forward != nil {
  27007. fields = append(fields, sopnode.FieldActionForward)
  27008. }
  27009. return fields
  27010. }
  27011. // Field returns the value of a field with the given name. The second boolean
  27012. // return value indicates that this field was not set, or was not defined in the
  27013. // schema.
  27014. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  27015. switch name {
  27016. case sopnode.FieldCreatedAt:
  27017. return m.CreatedAt()
  27018. case sopnode.FieldUpdatedAt:
  27019. return m.UpdatedAt()
  27020. case sopnode.FieldStatus:
  27021. return m.Status()
  27022. case sopnode.FieldDeletedAt:
  27023. return m.DeletedAt()
  27024. case sopnode.FieldStageID:
  27025. return m.StageID()
  27026. case sopnode.FieldParentID:
  27027. return m.ParentID()
  27028. case sopnode.FieldName:
  27029. return m.Name()
  27030. case sopnode.FieldConditionType:
  27031. return m.ConditionType()
  27032. case sopnode.FieldConditionList:
  27033. return m.ConditionList()
  27034. case sopnode.FieldNoReplyCondition:
  27035. return m.NoReplyCondition()
  27036. case sopnode.FieldNoReplyUnit:
  27037. return m.NoReplyUnit()
  27038. case sopnode.FieldActionMessage:
  27039. return m.ActionMessage()
  27040. case sopnode.FieldActionLabelAdd:
  27041. return m.ActionLabelAdd()
  27042. case sopnode.FieldActionLabelDel:
  27043. return m.ActionLabelDel()
  27044. case sopnode.FieldActionForward:
  27045. return m.ActionForward()
  27046. }
  27047. return nil, false
  27048. }
  27049. // OldField returns the old value of the field from the database. An error is
  27050. // returned if the mutation operation is not UpdateOne, or the query to the
  27051. // database failed.
  27052. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27053. switch name {
  27054. case sopnode.FieldCreatedAt:
  27055. return m.OldCreatedAt(ctx)
  27056. case sopnode.FieldUpdatedAt:
  27057. return m.OldUpdatedAt(ctx)
  27058. case sopnode.FieldStatus:
  27059. return m.OldStatus(ctx)
  27060. case sopnode.FieldDeletedAt:
  27061. return m.OldDeletedAt(ctx)
  27062. case sopnode.FieldStageID:
  27063. return m.OldStageID(ctx)
  27064. case sopnode.FieldParentID:
  27065. return m.OldParentID(ctx)
  27066. case sopnode.FieldName:
  27067. return m.OldName(ctx)
  27068. case sopnode.FieldConditionType:
  27069. return m.OldConditionType(ctx)
  27070. case sopnode.FieldConditionList:
  27071. return m.OldConditionList(ctx)
  27072. case sopnode.FieldNoReplyCondition:
  27073. return m.OldNoReplyCondition(ctx)
  27074. case sopnode.FieldNoReplyUnit:
  27075. return m.OldNoReplyUnit(ctx)
  27076. case sopnode.FieldActionMessage:
  27077. return m.OldActionMessage(ctx)
  27078. case sopnode.FieldActionLabelAdd:
  27079. return m.OldActionLabelAdd(ctx)
  27080. case sopnode.FieldActionLabelDel:
  27081. return m.OldActionLabelDel(ctx)
  27082. case sopnode.FieldActionForward:
  27083. return m.OldActionForward(ctx)
  27084. }
  27085. return nil, fmt.Errorf("unknown SopNode field %s", name)
  27086. }
  27087. // SetField sets the value of a field with the given name. It returns an error if
  27088. // the field is not defined in the schema, or if the type mismatched the field
  27089. // type.
  27090. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  27091. switch name {
  27092. case sopnode.FieldCreatedAt:
  27093. v, ok := value.(time.Time)
  27094. if !ok {
  27095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27096. }
  27097. m.SetCreatedAt(v)
  27098. return nil
  27099. case sopnode.FieldUpdatedAt:
  27100. v, ok := value.(time.Time)
  27101. if !ok {
  27102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27103. }
  27104. m.SetUpdatedAt(v)
  27105. return nil
  27106. case sopnode.FieldStatus:
  27107. v, ok := value.(uint8)
  27108. if !ok {
  27109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27110. }
  27111. m.SetStatus(v)
  27112. return nil
  27113. case sopnode.FieldDeletedAt:
  27114. v, ok := value.(time.Time)
  27115. if !ok {
  27116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27117. }
  27118. m.SetDeletedAt(v)
  27119. return nil
  27120. case sopnode.FieldStageID:
  27121. v, ok := value.(uint64)
  27122. if !ok {
  27123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27124. }
  27125. m.SetStageID(v)
  27126. return nil
  27127. case sopnode.FieldParentID:
  27128. v, ok := value.(uint64)
  27129. if !ok {
  27130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27131. }
  27132. m.SetParentID(v)
  27133. return nil
  27134. case sopnode.FieldName:
  27135. v, ok := value.(string)
  27136. if !ok {
  27137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27138. }
  27139. m.SetName(v)
  27140. return nil
  27141. case sopnode.FieldConditionType:
  27142. v, ok := value.(int)
  27143. if !ok {
  27144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27145. }
  27146. m.SetConditionType(v)
  27147. return nil
  27148. case sopnode.FieldConditionList:
  27149. v, ok := value.([]string)
  27150. if !ok {
  27151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27152. }
  27153. m.SetConditionList(v)
  27154. return nil
  27155. case sopnode.FieldNoReplyCondition:
  27156. v, ok := value.(uint64)
  27157. if !ok {
  27158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27159. }
  27160. m.SetNoReplyCondition(v)
  27161. return nil
  27162. case sopnode.FieldNoReplyUnit:
  27163. v, ok := value.(string)
  27164. if !ok {
  27165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27166. }
  27167. m.SetNoReplyUnit(v)
  27168. return nil
  27169. case sopnode.FieldActionMessage:
  27170. v, ok := value.([]custom_types.Action)
  27171. if !ok {
  27172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27173. }
  27174. m.SetActionMessage(v)
  27175. return nil
  27176. case sopnode.FieldActionLabelAdd:
  27177. v, ok := value.([]uint64)
  27178. if !ok {
  27179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27180. }
  27181. m.SetActionLabelAdd(v)
  27182. return nil
  27183. case sopnode.FieldActionLabelDel:
  27184. v, ok := value.([]uint64)
  27185. if !ok {
  27186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27187. }
  27188. m.SetActionLabelDel(v)
  27189. return nil
  27190. case sopnode.FieldActionForward:
  27191. v, ok := value.(*custom_types.ActionForward)
  27192. if !ok {
  27193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27194. }
  27195. m.SetActionForward(v)
  27196. return nil
  27197. }
  27198. return fmt.Errorf("unknown SopNode field %s", name)
  27199. }
  27200. // AddedFields returns all numeric fields that were incremented/decremented during
  27201. // this mutation.
  27202. func (m *SopNodeMutation) AddedFields() []string {
  27203. var fields []string
  27204. if m.addstatus != nil {
  27205. fields = append(fields, sopnode.FieldStatus)
  27206. }
  27207. if m.addparent_id != nil {
  27208. fields = append(fields, sopnode.FieldParentID)
  27209. }
  27210. if m.addcondition_type != nil {
  27211. fields = append(fields, sopnode.FieldConditionType)
  27212. }
  27213. if m.addno_reply_condition != nil {
  27214. fields = append(fields, sopnode.FieldNoReplyCondition)
  27215. }
  27216. return fields
  27217. }
  27218. // AddedField returns the numeric value that was incremented/decremented on a field
  27219. // with the given name. The second boolean return value indicates that this field
  27220. // was not set, or was not defined in the schema.
  27221. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  27222. switch name {
  27223. case sopnode.FieldStatus:
  27224. return m.AddedStatus()
  27225. case sopnode.FieldParentID:
  27226. return m.AddedParentID()
  27227. case sopnode.FieldConditionType:
  27228. return m.AddedConditionType()
  27229. case sopnode.FieldNoReplyCondition:
  27230. return m.AddedNoReplyCondition()
  27231. }
  27232. return nil, false
  27233. }
  27234. // AddField adds the value to the field with the given name. It returns an error if
  27235. // the field is not defined in the schema, or if the type mismatched the field
  27236. // type.
  27237. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  27238. switch name {
  27239. case sopnode.FieldStatus:
  27240. v, ok := value.(int8)
  27241. if !ok {
  27242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27243. }
  27244. m.AddStatus(v)
  27245. return nil
  27246. case sopnode.FieldParentID:
  27247. v, ok := value.(int64)
  27248. if !ok {
  27249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27250. }
  27251. m.AddParentID(v)
  27252. return nil
  27253. case sopnode.FieldConditionType:
  27254. v, ok := value.(int)
  27255. if !ok {
  27256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27257. }
  27258. m.AddConditionType(v)
  27259. return nil
  27260. case sopnode.FieldNoReplyCondition:
  27261. v, ok := value.(int64)
  27262. if !ok {
  27263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27264. }
  27265. m.AddNoReplyCondition(v)
  27266. return nil
  27267. }
  27268. return fmt.Errorf("unknown SopNode numeric field %s", name)
  27269. }
  27270. // ClearedFields returns all nullable fields that were cleared during this
  27271. // mutation.
  27272. func (m *SopNodeMutation) ClearedFields() []string {
  27273. var fields []string
  27274. if m.FieldCleared(sopnode.FieldStatus) {
  27275. fields = append(fields, sopnode.FieldStatus)
  27276. }
  27277. if m.FieldCleared(sopnode.FieldDeletedAt) {
  27278. fields = append(fields, sopnode.FieldDeletedAt)
  27279. }
  27280. if m.FieldCleared(sopnode.FieldConditionList) {
  27281. fields = append(fields, sopnode.FieldConditionList)
  27282. }
  27283. if m.FieldCleared(sopnode.FieldActionMessage) {
  27284. fields = append(fields, sopnode.FieldActionMessage)
  27285. }
  27286. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  27287. fields = append(fields, sopnode.FieldActionLabelAdd)
  27288. }
  27289. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  27290. fields = append(fields, sopnode.FieldActionLabelDel)
  27291. }
  27292. if m.FieldCleared(sopnode.FieldActionForward) {
  27293. fields = append(fields, sopnode.FieldActionForward)
  27294. }
  27295. return fields
  27296. }
  27297. // FieldCleared returns a boolean indicating if a field with the given name was
  27298. // cleared in this mutation.
  27299. func (m *SopNodeMutation) FieldCleared(name string) bool {
  27300. _, ok := m.clearedFields[name]
  27301. return ok
  27302. }
  27303. // ClearField clears the value of the field with the given name. It returns an
  27304. // error if the field is not defined in the schema.
  27305. func (m *SopNodeMutation) ClearField(name string) error {
  27306. switch name {
  27307. case sopnode.FieldStatus:
  27308. m.ClearStatus()
  27309. return nil
  27310. case sopnode.FieldDeletedAt:
  27311. m.ClearDeletedAt()
  27312. return nil
  27313. case sopnode.FieldConditionList:
  27314. m.ClearConditionList()
  27315. return nil
  27316. case sopnode.FieldActionMessage:
  27317. m.ClearActionMessage()
  27318. return nil
  27319. case sopnode.FieldActionLabelAdd:
  27320. m.ClearActionLabelAdd()
  27321. return nil
  27322. case sopnode.FieldActionLabelDel:
  27323. m.ClearActionLabelDel()
  27324. return nil
  27325. case sopnode.FieldActionForward:
  27326. m.ClearActionForward()
  27327. return nil
  27328. }
  27329. return fmt.Errorf("unknown SopNode nullable field %s", name)
  27330. }
  27331. // ResetField resets all changes in the mutation for the field with the given name.
  27332. // It returns an error if the field is not defined in the schema.
  27333. func (m *SopNodeMutation) ResetField(name string) error {
  27334. switch name {
  27335. case sopnode.FieldCreatedAt:
  27336. m.ResetCreatedAt()
  27337. return nil
  27338. case sopnode.FieldUpdatedAt:
  27339. m.ResetUpdatedAt()
  27340. return nil
  27341. case sopnode.FieldStatus:
  27342. m.ResetStatus()
  27343. return nil
  27344. case sopnode.FieldDeletedAt:
  27345. m.ResetDeletedAt()
  27346. return nil
  27347. case sopnode.FieldStageID:
  27348. m.ResetStageID()
  27349. return nil
  27350. case sopnode.FieldParentID:
  27351. m.ResetParentID()
  27352. return nil
  27353. case sopnode.FieldName:
  27354. m.ResetName()
  27355. return nil
  27356. case sopnode.FieldConditionType:
  27357. m.ResetConditionType()
  27358. return nil
  27359. case sopnode.FieldConditionList:
  27360. m.ResetConditionList()
  27361. return nil
  27362. case sopnode.FieldNoReplyCondition:
  27363. m.ResetNoReplyCondition()
  27364. return nil
  27365. case sopnode.FieldNoReplyUnit:
  27366. m.ResetNoReplyUnit()
  27367. return nil
  27368. case sopnode.FieldActionMessage:
  27369. m.ResetActionMessage()
  27370. return nil
  27371. case sopnode.FieldActionLabelAdd:
  27372. m.ResetActionLabelAdd()
  27373. return nil
  27374. case sopnode.FieldActionLabelDel:
  27375. m.ResetActionLabelDel()
  27376. return nil
  27377. case sopnode.FieldActionForward:
  27378. m.ResetActionForward()
  27379. return nil
  27380. }
  27381. return fmt.Errorf("unknown SopNode field %s", name)
  27382. }
  27383. // AddedEdges returns all edge names that were set/added in this mutation.
  27384. func (m *SopNodeMutation) AddedEdges() []string {
  27385. edges := make([]string, 0, 2)
  27386. if m.sop_stage != nil {
  27387. edges = append(edges, sopnode.EdgeSopStage)
  27388. }
  27389. if m.node_messages != nil {
  27390. edges = append(edges, sopnode.EdgeNodeMessages)
  27391. }
  27392. return edges
  27393. }
  27394. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27395. // name in this mutation.
  27396. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  27397. switch name {
  27398. case sopnode.EdgeSopStage:
  27399. if id := m.sop_stage; id != nil {
  27400. return []ent.Value{*id}
  27401. }
  27402. case sopnode.EdgeNodeMessages:
  27403. ids := make([]ent.Value, 0, len(m.node_messages))
  27404. for id := range m.node_messages {
  27405. ids = append(ids, id)
  27406. }
  27407. return ids
  27408. }
  27409. return nil
  27410. }
  27411. // RemovedEdges returns all edge names that were removed in this mutation.
  27412. func (m *SopNodeMutation) RemovedEdges() []string {
  27413. edges := make([]string, 0, 2)
  27414. if m.removednode_messages != nil {
  27415. edges = append(edges, sopnode.EdgeNodeMessages)
  27416. }
  27417. return edges
  27418. }
  27419. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27420. // the given name in this mutation.
  27421. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  27422. switch name {
  27423. case sopnode.EdgeNodeMessages:
  27424. ids := make([]ent.Value, 0, len(m.removednode_messages))
  27425. for id := range m.removednode_messages {
  27426. ids = append(ids, id)
  27427. }
  27428. return ids
  27429. }
  27430. return nil
  27431. }
  27432. // ClearedEdges returns all edge names that were cleared in this mutation.
  27433. func (m *SopNodeMutation) ClearedEdges() []string {
  27434. edges := make([]string, 0, 2)
  27435. if m.clearedsop_stage {
  27436. edges = append(edges, sopnode.EdgeSopStage)
  27437. }
  27438. if m.clearednode_messages {
  27439. edges = append(edges, sopnode.EdgeNodeMessages)
  27440. }
  27441. return edges
  27442. }
  27443. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27444. // was cleared in this mutation.
  27445. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  27446. switch name {
  27447. case sopnode.EdgeSopStage:
  27448. return m.clearedsop_stage
  27449. case sopnode.EdgeNodeMessages:
  27450. return m.clearednode_messages
  27451. }
  27452. return false
  27453. }
  27454. // ClearEdge clears the value of the edge with the given name. It returns an error
  27455. // if that edge is not defined in the schema.
  27456. func (m *SopNodeMutation) ClearEdge(name string) error {
  27457. switch name {
  27458. case sopnode.EdgeSopStage:
  27459. m.ClearSopStage()
  27460. return nil
  27461. }
  27462. return fmt.Errorf("unknown SopNode unique edge %s", name)
  27463. }
  27464. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27465. // It returns an error if the edge is not defined in the schema.
  27466. func (m *SopNodeMutation) ResetEdge(name string) error {
  27467. switch name {
  27468. case sopnode.EdgeSopStage:
  27469. m.ResetSopStage()
  27470. return nil
  27471. case sopnode.EdgeNodeMessages:
  27472. m.ResetNodeMessages()
  27473. return nil
  27474. }
  27475. return fmt.Errorf("unknown SopNode edge %s", name)
  27476. }
  27477. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  27478. type SopStageMutation struct {
  27479. config
  27480. op Op
  27481. typ string
  27482. id *uint64
  27483. created_at *time.Time
  27484. updated_at *time.Time
  27485. status *uint8
  27486. addstatus *int8
  27487. deleted_at *time.Time
  27488. name *string
  27489. condition_type *int
  27490. addcondition_type *int
  27491. condition_operator *int
  27492. addcondition_operator *int
  27493. condition_list *[]custom_types.Condition
  27494. appendcondition_list []custom_types.Condition
  27495. action_message *[]custom_types.Action
  27496. appendaction_message []custom_types.Action
  27497. action_label_add *[]uint64
  27498. appendaction_label_add []uint64
  27499. action_label_del *[]uint64
  27500. appendaction_label_del []uint64
  27501. action_forward **custom_types.ActionForward
  27502. index_sort *int
  27503. addindex_sort *int
  27504. clearedFields map[string]struct{}
  27505. sop_task *uint64
  27506. clearedsop_task bool
  27507. stage_nodes map[uint64]struct{}
  27508. removedstage_nodes map[uint64]struct{}
  27509. clearedstage_nodes bool
  27510. stage_messages map[uint64]struct{}
  27511. removedstage_messages map[uint64]struct{}
  27512. clearedstage_messages bool
  27513. done bool
  27514. oldValue func(context.Context) (*SopStage, error)
  27515. predicates []predicate.SopStage
  27516. }
  27517. var _ ent.Mutation = (*SopStageMutation)(nil)
  27518. // sopstageOption allows management of the mutation configuration using functional options.
  27519. type sopstageOption func(*SopStageMutation)
  27520. // newSopStageMutation creates new mutation for the SopStage entity.
  27521. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  27522. m := &SopStageMutation{
  27523. config: c,
  27524. op: op,
  27525. typ: TypeSopStage,
  27526. clearedFields: make(map[string]struct{}),
  27527. }
  27528. for _, opt := range opts {
  27529. opt(m)
  27530. }
  27531. return m
  27532. }
  27533. // withSopStageID sets the ID field of the mutation.
  27534. func withSopStageID(id uint64) sopstageOption {
  27535. return func(m *SopStageMutation) {
  27536. var (
  27537. err error
  27538. once sync.Once
  27539. value *SopStage
  27540. )
  27541. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  27542. once.Do(func() {
  27543. if m.done {
  27544. err = errors.New("querying old values post mutation is not allowed")
  27545. } else {
  27546. value, err = m.Client().SopStage.Get(ctx, id)
  27547. }
  27548. })
  27549. return value, err
  27550. }
  27551. m.id = &id
  27552. }
  27553. }
  27554. // withSopStage sets the old SopStage of the mutation.
  27555. func withSopStage(node *SopStage) sopstageOption {
  27556. return func(m *SopStageMutation) {
  27557. m.oldValue = func(context.Context) (*SopStage, error) {
  27558. return node, nil
  27559. }
  27560. m.id = &node.ID
  27561. }
  27562. }
  27563. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27564. // executed in a transaction (ent.Tx), a transactional client is returned.
  27565. func (m SopStageMutation) Client() *Client {
  27566. client := &Client{config: m.config}
  27567. client.init()
  27568. return client
  27569. }
  27570. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27571. // it returns an error otherwise.
  27572. func (m SopStageMutation) Tx() (*Tx, error) {
  27573. if _, ok := m.driver.(*txDriver); !ok {
  27574. return nil, errors.New("ent: mutation is not running in a transaction")
  27575. }
  27576. tx := &Tx{config: m.config}
  27577. tx.init()
  27578. return tx, nil
  27579. }
  27580. // SetID sets the value of the id field. Note that this
  27581. // operation is only accepted on creation of SopStage entities.
  27582. func (m *SopStageMutation) SetID(id uint64) {
  27583. m.id = &id
  27584. }
  27585. // ID returns the ID value in the mutation. Note that the ID is only available
  27586. // if it was provided to the builder or after it was returned from the database.
  27587. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  27588. if m.id == nil {
  27589. return
  27590. }
  27591. return *m.id, true
  27592. }
  27593. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27594. // That means, if the mutation is applied within a transaction with an isolation level such
  27595. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27596. // or updated by the mutation.
  27597. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  27598. switch {
  27599. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27600. id, exists := m.ID()
  27601. if exists {
  27602. return []uint64{id}, nil
  27603. }
  27604. fallthrough
  27605. case m.op.Is(OpUpdate | OpDelete):
  27606. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  27607. default:
  27608. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27609. }
  27610. }
  27611. // SetCreatedAt sets the "created_at" field.
  27612. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  27613. m.created_at = &t
  27614. }
  27615. // CreatedAt returns the value of the "created_at" field in the mutation.
  27616. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  27617. v := m.created_at
  27618. if v == nil {
  27619. return
  27620. }
  27621. return *v, true
  27622. }
  27623. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  27624. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27626. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27627. if !m.op.Is(OpUpdateOne) {
  27628. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27629. }
  27630. if m.id == nil || m.oldValue == nil {
  27631. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27632. }
  27633. oldValue, err := m.oldValue(ctx)
  27634. if err != nil {
  27635. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27636. }
  27637. return oldValue.CreatedAt, nil
  27638. }
  27639. // ResetCreatedAt resets all changes to the "created_at" field.
  27640. func (m *SopStageMutation) ResetCreatedAt() {
  27641. m.created_at = nil
  27642. }
  27643. // SetUpdatedAt sets the "updated_at" field.
  27644. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  27645. m.updated_at = &t
  27646. }
  27647. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27648. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  27649. v := m.updated_at
  27650. if v == nil {
  27651. return
  27652. }
  27653. return *v, true
  27654. }
  27655. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  27656. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27658. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27659. if !m.op.Is(OpUpdateOne) {
  27660. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27661. }
  27662. if m.id == nil || m.oldValue == nil {
  27663. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27664. }
  27665. oldValue, err := m.oldValue(ctx)
  27666. if err != nil {
  27667. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27668. }
  27669. return oldValue.UpdatedAt, nil
  27670. }
  27671. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27672. func (m *SopStageMutation) ResetUpdatedAt() {
  27673. m.updated_at = nil
  27674. }
  27675. // SetStatus sets the "status" field.
  27676. func (m *SopStageMutation) SetStatus(u uint8) {
  27677. m.status = &u
  27678. m.addstatus = nil
  27679. }
  27680. // Status returns the value of the "status" field in the mutation.
  27681. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  27682. v := m.status
  27683. if v == nil {
  27684. return
  27685. }
  27686. return *v, true
  27687. }
  27688. // OldStatus returns the old "status" field's value of the SopStage entity.
  27689. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27691. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27692. if !m.op.Is(OpUpdateOne) {
  27693. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27694. }
  27695. if m.id == nil || m.oldValue == nil {
  27696. return v, errors.New("OldStatus requires an ID field in the mutation")
  27697. }
  27698. oldValue, err := m.oldValue(ctx)
  27699. if err != nil {
  27700. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27701. }
  27702. return oldValue.Status, nil
  27703. }
  27704. // AddStatus adds u to the "status" field.
  27705. func (m *SopStageMutation) AddStatus(u int8) {
  27706. if m.addstatus != nil {
  27707. *m.addstatus += u
  27708. } else {
  27709. m.addstatus = &u
  27710. }
  27711. }
  27712. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27713. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  27714. v := m.addstatus
  27715. if v == nil {
  27716. return
  27717. }
  27718. return *v, true
  27719. }
  27720. // ClearStatus clears the value of the "status" field.
  27721. func (m *SopStageMutation) ClearStatus() {
  27722. m.status = nil
  27723. m.addstatus = nil
  27724. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  27725. }
  27726. // StatusCleared returns if the "status" field was cleared in this mutation.
  27727. func (m *SopStageMutation) StatusCleared() bool {
  27728. _, ok := m.clearedFields[sopstage.FieldStatus]
  27729. return ok
  27730. }
  27731. // ResetStatus resets all changes to the "status" field.
  27732. func (m *SopStageMutation) ResetStatus() {
  27733. m.status = nil
  27734. m.addstatus = nil
  27735. delete(m.clearedFields, sopstage.FieldStatus)
  27736. }
  27737. // SetDeletedAt sets the "deleted_at" field.
  27738. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  27739. m.deleted_at = &t
  27740. }
  27741. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27742. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  27743. v := m.deleted_at
  27744. if v == nil {
  27745. return
  27746. }
  27747. return *v, true
  27748. }
  27749. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  27750. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27752. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27753. if !m.op.Is(OpUpdateOne) {
  27754. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27755. }
  27756. if m.id == nil || m.oldValue == nil {
  27757. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27758. }
  27759. oldValue, err := m.oldValue(ctx)
  27760. if err != nil {
  27761. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27762. }
  27763. return oldValue.DeletedAt, nil
  27764. }
  27765. // ClearDeletedAt clears the value of the "deleted_at" field.
  27766. func (m *SopStageMutation) ClearDeletedAt() {
  27767. m.deleted_at = nil
  27768. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  27769. }
  27770. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27771. func (m *SopStageMutation) DeletedAtCleared() bool {
  27772. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  27773. return ok
  27774. }
  27775. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27776. func (m *SopStageMutation) ResetDeletedAt() {
  27777. m.deleted_at = nil
  27778. delete(m.clearedFields, sopstage.FieldDeletedAt)
  27779. }
  27780. // SetTaskID sets the "task_id" field.
  27781. func (m *SopStageMutation) SetTaskID(u uint64) {
  27782. m.sop_task = &u
  27783. }
  27784. // TaskID returns the value of the "task_id" field in the mutation.
  27785. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  27786. v := m.sop_task
  27787. if v == nil {
  27788. return
  27789. }
  27790. return *v, true
  27791. }
  27792. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  27793. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27795. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  27796. if !m.op.Is(OpUpdateOne) {
  27797. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  27798. }
  27799. if m.id == nil || m.oldValue == nil {
  27800. return v, errors.New("OldTaskID requires an ID field in the mutation")
  27801. }
  27802. oldValue, err := m.oldValue(ctx)
  27803. if err != nil {
  27804. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  27805. }
  27806. return oldValue.TaskID, nil
  27807. }
  27808. // ResetTaskID resets all changes to the "task_id" field.
  27809. func (m *SopStageMutation) ResetTaskID() {
  27810. m.sop_task = nil
  27811. }
  27812. // SetName sets the "name" field.
  27813. func (m *SopStageMutation) SetName(s string) {
  27814. m.name = &s
  27815. }
  27816. // Name returns the value of the "name" field in the mutation.
  27817. func (m *SopStageMutation) Name() (r string, exists bool) {
  27818. v := m.name
  27819. if v == nil {
  27820. return
  27821. }
  27822. return *v, true
  27823. }
  27824. // OldName returns the old "name" field's value of the SopStage entity.
  27825. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27827. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  27828. if !m.op.Is(OpUpdateOne) {
  27829. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27830. }
  27831. if m.id == nil || m.oldValue == nil {
  27832. return v, errors.New("OldName requires an ID field in the mutation")
  27833. }
  27834. oldValue, err := m.oldValue(ctx)
  27835. if err != nil {
  27836. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27837. }
  27838. return oldValue.Name, nil
  27839. }
  27840. // ResetName resets all changes to the "name" field.
  27841. func (m *SopStageMutation) ResetName() {
  27842. m.name = nil
  27843. }
  27844. // SetConditionType sets the "condition_type" field.
  27845. func (m *SopStageMutation) SetConditionType(i int) {
  27846. m.condition_type = &i
  27847. m.addcondition_type = nil
  27848. }
  27849. // ConditionType returns the value of the "condition_type" field in the mutation.
  27850. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  27851. v := m.condition_type
  27852. if v == nil {
  27853. return
  27854. }
  27855. return *v, true
  27856. }
  27857. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  27858. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27860. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  27861. if !m.op.Is(OpUpdateOne) {
  27862. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  27863. }
  27864. if m.id == nil || m.oldValue == nil {
  27865. return v, errors.New("OldConditionType requires an ID field in the mutation")
  27866. }
  27867. oldValue, err := m.oldValue(ctx)
  27868. if err != nil {
  27869. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  27870. }
  27871. return oldValue.ConditionType, nil
  27872. }
  27873. // AddConditionType adds i to the "condition_type" field.
  27874. func (m *SopStageMutation) AddConditionType(i int) {
  27875. if m.addcondition_type != nil {
  27876. *m.addcondition_type += i
  27877. } else {
  27878. m.addcondition_type = &i
  27879. }
  27880. }
  27881. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  27882. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  27883. v := m.addcondition_type
  27884. if v == nil {
  27885. return
  27886. }
  27887. return *v, true
  27888. }
  27889. // ResetConditionType resets all changes to the "condition_type" field.
  27890. func (m *SopStageMutation) ResetConditionType() {
  27891. m.condition_type = nil
  27892. m.addcondition_type = nil
  27893. }
  27894. // SetConditionOperator sets the "condition_operator" field.
  27895. func (m *SopStageMutation) SetConditionOperator(i int) {
  27896. m.condition_operator = &i
  27897. m.addcondition_operator = nil
  27898. }
  27899. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  27900. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  27901. v := m.condition_operator
  27902. if v == nil {
  27903. return
  27904. }
  27905. return *v, true
  27906. }
  27907. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  27908. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27910. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  27911. if !m.op.Is(OpUpdateOne) {
  27912. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  27913. }
  27914. if m.id == nil || m.oldValue == nil {
  27915. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  27916. }
  27917. oldValue, err := m.oldValue(ctx)
  27918. if err != nil {
  27919. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  27920. }
  27921. return oldValue.ConditionOperator, nil
  27922. }
  27923. // AddConditionOperator adds i to the "condition_operator" field.
  27924. func (m *SopStageMutation) AddConditionOperator(i int) {
  27925. if m.addcondition_operator != nil {
  27926. *m.addcondition_operator += i
  27927. } else {
  27928. m.addcondition_operator = &i
  27929. }
  27930. }
  27931. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  27932. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  27933. v := m.addcondition_operator
  27934. if v == nil {
  27935. return
  27936. }
  27937. return *v, true
  27938. }
  27939. // ResetConditionOperator resets all changes to the "condition_operator" field.
  27940. func (m *SopStageMutation) ResetConditionOperator() {
  27941. m.condition_operator = nil
  27942. m.addcondition_operator = nil
  27943. }
  27944. // SetConditionList sets the "condition_list" field.
  27945. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  27946. m.condition_list = &ct
  27947. m.appendcondition_list = nil
  27948. }
  27949. // ConditionList returns the value of the "condition_list" field in the mutation.
  27950. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  27951. v := m.condition_list
  27952. if v == nil {
  27953. return
  27954. }
  27955. return *v, true
  27956. }
  27957. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  27958. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27960. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  27961. if !m.op.Is(OpUpdateOne) {
  27962. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  27963. }
  27964. if m.id == nil || m.oldValue == nil {
  27965. return v, errors.New("OldConditionList requires an ID field in the mutation")
  27966. }
  27967. oldValue, err := m.oldValue(ctx)
  27968. if err != nil {
  27969. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27970. }
  27971. return oldValue.ConditionList, nil
  27972. }
  27973. // AppendConditionList adds ct to the "condition_list" field.
  27974. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  27975. m.appendcondition_list = append(m.appendcondition_list, ct...)
  27976. }
  27977. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27978. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  27979. if len(m.appendcondition_list) == 0 {
  27980. return nil, false
  27981. }
  27982. return m.appendcondition_list, true
  27983. }
  27984. // ResetConditionList resets all changes to the "condition_list" field.
  27985. func (m *SopStageMutation) ResetConditionList() {
  27986. m.condition_list = nil
  27987. m.appendcondition_list = nil
  27988. }
  27989. // SetActionMessage sets the "action_message" field.
  27990. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  27991. m.action_message = &ct
  27992. m.appendaction_message = nil
  27993. }
  27994. // ActionMessage returns the value of the "action_message" field in the mutation.
  27995. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27996. v := m.action_message
  27997. if v == nil {
  27998. return
  27999. }
  28000. return *v, true
  28001. }
  28002. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  28003. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28005. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28006. if !m.op.Is(OpUpdateOne) {
  28007. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28008. }
  28009. if m.id == nil || m.oldValue == nil {
  28010. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28011. }
  28012. oldValue, err := m.oldValue(ctx)
  28013. if err != nil {
  28014. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28015. }
  28016. return oldValue.ActionMessage, nil
  28017. }
  28018. // AppendActionMessage adds ct to the "action_message" field.
  28019. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  28020. m.appendaction_message = append(m.appendaction_message, ct...)
  28021. }
  28022. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  28023. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  28024. if len(m.appendaction_message) == 0 {
  28025. return nil, false
  28026. }
  28027. return m.appendaction_message, true
  28028. }
  28029. // ClearActionMessage clears the value of the "action_message" field.
  28030. func (m *SopStageMutation) ClearActionMessage() {
  28031. m.action_message = nil
  28032. m.appendaction_message = nil
  28033. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  28034. }
  28035. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  28036. func (m *SopStageMutation) ActionMessageCleared() bool {
  28037. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  28038. return ok
  28039. }
  28040. // ResetActionMessage resets all changes to the "action_message" field.
  28041. func (m *SopStageMutation) ResetActionMessage() {
  28042. m.action_message = nil
  28043. m.appendaction_message = nil
  28044. delete(m.clearedFields, sopstage.FieldActionMessage)
  28045. }
  28046. // SetActionLabelAdd sets the "action_label_add" field.
  28047. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  28048. m.action_label_add = &u
  28049. m.appendaction_label_add = nil
  28050. }
  28051. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  28052. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  28053. v := m.action_label_add
  28054. if v == nil {
  28055. return
  28056. }
  28057. return *v, true
  28058. }
  28059. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  28060. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28062. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  28063. if !m.op.Is(OpUpdateOne) {
  28064. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  28065. }
  28066. if m.id == nil || m.oldValue == nil {
  28067. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  28068. }
  28069. oldValue, err := m.oldValue(ctx)
  28070. if err != nil {
  28071. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  28072. }
  28073. return oldValue.ActionLabelAdd, nil
  28074. }
  28075. // AppendActionLabelAdd adds u to the "action_label_add" field.
  28076. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  28077. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  28078. }
  28079. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  28080. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  28081. if len(m.appendaction_label_add) == 0 {
  28082. return nil, false
  28083. }
  28084. return m.appendaction_label_add, true
  28085. }
  28086. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  28087. func (m *SopStageMutation) ClearActionLabelAdd() {
  28088. m.action_label_add = nil
  28089. m.appendaction_label_add = nil
  28090. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  28091. }
  28092. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  28093. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  28094. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  28095. return ok
  28096. }
  28097. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  28098. func (m *SopStageMutation) ResetActionLabelAdd() {
  28099. m.action_label_add = nil
  28100. m.appendaction_label_add = nil
  28101. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  28102. }
  28103. // SetActionLabelDel sets the "action_label_del" field.
  28104. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  28105. m.action_label_del = &u
  28106. m.appendaction_label_del = nil
  28107. }
  28108. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  28109. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  28110. v := m.action_label_del
  28111. if v == nil {
  28112. return
  28113. }
  28114. return *v, true
  28115. }
  28116. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  28117. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28119. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  28120. if !m.op.Is(OpUpdateOne) {
  28121. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  28122. }
  28123. if m.id == nil || m.oldValue == nil {
  28124. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  28125. }
  28126. oldValue, err := m.oldValue(ctx)
  28127. if err != nil {
  28128. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  28129. }
  28130. return oldValue.ActionLabelDel, nil
  28131. }
  28132. // AppendActionLabelDel adds u to the "action_label_del" field.
  28133. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  28134. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  28135. }
  28136. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  28137. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  28138. if len(m.appendaction_label_del) == 0 {
  28139. return nil, false
  28140. }
  28141. return m.appendaction_label_del, true
  28142. }
  28143. // ClearActionLabelDel clears the value of the "action_label_del" field.
  28144. func (m *SopStageMutation) ClearActionLabelDel() {
  28145. m.action_label_del = nil
  28146. m.appendaction_label_del = nil
  28147. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  28148. }
  28149. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  28150. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  28151. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  28152. return ok
  28153. }
  28154. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  28155. func (m *SopStageMutation) ResetActionLabelDel() {
  28156. m.action_label_del = nil
  28157. m.appendaction_label_del = nil
  28158. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  28159. }
  28160. // SetActionForward sets the "action_forward" field.
  28161. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  28162. m.action_forward = &ctf
  28163. }
  28164. // ActionForward returns the value of the "action_forward" field in the mutation.
  28165. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  28166. v := m.action_forward
  28167. if v == nil {
  28168. return
  28169. }
  28170. return *v, true
  28171. }
  28172. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  28173. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28175. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  28176. if !m.op.Is(OpUpdateOne) {
  28177. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  28178. }
  28179. if m.id == nil || m.oldValue == nil {
  28180. return v, errors.New("OldActionForward requires an ID field in the mutation")
  28181. }
  28182. oldValue, err := m.oldValue(ctx)
  28183. if err != nil {
  28184. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  28185. }
  28186. return oldValue.ActionForward, nil
  28187. }
  28188. // ClearActionForward clears the value of the "action_forward" field.
  28189. func (m *SopStageMutation) ClearActionForward() {
  28190. m.action_forward = nil
  28191. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  28192. }
  28193. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  28194. func (m *SopStageMutation) ActionForwardCleared() bool {
  28195. _, ok := m.clearedFields[sopstage.FieldActionForward]
  28196. return ok
  28197. }
  28198. // ResetActionForward resets all changes to the "action_forward" field.
  28199. func (m *SopStageMutation) ResetActionForward() {
  28200. m.action_forward = nil
  28201. delete(m.clearedFields, sopstage.FieldActionForward)
  28202. }
  28203. // SetIndexSort sets the "index_sort" field.
  28204. func (m *SopStageMutation) SetIndexSort(i int) {
  28205. m.index_sort = &i
  28206. m.addindex_sort = nil
  28207. }
  28208. // IndexSort returns the value of the "index_sort" field in the mutation.
  28209. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  28210. v := m.index_sort
  28211. if v == nil {
  28212. return
  28213. }
  28214. return *v, true
  28215. }
  28216. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  28217. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28219. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  28220. if !m.op.Is(OpUpdateOne) {
  28221. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  28222. }
  28223. if m.id == nil || m.oldValue == nil {
  28224. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  28225. }
  28226. oldValue, err := m.oldValue(ctx)
  28227. if err != nil {
  28228. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  28229. }
  28230. return oldValue.IndexSort, nil
  28231. }
  28232. // AddIndexSort adds i to the "index_sort" field.
  28233. func (m *SopStageMutation) AddIndexSort(i int) {
  28234. if m.addindex_sort != nil {
  28235. *m.addindex_sort += i
  28236. } else {
  28237. m.addindex_sort = &i
  28238. }
  28239. }
  28240. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  28241. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  28242. v := m.addindex_sort
  28243. if v == nil {
  28244. return
  28245. }
  28246. return *v, true
  28247. }
  28248. // ClearIndexSort clears the value of the "index_sort" field.
  28249. func (m *SopStageMutation) ClearIndexSort() {
  28250. m.index_sort = nil
  28251. m.addindex_sort = nil
  28252. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  28253. }
  28254. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  28255. func (m *SopStageMutation) IndexSortCleared() bool {
  28256. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  28257. return ok
  28258. }
  28259. // ResetIndexSort resets all changes to the "index_sort" field.
  28260. func (m *SopStageMutation) ResetIndexSort() {
  28261. m.index_sort = nil
  28262. m.addindex_sort = nil
  28263. delete(m.clearedFields, sopstage.FieldIndexSort)
  28264. }
  28265. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  28266. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  28267. m.sop_task = &id
  28268. }
  28269. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  28270. func (m *SopStageMutation) ClearSopTask() {
  28271. m.clearedsop_task = true
  28272. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  28273. }
  28274. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  28275. func (m *SopStageMutation) SopTaskCleared() bool {
  28276. return m.clearedsop_task
  28277. }
  28278. // SopTaskID returns the "sop_task" edge ID in the mutation.
  28279. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  28280. if m.sop_task != nil {
  28281. return *m.sop_task, true
  28282. }
  28283. return
  28284. }
  28285. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  28286. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28287. // SopTaskID instead. It exists only for internal usage by the builders.
  28288. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  28289. if id := m.sop_task; id != nil {
  28290. ids = append(ids, *id)
  28291. }
  28292. return
  28293. }
  28294. // ResetSopTask resets all changes to the "sop_task" edge.
  28295. func (m *SopStageMutation) ResetSopTask() {
  28296. m.sop_task = nil
  28297. m.clearedsop_task = false
  28298. }
  28299. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  28300. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  28301. if m.stage_nodes == nil {
  28302. m.stage_nodes = make(map[uint64]struct{})
  28303. }
  28304. for i := range ids {
  28305. m.stage_nodes[ids[i]] = struct{}{}
  28306. }
  28307. }
  28308. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  28309. func (m *SopStageMutation) ClearStageNodes() {
  28310. m.clearedstage_nodes = true
  28311. }
  28312. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  28313. func (m *SopStageMutation) StageNodesCleared() bool {
  28314. return m.clearedstage_nodes
  28315. }
  28316. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  28317. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  28318. if m.removedstage_nodes == nil {
  28319. m.removedstage_nodes = make(map[uint64]struct{})
  28320. }
  28321. for i := range ids {
  28322. delete(m.stage_nodes, ids[i])
  28323. m.removedstage_nodes[ids[i]] = struct{}{}
  28324. }
  28325. }
  28326. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  28327. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  28328. for id := range m.removedstage_nodes {
  28329. ids = append(ids, id)
  28330. }
  28331. return
  28332. }
  28333. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  28334. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  28335. for id := range m.stage_nodes {
  28336. ids = append(ids, id)
  28337. }
  28338. return
  28339. }
  28340. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  28341. func (m *SopStageMutation) ResetStageNodes() {
  28342. m.stage_nodes = nil
  28343. m.clearedstage_nodes = false
  28344. m.removedstage_nodes = nil
  28345. }
  28346. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  28347. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  28348. if m.stage_messages == nil {
  28349. m.stage_messages = make(map[uint64]struct{})
  28350. }
  28351. for i := range ids {
  28352. m.stage_messages[ids[i]] = struct{}{}
  28353. }
  28354. }
  28355. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  28356. func (m *SopStageMutation) ClearStageMessages() {
  28357. m.clearedstage_messages = true
  28358. }
  28359. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  28360. func (m *SopStageMutation) StageMessagesCleared() bool {
  28361. return m.clearedstage_messages
  28362. }
  28363. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  28364. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  28365. if m.removedstage_messages == nil {
  28366. m.removedstage_messages = make(map[uint64]struct{})
  28367. }
  28368. for i := range ids {
  28369. delete(m.stage_messages, ids[i])
  28370. m.removedstage_messages[ids[i]] = struct{}{}
  28371. }
  28372. }
  28373. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  28374. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  28375. for id := range m.removedstage_messages {
  28376. ids = append(ids, id)
  28377. }
  28378. return
  28379. }
  28380. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  28381. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  28382. for id := range m.stage_messages {
  28383. ids = append(ids, id)
  28384. }
  28385. return
  28386. }
  28387. // ResetStageMessages resets all changes to the "stage_messages" edge.
  28388. func (m *SopStageMutation) ResetStageMessages() {
  28389. m.stage_messages = nil
  28390. m.clearedstage_messages = false
  28391. m.removedstage_messages = nil
  28392. }
  28393. // Where appends a list predicates to the SopStageMutation builder.
  28394. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  28395. m.predicates = append(m.predicates, ps...)
  28396. }
  28397. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  28398. // users can use type-assertion to append predicates that do not depend on any generated package.
  28399. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  28400. p := make([]predicate.SopStage, len(ps))
  28401. for i := range ps {
  28402. p[i] = ps[i]
  28403. }
  28404. m.Where(p...)
  28405. }
  28406. // Op returns the operation name.
  28407. func (m *SopStageMutation) Op() Op {
  28408. return m.op
  28409. }
  28410. // SetOp allows setting the mutation operation.
  28411. func (m *SopStageMutation) SetOp(op Op) {
  28412. m.op = op
  28413. }
  28414. // Type returns the node type of this mutation (SopStage).
  28415. func (m *SopStageMutation) Type() string {
  28416. return m.typ
  28417. }
  28418. // Fields returns all fields that were changed during this mutation. Note that in
  28419. // order to get all numeric fields that were incremented/decremented, call
  28420. // AddedFields().
  28421. func (m *SopStageMutation) Fields() []string {
  28422. fields := make([]string, 0, 14)
  28423. if m.created_at != nil {
  28424. fields = append(fields, sopstage.FieldCreatedAt)
  28425. }
  28426. if m.updated_at != nil {
  28427. fields = append(fields, sopstage.FieldUpdatedAt)
  28428. }
  28429. if m.status != nil {
  28430. fields = append(fields, sopstage.FieldStatus)
  28431. }
  28432. if m.deleted_at != nil {
  28433. fields = append(fields, sopstage.FieldDeletedAt)
  28434. }
  28435. if m.sop_task != nil {
  28436. fields = append(fields, sopstage.FieldTaskID)
  28437. }
  28438. if m.name != nil {
  28439. fields = append(fields, sopstage.FieldName)
  28440. }
  28441. if m.condition_type != nil {
  28442. fields = append(fields, sopstage.FieldConditionType)
  28443. }
  28444. if m.condition_operator != nil {
  28445. fields = append(fields, sopstage.FieldConditionOperator)
  28446. }
  28447. if m.condition_list != nil {
  28448. fields = append(fields, sopstage.FieldConditionList)
  28449. }
  28450. if m.action_message != nil {
  28451. fields = append(fields, sopstage.FieldActionMessage)
  28452. }
  28453. if m.action_label_add != nil {
  28454. fields = append(fields, sopstage.FieldActionLabelAdd)
  28455. }
  28456. if m.action_label_del != nil {
  28457. fields = append(fields, sopstage.FieldActionLabelDel)
  28458. }
  28459. if m.action_forward != nil {
  28460. fields = append(fields, sopstage.FieldActionForward)
  28461. }
  28462. if m.index_sort != nil {
  28463. fields = append(fields, sopstage.FieldIndexSort)
  28464. }
  28465. return fields
  28466. }
  28467. // Field returns the value of a field with the given name. The second boolean
  28468. // return value indicates that this field was not set, or was not defined in the
  28469. // schema.
  28470. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  28471. switch name {
  28472. case sopstage.FieldCreatedAt:
  28473. return m.CreatedAt()
  28474. case sopstage.FieldUpdatedAt:
  28475. return m.UpdatedAt()
  28476. case sopstage.FieldStatus:
  28477. return m.Status()
  28478. case sopstage.FieldDeletedAt:
  28479. return m.DeletedAt()
  28480. case sopstage.FieldTaskID:
  28481. return m.TaskID()
  28482. case sopstage.FieldName:
  28483. return m.Name()
  28484. case sopstage.FieldConditionType:
  28485. return m.ConditionType()
  28486. case sopstage.FieldConditionOperator:
  28487. return m.ConditionOperator()
  28488. case sopstage.FieldConditionList:
  28489. return m.ConditionList()
  28490. case sopstage.FieldActionMessage:
  28491. return m.ActionMessage()
  28492. case sopstage.FieldActionLabelAdd:
  28493. return m.ActionLabelAdd()
  28494. case sopstage.FieldActionLabelDel:
  28495. return m.ActionLabelDel()
  28496. case sopstage.FieldActionForward:
  28497. return m.ActionForward()
  28498. case sopstage.FieldIndexSort:
  28499. return m.IndexSort()
  28500. }
  28501. return nil, false
  28502. }
  28503. // OldField returns the old value of the field from the database. An error is
  28504. // returned if the mutation operation is not UpdateOne, or the query to the
  28505. // database failed.
  28506. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28507. switch name {
  28508. case sopstage.FieldCreatedAt:
  28509. return m.OldCreatedAt(ctx)
  28510. case sopstage.FieldUpdatedAt:
  28511. return m.OldUpdatedAt(ctx)
  28512. case sopstage.FieldStatus:
  28513. return m.OldStatus(ctx)
  28514. case sopstage.FieldDeletedAt:
  28515. return m.OldDeletedAt(ctx)
  28516. case sopstage.FieldTaskID:
  28517. return m.OldTaskID(ctx)
  28518. case sopstage.FieldName:
  28519. return m.OldName(ctx)
  28520. case sopstage.FieldConditionType:
  28521. return m.OldConditionType(ctx)
  28522. case sopstage.FieldConditionOperator:
  28523. return m.OldConditionOperator(ctx)
  28524. case sopstage.FieldConditionList:
  28525. return m.OldConditionList(ctx)
  28526. case sopstage.FieldActionMessage:
  28527. return m.OldActionMessage(ctx)
  28528. case sopstage.FieldActionLabelAdd:
  28529. return m.OldActionLabelAdd(ctx)
  28530. case sopstage.FieldActionLabelDel:
  28531. return m.OldActionLabelDel(ctx)
  28532. case sopstage.FieldActionForward:
  28533. return m.OldActionForward(ctx)
  28534. case sopstage.FieldIndexSort:
  28535. return m.OldIndexSort(ctx)
  28536. }
  28537. return nil, fmt.Errorf("unknown SopStage field %s", name)
  28538. }
  28539. // SetField sets the value of a field with the given name. It returns an error if
  28540. // the field is not defined in the schema, or if the type mismatched the field
  28541. // type.
  28542. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  28543. switch name {
  28544. case sopstage.FieldCreatedAt:
  28545. v, ok := value.(time.Time)
  28546. if !ok {
  28547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28548. }
  28549. m.SetCreatedAt(v)
  28550. return nil
  28551. case sopstage.FieldUpdatedAt:
  28552. v, ok := value.(time.Time)
  28553. if !ok {
  28554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28555. }
  28556. m.SetUpdatedAt(v)
  28557. return nil
  28558. case sopstage.FieldStatus:
  28559. v, ok := value.(uint8)
  28560. if !ok {
  28561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28562. }
  28563. m.SetStatus(v)
  28564. return nil
  28565. case sopstage.FieldDeletedAt:
  28566. v, ok := value.(time.Time)
  28567. if !ok {
  28568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28569. }
  28570. m.SetDeletedAt(v)
  28571. return nil
  28572. case sopstage.FieldTaskID:
  28573. v, ok := value.(uint64)
  28574. if !ok {
  28575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28576. }
  28577. m.SetTaskID(v)
  28578. return nil
  28579. case sopstage.FieldName:
  28580. v, ok := value.(string)
  28581. if !ok {
  28582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28583. }
  28584. m.SetName(v)
  28585. return nil
  28586. case sopstage.FieldConditionType:
  28587. v, ok := value.(int)
  28588. if !ok {
  28589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28590. }
  28591. m.SetConditionType(v)
  28592. return nil
  28593. case sopstage.FieldConditionOperator:
  28594. v, ok := value.(int)
  28595. if !ok {
  28596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28597. }
  28598. m.SetConditionOperator(v)
  28599. return nil
  28600. case sopstage.FieldConditionList:
  28601. v, ok := value.([]custom_types.Condition)
  28602. if !ok {
  28603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28604. }
  28605. m.SetConditionList(v)
  28606. return nil
  28607. case sopstage.FieldActionMessage:
  28608. v, ok := value.([]custom_types.Action)
  28609. if !ok {
  28610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28611. }
  28612. m.SetActionMessage(v)
  28613. return nil
  28614. case sopstage.FieldActionLabelAdd:
  28615. v, ok := value.([]uint64)
  28616. if !ok {
  28617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28618. }
  28619. m.SetActionLabelAdd(v)
  28620. return nil
  28621. case sopstage.FieldActionLabelDel:
  28622. v, ok := value.([]uint64)
  28623. if !ok {
  28624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28625. }
  28626. m.SetActionLabelDel(v)
  28627. return nil
  28628. case sopstage.FieldActionForward:
  28629. v, ok := value.(*custom_types.ActionForward)
  28630. if !ok {
  28631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28632. }
  28633. m.SetActionForward(v)
  28634. return nil
  28635. case sopstage.FieldIndexSort:
  28636. v, ok := value.(int)
  28637. if !ok {
  28638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28639. }
  28640. m.SetIndexSort(v)
  28641. return nil
  28642. }
  28643. return fmt.Errorf("unknown SopStage field %s", name)
  28644. }
  28645. // AddedFields returns all numeric fields that were incremented/decremented during
  28646. // this mutation.
  28647. func (m *SopStageMutation) AddedFields() []string {
  28648. var fields []string
  28649. if m.addstatus != nil {
  28650. fields = append(fields, sopstage.FieldStatus)
  28651. }
  28652. if m.addcondition_type != nil {
  28653. fields = append(fields, sopstage.FieldConditionType)
  28654. }
  28655. if m.addcondition_operator != nil {
  28656. fields = append(fields, sopstage.FieldConditionOperator)
  28657. }
  28658. if m.addindex_sort != nil {
  28659. fields = append(fields, sopstage.FieldIndexSort)
  28660. }
  28661. return fields
  28662. }
  28663. // AddedField returns the numeric value that was incremented/decremented on a field
  28664. // with the given name. The second boolean return value indicates that this field
  28665. // was not set, or was not defined in the schema.
  28666. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  28667. switch name {
  28668. case sopstage.FieldStatus:
  28669. return m.AddedStatus()
  28670. case sopstage.FieldConditionType:
  28671. return m.AddedConditionType()
  28672. case sopstage.FieldConditionOperator:
  28673. return m.AddedConditionOperator()
  28674. case sopstage.FieldIndexSort:
  28675. return m.AddedIndexSort()
  28676. }
  28677. return nil, false
  28678. }
  28679. // AddField adds the value to the field with the given name. It returns an error if
  28680. // the field is not defined in the schema, or if the type mismatched the field
  28681. // type.
  28682. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  28683. switch name {
  28684. case sopstage.FieldStatus:
  28685. v, ok := value.(int8)
  28686. if !ok {
  28687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28688. }
  28689. m.AddStatus(v)
  28690. return nil
  28691. case sopstage.FieldConditionType:
  28692. v, ok := value.(int)
  28693. if !ok {
  28694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28695. }
  28696. m.AddConditionType(v)
  28697. return nil
  28698. case sopstage.FieldConditionOperator:
  28699. v, ok := value.(int)
  28700. if !ok {
  28701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28702. }
  28703. m.AddConditionOperator(v)
  28704. return nil
  28705. case sopstage.FieldIndexSort:
  28706. v, ok := value.(int)
  28707. if !ok {
  28708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28709. }
  28710. m.AddIndexSort(v)
  28711. return nil
  28712. }
  28713. return fmt.Errorf("unknown SopStage numeric field %s", name)
  28714. }
  28715. // ClearedFields returns all nullable fields that were cleared during this
  28716. // mutation.
  28717. func (m *SopStageMutation) ClearedFields() []string {
  28718. var fields []string
  28719. if m.FieldCleared(sopstage.FieldStatus) {
  28720. fields = append(fields, sopstage.FieldStatus)
  28721. }
  28722. if m.FieldCleared(sopstage.FieldDeletedAt) {
  28723. fields = append(fields, sopstage.FieldDeletedAt)
  28724. }
  28725. if m.FieldCleared(sopstage.FieldActionMessage) {
  28726. fields = append(fields, sopstage.FieldActionMessage)
  28727. }
  28728. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  28729. fields = append(fields, sopstage.FieldActionLabelAdd)
  28730. }
  28731. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  28732. fields = append(fields, sopstage.FieldActionLabelDel)
  28733. }
  28734. if m.FieldCleared(sopstage.FieldActionForward) {
  28735. fields = append(fields, sopstage.FieldActionForward)
  28736. }
  28737. if m.FieldCleared(sopstage.FieldIndexSort) {
  28738. fields = append(fields, sopstage.FieldIndexSort)
  28739. }
  28740. return fields
  28741. }
  28742. // FieldCleared returns a boolean indicating if a field with the given name was
  28743. // cleared in this mutation.
  28744. func (m *SopStageMutation) FieldCleared(name string) bool {
  28745. _, ok := m.clearedFields[name]
  28746. return ok
  28747. }
  28748. // ClearField clears the value of the field with the given name. It returns an
  28749. // error if the field is not defined in the schema.
  28750. func (m *SopStageMutation) ClearField(name string) error {
  28751. switch name {
  28752. case sopstage.FieldStatus:
  28753. m.ClearStatus()
  28754. return nil
  28755. case sopstage.FieldDeletedAt:
  28756. m.ClearDeletedAt()
  28757. return nil
  28758. case sopstage.FieldActionMessage:
  28759. m.ClearActionMessage()
  28760. return nil
  28761. case sopstage.FieldActionLabelAdd:
  28762. m.ClearActionLabelAdd()
  28763. return nil
  28764. case sopstage.FieldActionLabelDel:
  28765. m.ClearActionLabelDel()
  28766. return nil
  28767. case sopstage.FieldActionForward:
  28768. m.ClearActionForward()
  28769. return nil
  28770. case sopstage.FieldIndexSort:
  28771. m.ClearIndexSort()
  28772. return nil
  28773. }
  28774. return fmt.Errorf("unknown SopStage nullable field %s", name)
  28775. }
  28776. // ResetField resets all changes in the mutation for the field with the given name.
  28777. // It returns an error if the field is not defined in the schema.
  28778. func (m *SopStageMutation) ResetField(name string) error {
  28779. switch name {
  28780. case sopstage.FieldCreatedAt:
  28781. m.ResetCreatedAt()
  28782. return nil
  28783. case sopstage.FieldUpdatedAt:
  28784. m.ResetUpdatedAt()
  28785. return nil
  28786. case sopstage.FieldStatus:
  28787. m.ResetStatus()
  28788. return nil
  28789. case sopstage.FieldDeletedAt:
  28790. m.ResetDeletedAt()
  28791. return nil
  28792. case sopstage.FieldTaskID:
  28793. m.ResetTaskID()
  28794. return nil
  28795. case sopstage.FieldName:
  28796. m.ResetName()
  28797. return nil
  28798. case sopstage.FieldConditionType:
  28799. m.ResetConditionType()
  28800. return nil
  28801. case sopstage.FieldConditionOperator:
  28802. m.ResetConditionOperator()
  28803. return nil
  28804. case sopstage.FieldConditionList:
  28805. m.ResetConditionList()
  28806. return nil
  28807. case sopstage.FieldActionMessage:
  28808. m.ResetActionMessage()
  28809. return nil
  28810. case sopstage.FieldActionLabelAdd:
  28811. m.ResetActionLabelAdd()
  28812. return nil
  28813. case sopstage.FieldActionLabelDel:
  28814. m.ResetActionLabelDel()
  28815. return nil
  28816. case sopstage.FieldActionForward:
  28817. m.ResetActionForward()
  28818. return nil
  28819. case sopstage.FieldIndexSort:
  28820. m.ResetIndexSort()
  28821. return nil
  28822. }
  28823. return fmt.Errorf("unknown SopStage field %s", name)
  28824. }
  28825. // AddedEdges returns all edge names that were set/added in this mutation.
  28826. func (m *SopStageMutation) AddedEdges() []string {
  28827. edges := make([]string, 0, 3)
  28828. if m.sop_task != nil {
  28829. edges = append(edges, sopstage.EdgeSopTask)
  28830. }
  28831. if m.stage_nodes != nil {
  28832. edges = append(edges, sopstage.EdgeStageNodes)
  28833. }
  28834. if m.stage_messages != nil {
  28835. edges = append(edges, sopstage.EdgeStageMessages)
  28836. }
  28837. return edges
  28838. }
  28839. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28840. // name in this mutation.
  28841. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  28842. switch name {
  28843. case sopstage.EdgeSopTask:
  28844. if id := m.sop_task; id != nil {
  28845. return []ent.Value{*id}
  28846. }
  28847. case sopstage.EdgeStageNodes:
  28848. ids := make([]ent.Value, 0, len(m.stage_nodes))
  28849. for id := range m.stage_nodes {
  28850. ids = append(ids, id)
  28851. }
  28852. return ids
  28853. case sopstage.EdgeStageMessages:
  28854. ids := make([]ent.Value, 0, len(m.stage_messages))
  28855. for id := range m.stage_messages {
  28856. ids = append(ids, id)
  28857. }
  28858. return ids
  28859. }
  28860. return nil
  28861. }
  28862. // RemovedEdges returns all edge names that were removed in this mutation.
  28863. func (m *SopStageMutation) RemovedEdges() []string {
  28864. edges := make([]string, 0, 3)
  28865. if m.removedstage_nodes != nil {
  28866. edges = append(edges, sopstage.EdgeStageNodes)
  28867. }
  28868. if m.removedstage_messages != nil {
  28869. edges = append(edges, sopstage.EdgeStageMessages)
  28870. }
  28871. return edges
  28872. }
  28873. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28874. // the given name in this mutation.
  28875. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  28876. switch name {
  28877. case sopstage.EdgeStageNodes:
  28878. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  28879. for id := range m.removedstage_nodes {
  28880. ids = append(ids, id)
  28881. }
  28882. return ids
  28883. case sopstage.EdgeStageMessages:
  28884. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  28885. for id := range m.removedstage_messages {
  28886. ids = append(ids, id)
  28887. }
  28888. return ids
  28889. }
  28890. return nil
  28891. }
  28892. // ClearedEdges returns all edge names that were cleared in this mutation.
  28893. func (m *SopStageMutation) ClearedEdges() []string {
  28894. edges := make([]string, 0, 3)
  28895. if m.clearedsop_task {
  28896. edges = append(edges, sopstage.EdgeSopTask)
  28897. }
  28898. if m.clearedstage_nodes {
  28899. edges = append(edges, sopstage.EdgeStageNodes)
  28900. }
  28901. if m.clearedstage_messages {
  28902. edges = append(edges, sopstage.EdgeStageMessages)
  28903. }
  28904. return edges
  28905. }
  28906. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28907. // was cleared in this mutation.
  28908. func (m *SopStageMutation) EdgeCleared(name string) bool {
  28909. switch name {
  28910. case sopstage.EdgeSopTask:
  28911. return m.clearedsop_task
  28912. case sopstage.EdgeStageNodes:
  28913. return m.clearedstage_nodes
  28914. case sopstage.EdgeStageMessages:
  28915. return m.clearedstage_messages
  28916. }
  28917. return false
  28918. }
  28919. // ClearEdge clears the value of the edge with the given name. It returns an error
  28920. // if that edge is not defined in the schema.
  28921. func (m *SopStageMutation) ClearEdge(name string) error {
  28922. switch name {
  28923. case sopstage.EdgeSopTask:
  28924. m.ClearSopTask()
  28925. return nil
  28926. }
  28927. return fmt.Errorf("unknown SopStage unique edge %s", name)
  28928. }
  28929. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28930. // It returns an error if the edge is not defined in the schema.
  28931. func (m *SopStageMutation) ResetEdge(name string) error {
  28932. switch name {
  28933. case sopstage.EdgeSopTask:
  28934. m.ResetSopTask()
  28935. return nil
  28936. case sopstage.EdgeStageNodes:
  28937. m.ResetStageNodes()
  28938. return nil
  28939. case sopstage.EdgeStageMessages:
  28940. m.ResetStageMessages()
  28941. return nil
  28942. }
  28943. return fmt.Errorf("unknown SopStage edge %s", name)
  28944. }
  28945. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  28946. type SopTaskMutation struct {
  28947. config
  28948. op Op
  28949. typ string
  28950. id *uint64
  28951. created_at *time.Time
  28952. updated_at *time.Time
  28953. status *uint8
  28954. addstatus *int8
  28955. deleted_at *time.Time
  28956. name *string
  28957. bot_wxid_list *[]string
  28958. appendbot_wxid_list []string
  28959. _type *int
  28960. add_type *int
  28961. plan_start_time *time.Time
  28962. plan_end_time *time.Time
  28963. creator_id *string
  28964. organization_id *uint64
  28965. addorganization_id *int64
  28966. token *[]string
  28967. appendtoken []string
  28968. clearedFields map[string]struct{}
  28969. task_stages map[uint64]struct{}
  28970. removedtask_stages map[uint64]struct{}
  28971. clearedtask_stages bool
  28972. done bool
  28973. oldValue func(context.Context) (*SopTask, error)
  28974. predicates []predicate.SopTask
  28975. }
  28976. var _ ent.Mutation = (*SopTaskMutation)(nil)
  28977. // soptaskOption allows management of the mutation configuration using functional options.
  28978. type soptaskOption func(*SopTaskMutation)
  28979. // newSopTaskMutation creates new mutation for the SopTask entity.
  28980. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  28981. m := &SopTaskMutation{
  28982. config: c,
  28983. op: op,
  28984. typ: TypeSopTask,
  28985. clearedFields: make(map[string]struct{}),
  28986. }
  28987. for _, opt := range opts {
  28988. opt(m)
  28989. }
  28990. return m
  28991. }
  28992. // withSopTaskID sets the ID field of the mutation.
  28993. func withSopTaskID(id uint64) soptaskOption {
  28994. return func(m *SopTaskMutation) {
  28995. var (
  28996. err error
  28997. once sync.Once
  28998. value *SopTask
  28999. )
  29000. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  29001. once.Do(func() {
  29002. if m.done {
  29003. err = errors.New("querying old values post mutation is not allowed")
  29004. } else {
  29005. value, err = m.Client().SopTask.Get(ctx, id)
  29006. }
  29007. })
  29008. return value, err
  29009. }
  29010. m.id = &id
  29011. }
  29012. }
  29013. // withSopTask sets the old SopTask of the mutation.
  29014. func withSopTask(node *SopTask) soptaskOption {
  29015. return func(m *SopTaskMutation) {
  29016. m.oldValue = func(context.Context) (*SopTask, error) {
  29017. return node, nil
  29018. }
  29019. m.id = &node.ID
  29020. }
  29021. }
  29022. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29023. // executed in a transaction (ent.Tx), a transactional client is returned.
  29024. func (m SopTaskMutation) Client() *Client {
  29025. client := &Client{config: m.config}
  29026. client.init()
  29027. return client
  29028. }
  29029. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29030. // it returns an error otherwise.
  29031. func (m SopTaskMutation) Tx() (*Tx, error) {
  29032. if _, ok := m.driver.(*txDriver); !ok {
  29033. return nil, errors.New("ent: mutation is not running in a transaction")
  29034. }
  29035. tx := &Tx{config: m.config}
  29036. tx.init()
  29037. return tx, nil
  29038. }
  29039. // SetID sets the value of the id field. Note that this
  29040. // operation is only accepted on creation of SopTask entities.
  29041. func (m *SopTaskMutation) SetID(id uint64) {
  29042. m.id = &id
  29043. }
  29044. // ID returns the ID value in the mutation. Note that the ID is only available
  29045. // if it was provided to the builder or after it was returned from the database.
  29046. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  29047. if m.id == nil {
  29048. return
  29049. }
  29050. return *m.id, true
  29051. }
  29052. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29053. // That means, if the mutation is applied within a transaction with an isolation level such
  29054. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29055. // or updated by the mutation.
  29056. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  29057. switch {
  29058. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29059. id, exists := m.ID()
  29060. if exists {
  29061. return []uint64{id}, nil
  29062. }
  29063. fallthrough
  29064. case m.op.Is(OpUpdate | OpDelete):
  29065. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  29066. default:
  29067. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29068. }
  29069. }
  29070. // SetCreatedAt sets the "created_at" field.
  29071. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  29072. m.created_at = &t
  29073. }
  29074. // CreatedAt returns the value of the "created_at" field in the mutation.
  29075. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  29076. v := m.created_at
  29077. if v == nil {
  29078. return
  29079. }
  29080. return *v, true
  29081. }
  29082. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  29083. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29085. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29086. if !m.op.Is(OpUpdateOne) {
  29087. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29088. }
  29089. if m.id == nil || m.oldValue == nil {
  29090. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29091. }
  29092. oldValue, err := m.oldValue(ctx)
  29093. if err != nil {
  29094. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29095. }
  29096. return oldValue.CreatedAt, nil
  29097. }
  29098. // ResetCreatedAt resets all changes to the "created_at" field.
  29099. func (m *SopTaskMutation) ResetCreatedAt() {
  29100. m.created_at = nil
  29101. }
  29102. // SetUpdatedAt sets the "updated_at" field.
  29103. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  29104. m.updated_at = &t
  29105. }
  29106. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29107. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  29108. v := m.updated_at
  29109. if v == nil {
  29110. return
  29111. }
  29112. return *v, true
  29113. }
  29114. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  29115. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29117. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29118. if !m.op.Is(OpUpdateOne) {
  29119. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29120. }
  29121. if m.id == nil || m.oldValue == nil {
  29122. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29123. }
  29124. oldValue, err := m.oldValue(ctx)
  29125. if err != nil {
  29126. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29127. }
  29128. return oldValue.UpdatedAt, nil
  29129. }
  29130. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29131. func (m *SopTaskMutation) ResetUpdatedAt() {
  29132. m.updated_at = nil
  29133. }
  29134. // SetStatus sets the "status" field.
  29135. func (m *SopTaskMutation) SetStatus(u uint8) {
  29136. m.status = &u
  29137. m.addstatus = nil
  29138. }
  29139. // Status returns the value of the "status" field in the mutation.
  29140. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  29141. v := m.status
  29142. if v == nil {
  29143. return
  29144. }
  29145. return *v, true
  29146. }
  29147. // OldStatus returns the old "status" field's value of the SopTask entity.
  29148. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29150. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29151. if !m.op.Is(OpUpdateOne) {
  29152. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29153. }
  29154. if m.id == nil || m.oldValue == nil {
  29155. return v, errors.New("OldStatus requires an ID field in the mutation")
  29156. }
  29157. oldValue, err := m.oldValue(ctx)
  29158. if err != nil {
  29159. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29160. }
  29161. return oldValue.Status, nil
  29162. }
  29163. // AddStatus adds u to the "status" field.
  29164. func (m *SopTaskMutation) AddStatus(u int8) {
  29165. if m.addstatus != nil {
  29166. *m.addstatus += u
  29167. } else {
  29168. m.addstatus = &u
  29169. }
  29170. }
  29171. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29172. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  29173. v := m.addstatus
  29174. if v == nil {
  29175. return
  29176. }
  29177. return *v, true
  29178. }
  29179. // ClearStatus clears the value of the "status" field.
  29180. func (m *SopTaskMutation) ClearStatus() {
  29181. m.status = nil
  29182. m.addstatus = nil
  29183. m.clearedFields[soptask.FieldStatus] = struct{}{}
  29184. }
  29185. // StatusCleared returns if the "status" field was cleared in this mutation.
  29186. func (m *SopTaskMutation) StatusCleared() bool {
  29187. _, ok := m.clearedFields[soptask.FieldStatus]
  29188. return ok
  29189. }
  29190. // ResetStatus resets all changes to the "status" field.
  29191. func (m *SopTaskMutation) ResetStatus() {
  29192. m.status = nil
  29193. m.addstatus = nil
  29194. delete(m.clearedFields, soptask.FieldStatus)
  29195. }
  29196. // SetDeletedAt sets the "deleted_at" field.
  29197. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  29198. m.deleted_at = &t
  29199. }
  29200. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29201. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  29202. v := m.deleted_at
  29203. if v == nil {
  29204. return
  29205. }
  29206. return *v, true
  29207. }
  29208. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  29209. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29211. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29212. if !m.op.Is(OpUpdateOne) {
  29213. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29214. }
  29215. if m.id == nil || m.oldValue == nil {
  29216. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29217. }
  29218. oldValue, err := m.oldValue(ctx)
  29219. if err != nil {
  29220. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29221. }
  29222. return oldValue.DeletedAt, nil
  29223. }
  29224. // ClearDeletedAt clears the value of the "deleted_at" field.
  29225. func (m *SopTaskMutation) ClearDeletedAt() {
  29226. m.deleted_at = nil
  29227. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  29228. }
  29229. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29230. func (m *SopTaskMutation) DeletedAtCleared() bool {
  29231. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  29232. return ok
  29233. }
  29234. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29235. func (m *SopTaskMutation) ResetDeletedAt() {
  29236. m.deleted_at = nil
  29237. delete(m.clearedFields, soptask.FieldDeletedAt)
  29238. }
  29239. // SetName sets the "name" field.
  29240. func (m *SopTaskMutation) SetName(s string) {
  29241. m.name = &s
  29242. }
  29243. // Name returns the value of the "name" field in the mutation.
  29244. func (m *SopTaskMutation) Name() (r string, exists bool) {
  29245. v := m.name
  29246. if v == nil {
  29247. return
  29248. }
  29249. return *v, true
  29250. }
  29251. // OldName returns the old "name" field's value of the SopTask entity.
  29252. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29254. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  29255. if !m.op.Is(OpUpdateOne) {
  29256. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29257. }
  29258. if m.id == nil || m.oldValue == nil {
  29259. return v, errors.New("OldName requires an ID field in the mutation")
  29260. }
  29261. oldValue, err := m.oldValue(ctx)
  29262. if err != nil {
  29263. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29264. }
  29265. return oldValue.Name, nil
  29266. }
  29267. // ResetName resets all changes to the "name" field.
  29268. func (m *SopTaskMutation) ResetName() {
  29269. m.name = nil
  29270. }
  29271. // SetBotWxidList sets the "bot_wxid_list" field.
  29272. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  29273. m.bot_wxid_list = &s
  29274. m.appendbot_wxid_list = nil
  29275. }
  29276. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  29277. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  29278. v := m.bot_wxid_list
  29279. if v == nil {
  29280. return
  29281. }
  29282. return *v, true
  29283. }
  29284. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  29285. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29287. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  29288. if !m.op.Is(OpUpdateOne) {
  29289. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  29290. }
  29291. if m.id == nil || m.oldValue == nil {
  29292. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  29293. }
  29294. oldValue, err := m.oldValue(ctx)
  29295. if err != nil {
  29296. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  29297. }
  29298. return oldValue.BotWxidList, nil
  29299. }
  29300. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  29301. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  29302. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  29303. }
  29304. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  29305. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  29306. if len(m.appendbot_wxid_list) == 0 {
  29307. return nil, false
  29308. }
  29309. return m.appendbot_wxid_list, true
  29310. }
  29311. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  29312. func (m *SopTaskMutation) ClearBotWxidList() {
  29313. m.bot_wxid_list = nil
  29314. m.appendbot_wxid_list = nil
  29315. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  29316. }
  29317. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  29318. func (m *SopTaskMutation) BotWxidListCleared() bool {
  29319. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  29320. return ok
  29321. }
  29322. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  29323. func (m *SopTaskMutation) ResetBotWxidList() {
  29324. m.bot_wxid_list = nil
  29325. m.appendbot_wxid_list = nil
  29326. delete(m.clearedFields, soptask.FieldBotWxidList)
  29327. }
  29328. // SetType sets the "type" field.
  29329. func (m *SopTaskMutation) SetType(i int) {
  29330. m._type = &i
  29331. m.add_type = nil
  29332. }
  29333. // GetType returns the value of the "type" field in the mutation.
  29334. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  29335. v := m._type
  29336. if v == nil {
  29337. return
  29338. }
  29339. return *v, true
  29340. }
  29341. // OldType returns the old "type" field's value of the SopTask entity.
  29342. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29344. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  29345. if !m.op.Is(OpUpdateOne) {
  29346. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29347. }
  29348. if m.id == nil || m.oldValue == nil {
  29349. return v, errors.New("OldType requires an ID field in the mutation")
  29350. }
  29351. oldValue, err := m.oldValue(ctx)
  29352. if err != nil {
  29353. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29354. }
  29355. return oldValue.Type, nil
  29356. }
  29357. // AddType adds i to the "type" field.
  29358. func (m *SopTaskMutation) AddType(i int) {
  29359. if m.add_type != nil {
  29360. *m.add_type += i
  29361. } else {
  29362. m.add_type = &i
  29363. }
  29364. }
  29365. // AddedType returns the value that was added to the "type" field in this mutation.
  29366. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  29367. v := m.add_type
  29368. if v == nil {
  29369. return
  29370. }
  29371. return *v, true
  29372. }
  29373. // ResetType resets all changes to the "type" field.
  29374. func (m *SopTaskMutation) ResetType() {
  29375. m._type = nil
  29376. m.add_type = nil
  29377. }
  29378. // SetPlanStartTime sets the "plan_start_time" field.
  29379. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  29380. m.plan_start_time = &t
  29381. }
  29382. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  29383. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  29384. v := m.plan_start_time
  29385. if v == nil {
  29386. return
  29387. }
  29388. return *v, true
  29389. }
  29390. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  29391. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29393. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  29394. if !m.op.Is(OpUpdateOne) {
  29395. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  29396. }
  29397. if m.id == nil || m.oldValue == nil {
  29398. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  29399. }
  29400. oldValue, err := m.oldValue(ctx)
  29401. if err != nil {
  29402. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  29403. }
  29404. return oldValue.PlanStartTime, nil
  29405. }
  29406. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  29407. func (m *SopTaskMutation) ClearPlanStartTime() {
  29408. m.plan_start_time = nil
  29409. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  29410. }
  29411. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  29412. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  29413. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  29414. return ok
  29415. }
  29416. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  29417. func (m *SopTaskMutation) ResetPlanStartTime() {
  29418. m.plan_start_time = nil
  29419. delete(m.clearedFields, soptask.FieldPlanStartTime)
  29420. }
  29421. // SetPlanEndTime sets the "plan_end_time" field.
  29422. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  29423. m.plan_end_time = &t
  29424. }
  29425. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  29426. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  29427. v := m.plan_end_time
  29428. if v == nil {
  29429. return
  29430. }
  29431. return *v, true
  29432. }
  29433. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  29434. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29436. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  29437. if !m.op.Is(OpUpdateOne) {
  29438. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  29439. }
  29440. if m.id == nil || m.oldValue == nil {
  29441. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  29442. }
  29443. oldValue, err := m.oldValue(ctx)
  29444. if err != nil {
  29445. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  29446. }
  29447. return oldValue.PlanEndTime, nil
  29448. }
  29449. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  29450. func (m *SopTaskMutation) ClearPlanEndTime() {
  29451. m.plan_end_time = nil
  29452. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  29453. }
  29454. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  29455. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  29456. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  29457. return ok
  29458. }
  29459. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  29460. func (m *SopTaskMutation) ResetPlanEndTime() {
  29461. m.plan_end_time = nil
  29462. delete(m.clearedFields, soptask.FieldPlanEndTime)
  29463. }
  29464. // SetCreatorID sets the "creator_id" field.
  29465. func (m *SopTaskMutation) SetCreatorID(s string) {
  29466. m.creator_id = &s
  29467. }
  29468. // CreatorID returns the value of the "creator_id" field in the mutation.
  29469. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  29470. v := m.creator_id
  29471. if v == nil {
  29472. return
  29473. }
  29474. return *v, true
  29475. }
  29476. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  29477. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29479. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  29480. if !m.op.Is(OpUpdateOne) {
  29481. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  29482. }
  29483. if m.id == nil || m.oldValue == nil {
  29484. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  29485. }
  29486. oldValue, err := m.oldValue(ctx)
  29487. if err != nil {
  29488. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  29489. }
  29490. return oldValue.CreatorID, nil
  29491. }
  29492. // ClearCreatorID clears the value of the "creator_id" field.
  29493. func (m *SopTaskMutation) ClearCreatorID() {
  29494. m.creator_id = nil
  29495. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  29496. }
  29497. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  29498. func (m *SopTaskMutation) CreatorIDCleared() bool {
  29499. _, ok := m.clearedFields[soptask.FieldCreatorID]
  29500. return ok
  29501. }
  29502. // ResetCreatorID resets all changes to the "creator_id" field.
  29503. func (m *SopTaskMutation) ResetCreatorID() {
  29504. m.creator_id = nil
  29505. delete(m.clearedFields, soptask.FieldCreatorID)
  29506. }
  29507. // SetOrganizationID sets the "organization_id" field.
  29508. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  29509. m.organization_id = &u
  29510. m.addorganization_id = nil
  29511. }
  29512. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29513. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  29514. v := m.organization_id
  29515. if v == nil {
  29516. return
  29517. }
  29518. return *v, true
  29519. }
  29520. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  29521. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29523. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29524. if !m.op.Is(OpUpdateOne) {
  29525. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29526. }
  29527. if m.id == nil || m.oldValue == nil {
  29528. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29529. }
  29530. oldValue, err := m.oldValue(ctx)
  29531. if err != nil {
  29532. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29533. }
  29534. return oldValue.OrganizationID, nil
  29535. }
  29536. // AddOrganizationID adds u to the "organization_id" field.
  29537. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  29538. if m.addorganization_id != nil {
  29539. *m.addorganization_id += u
  29540. } else {
  29541. m.addorganization_id = &u
  29542. }
  29543. }
  29544. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29545. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  29546. v := m.addorganization_id
  29547. if v == nil {
  29548. return
  29549. }
  29550. return *v, true
  29551. }
  29552. // ClearOrganizationID clears the value of the "organization_id" field.
  29553. func (m *SopTaskMutation) ClearOrganizationID() {
  29554. m.organization_id = nil
  29555. m.addorganization_id = nil
  29556. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  29557. }
  29558. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29559. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  29560. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  29561. return ok
  29562. }
  29563. // ResetOrganizationID resets all changes to the "organization_id" field.
  29564. func (m *SopTaskMutation) ResetOrganizationID() {
  29565. m.organization_id = nil
  29566. m.addorganization_id = nil
  29567. delete(m.clearedFields, soptask.FieldOrganizationID)
  29568. }
  29569. // SetToken sets the "token" field.
  29570. func (m *SopTaskMutation) SetToken(s []string) {
  29571. m.token = &s
  29572. m.appendtoken = nil
  29573. }
  29574. // Token returns the value of the "token" field in the mutation.
  29575. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  29576. v := m.token
  29577. if v == nil {
  29578. return
  29579. }
  29580. return *v, true
  29581. }
  29582. // OldToken returns the old "token" field's value of the SopTask entity.
  29583. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29585. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  29586. if !m.op.Is(OpUpdateOne) {
  29587. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  29588. }
  29589. if m.id == nil || m.oldValue == nil {
  29590. return v, errors.New("OldToken requires an ID field in the mutation")
  29591. }
  29592. oldValue, err := m.oldValue(ctx)
  29593. if err != nil {
  29594. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  29595. }
  29596. return oldValue.Token, nil
  29597. }
  29598. // AppendToken adds s to the "token" field.
  29599. func (m *SopTaskMutation) AppendToken(s []string) {
  29600. m.appendtoken = append(m.appendtoken, s...)
  29601. }
  29602. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  29603. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  29604. if len(m.appendtoken) == 0 {
  29605. return nil, false
  29606. }
  29607. return m.appendtoken, true
  29608. }
  29609. // ClearToken clears the value of the "token" field.
  29610. func (m *SopTaskMutation) ClearToken() {
  29611. m.token = nil
  29612. m.appendtoken = nil
  29613. m.clearedFields[soptask.FieldToken] = struct{}{}
  29614. }
  29615. // TokenCleared returns if the "token" field was cleared in this mutation.
  29616. func (m *SopTaskMutation) TokenCleared() bool {
  29617. _, ok := m.clearedFields[soptask.FieldToken]
  29618. return ok
  29619. }
  29620. // ResetToken resets all changes to the "token" field.
  29621. func (m *SopTaskMutation) ResetToken() {
  29622. m.token = nil
  29623. m.appendtoken = nil
  29624. delete(m.clearedFields, soptask.FieldToken)
  29625. }
  29626. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  29627. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  29628. if m.task_stages == nil {
  29629. m.task_stages = make(map[uint64]struct{})
  29630. }
  29631. for i := range ids {
  29632. m.task_stages[ids[i]] = struct{}{}
  29633. }
  29634. }
  29635. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  29636. func (m *SopTaskMutation) ClearTaskStages() {
  29637. m.clearedtask_stages = true
  29638. }
  29639. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  29640. func (m *SopTaskMutation) TaskStagesCleared() bool {
  29641. return m.clearedtask_stages
  29642. }
  29643. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  29644. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  29645. if m.removedtask_stages == nil {
  29646. m.removedtask_stages = make(map[uint64]struct{})
  29647. }
  29648. for i := range ids {
  29649. delete(m.task_stages, ids[i])
  29650. m.removedtask_stages[ids[i]] = struct{}{}
  29651. }
  29652. }
  29653. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  29654. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  29655. for id := range m.removedtask_stages {
  29656. ids = append(ids, id)
  29657. }
  29658. return
  29659. }
  29660. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  29661. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  29662. for id := range m.task_stages {
  29663. ids = append(ids, id)
  29664. }
  29665. return
  29666. }
  29667. // ResetTaskStages resets all changes to the "task_stages" edge.
  29668. func (m *SopTaskMutation) ResetTaskStages() {
  29669. m.task_stages = nil
  29670. m.clearedtask_stages = false
  29671. m.removedtask_stages = nil
  29672. }
  29673. // Where appends a list predicates to the SopTaskMutation builder.
  29674. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  29675. m.predicates = append(m.predicates, ps...)
  29676. }
  29677. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  29678. // users can use type-assertion to append predicates that do not depend on any generated package.
  29679. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  29680. p := make([]predicate.SopTask, len(ps))
  29681. for i := range ps {
  29682. p[i] = ps[i]
  29683. }
  29684. m.Where(p...)
  29685. }
  29686. // Op returns the operation name.
  29687. func (m *SopTaskMutation) Op() Op {
  29688. return m.op
  29689. }
  29690. // SetOp allows setting the mutation operation.
  29691. func (m *SopTaskMutation) SetOp(op Op) {
  29692. m.op = op
  29693. }
  29694. // Type returns the node type of this mutation (SopTask).
  29695. func (m *SopTaskMutation) Type() string {
  29696. return m.typ
  29697. }
  29698. // Fields returns all fields that were changed during this mutation. Note that in
  29699. // order to get all numeric fields that were incremented/decremented, call
  29700. // AddedFields().
  29701. func (m *SopTaskMutation) Fields() []string {
  29702. fields := make([]string, 0, 12)
  29703. if m.created_at != nil {
  29704. fields = append(fields, soptask.FieldCreatedAt)
  29705. }
  29706. if m.updated_at != nil {
  29707. fields = append(fields, soptask.FieldUpdatedAt)
  29708. }
  29709. if m.status != nil {
  29710. fields = append(fields, soptask.FieldStatus)
  29711. }
  29712. if m.deleted_at != nil {
  29713. fields = append(fields, soptask.FieldDeletedAt)
  29714. }
  29715. if m.name != nil {
  29716. fields = append(fields, soptask.FieldName)
  29717. }
  29718. if m.bot_wxid_list != nil {
  29719. fields = append(fields, soptask.FieldBotWxidList)
  29720. }
  29721. if m._type != nil {
  29722. fields = append(fields, soptask.FieldType)
  29723. }
  29724. if m.plan_start_time != nil {
  29725. fields = append(fields, soptask.FieldPlanStartTime)
  29726. }
  29727. if m.plan_end_time != nil {
  29728. fields = append(fields, soptask.FieldPlanEndTime)
  29729. }
  29730. if m.creator_id != nil {
  29731. fields = append(fields, soptask.FieldCreatorID)
  29732. }
  29733. if m.organization_id != nil {
  29734. fields = append(fields, soptask.FieldOrganizationID)
  29735. }
  29736. if m.token != nil {
  29737. fields = append(fields, soptask.FieldToken)
  29738. }
  29739. return fields
  29740. }
  29741. // Field returns the value of a field with the given name. The second boolean
  29742. // return value indicates that this field was not set, or was not defined in the
  29743. // schema.
  29744. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  29745. switch name {
  29746. case soptask.FieldCreatedAt:
  29747. return m.CreatedAt()
  29748. case soptask.FieldUpdatedAt:
  29749. return m.UpdatedAt()
  29750. case soptask.FieldStatus:
  29751. return m.Status()
  29752. case soptask.FieldDeletedAt:
  29753. return m.DeletedAt()
  29754. case soptask.FieldName:
  29755. return m.Name()
  29756. case soptask.FieldBotWxidList:
  29757. return m.BotWxidList()
  29758. case soptask.FieldType:
  29759. return m.GetType()
  29760. case soptask.FieldPlanStartTime:
  29761. return m.PlanStartTime()
  29762. case soptask.FieldPlanEndTime:
  29763. return m.PlanEndTime()
  29764. case soptask.FieldCreatorID:
  29765. return m.CreatorID()
  29766. case soptask.FieldOrganizationID:
  29767. return m.OrganizationID()
  29768. case soptask.FieldToken:
  29769. return m.Token()
  29770. }
  29771. return nil, false
  29772. }
  29773. // OldField returns the old value of the field from the database. An error is
  29774. // returned if the mutation operation is not UpdateOne, or the query to the
  29775. // database failed.
  29776. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29777. switch name {
  29778. case soptask.FieldCreatedAt:
  29779. return m.OldCreatedAt(ctx)
  29780. case soptask.FieldUpdatedAt:
  29781. return m.OldUpdatedAt(ctx)
  29782. case soptask.FieldStatus:
  29783. return m.OldStatus(ctx)
  29784. case soptask.FieldDeletedAt:
  29785. return m.OldDeletedAt(ctx)
  29786. case soptask.FieldName:
  29787. return m.OldName(ctx)
  29788. case soptask.FieldBotWxidList:
  29789. return m.OldBotWxidList(ctx)
  29790. case soptask.FieldType:
  29791. return m.OldType(ctx)
  29792. case soptask.FieldPlanStartTime:
  29793. return m.OldPlanStartTime(ctx)
  29794. case soptask.FieldPlanEndTime:
  29795. return m.OldPlanEndTime(ctx)
  29796. case soptask.FieldCreatorID:
  29797. return m.OldCreatorID(ctx)
  29798. case soptask.FieldOrganizationID:
  29799. return m.OldOrganizationID(ctx)
  29800. case soptask.FieldToken:
  29801. return m.OldToken(ctx)
  29802. }
  29803. return nil, fmt.Errorf("unknown SopTask field %s", name)
  29804. }
  29805. // SetField sets the value of a field with the given name. It returns an error if
  29806. // the field is not defined in the schema, or if the type mismatched the field
  29807. // type.
  29808. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  29809. switch name {
  29810. case soptask.FieldCreatedAt:
  29811. v, ok := value.(time.Time)
  29812. if !ok {
  29813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29814. }
  29815. m.SetCreatedAt(v)
  29816. return nil
  29817. case soptask.FieldUpdatedAt:
  29818. v, ok := value.(time.Time)
  29819. if !ok {
  29820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29821. }
  29822. m.SetUpdatedAt(v)
  29823. return nil
  29824. case soptask.FieldStatus:
  29825. v, ok := value.(uint8)
  29826. if !ok {
  29827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29828. }
  29829. m.SetStatus(v)
  29830. return nil
  29831. case soptask.FieldDeletedAt:
  29832. v, ok := value.(time.Time)
  29833. if !ok {
  29834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29835. }
  29836. m.SetDeletedAt(v)
  29837. return nil
  29838. case soptask.FieldName:
  29839. v, ok := value.(string)
  29840. if !ok {
  29841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29842. }
  29843. m.SetName(v)
  29844. return nil
  29845. case soptask.FieldBotWxidList:
  29846. v, ok := value.([]string)
  29847. if !ok {
  29848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29849. }
  29850. m.SetBotWxidList(v)
  29851. return nil
  29852. case soptask.FieldType:
  29853. v, ok := value.(int)
  29854. if !ok {
  29855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29856. }
  29857. m.SetType(v)
  29858. return nil
  29859. case soptask.FieldPlanStartTime:
  29860. v, ok := value.(time.Time)
  29861. if !ok {
  29862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29863. }
  29864. m.SetPlanStartTime(v)
  29865. return nil
  29866. case soptask.FieldPlanEndTime:
  29867. v, ok := value.(time.Time)
  29868. if !ok {
  29869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29870. }
  29871. m.SetPlanEndTime(v)
  29872. return nil
  29873. case soptask.FieldCreatorID:
  29874. v, ok := value.(string)
  29875. if !ok {
  29876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29877. }
  29878. m.SetCreatorID(v)
  29879. return nil
  29880. case soptask.FieldOrganizationID:
  29881. v, ok := value.(uint64)
  29882. if !ok {
  29883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29884. }
  29885. m.SetOrganizationID(v)
  29886. return nil
  29887. case soptask.FieldToken:
  29888. v, ok := value.([]string)
  29889. if !ok {
  29890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29891. }
  29892. m.SetToken(v)
  29893. return nil
  29894. }
  29895. return fmt.Errorf("unknown SopTask field %s", name)
  29896. }
  29897. // AddedFields returns all numeric fields that were incremented/decremented during
  29898. // this mutation.
  29899. func (m *SopTaskMutation) AddedFields() []string {
  29900. var fields []string
  29901. if m.addstatus != nil {
  29902. fields = append(fields, soptask.FieldStatus)
  29903. }
  29904. if m.add_type != nil {
  29905. fields = append(fields, soptask.FieldType)
  29906. }
  29907. if m.addorganization_id != nil {
  29908. fields = append(fields, soptask.FieldOrganizationID)
  29909. }
  29910. return fields
  29911. }
  29912. // AddedField returns the numeric value that was incremented/decremented on a field
  29913. // with the given name. The second boolean return value indicates that this field
  29914. // was not set, or was not defined in the schema.
  29915. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  29916. switch name {
  29917. case soptask.FieldStatus:
  29918. return m.AddedStatus()
  29919. case soptask.FieldType:
  29920. return m.AddedType()
  29921. case soptask.FieldOrganizationID:
  29922. return m.AddedOrganizationID()
  29923. }
  29924. return nil, false
  29925. }
  29926. // AddField adds the value to the field with the given name. It returns an error if
  29927. // the field is not defined in the schema, or if the type mismatched the field
  29928. // type.
  29929. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  29930. switch name {
  29931. case soptask.FieldStatus:
  29932. v, ok := value.(int8)
  29933. if !ok {
  29934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29935. }
  29936. m.AddStatus(v)
  29937. return nil
  29938. case soptask.FieldType:
  29939. v, ok := value.(int)
  29940. if !ok {
  29941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29942. }
  29943. m.AddType(v)
  29944. return nil
  29945. case soptask.FieldOrganizationID:
  29946. v, ok := value.(int64)
  29947. if !ok {
  29948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29949. }
  29950. m.AddOrganizationID(v)
  29951. return nil
  29952. }
  29953. return fmt.Errorf("unknown SopTask numeric field %s", name)
  29954. }
  29955. // ClearedFields returns all nullable fields that were cleared during this
  29956. // mutation.
  29957. func (m *SopTaskMutation) ClearedFields() []string {
  29958. var fields []string
  29959. if m.FieldCleared(soptask.FieldStatus) {
  29960. fields = append(fields, soptask.FieldStatus)
  29961. }
  29962. if m.FieldCleared(soptask.FieldDeletedAt) {
  29963. fields = append(fields, soptask.FieldDeletedAt)
  29964. }
  29965. if m.FieldCleared(soptask.FieldBotWxidList) {
  29966. fields = append(fields, soptask.FieldBotWxidList)
  29967. }
  29968. if m.FieldCleared(soptask.FieldPlanStartTime) {
  29969. fields = append(fields, soptask.FieldPlanStartTime)
  29970. }
  29971. if m.FieldCleared(soptask.FieldPlanEndTime) {
  29972. fields = append(fields, soptask.FieldPlanEndTime)
  29973. }
  29974. if m.FieldCleared(soptask.FieldCreatorID) {
  29975. fields = append(fields, soptask.FieldCreatorID)
  29976. }
  29977. if m.FieldCleared(soptask.FieldOrganizationID) {
  29978. fields = append(fields, soptask.FieldOrganizationID)
  29979. }
  29980. if m.FieldCleared(soptask.FieldToken) {
  29981. fields = append(fields, soptask.FieldToken)
  29982. }
  29983. return fields
  29984. }
  29985. // FieldCleared returns a boolean indicating if a field with the given name was
  29986. // cleared in this mutation.
  29987. func (m *SopTaskMutation) FieldCleared(name string) bool {
  29988. _, ok := m.clearedFields[name]
  29989. return ok
  29990. }
  29991. // ClearField clears the value of the field with the given name. It returns an
  29992. // error if the field is not defined in the schema.
  29993. func (m *SopTaskMutation) ClearField(name string) error {
  29994. switch name {
  29995. case soptask.FieldStatus:
  29996. m.ClearStatus()
  29997. return nil
  29998. case soptask.FieldDeletedAt:
  29999. m.ClearDeletedAt()
  30000. return nil
  30001. case soptask.FieldBotWxidList:
  30002. m.ClearBotWxidList()
  30003. return nil
  30004. case soptask.FieldPlanStartTime:
  30005. m.ClearPlanStartTime()
  30006. return nil
  30007. case soptask.FieldPlanEndTime:
  30008. m.ClearPlanEndTime()
  30009. return nil
  30010. case soptask.FieldCreatorID:
  30011. m.ClearCreatorID()
  30012. return nil
  30013. case soptask.FieldOrganizationID:
  30014. m.ClearOrganizationID()
  30015. return nil
  30016. case soptask.FieldToken:
  30017. m.ClearToken()
  30018. return nil
  30019. }
  30020. return fmt.Errorf("unknown SopTask nullable field %s", name)
  30021. }
  30022. // ResetField resets all changes in the mutation for the field with the given name.
  30023. // It returns an error if the field is not defined in the schema.
  30024. func (m *SopTaskMutation) ResetField(name string) error {
  30025. switch name {
  30026. case soptask.FieldCreatedAt:
  30027. m.ResetCreatedAt()
  30028. return nil
  30029. case soptask.FieldUpdatedAt:
  30030. m.ResetUpdatedAt()
  30031. return nil
  30032. case soptask.FieldStatus:
  30033. m.ResetStatus()
  30034. return nil
  30035. case soptask.FieldDeletedAt:
  30036. m.ResetDeletedAt()
  30037. return nil
  30038. case soptask.FieldName:
  30039. m.ResetName()
  30040. return nil
  30041. case soptask.FieldBotWxidList:
  30042. m.ResetBotWxidList()
  30043. return nil
  30044. case soptask.FieldType:
  30045. m.ResetType()
  30046. return nil
  30047. case soptask.FieldPlanStartTime:
  30048. m.ResetPlanStartTime()
  30049. return nil
  30050. case soptask.FieldPlanEndTime:
  30051. m.ResetPlanEndTime()
  30052. return nil
  30053. case soptask.FieldCreatorID:
  30054. m.ResetCreatorID()
  30055. return nil
  30056. case soptask.FieldOrganizationID:
  30057. m.ResetOrganizationID()
  30058. return nil
  30059. case soptask.FieldToken:
  30060. m.ResetToken()
  30061. return nil
  30062. }
  30063. return fmt.Errorf("unknown SopTask field %s", name)
  30064. }
  30065. // AddedEdges returns all edge names that were set/added in this mutation.
  30066. func (m *SopTaskMutation) AddedEdges() []string {
  30067. edges := make([]string, 0, 1)
  30068. if m.task_stages != nil {
  30069. edges = append(edges, soptask.EdgeTaskStages)
  30070. }
  30071. return edges
  30072. }
  30073. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30074. // name in this mutation.
  30075. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  30076. switch name {
  30077. case soptask.EdgeTaskStages:
  30078. ids := make([]ent.Value, 0, len(m.task_stages))
  30079. for id := range m.task_stages {
  30080. ids = append(ids, id)
  30081. }
  30082. return ids
  30083. }
  30084. return nil
  30085. }
  30086. // RemovedEdges returns all edge names that were removed in this mutation.
  30087. func (m *SopTaskMutation) RemovedEdges() []string {
  30088. edges := make([]string, 0, 1)
  30089. if m.removedtask_stages != nil {
  30090. edges = append(edges, soptask.EdgeTaskStages)
  30091. }
  30092. return edges
  30093. }
  30094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30095. // the given name in this mutation.
  30096. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  30097. switch name {
  30098. case soptask.EdgeTaskStages:
  30099. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  30100. for id := range m.removedtask_stages {
  30101. ids = append(ids, id)
  30102. }
  30103. return ids
  30104. }
  30105. return nil
  30106. }
  30107. // ClearedEdges returns all edge names that were cleared in this mutation.
  30108. func (m *SopTaskMutation) ClearedEdges() []string {
  30109. edges := make([]string, 0, 1)
  30110. if m.clearedtask_stages {
  30111. edges = append(edges, soptask.EdgeTaskStages)
  30112. }
  30113. return edges
  30114. }
  30115. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30116. // was cleared in this mutation.
  30117. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  30118. switch name {
  30119. case soptask.EdgeTaskStages:
  30120. return m.clearedtask_stages
  30121. }
  30122. return false
  30123. }
  30124. // ClearEdge clears the value of the edge with the given name. It returns an error
  30125. // if that edge is not defined in the schema.
  30126. func (m *SopTaskMutation) ClearEdge(name string) error {
  30127. switch name {
  30128. }
  30129. return fmt.Errorf("unknown SopTask unique edge %s", name)
  30130. }
  30131. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30132. // It returns an error if the edge is not defined in the schema.
  30133. func (m *SopTaskMutation) ResetEdge(name string) error {
  30134. switch name {
  30135. case soptask.EdgeTaskStages:
  30136. m.ResetTaskStages()
  30137. return nil
  30138. }
  30139. return fmt.Errorf("unknown SopTask edge %s", name)
  30140. }
  30141. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  30142. type TokenMutation struct {
  30143. config
  30144. op Op
  30145. typ string
  30146. id *uint64
  30147. created_at *time.Time
  30148. updated_at *time.Time
  30149. deleted_at *time.Time
  30150. expire_at *time.Time
  30151. token *string
  30152. mac *string
  30153. organization_id *uint64
  30154. addorganization_id *int64
  30155. custom_agent_base *string
  30156. custom_agent_key *string
  30157. openai_base *string
  30158. openai_key *string
  30159. clearedFields map[string]struct{}
  30160. agent *uint64
  30161. clearedagent bool
  30162. done bool
  30163. oldValue func(context.Context) (*Token, error)
  30164. predicates []predicate.Token
  30165. }
  30166. var _ ent.Mutation = (*TokenMutation)(nil)
  30167. // tokenOption allows management of the mutation configuration using functional options.
  30168. type tokenOption func(*TokenMutation)
  30169. // newTokenMutation creates new mutation for the Token entity.
  30170. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  30171. m := &TokenMutation{
  30172. config: c,
  30173. op: op,
  30174. typ: TypeToken,
  30175. clearedFields: make(map[string]struct{}),
  30176. }
  30177. for _, opt := range opts {
  30178. opt(m)
  30179. }
  30180. return m
  30181. }
  30182. // withTokenID sets the ID field of the mutation.
  30183. func withTokenID(id uint64) tokenOption {
  30184. return func(m *TokenMutation) {
  30185. var (
  30186. err error
  30187. once sync.Once
  30188. value *Token
  30189. )
  30190. m.oldValue = func(ctx context.Context) (*Token, error) {
  30191. once.Do(func() {
  30192. if m.done {
  30193. err = errors.New("querying old values post mutation is not allowed")
  30194. } else {
  30195. value, err = m.Client().Token.Get(ctx, id)
  30196. }
  30197. })
  30198. return value, err
  30199. }
  30200. m.id = &id
  30201. }
  30202. }
  30203. // withToken sets the old Token of the mutation.
  30204. func withToken(node *Token) tokenOption {
  30205. return func(m *TokenMutation) {
  30206. m.oldValue = func(context.Context) (*Token, error) {
  30207. return node, nil
  30208. }
  30209. m.id = &node.ID
  30210. }
  30211. }
  30212. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30213. // executed in a transaction (ent.Tx), a transactional client is returned.
  30214. func (m TokenMutation) Client() *Client {
  30215. client := &Client{config: m.config}
  30216. client.init()
  30217. return client
  30218. }
  30219. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30220. // it returns an error otherwise.
  30221. func (m TokenMutation) Tx() (*Tx, error) {
  30222. if _, ok := m.driver.(*txDriver); !ok {
  30223. return nil, errors.New("ent: mutation is not running in a transaction")
  30224. }
  30225. tx := &Tx{config: m.config}
  30226. tx.init()
  30227. return tx, nil
  30228. }
  30229. // SetID sets the value of the id field. Note that this
  30230. // operation is only accepted on creation of Token entities.
  30231. func (m *TokenMutation) SetID(id uint64) {
  30232. m.id = &id
  30233. }
  30234. // ID returns the ID value in the mutation. Note that the ID is only available
  30235. // if it was provided to the builder or after it was returned from the database.
  30236. func (m *TokenMutation) ID() (id uint64, exists bool) {
  30237. if m.id == nil {
  30238. return
  30239. }
  30240. return *m.id, true
  30241. }
  30242. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30243. // That means, if the mutation is applied within a transaction with an isolation level such
  30244. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30245. // or updated by the mutation.
  30246. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  30247. switch {
  30248. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30249. id, exists := m.ID()
  30250. if exists {
  30251. return []uint64{id}, nil
  30252. }
  30253. fallthrough
  30254. case m.op.Is(OpUpdate | OpDelete):
  30255. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  30256. default:
  30257. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30258. }
  30259. }
  30260. // SetCreatedAt sets the "created_at" field.
  30261. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  30262. m.created_at = &t
  30263. }
  30264. // CreatedAt returns the value of the "created_at" field in the mutation.
  30265. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  30266. v := m.created_at
  30267. if v == nil {
  30268. return
  30269. }
  30270. return *v, true
  30271. }
  30272. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  30273. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30275. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30276. if !m.op.Is(OpUpdateOne) {
  30277. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30278. }
  30279. if m.id == nil || m.oldValue == nil {
  30280. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30281. }
  30282. oldValue, err := m.oldValue(ctx)
  30283. if err != nil {
  30284. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30285. }
  30286. return oldValue.CreatedAt, nil
  30287. }
  30288. // ResetCreatedAt resets all changes to the "created_at" field.
  30289. func (m *TokenMutation) ResetCreatedAt() {
  30290. m.created_at = nil
  30291. }
  30292. // SetUpdatedAt sets the "updated_at" field.
  30293. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  30294. m.updated_at = &t
  30295. }
  30296. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30297. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  30298. v := m.updated_at
  30299. if v == nil {
  30300. return
  30301. }
  30302. return *v, true
  30303. }
  30304. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  30305. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30307. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30308. if !m.op.Is(OpUpdateOne) {
  30309. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30310. }
  30311. if m.id == nil || m.oldValue == nil {
  30312. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30313. }
  30314. oldValue, err := m.oldValue(ctx)
  30315. if err != nil {
  30316. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30317. }
  30318. return oldValue.UpdatedAt, nil
  30319. }
  30320. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30321. func (m *TokenMutation) ResetUpdatedAt() {
  30322. m.updated_at = nil
  30323. }
  30324. // SetDeletedAt sets the "deleted_at" field.
  30325. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  30326. m.deleted_at = &t
  30327. }
  30328. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30329. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  30330. v := m.deleted_at
  30331. if v == nil {
  30332. return
  30333. }
  30334. return *v, true
  30335. }
  30336. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  30337. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30339. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30340. if !m.op.Is(OpUpdateOne) {
  30341. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30342. }
  30343. if m.id == nil || m.oldValue == nil {
  30344. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30345. }
  30346. oldValue, err := m.oldValue(ctx)
  30347. if err != nil {
  30348. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30349. }
  30350. return oldValue.DeletedAt, nil
  30351. }
  30352. // ClearDeletedAt clears the value of the "deleted_at" field.
  30353. func (m *TokenMutation) ClearDeletedAt() {
  30354. m.deleted_at = nil
  30355. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  30356. }
  30357. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30358. func (m *TokenMutation) DeletedAtCleared() bool {
  30359. _, ok := m.clearedFields[token.FieldDeletedAt]
  30360. return ok
  30361. }
  30362. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30363. func (m *TokenMutation) ResetDeletedAt() {
  30364. m.deleted_at = nil
  30365. delete(m.clearedFields, token.FieldDeletedAt)
  30366. }
  30367. // SetExpireAt sets the "expire_at" field.
  30368. func (m *TokenMutation) SetExpireAt(t time.Time) {
  30369. m.expire_at = &t
  30370. }
  30371. // ExpireAt returns the value of the "expire_at" field in the mutation.
  30372. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  30373. v := m.expire_at
  30374. if v == nil {
  30375. return
  30376. }
  30377. return *v, true
  30378. }
  30379. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  30380. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30382. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  30383. if !m.op.Is(OpUpdateOne) {
  30384. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  30385. }
  30386. if m.id == nil || m.oldValue == nil {
  30387. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  30388. }
  30389. oldValue, err := m.oldValue(ctx)
  30390. if err != nil {
  30391. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  30392. }
  30393. return oldValue.ExpireAt, nil
  30394. }
  30395. // ClearExpireAt clears the value of the "expire_at" field.
  30396. func (m *TokenMutation) ClearExpireAt() {
  30397. m.expire_at = nil
  30398. m.clearedFields[token.FieldExpireAt] = struct{}{}
  30399. }
  30400. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  30401. func (m *TokenMutation) ExpireAtCleared() bool {
  30402. _, ok := m.clearedFields[token.FieldExpireAt]
  30403. return ok
  30404. }
  30405. // ResetExpireAt resets all changes to the "expire_at" field.
  30406. func (m *TokenMutation) ResetExpireAt() {
  30407. m.expire_at = nil
  30408. delete(m.clearedFields, token.FieldExpireAt)
  30409. }
  30410. // SetToken sets the "token" field.
  30411. func (m *TokenMutation) SetToken(s string) {
  30412. m.token = &s
  30413. }
  30414. // Token returns the value of the "token" field in the mutation.
  30415. func (m *TokenMutation) Token() (r string, exists bool) {
  30416. v := m.token
  30417. if v == nil {
  30418. return
  30419. }
  30420. return *v, true
  30421. }
  30422. // OldToken returns the old "token" field's value of the Token entity.
  30423. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30425. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  30426. if !m.op.Is(OpUpdateOne) {
  30427. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30428. }
  30429. if m.id == nil || m.oldValue == nil {
  30430. return v, errors.New("OldToken requires an ID field in the mutation")
  30431. }
  30432. oldValue, err := m.oldValue(ctx)
  30433. if err != nil {
  30434. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30435. }
  30436. return oldValue.Token, nil
  30437. }
  30438. // ClearToken clears the value of the "token" field.
  30439. func (m *TokenMutation) ClearToken() {
  30440. m.token = nil
  30441. m.clearedFields[token.FieldToken] = struct{}{}
  30442. }
  30443. // TokenCleared returns if the "token" field was cleared in this mutation.
  30444. func (m *TokenMutation) TokenCleared() bool {
  30445. _, ok := m.clearedFields[token.FieldToken]
  30446. return ok
  30447. }
  30448. // ResetToken resets all changes to the "token" field.
  30449. func (m *TokenMutation) ResetToken() {
  30450. m.token = nil
  30451. delete(m.clearedFields, token.FieldToken)
  30452. }
  30453. // SetMAC sets the "mac" field.
  30454. func (m *TokenMutation) SetMAC(s string) {
  30455. m.mac = &s
  30456. }
  30457. // MAC returns the value of the "mac" field in the mutation.
  30458. func (m *TokenMutation) MAC() (r string, exists bool) {
  30459. v := m.mac
  30460. if v == nil {
  30461. return
  30462. }
  30463. return *v, true
  30464. }
  30465. // OldMAC returns the old "mac" field's value of the Token entity.
  30466. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30468. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  30469. if !m.op.Is(OpUpdateOne) {
  30470. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  30471. }
  30472. if m.id == nil || m.oldValue == nil {
  30473. return v, errors.New("OldMAC requires an ID field in the mutation")
  30474. }
  30475. oldValue, err := m.oldValue(ctx)
  30476. if err != nil {
  30477. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  30478. }
  30479. return oldValue.MAC, nil
  30480. }
  30481. // ClearMAC clears the value of the "mac" field.
  30482. func (m *TokenMutation) ClearMAC() {
  30483. m.mac = nil
  30484. m.clearedFields[token.FieldMAC] = struct{}{}
  30485. }
  30486. // MACCleared returns if the "mac" field was cleared in this mutation.
  30487. func (m *TokenMutation) MACCleared() bool {
  30488. _, ok := m.clearedFields[token.FieldMAC]
  30489. return ok
  30490. }
  30491. // ResetMAC resets all changes to the "mac" field.
  30492. func (m *TokenMutation) ResetMAC() {
  30493. m.mac = nil
  30494. delete(m.clearedFields, token.FieldMAC)
  30495. }
  30496. // SetOrganizationID sets the "organization_id" field.
  30497. func (m *TokenMutation) SetOrganizationID(u uint64) {
  30498. m.organization_id = &u
  30499. m.addorganization_id = nil
  30500. }
  30501. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30502. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  30503. v := m.organization_id
  30504. if v == nil {
  30505. return
  30506. }
  30507. return *v, true
  30508. }
  30509. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  30510. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30512. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30513. if !m.op.Is(OpUpdateOne) {
  30514. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30515. }
  30516. if m.id == nil || m.oldValue == nil {
  30517. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30518. }
  30519. oldValue, err := m.oldValue(ctx)
  30520. if err != nil {
  30521. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30522. }
  30523. return oldValue.OrganizationID, nil
  30524. }
  30525. // AddOrganizationID adds u to the "organization_id" field.
  30526. func (m *TokenMutation) AddOrganizationID(u int64) {
  30527. if m.addorganization_id != nil {
  30528. *m.addorganization_id += u
  30529. } else {
  30530. m.addorganization_id = &u
  30531. }
  30532. }
  30533. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30534. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  30535. v := m.addorganization_id
  30536. if v == nil {
  30537. return
  30538. }
  30539. return *v, true
  30540. }
  30541. // ResetOrganizationID resets all changes to the "organization_id" field.
  30542. func (m *TokenMutation) ResetOrganizationID() {
  30543. m.organization_id = nil
  30544. m.addorganization_id = nil
  30545. }
  30546. // SetAgentID sets the "agent_id" field.
  30547. func (m *TokenMutation) SetAgentID(u uint64) {
  30548. m.agent = &u
  30549. }
  30550. // AgentID returns the value of the "agent_id" field in the mutation.
  30551. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  30552. v := m.agent
  30553. if v == nil {
  30554. return
  30555. }
  30556. return *v, true
  30557. }
  30558. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  30559. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30561. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  30562. if !m.op.Is(OpUpdateOne) {
  30563. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  30564. }
  30565. if m.id == nil || m.oldValue == nil {
  30566. return v, errors.New("OldAgentID requires an ID field in the mutation")
  30567. }
  30568. oldValue, err := m.oldValue(ctx)
  30569. if err != nil {
  30570. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  30571. }
  30572. return oldValue.AgentID, nil
  30573. }
  30574. // ResetAgentID resets all changes to the "agent_id" field.
  30575. func (m *TokenMutation) ResetAgentID() {
  30576. m.agent = nil
  30577. }
  30578. // SetCustomAgentBase sets the "custom_agent_base" field.
  30579. func (m *TokenMutation) SetCustomAgentBase(s string) {
  30580. m.custom_agent_base = &s
  30581. }
  30582. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  30583. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  30584. v := m.custom_agent_base
  30585. if v == nil {
  30586. return
  30587. }
  30588. return *v, true
  30589. }
  30590. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  30591. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30593. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  30594. if !m.op.Is(OpUpdateOne) {
  30595. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  30596. }
  30597. if m.id == nil || m.oldValue == nil {
  30598. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  30599. }
  30600. oldValue, err := m.oldValue(ctx)
  30601. if err != nil {
  30602. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  30603. }
  30604. return oldValue.CustomAgentBase, nil
  30605. }
  30606. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  30607. func (m *TokenMutation) ClearCustomAgentBase() {
  30608. m.custom_agent_base = nil
  30609. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  30610. }
  30611. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  30612. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  30613. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  30614. return ok
  30615. }
  30616. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  30617. func (m *TokenMutation) ResetCustomAgentBase() {
  30618. m.custom_agent_base = nil
  30619. delete(m.clearedFields, token.FieldCustomAgentBase)
  30620. }
  30621. // SetCustomAgentKey sets the "custom_agent_key" field.
  30622. func (m *TokenMutation) SetCustomAgentKey(s string) {
  30623. m.custom_agent_key = &s
  30624. }
  30625. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  30626. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  30627. v := m.custom_agent_key
  30628. if v == nil {
  30629. return
  30630. }
  30631. return *v, true
  30632. }
  30633. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  30634. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30636. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  30637. if !m.op.Is(OpUpdateOne) {
  30638. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  30639. }
  30640. if m.id == nil || m.oldValue == nil {
  30641. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  30642. }
  30643. oldValue, err := m.oldValue(ctx)
  30644. if err != nil {
  30645. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  30646. }
  30647. return oldValue.CustomAgentKey, nil
  30648. }
  30649. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  30650. func (m *TokenMutation) ClearCustomAgentKey() {
  30651. m.custom_agent_key = nil
  30652. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  30653. }
  30654. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  30655. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  30656. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  30657. return ok
  30658. }
  30659. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  30660. func (m *TokenMutation) ResetCustomAgentKey() {
  30661. m.custom_agent_key = nil
  30662. delete(m.clearedFields, token.FieldCustomAgentKey)
  30663. }
  30664. // SetOpenaiBase sets the "openai_base" field.
  30665. func (m *TokenMutation) SetOpenaiBase(s string) {
  30666. m.openai_base = &s
  30667. }
  30668. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  30669. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  30670. v := m.openai_base
  30671. if v == nil {
  30672. return
  30673. }
  30674. return *v, true
  30675. }
  30676. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  30677. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30679. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  30680. if !m.op.Is(OpUpdateOne) {
  30681. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  30682. }
  30683. if m.id == nil || m.oldValue == nil {
  30684. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  30685. }
  30686. oldValue, err := m.oldValue(ctx)
  30687. if err != nil {
  30688. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  30689. }
  30690. return oldValue.OpenaiBase, nil
  30691. }
  30692. // ClearOpenaiBase clears the value of the "openai_base" field.
  30693. func (m *TokenMutation) ClearOpenaiBase() {
  30694. m.openai_base = nil
  30695. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  30696. }
  30697. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  30698. func (m *TokenMutation) OpenaiBaseCleared() bool {
  30699. _, ok := m.clearedFields[token.FieldOpenaiBase]
  30700. return ok
  30701. }
  30702. // ResetOpenaiBase resets all changes to the "openai_base" field.
  30703. func (m *TokenMutation) ResetOpenaiBase() {
  30704. m.openai_base = nil
  30705. delete(m.clearedFields, token.FieldOpenaiBase)
  30706. }
  30707. // SetOpenaiKey sets the "openai_key" field.
  30708. func (m *TokenMutation) SetOpenaiKey(s string) {
  30709. m.openai_key = &s
  30710. }
  30711. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  30712. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  30713. v := m.openai_key
  30714. if v == nil {
  30715. return
  30716. }
  30717. return *v, true
  30718. }
  30719. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  30720. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30722. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  30723. if !m.op.Is(OpUpdateOne) {
  30724. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  30725. }
  30726. if m.id == nil || m.oldValue == nil {
  30727. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  30728. }
  30729. oldValue, err := m.oldValue(ctx)
  30730. if err != nil {
  30731. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  30732. }
  30733. return oldValue.OpenaiKey, nil
  30734. }
  30735. // ClearOpenaiKey clears the value of the "openai_key" field.
  30736. func (m *TokenMutation) ClearOpenaiKey() {
  30737. m.openai_key = nil
  30738. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  30739. }
  30740. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  30741. func (m *TokenMutation) OpenaiKeyCleared() bool {
  30742. _, ok := m.clearedFields[token.FieldOpenaiKey]
  30743. return ok
  30744. }
  30745. // ResetOpenaiKey resets all changes to the "openai_key" field.
  30746. func (m *TokenMutation) ResetOpenaiKey() {
  30747. m.openai_key = nil
  30748. delete(m.clearedFields, token.FieldOpenaiKey)
  30749. }
  30750. // ClearAgent clears the "agent" edge to the Agent entity.
  30751. func (m *TokenMutation) ClearAgent() {
  30752. m.clearedagent = true
  30753. m.clearedFields[token.FieldAgentID] = struct{}{}
  30754. }
  30755. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  30756. func (m *TokenMutation) AgentCleared() bool {
  30757. return m.clearedagent
  30758. }
  30759. // AgentIDs returns the "agent" edge IDs in the mutation.
  30760. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30761. // AgentID instead. It exists only for internal usage by the builders.
  30762. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  30763. if id := m.agent; id != nil {
  30764. ids = append(ids, *id)
  30765. }
  30766. return
  30767. }
  30768. // ResetAgent resets all changes to the "agent" edge.
  30769. func (m *TokenMutation) ResetAgent() {
  30770. m.agent = nil
  30771. m.clearedagent = false
  30772. }
  30773. // Where appends a list predicates to the TokenMutation builder.
  30774. func (m *TokenMutation) Where(ps ...predicate.Token) {
  30775. m.predicates = append(m.predicates, ps...)
  30776. }
  30777. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  30778. // users can use type-assertion to append predicates that do not depend on any generated package.
  30779. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  30780. p := make([]predicate.Token, len(ps))
  30781. for i := range ps {
  30782. p[i] = ps[i]
  30783. }
  30784. m.Where(p...)
  30785. }
  30786. // Op returns the operation name.
  30787. func (m *TokenMutation) Op() Op {
  30788. return m.op
  30789. }
  30790. // SetOp allows setting the mutation operation.
  30791. func (m *TokenMutation) SetOp(op Op) {
  30792. m.op = op
  30793. }
  30794. // Type returns the node type of this mutation (Token).
  30795. func (m *TokenMutation) Type() string {
  30796. return m.typ
  30797. }
  30798. // Fields returns all fields that were changed during this mutation. Note that in
  30799. // order to get all numeric fields that were incremented/decremented, call
  30800. // AddedFields().
  30801. func (m *TokenMutation) Fields() []string {
  30802. fields := make([]string, 0, 12)
  30803. if m.created_at != nil {
  30804. fields = append(fields, token.FieldCreatedAt)
  30805. }
  30806. if m.updated_at != nil {
  30807. fields = append(fields, token.FieldUpdatedAt)
  30808. }
  30809. if m.deleted_at != nil {
  30810. fields = append(fields, token.FieldDeletedAt)
  30811. }
  30812. if m.expire_at != nil {
  30813. fields = append(fields, token.FieldExpireAt)
  30814. }
  30815. if m.token != nil {
  30816. fields = append(fields, token.FieldToken)
  30817. }
  30818. if m.mac != nil {
  30819. fields = append(fields, token.FieldMAC)
  30820. }
  30821. if m.organization_id != nil {
  30822. fields = append(fields, token.FieldOrganizationID)
  30823. }
  30824. if m.agent != nil {
  30825. fields = append(fields, token.FieldAgentID)
  30826. }
  30827. if m.custom_agent_base != nil {
  30828. fields = append(fields, token.FieldCustomAgentBase)
  30829. }
  30830. if m.custom_agent_key != nil {
  30831. fields = append(fields, token.FieldCustomAgentKey)
  30832. }
  30833. if m.openai_base != nil {
  30834. fields = append(fields, token.FieldOpenaiBase)
  30835. }
  30836. if m.openai_key != nil {
  30837. fields = append(fields, token.FieldOpenaiKey)
  30838. }
  30839. return fields
  30840. }
  30841. // Field returns the value of a field with the given name. The second boolean
  30842. // return value indicates that this field was not set, or was not defined in the
  30843. // schema.
  30844. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  30845. switch name {
  30846. case token.FieldCreatedAt:
  30847. return m.CreatedAt()
  30848. case token.FieldUpdatedAt:
  30849. return m.UpdatedAt()
  30850. case token.FieldDeletedAt:
  30851. return m.DeletedAt()
  30852. case token.FieldExpireAt:
  30853. return m.ExpireAt()
  30854. case token.FieldToken:
  30855. return m.Token()
  30856. case token.FieldMAC:
  30857. return m.MAC()
  30858. case token.FieldOrganizationID:
  30859. return m.OrganizationID()
  30860. case token.FieldAgentID:
  30861. return m.AgentID()
  30862. case token.FieldCustomAgentBase:
  30863. return m.CustomAgentBase()
  30864. case token.FieldCustomAgentKey:
  30865. return m.CustomAgentKey()
  30866. case token.FieldOpenaiBase:
  30867. return m.OpenaiBase()
  30868. case token.FieldOpenaiKey:
  30869. return m.OpenaiKey()
  30870. }
  30871. return nil, false
  30872. }
  30873. // OldField returns the old value of the field from the database. An error is
  30874. // returned if the mutation operation is not UpdateOne, or the query to the
  30875. // database failed.
  30876. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30877. switch name {
  30878. case token.FieldCreatedAt:
  30879. return m.OldCreatedAt(ctx)
  30880. case token.FieldUpdatedAt:
  30881. return m.OldUpdatedAt(ctx)
  30882. case token.FieldDeletedAt:
  30883. return m.OldDeletedAt(ctx)
  30884. case token.FieldExpireAt:
  30885. return m.OldExpireAt(ctx)
  30886. case token.FieldToken:
  30887. return m.OldToken(ctx)
  30888. case token.FieldMAC:
  30889. return m.OldMAC(ctx)
  30890. case token.FieldOrganizationID:
  30891. return m.OldOrganizationID(ctx)
  30892. case token.FieldAgentID:
  30893. return m.OldAgentID(ctx)
  30894. case token.FieldCustomAgentBase:
  30895. return m.OldCustomAgentBase(ctx)
  30896. case token.FieldCustomAgentKey:
  30897. return m.OldCustomAgentKey(ctx)
  30898. case token.FieldOpenaiBase:
  30899. return m.OldOpenaiBase(ctx)
  30900. case token.FieldOpenaiKey:
  30901. return m.OldOpenaiKey(ctx)
  30902. }
  30903. return nil, fmt.Errorf("unknown Token field %s", name)
  30904. }
  30905. // SetField sets the value of a field with the given name. It returns an error if
  30906. // the field is not defined in the schema, or if the type mismatched the field
  30907. // type.
  30908. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  30909. switch name {
  30910. case token.FieldCreatedAt:
  30911. v, ok := value.(time.Time)
  30912. if !ok {
  30913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30914. }
  30915. m.SetCreatedAt(v)
  30916. return nil
  30917. case token.FieldUpdatedAt:
  30918. v, ok := value.(time.Time)
  30919. if !ok {
  30920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30921. }
  30922. m.SetUpdatedAt(v)
  30923. return nil
  30924. case token.FieldDeletedAt:
  30925. v, ok := value.(time.Time)
  30926. if !ok {
  30927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30928. }
  30929. m.SetDeletedAt(v)
  30930. return nil
  30931. case token.FieldExpireAt:
  30932. v, ok := value.(time.Time)
  30933. if !ok {
  30934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30935. }
  30936. m.SetExpireAt(v)
  30937. return nil
  30938. case token.FieldToken:
  30939. v, ok := value.(string)
  30940. if !ok {
  30941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30942. }
  30943. m.SetToken(v)
  30944. return nil
  30945. case token.FieldMAC:
  30946. v, ok := value.(string)
  30947. if !ok {
  30948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30949. }
  30950. m.SetMAC(v)
  30951. return nil
  30952. case token.FieldOrganizationID:
  30953. v, ok := value.(uint64)
  30954. if !ok {
  30955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30956. }
  30957. m.SetOrganizationID(v)
  30958. return nil
  30959. case token.FieldAgentID:
  30960. v, ok := value.(uint64)
  30961. if !ok {
  30962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30963. }
  30964. m.SetAgentID(v)
  30965. return nil
  30966. case token.FieldCustomAgentBase:
  30967. v, ok := value.(string)
  30968. if !ok {
  30969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30970. }
  30971. m.SetCustomAgentBase(v)
  30972. return nil
  30973. case token.FieldCustomAgentKey:
  30974. v, ok := value.(string)
  30975. if !ok {
  30976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30977. }
  30978. m.SetCustomAgentKey(v)
  30979. return nil
  30980. case token.FieldOpenaiBase:
  30981. v, ok := value.(string)
  30982. if !ok {
  30983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30984. }
  30985. m.SetOpenaiBase(v)
  30986. return nil
  30987. case token.FieldOpenaiKey:
  30988. v, ok := value.(string)
  30989. if !ok {
  30990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30991. }
  30992. m.SetOpenaiKey(v)
  30993. return nil
  30994. }
  30995. return fmt.Errorf("unknown Token field %s", name)
  30996. }
  30997. // AddedFields returns all numeric fields that were incremented/decremented during
  30998. // this mutation.
  30999. func (m *TokenMutation) AddedFields() []string {
  31000. var fields []string
  31001. if m.addorganization_id != nil {
  31002. fields = append(fields, token.FieldOrganizationID)
  31003. }
  31004. return fields
  31005. }
  31006. // AddedField returns the numeric value that was incremented/decremented on a field
  31007. // with the given name. The second boolean return value indicates that this field
  31008. // was not set, or was not defined in the schema.
  31009. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  31010. switch name {
  31011. case token.FieldOrganizationID:
  31012. return m.AddedOrganizationID()
  31013. }
  31014. return nil, false
  31015. }
  31016. // AddField adds the value to the field with the given name. It returns an error if
  31017. // the field is not defined in the schema, or if the type mismatched the field
  31018. // type.
  31019. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  31020. switch name {
  31021. case token.FieldOrganizationID:
  31022. v, ok := value.(int64)
  31023. if !ok {
  31024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31025. }
  31026. m.AddOrganizationID(v)
  31027. return nil
  31028. }
  31029. return fmt.Errorf("unknown Token numeric field %s", name)
  31030. }
  31031. // ClearedFields returns all nullable fields that were cleared during this
  31032. // mutation.
  31033. func (m *TokenMutation) ClearedFields() []string {
  31034. var fields []string
  31035. if m.FieldCleared(token.FieldDeletedAt) {
  31036. fields = append(fields, token.FieldDeletedAt)
  31037. }
  31038. if m.FieldCleared(token.FieldExpireAt) {
  31039. fields = append(fields, token.FieldExpireAt)
  31040. }
  31041. if m.FieldCleared(token.FieldToken) {
  31042. fields = append(fields, token.FieldToken)
  31043. }
  31044. if m.FieldCleared(token.FieldMAC) {
  31045. fields = append(fields, token.FieldMAC)
  31046. }
  31047. if m.FieldCleared(token.FieldCustomAgentBase) {
  31048. fields = append(fields, token.FieldCustomAgentBase)
  31049. }
  31050. if m.FieldCleared(token.FieldCustomAgentKey) {
  31051. fields = append(fields, token.FieldCustomAgentKey)
  31052. }
  31053. if m.FieldCleared(token.FieldOpenaiBase) {
  31054. fields = append(fields, token.FieldOpenaiBase)
  31055. }
  31056. if m.FieldCleared(token.FieldOpenaiKey) {
  31057. fields = append(fields, token.FieldOpenaiKey)
  31058. }
  31059. return fields
  31060. }
  31061. // FieldCleared returns a boolean indicating if a field with the given name was
  31062. // cleared in this mutation.
  31063. func (m *TokenMutation) FieldCleared(name string) bool {
  31064. _, ok := m.clearedFields[name]
  31065. return ok
  31066. }
  31067. // ClearField clears the value of the field with the given name. It returns an
  31068. // error if the field is not defined in the schema.
  31069. func (m *TokenMutation) ClearField(name string) error {
  31070. switch name {
  31071. case token.FieldDeletedAt:
  31072. m.ClearDeletedAt()
  31073. return nil
  31074. case token.FieldExpireAt:
  31075. m.ClearExpireAt()
  31076. return nil
  31077. case token.FieldToken:
  31078. m.ClearToken()
  31079. return nil
  31080. case token.FieldMAC:
  31081. m.ClearMAC()
  31082. return nil
  31083. case token.FieldCustomAgentBase:
  31084. m.ClearCustomAgentBase()
  31085. return nil
  31086. case token.FieldCustomAgentKey:
  31087. m.ClearCustomAgentKey()
  31088. return nil
  31089. case token.FieldOpenaiBase:
  31090. m.ClearOpenaiBase()
  31091. return nil
  31092. case token.FieldOpenaiKey:
  31093. m.ClearOpenaiKey()
  31094. return nil
  31095. }
  31096. return fmt.Errorf("unknown Token nullable field %s", name)
  31097. }
  31098. // ResetField resets all changes in the mutation for the field with the given name.
  31099. // It returns an error if the field is not defined in the schema.
  31100. func (m *TokenMutation) ResetField(name string) error {
  31101. switch name {
  31102. case token.FieldCreatedAt:
  31103. m.ResetCreatedAt()
  31104. return nil
  31105. case token.FieldUpdatedAt:
  31106. m.ResetUpdatedAt()
  31107. return nil
  31108. case token.FieldDeletedAt:
  31109. m.ResetDeletedAt()
  31110. return nil
  31111. case token.FieldExpireAt:
  31112. m.ResetExpireAt()
  31113. return nil
  31114. case token.FieldToken:
  31115. m.ResetToken()
  31116. return nil
  31117. case token.FieldMAC:
  31118. m.ResetMAC()
  31119. return nil
  31120. case token.FieldOrganizationID:
  31121. m.ResetOrganizationID()
  31122. return nil
  31123. case token.FieldAgentID:
  31124. m.ResetAgentID()
  31125. return nil
  31126. case token.FieldCustomAgentBase:
  31127. m.ResetCustomAgentBase()
  31128. return nil
  31129. case token.FieldCustomAgentKey:
  31130. m.ResetCustomAgentKey()
  31131. return nil
  31132. case token.FieldOpenaiBase:
  31133. m.ResetOpenaiBase()
  31134. return nil
  31135. case token.FieldOpenaiKey:
  31136. m.ResetOpenaiKey()
  31137. return nil
  31138. }
  31139. return fmt.Errorf("unknown Token field %s", name)
  31140. }
  31141. // AddedEdges returns all edge names that were set/added in this mutation.
  31142. func (m *TokenMutation) AddedEdges() []string {
  31143. edges := make([]string, 0, 1)
  31144. if m.agent != nil {
  31145. edges = append(edges, token.EdgeAgent)
  31146. }
  31147. return edges
  31148. }
  31149. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31150. // name in this mutation.
  31151. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  31152. switch name {
  31153. case token.EdgeAgent:
  31154. if id := m.agent; id != nil {
  31155. return []ent.Value{*id}
  31156. }
  31157. }
  31158. return nil
  31159. }
  31160. // RemovedEdges returns all edge names that were removed in this mutation.
  31161. func (m *TokenMutation) RemovedEdges() []string {
  31162. edges := make([]string, 0, 1)
  31163. return edges
  31164. }
  31165. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31166. // the given name in this mutation.
  31167. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  31168. return nil
  31169. }
  31170. // ClearedEdges returns all edge names that were cleared in this mutation.
  31171. func (m *TokenMutation) ClearedEdges() []string {
  31172. edges := make([]string, 0, 1)
  31173. if m.clearedagent {
  31174. edges = append(edges, token.EdgeAgent)
  31175. }
  31176. return edges
  31177. }
  31178. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31179. // was cleared in this mutation.
  31180. func (m *TokenMutation) EdgeCleared(name string) bool {
  31181. switch name {
  31182. case token.EdgeAgent:
  31183. return m.clearedagent
  31184. }
  31185. return false
  31186. }
  31187. // ClearEdge clears the value of the edge with the given name. It returns an error
  31188. // if that edge is not defined in the schema.
  31189. func (m *TokenMutation) ClearEdge(name string) error {
  31190. switch name {
  31191. case token.EdgeAgent:
  31192. m.ClearAgent()
  31193. return nil
  31194. }
  31195. return fmt.Errorf("unknown Token unique edge %s", name)
  31196. }
  31197. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31198. // It returns an error if the edge is not defined in the schema.
  31199. func (m *TokenMutation) ResetEdge(name string) error {
  31200. switch name {
  31201. case token.EdgeAgent:
  31202. m.ResetAgent()
  31203. return nil
  31204. }
  31205. return fmt.Errorf("unknown Token edge %s", name)
  31206. }
  31207. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  31208. type TutorialMutation struct {
  31209. config
  31210. op Op
  31211. typ string
  31212. id *uint64
  31213. created_at *time.Time
  31214. updated_at *time.Time
  31215. deleted_at *time.Time
  31216. index *int
  31217. addindex *int
  31218. title *string
  31219. content *string
  31220. organization_id *uint64
  31221. addorganization_id *int64
  31222. clearedFields map[string]struct{}
  31223. employee *uint64
  31224. clearedemployee bool
  31225. done bool
  31226. oldValue func(context.Context) (*Tutorial, error)
  31227. predicates []predicate.Tutorial
  31228. }
  31229. var _ ent.Mutation = (*TutorialMutation)(nil)
  31230. // tutorialOption allows management of the mutation configuration using functional options.
  31231. type tutorialOption func(*TutorialMutation)
  31232. // newTutorialMutation creates new mutation for the Tutorial entity.
  31233. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  31234. m := &TutorialMutation{
  31235. config: c,
  31236. op: op,
  31237. typ: TypeTutorial,
  31238. clearedFields: make(map[string]struct{}),
  31239. }
  31240. for _, opt := range opts {
  31241. opt(m)
  31242. }
  31243. return m
  31244. }
  31245. // withTutorialID sets the ID field of the mutation.
  31246. func withTutorialID(id uint64) tutorialOption {
  31247. return func(m *TutorialMutation) {
  31248. var (
  31249. err error
  31250. once sync.Once
  31251. value *Tutorial
  31252. )
  31253. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  31254. once.Do(func() {
  31255. if m.done {
  31256. err = errors.New("querying old values post mutation is not allowed")
  31257. } else {
  31258. value, err = m.Client().Tutorial.Get(ctx, id)
  31259. }
  31260. })
  31261. return value, err
  31262. }
  31263. m.id = &id
  31264. }
  31265. }
  31266. // withTutorial sets the old Tutorial of the mutation.
  31267. func withTutorial(node *Tutorial) tutorialOption {
  31268. return func(m *TutorialMutation) {
  31269. m.oldValue = func(context.Context) (*Tutorial, error) {
  31270. return node, nil
  31271. }
  31272. m.id = &node.ID
  31273. }
  31274. }
  31275. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31276. // executed in a transaction (ent.Tx), a transactional client is returned.
  31277. func (m TutorialMutation) Client() *Client {
  31278. client := &Client{config: m.config}
  31279. client.init()
  31280. return client
  31281. }
  31282. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31283. // it returns an error otherwise.
  31284. func (m TutorialMutation) Tx() (*Tx, error) {
  31285. if _, ok := m.driver.(*txDriver); !ok {
  31286. return nil, errors.New("ent: mutation is not running in a transaction")
  31287. }
  31288. tx := &Tx{config: m.config}
  31289. tx.init()
  31290. return tx, nil
  31291. }
  31292. // SetID sets the value of the id field. Note that this
  31293. // operation is only accepted on creation of Tutorial entities.
  31294. func (m *TutorialMutation) SetID(id uint64) {
  31295. m.id = &id
  31296. }
  31297. // ID returns the ID value in the mutation. Note that the ID is only available
  31298. // if it was provided to the builder or after it was returned from the database.
  31299. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  31300. if m.id == nil {
  31301. return
  31302. }
  31303. return *m.id, true
  31304. }
  31305. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31306. // That means, if the mutation is applied within a transaction with an isolation level such
  31307. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31308. // or updated by the mutation.
  31309. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  31310. switch {
  31311. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31312. id, exists := m.ID()
  31313. if exists {
  31314. return []uint64{id}, nil
  31315. }
  31316. fallthrough
  31317. case m.op.Is(OpUpdate | OpDelete):
  31318. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  31319. default:
  31320. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31321. }
  31322. }
  31323. // SetCreatedAt sets the "created_at" field.
  31324. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  31325. m.created_at = &t
  31326. }
  31327. // CreatedAt returns the value of the "created_at" field in the mutation.
  31328. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  31329. v := m.created_at
  31330. if v == nil {
  31331. return
  31332. }
  31333. return *v, true
  31334. }
  31335. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  31336. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31338. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31339. if !m.op.Is(OpUpdateOne) {
  31340. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31341. }
  31342. if m.id == nil || m.oldValue == nil {
  31343. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31344. }
  31345. oldValue, err := m.oldValue(ctx)
  31346. if err != nil {
  31347. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31348. }
  31349. return oldValue.CreatedAt, nil
  31350. }
  31351. // ResetCreatedAt resets all changes to the "created_at" field.
  31352. func (m *TutorialMutation) ResetCreatedAt() {
  31353. m.created_at = nil
  31354. }
  31355. // SetUpdatedAt sets the "updated_at" field.
  31356. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  31357. m.updated_at = &t
  31358. }
  31359. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31360. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  31361. v := m.updated_at
  31362. if v == nil {
  31363. return
  31364. }
  31365. return *v, true
  31366. }
  31367. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  31368. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31370. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31371. if !m.op.Is(OpUpdateOne) {
  31372. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31373. }
  31374. if m.id == nil || m.oldValue == nil {
  31375. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31376. }
  31377. oldValue, err := m.oldValue(ctx)
  31378. if err != nil {
  31379. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31380. }
  31381. return oldValue.UpdatedAt, nil
  31382. }
  31383. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31384. func (m *TutorialMutation) ResetUpdatedAt() {
  31385. m.updated_at = nil
  31386. }
  31387. // SetDeletedAt sets the "deleted_at" field.
  31388. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  31389. m.deleted_at = &t
  31390. }
  31391. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31392. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  31393. v := m.deleted_at
  31394. if v == nil {
  31395. return
  31396. }
  31397. return *v, true
  31398. }
  31399. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  31400. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31402. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31403. if !m.op.Is(OpUpdateOne) {
  31404. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31405. }
  31406. if m.id == nil || m.oldValue == nil {
  31407. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31408. }
  31409. oldValue, err := m.oldValue(ctx)
  31410. if err != nil {
  31411. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31412. }
  31413. return oldValue.DeletedAt, nil
  31414. }
  31415. // ClearDeletedAt clears the value of the "deleted_at" field.
  31416. func (m *TutorialMutation) ClearDeletedAt() {
  31417. m.deleted_at = nil
  31418. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  31419. }
  31420. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31421. func (m *TutorialMutation) DeletedAtCleared() bool {
  31422. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  31423. return ok
  31424. }
  31425. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31426. func (m *TutorialMutation) ResetDeletedAt() {
  31427. m.deleted_at = nil
  31428. delete(m.clearedFields, tutorial.FieldDeletedAt)
  31429. }
  31430. // SetEmployeeID sets the "employee_id" field.
  31431. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  31432. m.employee = &u
  31433. }
  31434. // EmployeeID returns the value of the "employee_id" field in the mutation.
  31435. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  31436. v := m.employee
  31437. if v == nil {
  31438. return
  31439. }
  31440. return *v, true
  31441. }
  31442. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  31443. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31445. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  31446. if !m.op.Is(OpUpdateOne) {
  31447. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  31448. }
  31449. if m.id == nil || m.oldValue == nil {
  31450. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  31451. }
  31452. oldValue, err := m.oldValue(ctx)
  31453. if err != nil {
  31454. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  31455. }
  31456. return oldValue.EmployeeID, nil
  31457. }
  31458. // ResetEmployeeID resets all changes to the "employee_id" field.
  31459. func (m *TutorialMutation) ResetEmployeeID() {
  31460. m.employee = nil
  31461. }
  31462. // SetIndex sets the "index" field.
  31463. func (m *TutorialMutation) SetIndex(i int) {
  31464. m.index = &i
  31465. m.addindex = nil
  31466. }
  31467. // Index returns the value of the "index" field in the mutation.
  31468. func (m *TutorialMutation) Index() (r int, exists bool) {
  31469. v := m.index
  31470. if v == nil {
  31471. return
  31472. }
  31473. return *v, true
  31474. }
  31475. // OldIndex returns the old "index" field's value of the Tutorial entity.
  31476. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31478. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  31479. if !m.op.Is(OpUpdateOne) {
  31480. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  31481. }
  31482. if m.id == nil || m.oldValue == nil {
  31483. return v, errors.New("OldIndex requires an ID field in the mutation")
  31484. }
  31485. oldValue, err := m.oldValue(ctx)
  31486. if err != nil {
  31487. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  31488. }
  31489. return oldValue.Index, nil
  31490. }
  31491. // AddIndex adds i to the "index" field.
  31492. func (m *TutorialMutation) AddIndex(i int) {
  31493. if m.addindex != nil {
  31494. *m.addindex += i
  31495. } else {
  31496. m.addindex = &i
  31497. }
  31498. }
  31499. // AddedIndex returns the value that was added to the "index" field in this mutation.
  31500. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  31501. v := m.addindex
  31502. if v == nil {
  31503. return
  31504. }
  31505. return *v, true
  31506. }
  31507. // ResetIndex resets all changes to the "index" field.
  31508. func (m *TutorialMutation) ResetIndex() {
  31509. m.index = nil
  31510. m.addindex = nil
  31511. }
  31512. // SetTitle sets the "title" field.
  31513. func (m *TutorialMutation) SetTitle(s string) {
  31514. m.title = &s
  31515. }
  31516. // Title returns the value of the "title" field in the mutation.
  31517. func (m *TutorialMutation) Title() (r string, exists bool) {
  31518. v := m.title
  31519. if v == nil {
  31520. return
  31521. }
  31522. return *v, true
  31523. }
  31524. // OldTitle returns the old "title" field's value of the Tutorial entity.
  31525. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31527. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  31528. if !m.op.Is(OpUpdateOne) {
  31529. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  31530. }
  31531. if m.id == nil || m.oldValue == nil {
  31532. return v, errors.New("OldTitle requires an ID field in the mutation")
  31533. }
  31534. oldValue, err := m.oldValue(ctx)
  31535. if err != nil {
  31536. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  31537. }
  31538. return oldValue.Title, nil
  31539. }
  31540. // ResetTitle resets all changes to the "title" field.
  31541. func (m *TutorialMutation) ResetTitle() {
  31542. m.title = nil
  31543. }
  31544. // SetContent sets the "content" field.
  31545. func (m *TutorialMutation) SetContent(s string) {
  31546. m.content = &s
  31547. }
  31548. // Content returns the value of the "content" field in the mutation.
  31549. func (m *TutorialMutation) Content() (r string, exists bool) {
  31550. v := m.content
  31551. if v == nil {
  31552. return
  31553. }
  31554. return *v, true
  31555. }
  31556. // OldContent returns the old "content" field's value of the Tutorial entity.
  31557. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31559. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  31560. if !m.op.Is(OpUpdateOne) {
  31561. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  31562. }
  31563. if m.id == nil || m.oldValue == nil {
  31564. return v, errors.New("OldContent requires an ID field in the mutation")
  31565. }
  31566. oldValue, err := m.oldValue(ctx)
  31567. if err != nil {
  31568. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  31569. }
  31570. return oldValue.Content, nil
  31571. }
  31572. // ResetContent resets all changes to the "content" field.
  31573. func (m *TutorialMutation) ResetContent() {
  31574. m.content = nil
  31575. }
  31576. // SetOrganizationID sets the "organization_id" field.
  31577. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  31578. m.organization_id = &u
  31579. m.addorganization_id = nil
  31580. }
  31581. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31582. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  31583. v := m.organization_id
  31584. if v == nil {
  31585. return
  31586. }
  31587. return *v, true
  31588. }
  31589. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  31590. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31592. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31593. if !m.op.Is(OpUpdateOne) {
  31594. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31595. }
  31596. if m.id == nil || m.oldValue == nil {
  31597. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31598. }
  31599. oldValue, err := m.oldValue(ctx)
  31600. if err != nil {
  31601. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31602. }
  31603. return oldValue.OrganizationID, nil
  31604. }
  31605. // AddOrganizationID adds u to the "organization_id" field.
  31606. func (m *TutorialMutation) AddOrganizationID(u int64) {
  31607. if m.addorganization_id != nil {
  31608. *m.addorganization_id += u
  31609. } else {
  31610. m.addorganization_id = &u
  31611. }
  31612. }
  31613. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31614. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  31615. v := m.addorganization_id
  31616. if v == nil {
  31617. return
  31618. }
  31619. return *v, true
  31620. }
  31621. // ResetOrganizationID resets all changes to the "organization_id" field.
  31622. func (m *TutorialMutation) ResetOrganizationID() {
  31623. m.organization_id = nil
  31624. m.addorganization_id = nil
  31625. }
  31626. // ClearEmployee clears the "employee" edge to the Employee entity.
  31627. func (m *TutorialMutation) ClearEmployee() {
  31628. m.clearedemployee = true
  31629. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  31630. }
  31631. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  31632. func (m *TutorialMutation) EmployeeCleared() bool {
  31633. return m.clearedemployee
  31634. }
  31635. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  31636. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  31637. // EmployeeID instead. It exists only for internal usage by the builders.
  31638. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  31639. if id := m.employee; id != nil {
  31640. ids = append(ids, *id)
  31641. }
  31642. return
  31643. }
  31644. // ResetEmployee resets all changes to the "employee" edge.
  31645. func (m *TutorialMutation) ResetEmployee() {
  31646. m.employee = nil
  31647. m.clearedemployee = false
  31648. }
  31649. // Where appends a list predicates to the TutorialMutation builder.
  31650. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  31651. m.predicates = append(m.predicates, ps...)
  31652. }
  31653. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  31654. // users can use type-assertion to append predicates that do not depend on any generated package.
  31655. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  31656. p := make([]predicate.Tutorial, len(ps))
  31657. for i := range ps {
  31658. p[i] = ps[i]
  31659. }
  31660. m.Where(p...)
  31661. }
  31662. // Op returns the operation name.
  31663. func (m *TutorialMutation) Op() Op {
  31664. return m.op
  31665. }
  31666. // SetOp allows setting the mutation operation.
  31667. func (m *TutorialMutation) SetOp(op Op) {
  31668. m.op = op
  31669. }
  31670. // Type returns the node type of this mutation (Tutorial).
  31671. func (m *TutorialMutation) Type() string {
  31672. return m.typ
  31673. }
  31674. // Fields returns all fields that were changed during this mutation. Note that in
  31675. // order to get all numeric fields that were incremented/decremented, call
  31676. // AddedFields().
  31677. func (m *TutorialMutation) Fields() []string {
  31678. fields := make([]string, 0, 8)
  31679. if m.created_at != nil {
  31680. fields = append(fields, tutorial.FieldCreatedAt)
  31681. }
  31682. if m.updated_at != nil {
  31683. fields = append(fields, tutorial.FieldUpdatedAt)
  31684. }
  31685. if m.deleted_at != nil {
  31686. fields = append(fields, tutorial.FieldDeletedAt)
  31687. }
  31688. if m.employee != nil {
  31689. fields = append(fields, tutorial.FieldEmployeeID)
  31690. }
  31691. if m.index != nil {
  31692. fields = append(fields, tutorial.FieldIndex)
  31693. }
  31694. if m.title != nil {
  31695. fields = append(fields, tutorial.FieldTitle)
  31696. }
  31697. if m.content != nil {
  31698. fields = append(fields, tutorial.FieldContent)
  31699. }
  31700. if m.organization_id != nil {
  31701. fields = append(fields, tutorial.FieldOrganizationID)
  31702. }
  31703. return fields
  31704. }
  31705. // Field returns the value of a field with the given name. The second boolean
  31706. // return value indicates that this field was not set, or was not defined in the
  31707. // schema.
  31708. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  31709. switch name {
  31710. case tutorial.FieldCreatedAt:
  31711. return m.CreatedAt()
  31712. case tutorial.FieldUpdatedAt:
  31713. return m.UpdatedAt()
  31714. case tutorial.FieldDeletedAt:
  31715. return m.DeletedAt()
  31716. case tutorial.FieldEmployeeID:
  31717. return m.EmployeeID()
  31718. case tutorial.FieldIndex:
  31719. return m.Index()
  31720. case tutorial.FieldTitle:
  31721. return m.Title()
  31722. case tutorial.FieldContent:
  31723. return m.Content()
  31724. case tutorial.FieldOrganizationID:
  31725. return m.OrganizationID()
  31726. }
  31727. return nil, false
  31728. }
  31729. // OldField returns the old value of the field from the database. An error is
  31730. // returned if the mutation operation is not UpdateOne, or the query to the
  31731. // database failed.
  31732. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31733. switch name {
  31734. case tutorial.FieldCreatedAt:
  31735. return m.OldCreatedAt(ctx)
  31736. case tutorial.FieldUpdatedAt:
  31737. return m.OldUpdatedAt(ctx)
  31738. case tutorial.FieldDeletedAt:
  31739. return m.OldDeletedAt(ctx)
  31740. case tutorial.FieldEmployeeID:
  31741. return m.OldEmployeeID(ctx)
  31742. case tutorial.FieldIndex:
  31743. return m.OldIndex(ctx)
  31744. case tutorial.FieldTitle:
  31745. return m.OldTitle(ctx)
  31746. case tutorial.FieldContent:
  31747. return m.OldContent(ctx)
  31748. case tutorial.FieldOrganizationID:
  31749. return m.OldOrganizationID(ctx)
  31750. }
  31751. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  31752. }
  31753. // SetField sets the value of a field with the given name. It returns an error if
  31754. // the field is not defined in the schema, or if the type mismatched the field
  31755. // type.
  31756. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  31757. switch name {
  31758. case tutorial.FieldCreatedAt:
  31759. v, ok := value.(time.Time)
  31760. if !ok {
  31761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31762. }
  31763. m.SetCreatedAt(v)
  31764. return nil
  31765. case tutorial.FieldUpdatedAt:
  31766. v, ok := value.(time.Time)
  31767. if !ok {
  31768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31769. }
  31770. m.SetUpdatedAt(v)
  31771. return nil
  31772. case tutorial.FieldDeletedAt:
  31773. v, ok := value.(time.Time)
  31774. if !ok {
  31775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31776. }
  31777. m.SetDeletedAt(v)
  31778. return nil
  31779. case tutorial.FieldEmployeeID:
  31780. v, ok := value.(uint64)
  31781. if !ok {
  31782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31783. }
  31784. m.SetEmployeeID(v)
  31785. return nil
  31786. case tutorial.FieldIndex:
  31787. v, ok := value.(int)
  31788. if !ok {
  31789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31790. }
  31791. m.SetIndex(v)
  31792. return nil
  31793. case tutorial.FieldTitle:
  31794. v, ok := value.(string)
  31795. if !ok {
  31796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31797. }
  31798. m.SetTitle(v)
  31799. return nil
  31800. case tutorial.FieldContent:
  31801. v, ok := value.(string)
  31802. if !ok {
  31803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31804. }
  31805. m.SetContent(v)
  31806. return nil
  31807. case tutorial.FieldOrganizationID:
  31808. v, ok := value.(uint64)
  31809. if !ok {
  31810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31811. }
  31812. m.SetOrganizationID(v)
  31813. return nil
  31814. }
  31815. return fmt.Errorf("unknown Tutorial field %s", name)
  31816. }
  31817. // AddedFields returns all numeric fields that were incremented/decremented during
  31818. // this mutation.
  31819. func (m *TutorialMutation) AddedFields() []string {
  31820. var fields []string
  31821. if m.addindex != nil {
  31822. fields = append(fields, tutorial.FieldIndex)
  31823. }
  31824. if m.addorganization_id != nil {
  31825. fields = append(fields, tutorial.FieldOrganizationID)
  31826. }
  31827. return fields
  31828. }
  31829. // AddedField returns the numeric value that was incremented/decremented on a field
  31830. // with the given name. The second boolean return value indicates that this field
  31831. // was not set, or was not defined in the schema.
  31832. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  31833. switch name {
  31834. case tutorial.FieldIndex:
  31835. return m.AddedIndex()
  31836. case tutorial.FieldOrganizationID:
  31837. return m.AddedOrganizationID()
  31838. }
  31839. return nil, false
  31840. }
  31841. // AddField adds the value to the field with the given name. It returns an error if
  31842. // the field is not defined in the schema, or if the type mismatched the field
  31843. // type.
  31844. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  31845. switch name {
  31846. case tutorial.FieldIndex:
  31847. v, ok := value.(int)
  31848. if !ok {
  31849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31850. }
  31851. m.AddIndex(v)
  31852. return nil
  31853. case tutorial.FieldOrganizationID:
  31854. v, ok := value.(int64)
  31855. if !ok {
  31856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31857. }
  31858. m.AddOrganizationID(v)
  31859. return nil
  31860. }
  31861. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  31862. }
  31863. // ClearedFields returns all nullable fields that were cleared during this
  31864. // mutation.
  31865. func (m *TutorialMutation) ClearedFields() []string {
  31866. var fields []string
  31867. if m.FieldCleared(tutorial.FieldDeletedAt) {
  31868. fields = append(fields, tutorial.FieldDeletedAt)
  31869. }
  31870. return fields
  31871. }
  31872. // FieldCleared returns a boolean indicating if a field with the given name was
  31873. // cleared in this mutation.
  31874. func (m *TutorialMutation) FieldCleared(name string) bool {
  31875. _, ok := m.clearedFields[name]
  31876. return ok
  31877. }
  31878. // ClearField clears the value of the field with the given name. It returns an
  31879. // error if the field is not defined in the schema.
  31880. func (m *TutorialMutation) ClearField(name string) error {
  31881. switch name {
  31882. case tutorial.FieldDeletedAt:
  31883. m.ClearDeletedAt()
  31884. return nil
  31885. }
  31886. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  31887. }
  31888. // ResetField resets all changes in the mutation for the field with the given name.
  31889. // It returns an error if the field is not defined in the schema.
  31890. func (m *TutorialMutation) ResetField(name string) error {
  31891. switch name {
  31892. case tutorial.FieldCreatedAt:
  31893. m.ResetCreatedAt()
  31894. return nil
  31895. case tutorial.FieldUpdatedAt:
  31896. m.ResetUpdatedAt()
  31897. return nil
  31898. case tutorial.FieldDeletedAt:
  31899. m.ResetDeletedAt()
  31900. return nil
  31901. case tutorial.FieldEmployeeID:
  31902. m.ResetEmployeeID()
  31903. return nil
  31904. case tutorial.FieldIndex:
  31905. m.ResetIndex()
  31906. return nil
  31907. case tutorial.FieldTitle:
  31908. m.ResetTitle()
  31909. return nil
  31910. case tutorial.FieldContent:
  31911. m.ResetContent()
  31912. return nil
  31913. case tutorial.FieldOrganizationID:
  31914. m.ResetOrganizationID()
  31915. return nil
  31916. }
  31917. return fmt.Errorf("unknown Tutorial field %s", name)
  31918. }
  31919. // AddedEdges returns all edge names that were set/added in this mutation.
  31920. func (m *TutorialMutation) AddedEdges() []string {
  31921. edges := make([]string, 0, 1)
  31922. if m.employee != nil {
  31923. edges = append(edges, tutorial.EdgeEmployee)
  31924. }
  31925. return edges
  31926. }
  31927. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31928. // name in this mutation.
  31929. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  31930. switch name {
  31931. case tutorial.EdgeEmployee:
  31932. if id := m.employee; id != nil {
  31933. return []ent.Value{*id}
  31934. }
  31935. }
  31936. return nil
  31937. }
  31938. // RemovedEdges returns all edge names that were removed in this mutation.
  31939. func (m *TutorialMutation) RemovedEdges() []string {
  31940. edges := make([]string, 0, 1)
  31941. return edges
  31942. }
  31943. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31944. // the given name in this mutation.
  31945. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  31946. return nil
  31947. }
  31948. // ClearedEdges returns all edge names that were cleared in this mutation.
  31949. func (m *TutorialMutation) ClearedEdges() []string {
  31950. edges := make([]string, 0, 1)
  31951. if m.clearedemployee {
  31952. edges = append(edges, tutorial.EdgeEmployee)
  31953. }
  31954. return edges
  31955. }
  31956. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31957. // was cleared in this mutation.
  31958. func (m *TutorialMutation) EdgeCleared(name string) bool {
  31959. switch name {
  31960. case tutorial.EdgeEmployee:
  31961. return m.clearedemployee
  31962. }
  31963. return false
  31964. }
  31965. // ClearEdge clears the value of the edge with the given name. It returns an error
  31966. // if that edge is not defined in the schema.
  31967. func (m *TutorialMutation) ClearEdge(name string) error {
  31968. switch name {
  31969. case tutorial.EdgeEmployee:
  31970. m.ClearEmployee()
  31971. return nil
  31972. }
  31973. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  31974. }
  31975. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31976. // It returns an error if the edge is not defined in the schema.
  31977. func (m *TutorialMutation) ResetEdge(name string) error {
  31978. switch name {
  31979. case tutorial.EdgeEmployee:
  31980. m.ResetEmployee()
  31981. return nil
  31982. }
  31983. return fmt.Errorf("unknown Tutorial edge %s", name)
  31984. }
  31985. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  31986. type UsageDetailMutation struct {
  31987. config
  31988. op Op
  31989. typ string
  31990. id *uint64
  31991. created_at *time.Time
  31992. updated_at *time.Time
  31993. status *uint8
  31994. addstatus *int8
  31995. _type *int
  31996. add_type *int
  31997. bot_id *string
  31998. receiver_id *string
  31999. app *int
  32000. addapp *int
  32001. session_id *uint64
  32002. addsession_id *int64
  32003. request *string
  32004. response *string
  32005. original_data *custom_types.OriginalData
  32006. total_tokens *uint64
  32007. addtotal_tokens *int64
  32008. prompt_tokens *uint64
  32009. addprompt_tokens *int64
  32010. completion_tokens *uint64
  32011. addcompletion_tokens *int64
  32012. organization_id *uint64
  32013. addorganization_id *int64
  32014. clearedFields map[string]struct{}
  32015. done bool
  32016. oldValue func(context.Context) (*UsageDetail, error)
  32017. predicates []predicate.UsageDetail
  32018. }
  32019. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  32020. // usagedetailOption allows management of the mutation configuration using functional options.
  32021. type usagedetailOption func(*UsageDetailMutation)
  32022. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  32023. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  32024. m := &UsageDetailMutation{
  32025. config: c,
  32026. op: op,
  32027. typ: TypeUsageDetail,
  32028. clearedFields: make(map[string]struct{}),
  32029. }
  32030. for _, opt := range opts {
  32031. opt(m)
  32032. }
  32033. return m
  32034. }
  32035. // withUsageDetailID sets the ID field of the mutation.
  32036. func withUsageDetailID(id uint64) usagedetailOption {
  32037. return func(m *UsageDetailMutation) {
  32038. var (
  32039. err error
  32040. once sync.Once
  32041. value *UsageDetail
  32042. )
  32043. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  32044. once.Do(func() {
  32045. if m.done {
  32046. err = errors.New("querying old values post mutation is not allowed")
  32047. } else {
  32048. value, err = m.Client().UsageDetail.Get(ctx, id)
  32049. }
  32050. })
  32051. return value, err
  32052. }
  32053. m.id = &id
  32054. }
  32055. }
  32056. // withUsageDetail sets the old UsageDetail of the mutation.
  32057. func withUsageDetail(node *UsageDetail) usagedetailOption {
  32058. return func(m *UsageDetailMutation) {
  32059. m.oldValue = func(context.Context) (*UsageDetail, error) {
  32060. return node, nil
  32061. }
  32062. m.id = &node.ID
  32063. }
  32064. }
  32065. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32066. // executed in a transaction (ent.Tx), a transactional client is returned.
  32067. func (m UsageDetailMutation) Client() *Client {
  32068. client := &Client{config: m.config}
  32069. client.init()
  32070. return client
  32071. }
  32072. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32073. // it returns an error otherwise.
  32074. func (m UsageDetailMutation) Tx() (*Tx, error) {
  32075. if _, ok := m.driver.(*txDriver); !ok {
  32076. return nil, errors.New("ent: mutation is not running in a transaction")
  32077. }
  32078. tx := &Tx{config: m.config}
  32079. tx.init()
  32080. return tx, nil
  32081. }
  32082. // SetID sets the value of the id field. Note that this
  32083. // operation is only accepted on creation of UsageDetail entities.
  32084. func (m *UsageDetailMutation) SetID(id uint64) {
  32085. m.id = &id
  32086. }
  32087. // ID returns the ID value in the mutation. Note that the ID is only available
  32088. // if it was provided to the builder or after it was returned from the database.
  32089. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  32090. if m.id == nil {
  32091. return
  32092. }
  32093. return *m.id, true
  32094. }
  32095. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32096. // That means, if the mutation is applied within a transaction with an isolation level such
  32097. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32098. // or updated by the mutation.
  32099. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  32100. switch {
  32101. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32102. id, exists := m.ID()
  32103. if exists {
  32104. return []uint64{id}, nil
  32105. }
  32106. fallthrough
  32107. case m.op.Is(OpUpdate | OpDelete):
  32108. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  32109. default:
  32110. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32111. }
  32112. }
  32113. // SetCreatedAt sets the "created_at" field.
  32114. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  32115. m.created_at = &t
  32116. }
  32117. // CreatedAt returns the value of the "created_at" field in the mutation.
  32118. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  32119. v := m.created_at
  32120. if v == nil {
  32121. return
  32122. }
  32123. return *v, true
  32124. }
  32125. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  32126. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32128. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32129. if !m.op.Is(OpUpdateOne) {
  32130. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32131. }
  32132. if m.id == nil || m.oldValue == nil {
  32133. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32134. }
  32135. oldValue, err := m.oldValue(ctx)
  32136. if err != nil {
  32137. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32138. }
  32139. return oldValue.CreatedAt, nil
  32140. }
  32141. // ResetCreatedAt resets all changes to the "created_at" field.
  32142. func (m *UsageDetailMutation) ResetCreatedAt() {
  32143. m.created_at = nil
  32144. }
  32145. // SetUpdatedAt sets the "updated_at" field.
  32146. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  32147. m.updated_at = &t
  32148. }
  32149. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32150. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  32151. v := m.updated_at
  32152. if v == nil {
  32153. return
  32154. }
  32155. return *v, true
  32156. }
  32157. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  32158. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32160. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32161. if !m.op.Is(OpUpdateOne) {
  32162. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32163. }
  32164. if m.id == nil || m.oldValue == nil {
  32165. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32166. }
  32167. oldValue, err := m.oldValue(ctx)
  32168. if err != nil {
  32169. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32170. }
  32171. return oldValue.UpdatedAt, nil
  32172. }
  32173. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32174. func (m *UsageDetailMutation) ResetUpdatedAt() {
  32175. m.updated_at = nil
  32176. }
  32177. // SetStatus sets the "status" field.
  32178. func (m *UsageDetailMutation) SetStatus(u uint8) {
  32179. m.status = &u
  32180. m.addstatus = nil
  32181. }
  32182. // Status returns the value of the "status" field in the mutation.
  32183. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  32184. v := m.status
  32185. if v == nil {
  32186. return
  32187. }
  32188. return *v, true
  32189. }
  32190. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  32191. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32193. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32194. if !m.op.Is(OpUpdateOne) {
  32195. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32196. }
  32197. if m.id == nil || m.oldValue == nil {
  32198. return v, errors.New("OldStatus requires an ID field in the mutation")
  32199. }
  32200. oldValue, err := m.oldValue(ctx)
  32201. if err != nil {
  32202. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32203. }
  32204. return oldValue.Status, nil
  32205. }
  32206. // AddStatus adds u to the "status" field.
  32207. func (m *UsageDetailMutation) AddStatus(u int8) {
  32208. if m.addstatus != nil {
  32209. *m.addstatus += u
  32210. } else {
  32211. m.addstatus = &u
  32212. }
  32213. }
  32214. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32215. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  32216. v := m.addstatus
  32217. if v == nil {
  32218. return
  32219. }
  32220. return *v, true
  32221. }
  32222. // ClearStatus clears the value of the "status" field.
  32223. func (m *UsageDetailMutation) ClearStatus() {
  32224. m.status = nil
  32225. m.addstatus = nil
  32226. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  32227. }
  32228. // StatusCleared returns if the "status" field was cleared in this mutation.
  32229. func (m *UsageDetailMutation) StatusCleared() bool {
  32230. _, ok := m.clearedFields[usagedetail.FieldStatus]
  32231. return ok
  32232. }
  32233. // ResetStatus resets all changes to the "status" field.
  32234. func (m *UsageDetailMutation) ResetStatus() {
  32235. m.status = nil
  32236. m.addstatus = nil
  32237. delete(m.clearedFields, usagedetail.FieldStatus)
  32238. }
  32239. // SetType sets the "type" field.
  32240. func (m *UsageDetailMutation) SetType(i int) {
  32241. m._type = &i
  32242. m.add_type = nil
  32243. }
  32244. // GetType returns the value of the "type" field in the mutation.
  32245. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  32246. v := m._type
  32247. if v == nil {
  32248. return
  32249. }
  32250. return *v, true
  32251. }
  32252. // OldType returns the old "type" field's value of the UsageDetail entity.
  32253. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32255. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  32256. if !m.op.Is(OpUpdateOne) {
  32257. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32258. }
  32259. if m.id == nil || m.oldValue == nil {
  32260. return v, errors.New("OldType requires an ID field in the mutation")
  32261. }
  32262. oldValue, err := m.oldValue(ctx)
  32263. if err != nil {
  32264. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32265. }
  32266. return oldValue.Type, nil
  32267. }
  32268. // AddType adds i to the "type" field.
  32269. func (m *UsageDetailMutation) AddType(i int) {
  32270. if m.add_type != nil {
  32271. *m.add_type += i
  32272. } else {
  32273. m.add_type = &i
  32274. }
  32275. }
  32276. // AddedType returns the value that was added to the "type" field in this mutation.
  32277. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  32278. v := m.add_type
  32279. if v == nil {
  32280. return
  32281. }
  32282. return *v, true
  32283. }
  32284. // ClearType clears the value of the "type" field.
  32285. func (m *UsageDetailMutation) ClearType() {
  32286. m._type = nil
  32287. m.add_type = nil
  32288. m.clearedFields[usagedetail.FieldType] = struct{}{}
  32289. }
  32290. // TypeCleared returns if the "type" field was cleared in this mutation.
  32291. func (m *UsageDetailMutation) TypeCleared() bool {
  32292. _, ok := m.clearedFields[usagedetail.FieldType]
  32293. return ok
  32294. }
  32295. // ResetType resets all changes to the "type" field.
  32296. func (m *UsageDetailMutation) ResetType() {
  32297. m._type = nil
  32298. m.add_type = nil
  32299. delete(m.clearedFields, usagedetail.FieldType)
  32300. }
  32301. // SetBotID sets the "bot_id" field.
  32302. func (m *UsageDetailMutation) SetBotID(s string) {
  32303. m.bot_id = &s
  32304. }
  32305. // BotID returns the value of the "bot_id" field in the mutation.
  32306. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  32307. v := m.bot_id
  32308. if v == nil {
  32309. return
  32310. }
  32311. return *v, true
  32312. }
  32313. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  32314. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32316. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  32317. if !m.op.Is(OpUpdateOne) {
  32318. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32319. }
  32320. if m.id == nil || m.oldValue == nil {
  32321. return v, errors.New("OldBotID requires an ID field in the mutation")
  32322. }
  32323. oldValue, err := m.oldValue(ctx)
  32324. if err != nil {
  32325. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32326. }
  32327. return oldValue.BotID, nil
  32328. }
  32329. // ResetBotID resets all changes to the "bot_id" field.
  32330. func (m *UsageDetailMutation) ResetBotID() {
  32331. m.bot_id = nil
  32332. }
  32333. // SetReceiverID sets the "receiver_id" field.
  32334. func (m *UsageDetailMutation) SetReceiverID(s string) {
  32335. m.receiver_id = &s
  32336. }
  32337. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  32338. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  32339. v := m.receiver_id
  32340. if v == nil {
  32341. return
  32342. }
  32343. return *v, true
  32344. }
  32345. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  32346. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32348. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  32349. if !m.op.Is(OpUpdateOne) {
  32350. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  32351. }
  32352. if m.id == nil || m.oldValue == nil {
  32353. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  32354. }
  32355. oldValue, err := m.oldValue(ctx)
  32356. if err != nil {
  32357. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  32358. }
  32359. return oldValue.ReceiverID, nil
  32360. }
  32361. // ResetReceiverID resets all changes to the "receiver_id" field.
  32362. func (m *UsageDetailMutation) ResetReceiverID() {
  32363. m.receiver_id = nil
  32364. }
  32365. // SetApp sets the "app" field.
  32366. func (m *UsageDetailMutation) SetApp(i int) {
  32367. m.app = &i
  32368. m.addapp = nil
  32369. }
  32370. // App returns the value of the "app" field in the mutation.
  32371. func (m *UsageDetailMutation) App() (r int, exists bool) {
  32372. v := m.app
  32373. if v == nil {
  32374. return
  32375. }
  32376. return *v, true
  32377. }
  32378. // OldApp returns the old "app" field's value of the UsageDetail entity.
  32379. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32381. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  32382. if !m.op.Is(OpUpdateOne) {
  32383. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  32384. }
  32385. if m.id == nil || m.oldValue == nil {
  32386. return v, errors.New("OldApp requires an ID field in the mutation")
  32387. }
  32388. oldValue, err := m.oldValue(ctx)
  32389. if err != nil {
  32390. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  32391. }
  32392. return oldValue.App, nil
  32393. }
  32394. // AddApp adds i to the "app" field.
  32395. func (m *UsageDetailMutation) AddApp(i int) {
  32396. if m.addapp != nil {
  32397. *m.addapp += i
  32398. } else {
  32399. m.addapp = &i
  32400. }
  32401. }
  32402. // AddedApp returns the value that was added to the "app" field in this mutation.
  32403. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  32404. v := m.addapp
  32405. if v == nil {
  32406. return
  32407. }
  32408. return *v, true
  32409. }
  32410. // ClearApp clears the value of the "app" field.
  32411. func (m *UsageDetailMutation) ClearApp() {
  32412. m.app = nil
  32413. m.addapp = nil
  32414. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  32415. }
  32416. // AppCleared returns if the "app" field was cleared in this mutation.
  32417. func (m *UsageDetailMutation) AppCleared() bool {
  32418. _, ok := m.clearedFields[usagedetail.FieldApp]
  32419. return ok
  32420. }
  32421. // ResetApp resets all changes to the "app" field.
  32422. func (m *UsageDetailMutation) ResetApp() {
  32423. m.app = nil
  32424. m.addapp = nil
  32425. delete(m.clearedFields, usagedetail.FieldApp)
  32426. }
  32427. // SetSessionID sets the "session_id" field.
  32428. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  32429. m.session_id = &u
  32430. m.addsession_id = nil
  32431. }
  32432. // SessionID returns the value of the "session_id" field in the mutation.
  32433. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  32434. v := m.session_id
  32435. if v == nil {
  32436. return
  32437. }
  32438. return *v, true
  32439. }
  32440. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  32441. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32443. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  32444. if !m.op.Is(OpUpdateOne) {
  32445. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  32446. }
  32447. if m.id == nil || m.oldValue == nil {
  32448. return v, errors.New("OldSessionID requires an ID field in the mutation")
  32449. }
  32450. oldValue, err := m.oldValue(ctx)
  32451. if err != nil {
  32452. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  32453. }
  32454. return oldValue.SessionID, nil
  32455. }
  32456. // AddSessionID adds u to the "session_id" field.
  32457. func (m *UsageDetailMutation) AddSessionID(u int64) {
  32458. if m.addsession_id != nil {
  32459. *m.addsession_id += u
  32460. } else {
  32461. m.addsession_id = &u
  32462. }
  32463. }
  32464. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  32465. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  32466. v := m.addsession_id
  32467. if v == nil {
  32468. return
  32469. }
  32470. return *v, true
  32471. }
  32472. // ClearSessionID clears the value of the "session_id" field.
  32473. func (m *UsageDetailMutation) ClearSessionID() {
  32474. m.session_id = nil
  32475. m.addsession_id = nil
  32476. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  32477. }
  32478. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  32479. func (m *UsageDetailMutation) SessionIDCleared() bool {
  32480. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  32481. return ok
  32482. }
  32483. // ResetSessionID resets all changes to the "session_id" field.
  32484. func (m *UsageDetailMutation) ResetSessionID() {
  32485. m.session_id = nil
  32486. m.addsession_id = nil
  32487. delete(m.clearedFields, usagedetail.FieldSessionID)
  32488. }
  32489. // SetRequest sets the "request" field.
  32490. func (m *UsageDetailMutation) SetRequest(s string) {
  32491. m.request = &s
  32492. }
  32493. // Request returns the value of the "request" field in the mutation.
  32494. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  32495. v := m.request
  32496. if v == nil {
  32497. return
  32498. }
  32499. return *v, true
  32500. }
  32501. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  32502. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32504. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  32505. if !m.op.Is(OpUpdateOne) {
  32506. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  32507. }
  32508. if m.id == nil || m.oldValue == nil {
  32509. return v, errors.New("OldRequest requires an ID field in the mutation")
  32510. }
  32511. oldValue, err := m.oldValue(ctx)
  32512. if err != nil {
  32513. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  32514. }
  32515. return oldValue.Request, nil
  32516. }
  32517. // ResetRequest resets all changes to the "request" field.
  32518. func (m *UsageDetailMutation) ResetRequest() {
  32519. m.request = nil
  32520. }
  32521. // SetResponse sets the "response" field.
  32522. func (m *UsageDetailMutation) SetResponse(s string) {
  32523. m.response = &s
  32524. }
  32525. // Response returns the value of the "response" field in the mutation.
  32526. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  32527. v := m.response
  32528. if v == nil {
  32529. return
  32530. }
  32531. return *v, true
  32532. }
  32533. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  32534. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32536. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  32537. if !m.op.Is(OpUpdateOne) {
  32538. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  32539. }
  32540. if m.id == nil || m.oldValue == nil {
  32541. return v, errors.New("OldResponse requires an ID field in the mutation")
  32542. }
  32543. oldValue, err := m.oldValue(ctx)
  32544. if err != nil {
  32545. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  32546. }
  32547. return oldValue.Response, nil
  32548. }
  32549. // ResetResponse resets all changes to the "response" field.
  32550. func (m *UsageDetailMutation) ResetResponse() {
  32551. m.response = nil
  32552. }
  32553. // SetOriginalData sets the "original_data" field.
  32554. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  32555. m.original_data = &ctd
  32556. }
  32557. // OriginalData returns the value of the "original_data" field in the mutation.
  32558. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  32559. v := m.original_data
  32560. if v == nil {
  32561. return
  32562. }
  32563. return *v, true
  32564. }
  32565. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  32566. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32568. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  32569. if !m.op.Is(OpUpdateOne) {
  32570. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  32571. }
  32572. if m.id == nil || m.oldValue == nil {
  32573. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  32574. }
  32575. oldValue, err := m.oldValue(ctx)
  32576. if err != nil {
  32577. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  32578. }
  32579. return oldValue.OriginalData, nil
  32580. }
  32581. // ResetOriginalData resets all changes to the "original_data" field.
  32582. func (m *UsageDetailMutation) ResetOriginalData() {
  32583. m.original_data = nil
  32584. }
  32585. // SetTotalTokens sets the "total_tokens" field.
  32586. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  32587. m.total_tokens = &u
  32588. m.addtotal_tokens = nil
  32589. }
  32590. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  32591. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  32592. v := m.total_tokens
  32593. if v == nil {
  32594. return
  32595. }
  32596. return *v, true
  32597. }
  32598. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  32599. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32601. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  32602. if !m.op.Is(OpUpdateOne) {
  32603. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  32604. }
  32605. if m.id == nil || m.oldValue == nil {
  32606. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  32607. }
  32608. oldValue, err := m.oldValue(ctx)
  32609. if err != nil {
  32610. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  32611. }
  32612. return oldValue.TotalTokens, nil
  32613. }
  32614. // AddTotalTokens adds u to the "total_tokens" field.
  32615. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  32616. if m.addtotal_tokens != nil {
  32617. *m.addtotal_tokens += u
  32618. } else {
  32619. m.addtotal_tokens = &u
  32620. }
  32621. }
  32622. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  32623. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  32624. v := m.addtotal_tokens
  32625. if v == nil {
  32626. return
  32627. }
  32628. return *v, true
  32629. }
  32630. // ClearTotalTokens clears the value of the "total_tokens" field.
  32631. func (m *UsageDetailMutation) ClearTotalTokens() {
  32632. m.total_tokens = nil
  32633. m.addtotal_tokens = nil
  32634. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  32635. }
  32636. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  32637. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  32638. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  32639. return ok
  32640. }
  32641. // ResetTotalTokens resets all changes to the "total_tokens" field.
  32642. func (m *UsageDetailMutation) ResetTotalTokens() {
  32643. m.total_tokens = nil
  32644. m.addtotal_tokens = nil
  32645. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  32646. }
  32647. // SetPromptTokens sets the "prompt_tokens" field.
  32648. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  32649. m.prompt_tokens = &u
  32650. m.addprompt_tokens = nil
  32651. }
  32652. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  32653. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  32654. v := m.prompt_tokens
  32655. if v == nil {
  32656. return
  32657. }
  32658. return *v, true
  32659. }
  32660. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  32661. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32663. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  32664. if !m.op.Is(OpUpdateOne) {
  32665. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  32666. }
  32667. if m.id == nil || m.oldValue == nil {
  32668. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  32669. }
  32670. oldValue, err := m.oldValue(ctx)
  32671. if err != nil {
  32672. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  32673. }
  32674. return oldValue.PromptTokens, nil
  32675. }
  32676. // AddPromptTokens adds u to the "prompt_tokens" field.
  32677. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  32678. if m.addprompt_tokens != nil {
  32679. *m.addprompt_tokens += u
  32680. } else {
  32681. m.addprompt_tokens = &u
  32682. }
  32683. }
  32684. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  32685. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  32686. v := m.addprompt_tokens
  32687. if v == nil {
  32688. return
  32689. }
  32690. return *v, true
  32691. }
  32692. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  32693. func (m *UsageDetailMutation) ClearPromptTokens() {
  32694. m.prompt_tokens = nil
  32695. m.addprompt_tokens = nil
  32696. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  32697. }
  32698. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  32699. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  32700. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  32701. return ok
  32702. }
  32703. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  32704. func (m *UsageDetailMutation) ResetPromptTokens() {
  32705. m.prompt_tokens = nil
  32706. m.addprompt_tokens = nil
  32707. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  32708. }
  32709. // SetCompletionTokens sets the "completion_tokens" field.
  32710. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  32711. m.completion_tokens = &u
  32712. m.addcompletion_tokens = nil
  32713. }
  32714. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  32715. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  32716. v := m.completion_tokens
  32717. if v == nil {
  32718. return
  32719. }
  32720. return *v, true
  32721. }
  32722. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  32723. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32725. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  32726. if !m.op.Is(OpUpdateOne) {
  32727. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  32728. }
  32729. if m.id == nil || m.oldValue == nil {
  32730. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  32731. }
  32732. oldValue, err := m.oldValue(ctx)
  32733. if err != nil {
  32734. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  32735. }
  32736. return oldValue.CompletionTokens, nil
  32737. }
  32738. // AddCompletionTokens adds u to the "completion_tokens" field.
  32739. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  32740. if m.addcompletion_tokens != nil {
  32741. *m.addcompletion_tokens += u
  32742. } else {
  32743. m.addcompletion_tokens = &u
  32744. }
  32745. }
  32746. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  32747. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  32748. v := m.addcompletion_tokens
  32749. if v == nil {
  32750. return
  32751. }
  32752. return *v, true
  32753. }
  32754. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  32755. func (m *UsageDetailMutation) ClearCompletionTokens() {
  32756. m.completion_tokens = nil
  32757. m.addcompletion_tokens = nil
  32758. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  32759. }
  32760. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  32761. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  32762. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  32763. return ok
  32764. }
  32765. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  32766. func (m *UsageDetailMutation) ResetCompletionTokens() {
  32767. m.completion_tokens = nil
  32768. m.addcompletion_tokens = nil
  32769. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  32770. }
  32771. // SetOrganizationID sets the "organization_id" field.
  32772. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  32773. m.organization_id = &u
  32774. m.addorganization_id = nil
  32775. }
  32776. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32777. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  32778. v := m.organization_id
  32779. if v == nil {
  32780. return
  32781. }
  32782. return *v, true
  32783. }
  32784. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  32785. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32787. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32788. if !m.op.Is(OpUpdateOne) {
  32789. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32790. }
  32791. if m.id == nil || m.oldValue == nil {
  32792. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32793. }
  32794. oldValue, err := m.oldValue(ctx)
  32795. if err != nil {
  32796. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32797. }
  32798. return oldValue.OrganizationID, nil
  32799. }
  32800. // AddOrganizationID adds u to the "organization_id" field.
  32801. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  32802. if m.addorganization_id != nil {
  32803. *m.addorganization_id += u
  32804. } else {
  32805. m.addorganization_id = &u
  32806. }
  32807. }
  32808. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32809. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  32810. v := m.addorganization_id
  32811. if v == nil {
  32812. return
  32813. }
  32814. return *v, true
  32815. }
  32816. // ClearOrganizationID clears the value of the "organization_id" field.
  32817. func (m *UsageDetailMutation) ClearOrganizationID() {
  32818. m.organization_id = nil
  32819. m.addorganization_id = nil
  32820. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  32821. }
  32822. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32823. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  32824. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  32825. return ok
  32826. }
  32827. // ResetOrganizationID resets all changes to the "organization_id" field.
  32828. func (m *UsageDetailMutation) ResetOrganizationID() {
  32829. m.organization_id = nil
  32830. m.addorganization_id = nil
  32831. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  32832. }
  32833. // Where appends a list predicates to the UsageDetailMutation builder.
  32834. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  32835. m.predicates = append(m.predicates, ps...)
  32836. }
  32837. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  32838. // users can use type-assertion to append predicates that do not depend on any generated package.
  32839. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  32840. p := make([]predicate.UsageDetail, len(ps))
  32841. for i := range ps {
  32842. p[i] = ps[i]
  32843. }
  32844. m.Where(p...)
  32845. }
  32846. // Op returns the operation name.
  32847. func (m *UsageDetailMutation) Op() Op {
  32848. return m.op
  32849. }
  32850. // SetOp allows setting the mutation operation.
  32851. func (m *UsageDetailMutation) SetOp(op Op) {
  32852. m.op = op
  32853. }
  32854. // Type returns the node type of this mutation (UsageDetail).
  32855. func (m *UsageDetailMutation) Type() string {
  32856. return m.typ
  32857. }
  32858. // Fields returns all fields that were changed during this mutation. Note that in
  32859. // order to get all numeric fields that were incremented/decremented, call
  32860. // AddedFields().
  32861. func (m *UsageDetailMutation) Fields() []string {
  32862. fields := make([]string, 0, 15)
  32863. if m.created_at != nil {
  32864. fields = append(fields, usagedetail.FieldCreatedAt)
  32865. }
  32866. if m.updated_at != nil {
  32867. fields = append(fields, usagedetail.FieldUpdatedAt)
  32868. }
  32869. if m.status != nil {
  32870. fields = append(fields, usagedetail.FieldStatus)
  32871. }
  32872. if m._type != nil {
  32873. fields = append(fields, usagedetail.FieldType)
  32874. }
  32875. if m.bot_id != nil {
  32876. fields = append(fields, usagedetail.FieldBotID)
  32877. }
  32878. if m.receiver_id != nil {
  32879. fields = append(fields, usagedetail.FieldReceiverID)
  32880. }
  32881. if m.app != nil {
  32882. fields = append(fields, usagedetail.FieldApp)
  32883. }
  32884. if m.session_id != nil {
  32885. fields = append(fields, usagedetail.FieldSessionID)
  32886. }
  32887. if m.request != nil {
  32888. fields = append(fields, usagedetail.FieldRequest)
  32889. }
  32890. if m.response != nil {
  32891. fields = append(fields, usagedetail.FieldResponse)
  32892. }
  32893. if m.original_data != nil {
  32894. fields = append(fields, usagedetail.FieldOriginalData)
  32895. }
  32896. if m.total_tokens != nil {
  32897. fields = append(fields, usagedetail.FieldTotalTokens)
  32898. }
  32899. if m.prompt_tokens != nil {
  32900. fields = append(fields, usagedetail.FieldPromptTokens)
  32901. }
  32902. if m.completion_tokens != nil {
  32903. fields = append(fields, usagedetail.FieldCompletionTokens)
  32904. }
  32905. if m.organization_id != nil {
  32906. fields = append(fields, usagedetail.FieldOrganizationID)
  32907. }
  32908. return fields
  32909. }
  32910. // Field returns the value of a field with the given name. The second boolean
  32911. // return value indicates that this field was not set, or was not defined in the
  32912. // schema.
  32913. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  32914. switch name {
  32915. case usagedetail.FieldCreatedAt:
  32916. return m.CreatedAt()
  32917. case usagedetail.FieldUpdatedAt:
  32918. return m.UpdatedAt()
  32919. case usagedetail.FieldStatus:
  32920. return m.Status()
  32921. case usagedetail.FieldType:
  32922. return m.GetType()
  32923. case usagedetail.FieldBotID:
  32924. return m.BotID()
  32925. case usagedetail.FieldReceiverID:
  32926. return m.ReceiverID()
  32927. case usagedetail.FieldApp:
  32928. return m.App()
  32929. case usagedetail.FieldSessionID:
  32930. return m.SessionID()
  32931. case usagedetail.FieldRequest:
  32932. return m.Request()
  32933. case usagedetail.FieldResponse:
  32934. return m.Response()
  32935. case usagedetail.FieldOriginalData:
  32936. return m.OriginalData()
  32937. case usagedetail.FieldTotalTokens:
  32938. return m.TotalTokens()
  32939. case usagedetail.FieldPromptTokens:
  32940. return m.PromptTokens()
  32941. case usagedetail.FieldCompletionTokens:
  32942. return m.CompletionTokens()
  32943. case usagedetail.FieldOrganizationID:
  32944. return m.OrganizationID()
  32945. }
  32946. return nil, false
  32947. }
  32948. // OldField returns the old value of the field from the database. An error is
  32949. // returned if the mutation operation is not UpdateOne, or the query to the
  32950. // database failed.
  32951. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32952. switch name {
  32953. case usagedetail.FieldCreatedAt:
  32954. return m.OldCreatedAt(ctx)
  32955. case usagedetail.FieldUpdatedAt:
  32956. return m.OldUpdatedAt(ctx)
  32957. case usagedetail.FieldStatus:
  32958. return m.OldStatus(ctx)
  32959. case usagedetail.FieldType:
  32960. return m.OldType(ctx)
  32961. case usagedetail.FieldBotID:
  32962. return m.OldBotID(ctx)
  32963. case usagedetail.FieldReceiverID:
  32964. return m.OldReceiverID(ctx)
  32965. case usagedetail.FieldApp:
  32966. return m.OldApp(ctx)
  32967. case usagedetail.FieldSessionID:
  32968. return m.OldSessionID(ctx)
  32969. case usagedetail.FieldRequest:
  32970. return m.OldRequest(ctx)
  32971. case usagedetail.FieldResponse:
  32972. return m.OldResponse(ctx)
  32973. case usagedetail.FieldOriginalData:
  32974. return m.OldOriginalData(ctx)
  32975. case usagedetail.FieldTotalTokens:
  32976. return m.OldTotalTokens(ctx)
  32977. case usagedetail.FieldPromptTokens:
  32978. return m.OldPromptTokens(ctx)
  32979. case usagedetail.FieldCompletionTokens:
  32980. return m.OldCompletionTokens(ctx)
  32981. case usagedetail.FieldOrganizationID:
  32982. return m.OldOrganizationID(ctx)
  32983. }
  32984. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  32985. }
  32986. // SetField sets the value of a field with the given name. It returns an error if
  32987. // the field is not defined in the schema, or if the type mismatched the field
  32988. // type.
  32989. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  32990. switch name {
  32991. case usagedetail.FieldCreatedAt:
  32992. v, ok := value.(time.Time)
  32993. if !ok {
  32994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32995. }
  32996. m.SetCreatedAt(v)
  32997. return nil
  32998. case usagedetail.FieldUpdatedAt:
  32999. v, ok := value.(time.Time)
  33000. if !ok {
  33001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33002. }
  33003. m.SetUpdatedAt(v)
  33004. return nil
  33005. case usagedetail.FieldStatus:
  33006. v, ok := value.(uint8)
  33007. if !ok {
  33008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33009. }
  33010. m.SetStatus(v)
  33011. return nil
  33012. case usagedetail.FieldType:
  33013. v, ok := value.(int)
  33014. if !ok {
  33015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33016. }
  33017. m.SetType(v)
  33018. return nil
  33019. case usagedetail.FieldBotID:
  33020. v, ok := value.(string)
  33021. if !ok {
  33022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33023. }
  33024. m.SetBotID(v)
  33025. return nil
  33026. case usagedetail.FieldReceiverID:
  33027. v, ok := value.(string)
  33028. if !ok {
  33029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33030. }
  33031. m.SetReceiverID(v)
  33032. return nil
  33033. case usagedetail.FieldApp:
  33034. v, ok := value.(int)
  33035. if !ok {
  33036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33037. }
  33038. m.SetApp(v)
  33039. return nil
  33040. case usagedetail.FieldSessionID:
  33041. v, ok := value.(uint64)
  33042. if !ok {
  33043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33044. }
  33045. m.SetSessionID(v)
  33046. return nil
  33047. case usagedetail.FieldRequest:
  33048. v, ok := value.(string)
  33049. if !ok {
  33050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33051. }
  33052. m.SetRequest(v)
  33053. return nil
  33054. case usagedetail.FieldResponse:
  33055. v, ok := value.(string)
  33056. if !ok {
  33057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33058. }
  33059. m.SetResponse(v)
  33060. return nil
  33061. case usagedetail.FieldOriginalData:
  33062. v, ok := value.(custom_types.OriginalData)
  33063. if !ok {
  33064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33065. }
  33066. m.SetOriginalData(v)
  33067. return nil
  33068. case usagedetail.FieldTotalTokens:
  33069. v, ok := value.(uint64)
  33070. if !ok {
  33071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33072. }
  33073. m.SetTotalTokens(v)
  33074. return nil
  33075. case usagedetail.FieldPromptTokens:
  33076. v, ok := value.(uint64)
  33077. if !ok {
  33078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33079. }
  33080. m.SetPromptTokens(v)
  33081. return nil
  33082. case usagedetail.FieldCompletionTokens:
  33083. v, ok := value.(uint64)
  33084. if !ok {
  33085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33086. }
  33087. m.SetCompletionTokens(v)
  33088. return nil
  33089. case usagedetail.FieldOrganizationID:
  33090. v, ok := value.(uint64)
  33091. if !ok {
  33092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33093. }
  33094. m.SetOrganizationID(v)
  33095. return nil
  33096. }
  33097. return fmt.Errorf("unknown UsageDetail field %s", name)
  33098. }
  33099. // AddedFields returns all numeric fields that were incremented/decremented during
  33100. // this mutation.
  33101. func (m *UsageDetailMutation) AddedFields() []string {
  33102. var fields []string
  33103. if m.addstatus != nil {
  33104. fields = append(fields, usagedetail.FieldStatus)
  33105. }
  33106. if m.add_type != nil {
  33107. fields = append(fields, usagedetail.FieldType)
  33108. }
  33109. if m.addapp != nil {
  33110. fields = append(fields, usagedetail.FieldApp)
  33111. }
  33112. if m.addsession_id != nil {
  33113. fields = append(fields, usagedetail.FieldSessionID)
  33114. }
  33115. if m.addtotal_tokens != nil {
  33116. fields = append(fields, usagedetail.FieldTotalTokens)
  33117. }
  33118. if m.addprompt_tokens != nil {
  33119. fields = append(fields, usagedetail.FieldPromptTokens)
  33120. }
  33121. if m.addcompletion_tokens != nil {
  33122. fields = append(fields, usagedetail.FieldCompletionTokens)
  33123. }
  33124. if m.addorganization_id != nil {
  33125. fields = append(fields, usagedetail.FieldOrganizationID)
  33126. }
  33127. return fields
  33128. }
  33129. // AddedField returns the numeric value that was incremented/decremented on a field
  33130. // with the given name. The second boolean return value indicates that this field
  33131. // was not set, or was not defined in the schema.
  33132. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  33133. switch name {
  33134. case usagedetail.FieldStatus:
  33135. return m.AddedStatus()
  33136. case usagedetail.FieldType:
  33137. return m.AddedType()
  33138. case usagedetail.FieldApp:
  33139. return m.AddedApp()
  33140. case usagedetail.FieldSessionID:
  33141. return m.AddedSessionID()
  33142. case usagedetail.FieldTotalTokens:
  33143. return m.AddedTotalTokens()
  33144. case usagedetail.FieldPromptTokens:
  33145. return m.AddedPromptTokens()
  33146. case usagedetail.FieldCompletionTokens:
  33147. return m.AddedCompletionTokens()
  33148. case usagedetail.FieldOrganizationID:
  33149. return m.AddedOrganizationID()
  33150. }
  33151. return nil, false
  33152. }
  33153. // AddField adds the value to the field with the given name. It returns an error if
  33154. // the field is not defined in the schema, or if the type mismatched the field
  33155. // type.
  33156. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  33157. switch name {
  33158. case usagedetail.FieldStatus:
  33159. v, ok := value.(int8)
  33160. if !ok {
  33161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33162. }
  33163. m.AddStatus(v)
  33164. return nil
  33165. case usagedetail.FieldType:
  33166. v, ok := value.(int)
  33167. if !ok {
  33168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33169. }
  33170. m.AddType(v)
  33171. return nil
  33172. case usagedetail.FieldApp:
  33173. v, ok := value.(int)
  33174. if !ok {
  33175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33176. }
  33177. m.AddApp(v)
  33178. return nil
  33179. case usagedetail.FieldSessionID:
  33180. v, ok := value.(int64)
  33181. if !ok {
  33182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33183. }
  33184. m.AddSessionID(v)
  33185. return nil
  33186. case usagedetail.FieldTotalTokens:
  33187. v, ok := value.(int64)
  33188. if !ok {
  33189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33190. }
  33191. m.AddTotalTokens(v)
  33192. return nil
  33193. case usagedetail.FieldPromptTokens:
  33194. v, ok := value.(int64)
  33195. if !ok {
  33196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33197. }
  33198. m.AddPromptTokens(v)
  33199. return nil
  33200. case usagedetail.FieldCompletionTokens:
  33201. v, ok := value.(int64)
  33202. if !ok {
  33203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33204. }
  33205. m.AddCompletionTokens(v)
  33206. return nil
  33207. case usagedetail.FieldOrganizationID:
  33208. v, ok := value.(int64)
  33209. if !ok {
  33210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33211. }
  33212. m.AddOrganizationID(v)
  33213. return nil
  33214. }
  33215. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  33216. }
  33217. // ClearedFields returns all nullable fields that were cleared during this
  33218. // mutation.
  33219. func (m *UsageDetailMutation) ClearedFields() []string {
  33220. var fields []string
  33221. if m.FieldCleared(usagedetail.FieldStatus) {
  33222. fields = append(fields, usagedetail.FieldStatus)
  33223. }
  33224. if m.FieldCleared(usagedetail.FieldType) {
  33225. fields = append(fields, usagedetail.FieldType)
  33226. }
  33227. if m.FieldCleared(usagedetail.FieldApp) {
  33228. fields = append(fields, usagedetail.FieldApp)
  33229. }
  33230. if m.FieldCleared(usagedetail.FieldSessionID) {
  33231. fields = append(fields, usagedetail.FieldSessionID)
  33232. }
  33233. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  33234. fields = append(fields, usagedetail.FieldTotalTokens)
  33235. }
  33236. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  33237. fields = append(fields, usagedetail.FieldPromptTokens)
  33238. }
  33239. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  33240. fields = append(fields, usagedetail.FieldCompletionTokens)
  33241. }
  33242. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  33243. fields = append(fields, usagedetail.FieldOrganizationID)
  33244. }
  33245. return fields
  33246. }
  33247. // FieldCleared returns a boolean indicating if a field with the given name was
  33248. // cleared in this mutation.
  33249. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  33250. _, ok := m.clearedFields[name]
  33251. return ok
  33252. }
  33253. // ClearField clears the value of the field with the given name. It returns an
  33254. // error if the field is not defined in the schema.
  33255. func (m *UsageDetailMutation) ClearField(name string) error {
  33256. switch name {
  33257. case usagedetail.FieldStatus:
  33258. m.ClearStatus()
  33259. return nil
  33260. case usagedetail.FieldType:
  33261. m.ClearType()
  33262. return nil
  33263. case usagedetail.FieldApp:
  33264. m.ClearApp()
  33265. return nil
  33266. case usagedetail.FieldSessionID:
  33267. m.ClearSessionID()
  33268. return nil
  33269. case usagedetail.FieldTotalTokens:
  33270. m.ClearTotalTokens()
  33271. return nil
  33272. case usagedetail.FieldPromptTokens:
  33273. m.ClearPromptTokens()
  33274. return nil
  33275. case usagedetail.FieldCompletionTokens:
  33276. m.ClearCompletionTokens()
  33277. return nil
  33278. case usagedetail.FieldOrganizationID:
  33279. m.ClearOrganizationID()
  33280. return nil
  33281. }
  33282. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  33283. }
  33284. // ResetField resets all changes in the mutation for the field with the given name.
  33285. // It returns an error if the field is not defined in the schema.
  33286. func (m *UsageDetailMutation) ResetField(name string) error {
  33287. switch name {
  33288. case usagedetail.FieldCreatedAt:
  33289. m.ResetCreatedAt()
  33290. return nil
  33291. case usagedetail.FieldUpdatedAt:
  33292. m.ResetUpdatedAt()
  33293. return nil
  33294. case usagedetail.FieldStatus:
  33295. m.ResetStatus()
  33296. return nil
  33297. case usagedetail.FieldType:
  33298. m.ResetType()
  33299. return nil
  33300. case usagedetail.FieldBotID:
  33301. m.ResetBotID()
  33302. return nil
  33303. case usagedetail.FieldReceiverID:
  33304. m.ResetReceiverID()
  33305. return nil
  33306. case usagedetail.FieldApp:
  33307. m.ResetApp()
  33308. return nil
  33309. case usagedetail.FieldSessionID:
  33310. m.ResetSessionID()
  33311. return nil
  33312. case usagedetail.FieldRequest:
  33313. m.ResetRequest()
  33314. return nil
  33315. case usagedetail.FieldResponse:
  33316. m.ResetResponse()
  33317. return nil
  33318. case usagedetail.FieldOriginalData:
  33319. m.ResetOriginalData()
  33320. return nil
  33321. case usagedetail.FieldTotalTokens:
  33322. m.ResetTotalTokens()
  33323. return nil
  33324. case usagedetail.FieldPromptTokens:
  33325. m.ResetPromptTokens()
  33326. return nil
  33327. case usagedetail.FieldCompletionTokens:
  33328. m.ResetCompletionTokens()
  33329. return nil
  33330. case usagedetail.FieldOrganizationID:
  33331. m.ResetOrganizationID()
  33332. return nil
  33333. }
  33334. return fmt.Errorf("unknown UsageDetail field %s", name)
  33335. }
  33336. // AddedEdges returns all edge names that were set/added in this mutation.
  33337. func (m *UsageDetailMutation) AddedEdges() []string {
  33338. edges := make([]string, 0, 0)
  33339. return edges
  33340. }
  33341. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33342. // name in this mutation.
  33343. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  33344. return nil
  33345. }
  33346. // RemovedEdges returns all edge names that were removed in this mutation.
  33347. func (m *UsageDetailMutation) RemovedEdges() []string {
  33348. edges := make([]string, 0, 0)
  33349. return edges
  33350. }
  33351. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33352. // the given name in this mutation.
  33353. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  33354. return nil
  33355. }
  33356. // ClearedEdges returns all edge names that were cleared in this mutation.
  33357. func (m *UsageDetailMutation) ClearedEdges() []string {
  33358. edges := make([]string, 0, 0)
  33359. return edges
  33360. }
  33361. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33362. // was cleared in this mutation.
  33363. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  33364. return false
  33365. }
  33366. // ClearEdge clears the value of the edge with the given name. It returns an error
  33367. // if that edge is not defined in the schema.
  33368. func (m *UsageDetailMutation) ClearEdge(name string) error {
  33369. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  33370. }
  33371. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33372. // It returns an error if the edge is not defined in the schema.
  33373. func (m *UsageDetailMutation) ResetEdge(name string) error {
  33374. return fmt.Errorf("unknown UsageDetail edge %s", name)
  33375. }
  33376. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  33377. type UsageStatisticDayMutation struct {
  33378. config
  33379. op Op
  33380. typ string
  33381. id *uint64
  33382. created_at *time.Time
  33383. updated_at *time.Time
  33384. status *uint8
  33385. addstatus *int8
  33386. deleted_at *time.Time
  33387. addtime *uint64
  33388. addaddtime *int64
  33389. _type *int
  33390. add_type *int
  33391. bot_id *string
  33392. organization_id *uint64
  33393. addorganization_id *int64
  33394. ai_response *uint64
  33395. addai_response *int64
  33396. sop_run *uint64
  33397. addsop_run *int64
  33398. total_friend *uint64
  33399. addtotal_friend *int64
  33400. total_group *uint64
  33401. addtotal_group *int64
  33402. account_balance *uint64
  33403. addaccount_balance *int64
  33404. consume_token *uint64
  33405. addconsume_token *int64
  33406. active_user *uint64
  33407. addactive_user *int64
  33408. new_user *int64
  33409. addnew_user *int64
  33410. label_dist *[]custom_types.LabelDist
  33411. appendlabel_dist []custom_types.LabelDist
  33412. clearedFields map[string]struct{}
  33413. done bool
  33414. oldValue func(context.Context) (*UsageStatisticDay, error)
  33415. predicates []predicate.UsageStatisticDay
  33416. }
  33417. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  33418. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  33419. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  33420. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  33421. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  33422. m := &UsageStatisticDayMutation{
  33423. config: c,
  33424. op: op,
  33425. typ: TypeUsageStatisticDay,
  33426. clearedFields: make(map[string]struct{}),
  33427. }
  33428. for _, opt := range opts {
  33429. opt(m)
  33430. }
  33431. return m
  33432. }
  33433. // withUsageStatisticDayID sets the ID field of the mutation.
  33434. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  33435. return func(m *UsageStatisticDayMutation) {
  33436. var (
  33437. err error
  33438. once sync.Once
  33439. value *UsageStatisticDay
  33440. )
  33441. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  33442. once.Do(func() {
  33443. if m.done {
  33444. err = errors.New("querying old values post mutation is not allowed")
  33445. } else {
  33446. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  33447. }
  33448. })
  33449. return value, err
  33450. }
  33451. m.id = &id
  33452. }
  33453. }
  33454. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  33455. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  33456. return func(m *UsageStatisticDayMutation) {
  33457. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  33458. return node, nil
  33459. }
  33460. m.id = &node.ID
  33461. }
  33462. }
  33463. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33464. // executed in a transaction (ent.Tx), a transactional client is returned.
  33465. func (m UsageStatisticDayMutation) Client() *Client {
  33466. client := &Client{config: m.config}
  33467. client.init()
  33468. return client
  33469. }
  33470. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33471. // it returns an error otherwise.
  33472. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  33473. if _, ok := m.driver.(*txDriver); !ok {
  33474. return nil, errors.New("ent: mutation is not running in a transaction")
  33475. }
  33476. tx := &Tx{config: m.config}
  33477. tx.init()
  33478. return tx, nil
  33479. }
  33480. // SetID sets the value of the id field. Note that this
  33481. // operation is only accepted on creation of UsageStatisticDay entities.
  33482. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  33483. m.id = &id
  33484. }
  33485. // ID returns the ID value in the mutation. Note that the ID is only available
  33486. // if it was provided to the builder or after it was returned from the database.
  33487. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  33488. if m.id == nil {
  33489. return
  33490. }
  33491. return *m.id, true
  33492. }
  33493. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33494. // That means, if the mutation is applied within a transaction with an isolation level such
  33495. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33496. // or updated by the mutation.
  33497. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  33498. switch {
  33499. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33500. id, exists := m.ID()
  33501. if exists {
  33502. return []uint64{id}, nil
  33503. }
  33504. fallthrough
  33505. case m.op.Is(OpUpdate | OpDelete):
  33506. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  33507. default:
  33508. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33509. }
  33510. }
  33511. // SetCreatedAt sets the "created_at" field.
  33512. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  33513. m.created_at = &t
  33514. }
  33515. // CreatedAt returns the value of the "created_at" field in the mutation.
  33516. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  33517. v := m.created_at
  33518. if v == nil {
  33519. return
  33520. }
  33521. return *v, true
  33522. }
  33523. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  33524. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33526. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33527. if !m.op.Is(OpUpdateOne) {
  33528. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33529. }
  33530. if m.id == nil || m.oldValue == nil {
  33531. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33532. }
  33533. oldValue, err := m.oldValue(ctx)
  33534. if err != nil {
  33535. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33536. }
  33537. return oldValue.CreatedAt, nil
  33538. }
  33539. // ResetCreatedAt resets all changes to the "created_at" field.
  33540. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  33541. m.created_at = nil
  33542. }
  33543. // SetUpdatedAt sets the "updated_at" field.
  33544. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  33545. m.updated_at = &t
  33546. }
  33547. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33548. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  33549. v := m.updated_at
  33550. if v == nil {
  33551. return
  33552. }
  33553. return *v, true
  33554. }
  33555. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  33556. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33558. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33559. if !m.op.Is(OpUpdateOne) {
  33560. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33561. }
  33562. if m.id == nil || m.oldValue == nil {
  33563. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33564. }
  33565. oldValue, err := m.oldValue(ctx)
  33566. if err != nil {
  33567. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33568. }
  33569. return oldValue.UpdatedAt, nil
  33570. }
  33571. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33572. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  33573. m.updated_at = nil
  33574. }
  33575. // SetStatus sets the "status" field.
  33576. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  33577. m.status = &u
  33578. m.addstatus = nil
  33579. }
  33580. // Status returns the value of the "status" field in the mutation.
  33581. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  33582. v := m.status
  33583. if v == nil {
  33584. return
  33585. }
  33586. return *v, true
  33587. }
  33588. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  33589. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33591. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33592. if !m.op.Is(OpUpdateOne) {
  33593. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33594. }
  33595. if m.id == nil || m.oldValue == nil {
  33596. return v, errors.New("OldStatus requires an ID field in the mutation")
  33597. }
  33598. oldValue, err := m.oldValue(ctx)
  33599. if err != nil {
  33600. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33601. }
  33602. return oldValue.Status, nil
  33603. }
  33604. // AddStatus adds u to the "status" field.
  33605. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  33606. if m.addstatus != nil {
  33607. *m.addstatus += u
  33608. } else {
  33609. m.addstatus = &u
  33610. }
  33611. }
  33612. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33613. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  33614. v := m.addstatus
  33615. if v == nil {
  33616. return
  33617. }
  33618. return *v, true
  33619. }
  33620. // ClearStatus clears the value of the "status" field.
  33621. func (m *UsageStatisticDayMutation) ClearStatus() {
  33622. m.status = nil
  33623. m.addstatus = nil
  33624. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  33625. }
  33626. // StatusCleared returns if the "status" field was cleared in this mutation.
  33627. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  33628. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  33629. return ok
  33630. }
  33631. // ResetStatus resets all changes to the "status" field.
  33632. func (m *UsageStatisticDayMutation) ResetStatus() {
  33633. m.status = nil
  33634. m.addstatus = nil
  33635. delete(m.clearedFields, usagestatisticday.FieldStatus)
  33636. }
  33637. // SetDeletedAt sets the "deleted_at" field.
  33638. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  33639. m.deleted_at = &t
  33640. }
  33641. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33642. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  33643. v := m.deleted_at
  33644. if v == nil {
  33645. return
  33646. }
  33647. return *v, true
  33648. }
  33649. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  33650. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33652. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33653. if !m.op.Is(OpUpdateOne) {
  33654. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33655. }
  33656. if m.id == nil || m.oldValue == nil {
  33657. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33658. }
  33659. oldValue, err := m.oldValue(ctx)
  33660. if err != nil {
  33661. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33662. }
  33663. return oldValue.DeletedAt, nil
  33664. }
  33665. // ClearDeletedAt clears the value of the "deleted_at" field.
  33666. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  33667. m.deleted_at = nil
  33668. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  33669. }
  33670. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33671. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  33672. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  33673. return ok
  33674. }
  33675. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33676. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  33677. m.deleted_at = nil
  33678. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  33679. }
  33680. // SetAddtime sets the "addtime" field.
  33681. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  33682. m.addtime = &u
  33683. m.addaddtime = nil
  33684. }
  33685. // Addtime returns the value of the "addtime" field in the mutation.
  33686. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  33687. v := m.addtime
  33688. if v == nil {
  33689. return
  33690. }
  33691. return *v, true
  33692. }
  33693. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  33694. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33696. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33697. if !m.op.Is(OpUpdateOne) {
  33698. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33699. }
  33700. if m.id == nil || m.oldValue == nil {
  33701. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33702. }
  33703. oldValue, err := m.oldValue(ctx)
  33704. if err != nil {
  33705. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33706. }
  33707. return oldValue.Addtime, nil
  33708. }
  33709. // AddAddtime adds u to the "addtime" field.
  33710. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  33711. if m.addaddtime != nil {
  33712. *m.addaddtime += u
  33713. } else {
  33714. m.addaddtime = &u
  33715. }
  33716. }
  33717. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33718. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  33719. v := m.addaddtime
  33720. if v == nil {
  33721. return
  33722. }
  33723. return *v, true
  33724. }
  33725. // ResetAddtime resets all changes to the "addtime" field.
  33726. func (m *UsageStatisticDayMutation) ResetAddtime() {
  33727. m.addtime = nil
  33728. m.addaddtime = nil
  33729. }
  33730. // SetType sets the "type" field.
  33731. func (m *UsageStatisticDayMutation) SetType(i int) {
  33732. m._type = &i
  33733. m.add_type = nil
  33734. }
  33735. // GetType returns the value of the "type" field in the mutation.
  33736. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  33737. v := m._type
  33738. if v == nil {
  33739. return
  33740. }
  33741. return *v, true
  33742. }
  33743. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  33744. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33746. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  33747. if !m.op.Is(OpUpdateOne) {
  33748. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33749. }
  33750. if m.id == nil || m.oldValue == nil {
  33751. return v, errors.New("OldType requires an ID field in the mutation")
  33752. }
  33753. oldValue, err := m.oldValue(ctx)
  33754. if err != nil {
  33755. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33756. }
  33757. return oldValue.Type, nil
  33758. }
  33759. // AddType adds i to the "type" field.
  33760. func (m *UsageStatisticDayMutation) AddType(i int) {
  33761. if m.add_type != nil {
  33762. *m.add_type += i
  33763. } else {
  33764. m.add_type = &i
  33765. }
  33766. }
  33767. // AddedType returns the value that was added to the "type" field in this mutation.
  33768. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  33769. v := m.add_type
  33770. if v == nil {
  33771. return
  33772. }
  33773. return *v, true
  33774. }
  33775. // ResetType resets all changes to the "type" field.
  33776. func (m *UsageStatisticDayMutation) ResetType() {
  33777. m._type = nil
  33778. m.add_type = nil
  33779. }
  33780. // SetBotID sets the "bot_id" field.
  33781. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  33782. m.bot_id = &s
  33783. }
  33784. // BotID returns the value of the "bot_id" field in the mutation.
  33785. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  33786. v := m.bot_id
  33787. if v == nil {
  33788. return
  33789. }
  33790. return *v, true
  33791. }
  33792. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  33793. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33795. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  33796. if !m.op.Is(OpUpdateOne) {
  33797. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33798. }
  33799. if m.id == nil || m.oldValue == nil {
  33800. return v, errors.New("OldBotID requires an ID field in the mutation")
  33801. }
  33802. oldValue, err := m.oldValue(ctx)
  33803. if err != nil {
  33804. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33805. }
  33806. return oldValue.BotID, nil
  33807. }
  33808. // ClearBotID clears the value of the "bot_id" field.
  33809. func (m *UsageStatisticDayMutation) ClearBotID() {
  33810. m.bot_id = nil
  33811. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  33812. }
  33813. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33814. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  33815. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  33816. return ok
  33817. }
  33818. // ResetBotID resets all changes to the "bot_id" field.
  33819. func (m *UsageStatisticDayMutation) ResetBotID() {
  33820. m.bot_id = nil
  33821. delete(m.clearedFields, usagestatisticday.FieldBotID)
  33822. }
  33823. // SetOrganizationID sets the "organization_id" field.
  33824. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  33825. m.organization_id = &u
  33826. m.addorganization_id = nil
  33827. }
  33828. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33829. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  33830. v := m.organization_id
  33831. if v == nil {
  33832. return
  33833. }
  33834. return *v, true
  33835. }
  33836. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  33837. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33839. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33840. if !m.op.Is(OpUpdateOne) {
  33841. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33842. }
  33843. if m.id == nil || m.oldValue == nil {
  33844. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33845. }
  33846. oldValue, err := m.oldValue(ctx)
  33847. if err != nil {
  33848. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33849. }
  33850. return oldValue.OrganizationID, nil
  33851. }
  33852. // AddOrganizationID adds u to the "organization_id" field.
  33853. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  33854. if m.addorganization_id != nil {
  33855. *m.addorganization_id += u
  33856. } else {
  33857. m.addorganization_id = &u
  33858. }
  33859. }
  33860. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33861. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  33862. v := m.addorganization_id
  33863. if v == nil {
  33864. return
  33865. }
  33866. return *v, true
  33867. }
  33868. // ClearOrganizationID clears the value of the "organization_id" field.
  33869. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  33870. m.organization_id = nil
  33871. m.addorganization_id = nil
  33872. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  33873. }
  33874. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33875. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  33876. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  33877. return ok
  33878. }
  33879. // ResetOrganizationID resets all changes to the "organization_id" field.
  33880. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  33881. m.organization_id = nil
  33882. m.addorganization_id = nil
  33883. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  33884. }
  33885. // SetAiResponse sets the "ai_response" field.
  33886. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  33887. m.ai_response = &u
  33888. m.addai_response = nil
  33889. }
  33890. // AiResponse returns the value of the "ai_response" field in the mutation.
  33891. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  33892. v := m.ai_response
  33893. if v == nil {
  33894. return
  33895. }
  33896. return *v, true
  33897. }
  33898. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  33899. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33901. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33902. if !m.op.Is(OpUpdateOne) {
  33903. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33904. }
  33905. if m.id == nil || m.oldValue == nil {
  33906. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33907. }
  33908. oldValue, err := m.oldValue(ctx)
  33909. if err != nil {
  33910. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33911. }
  33912. return oldValue.AiResponse, nil
  33913. }
  33914. // AddAiResponse adds u to the "ai_response" field.
  33915. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  33916. if m.addai_response != nil {
  33917. *m.addai_response += u
  33918. } else {
  33919. m.addai_response = &u
  33920. }
  33921. }
  33922. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33923. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  33924. v := m.addai_response
  33925. if v == nil {
  33926. return
  33927. }
  33928. return *v, true
  33929. }
  33930. // ResetAiResponse resets all changes to the "ai_response" field.
  33931. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  33932. m.ai_response = nil
  33933. m.addai_response = nil
  33934. }
  33935. // SetSopRun sets the "sop_run" field.
  33936. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  33937. m.sop_run = &u
  33938. m.addsop_run = nil
  33939. }
  33940. // SopRun returns the value of the "sop_run" field in the mutation.
  33941. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  33942. v := m.sop_run
  33943. if v == nil {
  33944. return
  33945. }
  33946. return *v, true
  33947. }
  33948. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  33949. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33951. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33952. if !m.op.Is(OpUpdateOne) {
  33953. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33954. }
  33955. if m.id == nil || m.oldValue == nil {
  33956. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33957. }
  33958. oldValue, err := m.oldValue(ctx)
  33959. if err != nil {
  33960. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33961. }
  33962. return oldValue.SopRun, nil
  33963. }
  33964. // AddSopRun adds u to the "sop_run" field.
  33965. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  33966. if m.addsop_run != nil {
  33967. *m.addsop_run += u
  33968. } else {
  33969. m.addsop_run = &u
  33970. }
  33971. }
  33972. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33973. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  33974. v := m.addsop_run
  33975. if v == nil {
  33976. return
  33977. }
  33978. return *v, true
  33979. }
  33980. // ResetSopRun resets all changes to the "sop_run" field.
  33981. func (m *UsageStatisticDayMutation) ResetSopRun() {
  33982. m.sop_run = nil
  33983. m.addsop_run = nil
  33984. }
  33985. // SetTotalFriend sets the "total_friend" field.
  33986. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  33987. m.total_friend = &u
  33988. m.addtotal_friend = nil
  33989. }
  33990. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33991. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  33992. v := m.total_friend
  33993. if v == nil {
  33994. return
  33995. }
  33996. return *v, true
  33997. }
  33998. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  33999. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34001. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34002. if !m.op.Is(OpUpdateOne) {
  34003. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34004. }
  34005. if m.id == nil || m.oldValue == nil {
  34006. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34007. }
  34008. oldValue, err := m.oldValue(ctx)
  34009. if err != nil {
  34010. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34011. }
  34012. return oldValue.TotalFriend, nil
  34013. }
  34014. // AddTotalFriend adds u to the "total_friend" field.
  34015. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  34016. if m.addtotal_friend != nil {
  34017. *m.addtotal_friend += u
  34018. } else {
  34019. m.addtotal_friend = &u
  34020. }
  34021. }
  34022. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34023. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  34024. v := m.addtotal_friend
  34025. if v == nil {
  34026. return
  34027. }
  34028. return *v, true
  34029. }
  34030. // ResetTotalFriend resets all changes to the "total_friend" field.
  34031. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  34032. m.total_friend = nil
  34033. m.addtotal_friend = nil
  34034. }
  34035. // SetTotalGroup sets the "total_group" field.
  34036. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  34037. m.total_group = &u
  34038. m.addtotal_group = nil
  34039. }
  34040. // TotalGroup returns the value of the "total_group" field in the mutation.
  34041. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  34042. v := m.total_group
  34043. if v == nil {
  34044. return
  34045. }
  34046. return *v, true
  34047. }
  34048. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  34049. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34051. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34052. if !m.op.Is(OpUpdateOne) {
  34053. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34054. }
  34055. if m.id == nil || m.oldValue == nil {
  34056. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34057. }
  34058. oldValue, err := m.oldValue(ctx)
  34059. if err != nil {
  34060. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34061. }
  34062. return oldValue.TotalGroup, nil
  34063. }
  34064. // AddTotalGroup adds u to the "total_group" field.
  34065. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  34066. if m.addtotal_group != nil {
  34067. *m.addtotal_group += u
  34068. } else {
  34069. m.addtotal_group = &u
  34070. }
  34071. }
  34072. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34073. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  34074. v := m.addtotal_group
  34075. if v == nil {
  34076. return
  34077. }
  34078. return *v, true
  34079. }
  34080. // ResetTotalGroup resets all changes to the "total_group" field.
  34081. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  34082. m.total_group = nil
  34083. m.addtotal_group = nil
  34084. }
  34085. // SetAccountBalance sets the "account_balance" field.
  34086. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  34087. m.account_balance = &u
  34088. m.addaccount_balance = nil
  34089. }
  34090. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34091. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  34092. v := m.account_balance
  34093. if v == nil {
  34094. return
  34095. }
  34096. return *v, true
  34097. }
  34098. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  34099. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34101. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34102. if !m.op.Is(OpUpdateOne) {
  34103. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34104. }
  34105. if m.id == nil || m.oldValue == nil {
  34106. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34107. }
  34108. oldValue, err := m.oldValue(ctx)
  34109. if err != nil {
  34110. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34111. }
  34112. return oldValue.AccountBalance, nil
  34113. }
  34114. // AddAccountBalance adds u to the "account_balance" field.
  34115. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  34116. if m.addaccount_balance != nil {
  34117. *m.addaccount_balance += u
  34118. } else {
  34119. m.addaccount_balance = &u
  34120. }
  34121. }
  34122. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34123. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  34124. v := m.addaccount_balance
  34125. if v == nil {
  34126. return
  34127. }
  34128. return *v, true
  34129. }
  34130. // ResetAccountBalance resets all changes to the "account_balance" field.
  34131. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  34132. m.account_balance = nil
  34133. m.addaccount_balance = nil
  34134. }
  34135. // SetConsumeToken sets the "consume_token" field.
  34136. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  34137. m.consume_token = &u
  34138. m.addconsume_token = nil
  34139. }
  34140. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34141. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  34142. v := m.consume_token
  34143. if v == nil {
  34144. return
  34145. }
  34146. return *v, true
  34147. }
  34148. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  34149. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34151. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34152. if !m.op.Is(OpUpdateOne) {
  34153. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34154. }
  34155. if m.id == nil || m.oldValue == nil {
  34156. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34157. }
  34158. oldValue, err := m.oldValue(ctx)
  34159. if err != nil {
  34160. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34161. }
  34162. return oldValue.ConsumeToken, nil
  34163. }
  34164. // AddConsumeToken adds u to the "consume_token" field.
  34165. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  34166. if m.addconsume_token != nil {
  34167. *m.addconsume_token += u
  34168. } else {
  34169. m.addconsume_token = &u
  34170. }
  34171. }
  34172. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34173. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  34174. v := m.addconsume_token
  34175. if v == nil {
  34176. return
  34177. }
  34178. return *v, true
  34179. }
  34180. // ResetConsumeToken resets all changes to the "consume_token" field.
  34181. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  34182. m.consume_token = nil
  34183. m.addconsume_token = nil
  34184. }
  34185. // SetActiveUser sets the "active_user" field.
  34186. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  34187. m.active_user = &u
  34188. m.addactive_user = nil
  34189. }
  34190. // ActiveUser returns the value of the "active_user" field in the mutation.
  34191. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  34192. v := m.active_user
  34193. if v == nil {
  34194. return
  34195. }
  34196. return *v, true
  34197. }
  34198. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  34199. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34201. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34202. if !m.op.Is(OpUpdateOne) {
  34203. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34204. }
  34205. if m.id == nil || m.oldValue == nil {
  34206. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34207. }
  34208. oldValue, err := m.oldValue(ctx)
  34209. if err != nil {
  34210. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34211. }
  34212. return oldValue.ActiveUser, nil
  34213. }
  34214. // AddActiveUser adds u to the "active_user" field.
  34215. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  34216. if m.addactive_user != nil {
  34217. *m.addactive_user += u
  34218. } else {
  34219. m.addactive_user = &u
  34220. }
  34221. }
  34222. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34223. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  34224. v := m.addactive_user
  34225. if v == nil {
  34226. return
  34227. }
  34228. return *v, true
  34229. }
  34230. // ResetActiveUser resets all changes to the "active_user" field.
  34231. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  34232. m.active_user = nil
  34233. m.addactive_user = nil
  34234. }
  34235. // SetNewUser sets the "new_user" field.
  34236. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  34237. m.new_user = &i
  34238. m.addnew_user = nil
  34239. }
  34240. // NewUser returns the value of the "new_user" field in the mutation.
  34241. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  34242. v := m.new_user
  34243. if v == nil {
  34244. return
  34245. }
  34246. return *v, true
  34247. }
  34248. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  34249. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34251. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34252. if !m.op.Is(OpUpdateOne) {
  34253. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34254. }
  34255. if m.id == nil || m.oldValue == nil {
  34256. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34257. }
  34258. oldValue, err := m.oldValue(ctx)
  34259. if err != nil {
  34260. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34261. }
  34262. return oldValue.NewUser, nil
  34263. }
  34264. // AddNewUser adds i to the "new_user" field.
  34265. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  34266. if m.addnew_user != nil {
  34267. *m.addnew_user += i
  34268. } else {
  34269. m.addnew_user = &i
  34270. }
  34271. }
  34272. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34273. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  34274. v := m.addnew_user
  34275. if v == nil {
  34276. return
  34277. }
  34278. return *v, true
  34279. }
  34280. // ResetNewUser resets all changes to the "new_user" field.
  34281. func (m *UsageStatisticDayMutation) ResetNewUser() {
  34282. m.new_user = nil
  34283. m.addnew_user = nil
  34284. }
  34285. // SetLabelDist sets the "label_dist" field.
  34286. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34287. m.label_dist = &ctd
  34288. m.appendlabel_dist = nil
  34289. }
  34290. // LabelDist returns the value of the "label_dist" field in the mutation.
  34291. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34292. v := m.label_dist
  34293. if v == nil {
  34294. return
  34295. }
  34296. return *v, true
  34297. }
  34298. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  34299. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34301. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34302. if !m.op.Is(OpUpdateOne) {
  34303. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34304. }
  34305. if m.id == nil || m.oldValue == nil {
  34306. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34307. }
  34308. oldValue, err := m.oldValue(ctx)
  34309. if err != nil {
  34310. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34311. }
  34312. return oldValue.LabelDist, nil
  34313. }
  34314. // AppendLabelDist adds ctd to the "label_dist" field.
  34315. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34316. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34317. }
  34318. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34319. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34320. if len(m.appendlabel_dist) == 0 {
  34321. return nil, false
  34322. }
  34323. return m.appendlabel_dist, true
  34324. }
  34325. // ResetLabelDist resets all changes to the "label_dist" field.
  34326. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  34327. m.label_dist = nil
  34328. m.appendlabel_dist = nil
  34329. }
  34330. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  34331. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  34332. m.predicates = append(m.predicates, ps...)
  34333. }
  34334. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  34335. // users can use type-assertion to append predicates that do not depend on any generated package.
  34336. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  34337. p := make([]predicate.UsageStatisticDay, len(ps))
  34338. for i := range ps {
  34339. p[i] = ps[i]
  34340. }
  34341. m.Where(p...)
  34342. }
  34343. // Op returns the operation name.
  34344. func (m *UsageStatisticDayMutation) Op() Op {
  34345. return m.op
  34346. }
  34347. // SetOp allows setting the mutation operation.
  34348. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  34349. m.op = op
  34350. }
  34351. // Type returns the node type of this mutation (UsageStatisticDay).
  34352. func (m *UsageStatisticDayMutation) Type() string {
  34353. return m.typ
  34354. }
  34355. // Fields returns all fields that were changed during this mutation. Note that in
  34356. // order to get all numeric fields that were incremented/decremented, call
  34357. // AddedFields().
  34358. func (m *UsageStatisticDayMutation) Fields() []string {
  34359. fields := make([]string, 0, 17)
  34360. if m.created_at != nil {
  34361. fields = append(fields, usagestatisticday.FieldCreatedAt)
  34362. }
  34363. if m.updated_at != nil {
  34364. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  34365. }
  34366. if m.status != nil {
  34367. fields = append(fields, usagestatisticday.FieldStatus)
  34368. }
  34369. if m.deleted_at != nil {
  34370. fields = append(fields, usagestatisticday.FieldDeletedAt)
  34371. }
  34372. if m.addtime != nil {
  34373. fields = append(fields, usagestatisticday.FieldAddtime)
  34374. }
  34375. if m._type != nil {
  34376. fields = append(fields, usagestatisticday.FieldType)
  34377. }
  34378. if m.bot_id != nil {
  34379. fields = append(fields, usagestatisticday.FieldBotID)
  34380. }
  34381. if m.organization_id != nil {
  34382. fields = append(fields, usagestatisticday.FieldOrganizationID)
  34383. }
  34384. if m.ai_response != nil {
  34385. fields = append(fields, usagestatisticday.FieldAiResponse)
  34386. }
  34387. if m.sop_run != nil {
  34388. fields = append(fields, usagestatisticday.FieldSopRun)
  34389. }
  34390. if m.total_friend != nil {
  34391. fields = append(fields, usagestatisticday.FieldTotalFriend)
  34392. }
  34393. if m.total_group != nil {
  34394. fields = append(fields, usagestatisticday.FieldTotalGroup)
  34395. }
  34396. if m.account_balance != nil {
  34397. fields = append(fields, usagestatisticday.FieldAccountBalance)
  34398. }
  34399. if m.consume_token != nil {
  34400. fields = append(fields, usagestatisticday.FieldConsumeToken)
  34401. }
  34402. if m.active_user != nil {
  34403. fields = append(fields, usagestatisticday.FieldActiveUser)
  34404. }
  34405. if m.new_user != nil {
  34406. fields = append(fields, usagestatisticday.FieldNewUser)
  34407. }
  34408. if m.label_dist != nil {
  34409. fields = append(fields, usagestatisticday.FieldLabelDist)
  34410. }
  34411. return fields
  34412. }
  34413. // Field returns the value of a field with the given name. The second boolean
  34414. // return value indicates that this field was not set, or was not defined in the
  34415. // schema.
  34416. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  34417. switch name {
  34418. case usagestatisticday.FieldCreatedAt:
  34419. return m.CreatedAt()
  34420. case usagestatisticday.FieldUpdatedAt:
  34421. return m.UpdatedAt()
  34422. case usagestatisticday.FieldStatus:
  34423. return m.Status()
  34424. case usagestatisticday.FieldDeletedAt:
  34425. return m.DeletedAt()
  34426. case usagestatisticday.FieldAddtime:
  34427. return m.Addtime()
  34428. case usagestatisticday.FieldType:
  34429. return m.GetType()
  34430. case usagestatisticday.FieldBotID:
  34431. return m.BotID()
  34432. case usagestatisticday.FieldOrganizationID:
  34433. return m.OrganizationID()
  34434. case usagestatisticday.FieldAiResponse:
  34435. return m.AiResponse()
  34436. case usagestatisticday.FieldSopRun:
  34437. return m.SopRun()
  34438. case usagestatisticday.FieldTotalFriend:
  34439. return m.TotalFriend()
  34440. case usagestatisticday.FieldTotalGroup:
  34441. return m.TotalGroup()
  34442. case usagestatisticday.FieldAccountBalance:
  34443. return m.AccountBalance()
  34444. case usagestatisticday.FieldConsumeToken:
  34445. return m.ConsumeToken()
  34446. case usagestatisticday.FieldActiveUser:
  34447. return m.ActiveUser()
  34448. case usagestatisticday.FieldNewUser:
  34449. return m.NewUser()
  34450. case usagestatisticday.FieldLabelDist:
  34451. return m.LabelDist()
  34452. }
  34453. return nil, false
  34454. }
  34455. // OldField returns the old value of the field from the database. An error is
  34456. // returned if the mutation operation is not UpdateOne, or the query to the
  34457. // database failed.
  34458. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34459. switch name {
  34460. case usagestatisticday.FieldCreatedAt:
  34461. return m.OldCreatedAt(ctx)
  34462. case usagestatisticday.FieldUpdatedAt:
  34463. return m.OldUpdatedAt(ctx)
  34464. case usagestatisticday.FieldStatus:
  34465. return m.OldStatus(ctx)
  34466. case usagestatisticday.FieldDeletedAt:
  34467. return m.OldDeletedAt(ctx)
  34468. case usagestatisticday.FieldAddtime:
  34469. return m.OldAddtime(ctx)
  34470. case usagestatisticday.FieldType:
  34471. return m.OldType(ctx)
  34472. case usagestatisticday.FieldBotID:
  34473. return m.OldBotID(ctx)
  34474. case usagestatisticday.FieldOrganizationID:
  34475. return m.OldOrganizationID(ctx)
  34476. case usagestatisticday.FieldAiResponse:
  34477. return m.OldAiResponse(ctx)
  34478. case usagestatisticday.FieldSopRun:
  34479. return m.OldSopRun(ctx)
  34480. case usagestatisticday.FieldTotalFriend:
  34481. return m.OldTotalFriend(ctx)
  34482. case usagestatisticday.FieldTotalGroup:
  34483. return m.OldTotalGroup(ctx)
  34484. case usagestatisticday.FieldAccountBalance:
  34485. return m.OldAccountBalance(ctx)
  34486. case usagestatisticday.FieldConsumeToken:
  34487. return m.OldConsumeToken(ctx)
  34488. case usagestatisticday.FieldActiveUser:
  34489. return m.OldActiveUser(ctx)
  34490. case usagestatisticday.FieldNewUser:
  34491. return m.OldNewUser(ctx)
  34492. case usagestatisticday.FieldLabelDist:
  34493. return m.OldLabelDist(ctx)
  34494. }
  34495. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  34496. }
  34497. // SetField sets the value of a field with the given name. It returns an error if
  34498. // the field is not defined in the schema, or if the type mismatched the field
  34499. // type.
  34500. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  34501. switch name {
  34502. case usagestatisticday.FieldCreatedAt:
  34503. v, ok := value.(time.Time)
  34504. if !ok {
  34505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34506. }
  34507. m.SetCreatedAt(v)
  34508. return nil
  34509. case usagestatisticday.FieldUpdatedAt:
  34510. v, ok := value.(time.Time)
  34511. if !ok {
  34512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34513. }
  34514. m.SetUpdatedAt(v)
  34515. return nil
  34516. case usagestatisticday.FieldStatus:
  34517. v, ok := value.(uint8)
  34518. if !ok {
  34519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34520. }
  34521. m.SetStatus(v)
  34522. return nil
  34523. case usagestatisticday.FieldDeletedAt:
  34524. v, ok := value.(time.Time)
  34525. if !ok {
  34526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34527. }
  34528. m.SetDeletedAt(v)
  34529. return nil
  34530. case usagestatisticday.FieldAddtime:
  34531. v, ok := value.(uint64)
  34532. if !ok {
  34533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34534. }
  34535. m.SetAddtime(v)
  34536. return nil
  34537. case usagestatisticday.FieldType:
  34538. v, ok := value.(int)
  34539. if !ok {
  34540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34541. }
  34542. m.SetType(v)
  34543. return nil
  34544. case usagestatisticday.FieldBotID:
  34545. v, ok := value.(string)
  34546. if !ok {
  34547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34548. }
  34549. m.SetBotID(v)
  34550. return nil
  34551. case usagestatisticday.FieldOrganizationID:
  34552. v, ok := value.(uint64)
  34553. if !ok {
  34554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34555. }
  34556. m.SetOrganizationID(v)
  34557. return nil
  34558. case usagestatisticday.FieldAiResponse:
  34559. v, ok := value.(uint64)
  34560. if !ok {
  34561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34562. }
  34563. m.SetAiResponse(v)
  34564. return nil
  34565. case usagestatisticday.FieldSopRun:
  34566. v, ok := value.(uint64)
  34567. if !ok {
  34568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34569. }
  34570. m.SetSopRun(v)
  34571. return nil
  34572. case usagestatisticday.FieldTotalFriend:
  34573. v, ok := value.(uint64)
  34574. if !ok {
  34575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34576. }
  34577. m.SetTotalFriend(v)
  34578. return nil
  34579. case usagestatisticday.FieldTotalGroup:
  34580. v, ok := value.(uint64)
  34581. if !ok {
  34582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34583. }
  34584. m.SetTotalGroup(v)
  34585. return nil
  34586. case usagestatisticday.FieldAccountBalance:
  34587. v, ok := value.(uint64)
  34588. if !ok {
  34589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34590. }
  34591. m.SetAccountBalance(v)
  34592. return nil
  34593. case usagestatisticday.FieldConsumeToken:
  34594. v, ok := value.(uint64)
  34595. if !ok {
  34596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34597. }
  34598. m.SetConsumeToken(v)
  34599. return nil
  34600. case usagestatisticday.FieldActiveUser:
  34601. v, ok := value.(uint64)
  34602. if !ok {
  34603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34604. }
  34605. m.SetActiveUser(v)
  34606. return nil
  34607. case usagestatisticday.FieldNewUser:
  34608. v, ok := value.(int64)
  34609. if !ok {
  34610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34611. }
  34612. m.SetNewUser(v)
  34613. return nil
  34614. case usagestatisticday.FieldLabelDist:
  34615. v, ok := value.([]custom_types.LabelDist)
  34616. if !ok {
  34617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34618. }
  34619. m.SetLabelDist(v)
  34620. return nil
  34621. }
  34622. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  34623. }
  34624. // AddedFields returns all numeric fields that were incremented/decremented during
  34625. // this mutation.
  34626. func (m *UsageStatisticDayMutation) AddedFields() []string {
  34627. var fields []string
  34628. if m.addstatus != nil {
  34629. fields = append(fields, usagestatisticday.FieldStatus)
  34630. }
  34631. if m.addaddtime != nil {
  34632. fields = append(fields, usagestatisticday.FieldAddtime)
  34633. }
  34634. if m.add_type != nil {
  34635. fields = append(fields, usagestatisticday.FieldType)
  34636. }
  34637. if m.addorganization_id != nil {
  34638. fields = append(fields, usagestatisticday.FieldOrganizationID)
  34639. }
  34640. if m.addai_response != nil {
  34641. fields = append(fields, usagestatisticday.FieldAiResponse)
  34642. }
  34643. if m.addsop_run != nil {
  34644. fields = append(fields, usagestatisticday.FieldSopRun)
  34645. }
  34646. if m.addtotal_friend != nil {
  34647. fields = append(fields, usagestatisticday.FieldTotalFriend)
  34648. }
  34649. if m.addtotal_group != nil {
  34650. fields = append(fields, usagestatisticday.FieldTotalGroup)
  34651. }
  34652. if m.addaccount_balance != nil {
  34653. fields = append(fields, usagestatisticday.FieldAccountBalance)
  34654. }
  34655. if m.addconsume_token != nil {
  34656. fields = append(fields, usagestatisticday.FieldConsumeToken)
  34657. }
  34658. if m.addactive_user != nil {
  34659. fields = append(fields, usagestatisticday.FieldActiveUser)
  34660. }
  34661. if m.addnew_user != nil {
  34662. fields = append(fields, usagestatisticday.FieldNewUser)
  34663. }
  34664. return fields
  34665. }
  34666. // AddedField returns the numeric value that was incremented/decremented on a field
  34667. // with the given name. The second boolean return value indicates that this field
  34668. // was not set, or was not defined in the schema.
  34669. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  34670. switch name {
  34671. case usagestatisticday.FieldStatus:
  34672. return m.AddedStatus()
  34673. case usagestatisticday.FieldAddtime:
  34674. return m.AddedAddtime()
  34675. case usagestatisticday.FieldType:
  34676. return m.AddedType()
  34677. case usagestatisticday.FieldOrganizationID:
  34678. return m.AddedOrganizationID()
  34679. case usagestatisticday.FieldAiResponse:
  34680. return m.AddedAiResponse()
  34681. case usagestatisticday.FieldSopRun:
  34682. return m.AddedSopRun()
  34683. case usagestatisticday.FieldTotalFriend:
  34684. return m.AddedTotalFriend()
  34685. case usagestatisticday.FieldTotalGroup:
  34686. return m.AddedTotalGroup()
  34687. case usagestatisticday.FieldAccountBalance:
  34688. return m.AddedAccountBalance()
  34689. case usagestatisticday.FieldConsumeToken:
  34690. return m.AddedConsumeToken()
  34691. case usagestatisticday.FieldActiveUser:
  34692. return m.AddedActiveUser()
  34693. case usagestatisticday.FieldNewUser:
  34694. return m.AddedNewUser()
  34695. }
  34696. return nil, false
  34697. }
  34698. // AddField adds the value to the field with the given name. It returns an error if
  34699. // the field is not defined in the schema, or if the type mismatched the field
  34700. // type.
  34701. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  34702. switch name {
  34703. case usagestatisticday.FieldStatus:
  34704. v, ok := value.(int8)
  34705. if !ok {
  34706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34707. }
  34708. m.AddStatus(v)
  34709. return nil
  34710. case usagestatisticday.FieldAddtime:
  34711. v, ok := value.(int64)
  34712. if !ok {
  34713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34714. }
  34715. m.AddAddtime(v)
  34716. return nil
  34717. case usagestatisticday.FieldType:
  34718. v, ok := value.(int)
  34719. if !ok {
  34720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34721. }
  34722. m.AddType(v)
  34723. return nil
  34724. case usagestatisticday.FieldOrganizationID:
  34725. v, ok := value.(int64)
  34726. if !ok {
  34727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34728. }
  34729. m.AddOrganizationID(v)
  34730. return nil
  34731. case usagestatisticday.FieldAiResponse:
  34732. v, ok := value.(int64)
  34733. if !ok {
  34734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34735. }
  34736. m.AddAiResponse(v)
  34737. return nil
  34738. case usagestatisticday.FieldSopRun:
  34739. v, ok := value.(int64)
  34740. if !ok {
  34741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34742. }
  34743. m.AddSopRun(v)
  34744. return nil
  34745. case usagestatisticday.FieldTotalFriend:
  34746. v, ok := value.(int64)
  34747. if !ok {
  34748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34749. }
  34750. m.AddTotalFriend(v)
  34751. return nil
  34752. case usagestatisticday.FieldTotalGroup:
  34753. v, ok := value.(int64)
  34754. if !ok {
  34755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34756. }
  34757. m.AddTotalGroup(v)
  34758. return nil
  34759. case usagestatisticday.FieldAccountBalance:
  34760. v, ok := value.(int64)
  34761. if !ok {
  34762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34763. }
  34764. m.AddAccountBalance(v)
  34765. return nil
  34766. case usagestatisticday.FieldConsumeToken:
  34767. v, ok := value.(int64)
  34768. if !ok {
  34769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34770. }
  34771. m.AddConsumeToken(v)
  34772. return nil
  34773. case usagestatisticday.FieldActiveUser:
  34774. v, ok := value.(int64)
  34775. if !ok {
  34776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34777. }
  34778. m.AddActiveUser(v)
  34779. return nil
  34780. case usagestatisticday.FieldNewUser:
  34781. v, ok := value.(int64)
  34782. if !ok {
  34783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34784. }
  34785. m.AddNewUser(v)
  34786. return nil
  34787. }
  34788. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  34789. }
  34790. // ClearedFields returns all nullable fields that were cleared during this
  34791. // mutation.
  34792. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  34793. var fields []string
  34794. if m.FieldCleared(usagestatisticday.FieldStatus) {
  34795. fields = append(fields, usagestatisticday.FieldStatus)
  34796. }
  34797. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  34798. fields = append(fields, usagestatisticday.FieldDeletedAt)
  34799. }
  34800. if m.FieldCleared(usagestatisticday.FieldBotID) {
  34801. fields = append(fields, usagestatisticday.FieldBotID)
  34802. }
  34803. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  34804. fields = append(fields, usagestatisticday.FieldOrganizationID)
  34805. }
  34806. return fields
  34807. }
  34808. // FieldCleared returns a boolean indicating if a field with the given name was
  34809. // cleared in this mutation.
  34810. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  34811. _, ok := m.clearedFields[name]
  34812. return ok
  34813. }
  34814. // ClearField clears the value of the field with the given name. It returns an
  34815. // error if the field is not defined in the schema.
  34816. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  34817. switch name {
  34818. case usagestatisticday.FieldStatus:
  34819. m.ClearStatus()
  34820. return nil
  34821. case usagestatisticday.FieldDeletedAt:
  34822. m.ClearDeletedAt()
  34823. return nil
  34824. case usagestatisticday.FieldBotID:
  34825. m.ClearBotID()
  34826. return nil
  34827. case usagestatisticday.FieldOrganizationID:
  34828. m.ClearOrganizationID()
  34829. return nil
  34830. }
  34831. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  34832. }
  34833. // ResetField resets all changes in the mutation for the field with the given name.
  34834. // It returns an error if the field is not defined in the schema.
  34835. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  34836. switch name {
  34837. case usagestatisticday.FieldCreatedAt:
  34838. m.ResetCreatedAt()
  34839. return nil
  34840. case usagestatisticday.FieldUpdatedAt:
  34841. m.ResetUpdatedAt()
  34842. return nil
  34843. case usagestatisticday.FieldStatus:
  34844. m.ResetStatus()
  34845. return nil
  34846. case usagestatisticday.FieldDeletedAt:
  34847. m.ResetDeletedAt()
  34848. return nil
  34849. case usagestatisticday.FieldAddtime:
  34850. m.ResetAddtime()
  34851. return nil
  34852. case usagestatisticday.FieldType:
  34853. m.ResetType()
  34854. return nil
  34855. case usagestatisticday.FieldBotID:
  34856. m.ResetBotID()
  34857. return nil
  34858. case usagestatisticday.FieldOrganizationID:
  34859. m.ResetOrganizationID()
  34860. return nil
  34861. case usagestatisticday.FieldAiResponse:
  34862. m.ResetAiResponse()
  34863. return nil
  34864. case usagestatisticday.FieldSopRun:
  34865. m.ResetSopRun()
  34866. return nil
  34867. case usagestatisticday.FieldTotalFriend:
  34868. m.ResetTotalFriend()
  34869. return nil
  34870. case usagestatisticday.FieldTotalGroup:
  34871. m.ResetTotalGroup()
  34872. return nil
  34873. case usagestatisticday.FieldAccountBalance:
  34874. m.ResetAccountBalance()
  34875. return nil
  34876. case usagestatisticday.FieldConsumeToken:
  34877. m.ResetConsumeToken()
  34878. return nil
  34879. case usagestatisticday.FieldActiveUser:
  34880. m.ResetActiveUser()
  34881. return nil
  34882. case usagestatisticday.FieldNewUser:
  34883. m.ResetNewUser()
  34884. return nil
  34885. case usagestatisticday.FieldLabelDist:
  34886. m.ResetLabelDist()
  34887. return nil
  34888. }
  34889. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  34890. }
  34891. // AddedEdges returns all edge names that were set/added in this mutation.
  34892. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  34893. edges := make([]string, 0, 0)
  34894. return edges
  34895. }
  34896. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34897. // name in this mutation.
  34898. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  34899. return nil
  34900. }
  34901. // RemovedEdges returns all edge names that were removed in this mutation.
  34902. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  34903. edges := make([]string, 0, 0)
  34904. return edges
  34905. }
  34906. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34907. // the given name in this mutation.
  34908. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  34909. return nil
  34910. }
  34911. // ClearedEdges returns all edge names that were cleared in this mutation.
  34912. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  34913. edges := make([]string, 0, 0)
  34914. return edges
  34915. }
  34916. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34917. // was cleared in this mutation.
  34918. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  34919. return false
  34920. }
  34921. // ClearEdge clears the value of the edge with the given name. It returns an error
  34922. // if that edge is not defined in the schema.
  34923. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  34924. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  34925. }
  34926. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34927. // It returns an error if the edge is not defined in the schema.
  34928. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  34929. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  34930. }
  34931. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  34932. type UsageStatisticHourMutation struct {
  34933. config
  34934. op Op
  34935. typ string
  34936. id *uint64
  34937. created_at *time.Time
  34938. updated_at *time.Time
  34939. status *uint8
  34940. addstatus *int8
  34941. deleted_at *time.Time
  34942. addtime *uint64
  34943. addaddtime *int64
  34944. _type *int
  34945. add_type *int
  34946. bot_id *string
  34947. organization_id *uint64
  34948. addorganization_id *int64
  34949. ai_response *uint64
  34950. addai_response *int64
  34951. sop_run *uint64
  34952. addsop_run *int64
  34953. total_friend *uint64
  34954. addtotal_friend *int64
  34955. total_group *uint64
  34956. addtotal_group *int64
  34957. account_balance *uint64
  34958. addaccount_balance *int64
  34959. consume_token *uint64
  34960. addconsume_token *int64
  34961. active_user *uint64
  34962. addactive_user *int64
  34963. new_user *int64
  34964. addnew_user *int64
  34965. label_dist *[]custom_types.LabelDist
  34966. appendlabel_dist []custom_types.LabelDist
  34967. clearedFields map[string]struct{}
  34968. done bool
  34969. oldValue func(context.Context) (*UsageStatisticHour, error)
  34970. predicates []predicate.UsageStatisticHour
  34971. }
  34972. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  34973. // usagestatistichourOption allows management of the mutation configuration using functional options.
  34974. type usagestatistichourOption func(*UsageStatisticHourMutation)
  34975. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  34976. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  34977. m := &UsageStatisticHourMutation{
  34978. config: c,
  34979. op: op,
  34980. typ: TypeUsageStatisticHour,
  34981. clearedFields: make(map[string]struct{}),
  34982. }
  34983. for _, opt := range opts {
  34984. opt(m)
  34985. }
  34986. return m
  34987. }
  34988. // withUsageStatisticHourID sets the ID field of the mutation.
  34989. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  34990. return func(m *UsageStatisticHourMutation) {
  34991. var (
  34992. err error
  34993. once sync.Once
  34994. value *UsageStatisticHour
  34995. )
  34996. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  34997. once.Do(func() {
  34998. if m.done {
  34999. err = errors.New("querying old values post mutation is not allowed")
  35000. } else {
  35001. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  35002. }
  35003. })
  35004. return value, err
  35005. }
  35006. m.id = &id
  35007. }
  35008. }
  35009. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  35010. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  35011. return func(m *UsageStatisticHourMutation) {
  35012. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  35013. return node, nil
  35014. }
  35015. m.id = &node.ID
  35016. }
  35017. }
  35018. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35019. // executed in a transaction (ent.Tx), a transactional client is returned.
  35020. func (m UsageStatisticHourMutation) Client() *Client {
  35021. client := &Client{config: m.config}
  35022. client.init()
  35023. return client
  35024. }
  35025. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35026. // it returns an error otherwise.
  35027. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  35028. if _, ok := m.driver.(*txDriver); !ok {
  35029. return nil, errors.New("ent: mutation is not running in a transaction")
  35030. }
  35031. tx := &Tx{config: m.config}
  35032. tx.init()
  35033. return tx, nil
  35034. }
  35035. // SetID sets the value of the id field. Note that this
  35036. // operation is only accepted on creation of UsageStatisticHour entities.
  35037. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  35038. m.id = &id
  35039. }
  35040. // ID returns the ID value in the mutation. Note that the ID is only available
  35041. // if it was provided to the builder or after it was returned from the database.
  35042. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  35043. if m.id == nil {
  35044. return
  35045. }
  35046. return *m.id, true
  35047. }
  35048. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35049. // That means, if the mutation is applied within a transaction with an isolation level such
  35050. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35051. // or updated by the mutation.
  35052. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  35053. switch {
  35054. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35055. id, exists := m.ID()
  35056. if exists {
  35057. return []uint64{id}, nil
  35058. }
  35059. fallthrough
  35060. case m.op.Is(OpUpdate | OpDelete):
  35061. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  35062. default:
  35063. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35064. }
  35065. }
  35066. // SetCreatedAt sets the "created_at" field.
  35067. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  35068. m.created_at = &t
  35069. }
  35070. // CreatedAt returns the value of the "created_at" field in the mutation.
  35071. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  35072. v := m.created_at
  35073. if v == nil {
  35074. return
  35075. }
  35076. return *v, true
  35077. }
  35078. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  35079. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35081. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35082. if !m.op.Is(OpUpdateOne) {
  35083. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35084. }
  35085. if m.id == nil || m.oldValue == nil {
  35086. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35087. }
  35088. oldValue, err := m.oldValue(ctx)
  35089. if err != nil {
  35090. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35091. }
  35092. return oldValue.CreatedAt, nil
  35093. }
  35094. // ResetCreatedAt resets all changes to the "created_at" field.
  35095. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  35096. m.created_at = nil
  35097. }
  35098. // SetUpdatedAt sets the "updated_at" field.
  35099. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  35100. m.updated_at = &t
  35101. }
  35102. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35103. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  35104. v := m.updated_at
  35105. if v == nil {
  35106. return
  35107. }
  35108. return *v, true
  35109. }
  35110. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  35111. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35113. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35114. if !m.op.Is(OpUpdateOne) {
  35115. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35116. }
  35117. if m.id == nil || m.oldValue == nil {
  35118. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35119. }
  35120. oldValue, err := m.oldValue(ctx)
  35121. if err != nil {
  35122. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35123. }
  35124. return oldValue.UpdatedAt, nil
  35125. }
  35126. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35127. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  35128. m.updated_at = nil
  35129. }
  35130. // SetStatus sets the "status" field.
  35131. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  35132. m.status = &u
  35133. m.addstatus = nil
  35134. }
  35135. // Status returns the value of the "status" field in the mutation.
  35136. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  35137. v := m.status
  35138. if v == nil {
  35139. return
  35140. }
  35141. return *v, true
  35142. }
  35143. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  35144. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35146. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35147. if !m.op.Is(OpUpdateOne) {
  35148. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35149. }
  35150. if m.id == nil || m.oldValue == nil {
  35151. return v, errors.New("OldStatus requires an ID field in the mutation")
  35152. }
  35153. oldValue, err := m.oldValue(ctx)
  35154. if err != nil {
  35155. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35156. }
  35157. return oldValue.Status, nil
  35158. }
  35159. // AddStatus adds u to the "status" field.
  35160. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  35161. if m.addstatus != nil {
  35162. *m.addstatus += u
  35163. } else {
  35164. m.addstatus = &u
  35165. }
  35166. }
  35167. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35168. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  35169. v := m.addstatus
  35170. if v == nil {
  35171. return
  35172. }
  35173. return *v, true
  35174. }
  35175. // ClearStatus clears the value of the "status" field.
  35176. func (m *UsageStatisticHourMutation) ClearStatus() {
  35177. m.status = nil
  35178. m.addstatus = nil
  35179. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  35180. }
  35181. // StatusCleared returns if the "status" field was cleared in this mutation.
  35182. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  35183. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  35184. return ok
  35185. }
  35186. // ResetStatus resets all changes to the "status" field.
  35187. func (m *UsageStatisticHourMutation) ResetStatus() {
  35188. m.status = nil
  35189. m.addstatus = nil
  35190. delete(m.clearedFields, usagestatistichour.FieldStatus)
  35191. }
  35192. // SetDeletedAt sets the "deleted_at" field.
  35193. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  35194. m.deleted_at = &t
  35195. }
  35196. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35197. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  35198. v := m.deleted_at
  35199. if v == nil {
  35200. return
  35201. }
  35202. return *v, true
  35203. }
  35204. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  35205. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35207. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35208. if !m.op.Is(OpUpdateOne) {
  35209. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35210. }
  35211. if m.id == nil || m.oldValue == nil {
  35212. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35213. }
  35214. oldValue, err := m.oldValue(ctx)
  35215. if err != nil {
  35216. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35217. }
  35218. return oldValue.DeletedAt, nil
  35219. }
  35220. // ClearDeletedAt clears the value of the "deleted_at" field.
  35221. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  35222. m.deleted_at = nil
  35223. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  35224. }
  35225. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35226. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  35227. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  35228. return ok
  35229. }
  35230. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35231. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  35232. m.deleted_at = nil
  35233. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  35234. }
  35235. // SetAddtime sets the "addtime" field.
  35236. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  35237. m.addtime = &u
  35238. m.addaddtime = nil
  35239. }
  35240. // Addtime returns the value of the "addtime" field in the mutation.
  35241. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  35242. v := m.addtime
  35243. if v == nil {
  35244. return
  35245. }
  35246. return *v, true
  35247. }
  35248. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  35249. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35251. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35252. if !m.op.Is(OpUpdateOne) {
  35253. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35254. }
  35255. if m.id == nil || m.oldValue == nil {
  35256. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35257. }
  35258. oldValue, err := m.oldValue(ctx)
  35259. if err != nil {
  35260. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35261. }
  35262. return oldValue.Addtime, nil
  35263. }
  35264. // AddAddtime adds u to the "addtime" field.
  35265. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  35266. if m.addaddtime != nil {
  35267. *m.addaddtime += u
  35268. } else {
  35269. m.addaddtime = &u
  35270. }
  35271. }
  35272. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35273. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  35274. v := m.addaddtime
  35275. if v == nil {
  35276. return
  35277. }
  35278. return *v, true
  35279. }
  35280. // ResetAddtime resets all changes to the "addtime" field.
  35281. func (m *UsageStatisticHourMutation) ResetAddtime() {
  35282. m.addtime = nil
  35283. m.addaddtime = nil
  35284. }
  35285. // SetType sets the "type" field.
  35286. func (m *UsageStatisticHourMutation) SetType(i int) {
  35287. m._type = &i
  35288. m.add_type = nil
  35289. }
  35290. // GetType returns the value of the "type" field in the mutation.
  35291. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  35292. v := m._type
  35293. if v == nil {
  35294. return
  35295. }
  35296. return *v, true
  35297. }
  35298. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  35299. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35301. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  35302. if !m.op.Is(OpUpdateOne) {
  35303. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35304. }
  35305. if m.id == nil || m.oldValue == nil {
  35306. return v, errors.New("OldType requires an ID field in the mutation")
  35307. }
  35308. oldValue, err := m.oldValue(ctx)
  35309. if err != nil {
  35310. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35311. }
  35312. return oldValue.Type, nil
  35313. }
  35314. // AddType adds i to the "type" field.
  35315. func (m *UsageStatisticHourMutation) AddType(i int) {
  35316. if m.add_type != nil {
  35317. *m.add_type += i
  35318. } else {
  35319. m.add_type = &i
  35320. }
  35321. }
  35322. // AddedType returns the value that was added to the "type" field in this mutation.
  35323. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  35324. v := m.add_type
  35325. if v == nil {
  35326. return
  35327. }
  35328. return *v, true
  35329. }
  35330. // ResetType resets all changes to the "type" field.
  35331. func (m *UsageStatisticHourMutation) ResetType() {
  35332. m._type = nil
  35333. m.add_type = nil
  35334. }
  35335. // SetBotID sets the "bot_id" field.
  35336. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  35337. m.bot_id = &s
  35338. }
  35339. // BotID returns the value of the "bot_id" field in the mutation.
  35340. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  35341. v := m.bot_id
  35342. if v == nil {
  35343. return
  35344. }
  35345. return *v, true
  35346. }
  35347. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  35348. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35350. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  35351. if !m.op.Is(OpUpdateOne) {
  35352. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35353. }
  35354. if m.id == nil || m.oldValue == nil {
  35355. return v, errors.New("OldBotID requires an ID field in the mutation")
  35356. }
  35357. oldValue, err := m.oldValue(ctx)
  35358. if err != nil {
  35359. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35360. }
  35361. return oldValue.BotID, nil
  35362. }
  35363. // ClearBotID clears the value of the "bot_id" field.
  35364. func (m *UsageStatisticHourMutation) ClearBotID() {
  35365. m.bot_id = nil
  35366. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  35367. }
  35368. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35369. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  35370. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  35371. return ok
  35372. }
  35373. // ResetBotID resets all changes to the "bot_id" field.
  35374. func (m *UsageStatisticHourMutation) ResetBotID() {
  35375. m.bot_id = nil
  35376. delete(m.clearedFields, usagestatistichour.FieldBotID)
  35377. }
  35378. // SetOrganizationID sets the "organization_id" field.
  35379. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  35380. m.organization_id = &u
  35381. m.addorganization_id = nil
  35382. }
  35383. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35384. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  35385. v := m.organization_id
  35386. if v == nil {
  35387. return
  35388. }
  35389. return *v, true
  35390. }
  35391. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  35392. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35394. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35395. if !m.op.Is(OpUpdateOne) {
  35396. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35397. }
  35398. if m.id == nil || m.oldValue == nil {
  35399. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35400. }
  35401. oldValue, err := m.oldValue(ctx)
  35402. if err != nil {
  35403. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35404. }
  35405. return oldValue.OrganizationID, nil
  35406. }
  35407. // AddOrganizationID adds u to the "organization_id" field.
  35408. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  35409. if m.addorganization_id != nil {
  35410. *m.addorganization_id += u
  35411. } else {
  35412. m.addorganization_id = &u
  35413. }
  35414. }
  35415. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35416. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  35417. v := m.addorganization_id
  35418. if v == nil {
  35419. return
  35420. }
  35421. return *v, true
  35422. }
  35423. // ClearOrganizationID clears the value of the "organization_id" field.
  35424. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  35425. m.organization_id = nil
  35426. m.addorganization_id = nil
  35427. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  35428. }
  35429. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35430. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  35431. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  35432. return ok
  35433. }
  35434. // ResetOrganizationID resets all changes to the "organization_id" field.
  35435. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  35436. m.organization_id = nil
  35437. m.addorganization_id = nil
  35438. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  35439. }
  35440. // SetAiResponse sets the "ai_response" field.
  35441. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  35442. m.ai_response = &u
  35443. m.addai_response = nil
  35444. }
  35445. // AiResponse returns the value of the "ai_response" field in the mutation.
  35446. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  35447. v := m.ai_response
  35448. if v == nil {
  35449. return
  35450. }
  35451. return *v, true
  35452. }
  35453. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  35454. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35456. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35457. if !m.op.Is(OpUpdateOne) {
  35458. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35459. }
  35460. if m.id == nil || m.oldValue == nil {
  35461. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35462. }
  35463. oldValue, err := m.oldValue(ctx)
  35464. if err != nil {
  35465. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35466. }
  35467. return oldValue.AiResponse, nil
  35468. }
  35469. // AddAiResponse adds u to the "ai_response" field.
  35470. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  35471. if m.addai_response != nil {
  35472. *m.addai_response += u
  35473. } else {
  35474. m.addai_response = &u
  35475. }
  35476. }
  35477. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35478. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  35479. v := m.addai_response
  35480. if v == nil {
  35481. return
  35482. }
  35483. return *v, true
  35484. }
  35485. // ResetAiResponse resets all changes to the "ai_response" field.
  35486. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  35487. m.ai_response = nil
  35488. m.addai_response = nil
  35489. }
  35490. // SetSopRun sets the "sop_run" field.
  35491. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  35492. m.sop_run = &u
  35493. m.addsop_run = nil
  35494. }
  35495. // SopRun returns the value of the "sop_run" field in the mutation.
  35496. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  35497. v := m.sop_run
  35498. if v == nil {
  35499. return
  35500. }
  35501. return *v, true
  35502. }
  35503. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  35504. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35506. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35507. if !m.op.Is(OpUpdateOne) {
  35508. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35509. }
  35510. if m.id == nil || m.oldValue == nil {
  35511. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35512. }
  35513. oldValue, err := m.oldValue(ctx)
  35514. if err != nil {
  35515. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35516. }
  35517. return oldValue.SopRun, nil
  35518. }
  35519. // AddSopRun adds u to the "sop_run" field.
  35520. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  35521. if m.addsop_run != nil {
  35522. *m.addsop_run += u
  35523. } else {
  35524. m.addsop_run = &u
  35525. }
  35526. }
  35527. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35528. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  35529. v := m.addsop_run
  35530. if v == nil {
  35531. return
  35532. }
  35533. return *v, true
  35534. }
  35535. // ResetSopRun resets all changes to the "sop_run" field.
  35536. func (m *UsageStatisticHourMutation) ResetSopRun() {
  35537. m.sop_run = nil
  35538. m.addsop_run = nil
  35539. }
  35540. // SetTotalFriend sets the "total_friend" field.
  35541. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  35542. m.total_friend = &u
  35543. m.addtotal_friend = nil
  35544. }
  35545. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35546. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  35547. v := m.total_friend
  35548. if v == nil {
  35549. return
  35550. }
  35551. return *v, true
  35552. }
  35553. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  35554. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35556. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35557. if !m.op.Is(OpUpdateOne) {
  35558. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35559. }
  35560. if m.id == nil || m.oldValue == nil {
  35561. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35562. }
  35563. oldValue, err := m.oldValue(ctx)
  35564. if err != nil {
  35565. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35566. }
  35567. return oldValue.TotalFriend, nil
  35568. }
  35569. // AddTotalFriend adds u to the "total_friend" field.
  35570. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  35571. if m.addtotal_friend != nil {
  35572. *m.addtotal_friend += u
  35573. } else {
  35574. m.addtotal_friend = &u
  35575. }
  35576. }
  35577. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35578. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  35579. v := m.addtotal_friend
  35580. if v == nil {
  35581. return
  35582. }
  35583. return *v, true
  35584. }
  35585. // ResetTotalFriend resets all changes to the "total_friend" field.
  35586. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  35587. m.total_friend = nil
  35588. m.addtotal_friend = nil
  35589. }
  35590. // SetTotalGroup sets the "total_group" field.
  35591. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  35592. m.total_group = &u
  35593. m.addtotal_group = nil
  35594. }
  35595. // TotalGroup returns the value of the "total_group" field in the mutation.
  35596. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  35597. v := m.total_group
  35598. if v == nil {
  35599. return
  35600. }
  35601. return *v, true
  35602. }
  35603. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  35604. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35606. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35607. if !m.op.Is(OpUpdateOne) {
  35608. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35609. }
  35610. if m.id == nil || m.oldValue == nil {
  35611. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35612. }
  35613. oldValue, err := m.oldValue(ctx)
  35614. if err != nil {
  35615. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35616. }
  35617. return oldValue.TotalGroup, nil
  35618. }
  35619. // AddTotalGroup adds u to the "total_group" field.
  35620. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  35621. if m.addtotal_group != nil {
  35622. *m.addtotal_group += u
  35623. } else {
  35624. m.addtotal_group = &u
  35625. }
  35626. }
  35627. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35628. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  35629. v := m.addtotal_group
  35630. if v == nil {
  35631. return
  35632. }
  35633. return *v, true
  35634. }
  35635. // ResetTotalGroup resets all changes to the "total_group" field.
  35636. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  35637. m.total_group = nil
  35638. m.addtotal_group = nil
  35639. }
  35640. // SetAccountBalance sets the "account_balance" field.
  35641. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  35642. m.account_balance = &u
  35643. m.addaccount_balance = nil
  35644. }
  35645. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35646. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  35647. v := m.account_balance
  35648. if v == nil {
  35649. return
  35650. }
  35651. return *v, true
  35652. }
  35653. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  35654. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35656. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  35657. if !m.op.Is(OpUpdateOne) {
  35658. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  35659. }
  35660. if m.id == nil || m.oldValue == nil {
  35661. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  35662. }
  35663. oldValue, err := m.oldValue(ctx)
  35664. if err != nil {
  35665. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  35666. }
  35667. return oldValue.AccountBalance, nil
  35668. }
  35669. // AddAccountBalance adds u to the "account_balance" field.
  35670. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  35671. if m.addaccount_balance != nil {
  35672. *m.addaccount_balance += u
  35673. } else {
  35674. m.addaccount_balance = &u
  35675. }
  35676. }
  35677. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  35678. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  35679. v := m.addaccount_balance
  35680. if v == nil {
  35681. return
  35682. }
  35683. return *v, true
  35684. }
  35685. // ResetAccountBalance resets all changes to the "account_balance" field.
  35686. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  35687. m.account_balance = nil
  35688. m.addaccount_balance = nil
  35689. }
  35690. // SetConsumeToken sets the "consume_token" field.
  35691. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  35692. m.consume_token = &u
  35693. m.addconsume_token = nil
  35694. }
  35695. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  35696. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  35697. v := m.consume_token
  35698. if v == nil {
  35699. return
  35700. }
  35701. return *v, true
  35702. }
  35703. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  35704. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35706. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  35707. if !m.op.Is(OpUpdateOne) {
  35708. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  35709. }
  35710. if m.id == nil || m.oldValue == nil {
  35711. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  35712. }
  35713. oldValue, err := m.oldValue(ctx)
  35714. if err != nil {
  35715. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  35716. }
  35717. return oldValue.ConsumeToken, nil
  35718. }
  35719. // AddConsumeToken adds u to the "consume_token" field.
  35720. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  35721. if m.addconsume_token != nil {
  35722. *m.addconsume_token += u
  35723. } else {
  35724. m.addconsume_token = &u
  35725. }
  35726. }
  35727. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  35728. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  35729. v := m.addconsume_token
  35730. if v == nil {
  35731. return
  35732. }
  35733. return *v, true
  35734. }
  35735. // ResetConsumeToken resets all changes to the "consume_token" field.
  35736. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  35737. m.consume_token = nil
  35738. m.addconsume_token = nil
  35739. }
  35740. // SetActiveUser sets the "active_user" field.
  35741. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  35742. m.active_user = &u
  35743. m.addactive_user = nil
  35744. }
  35745. // ActiveUser returns the value of the "active_user" field in the mutation.
  35746. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  35747. v := m.active_user
  35748. if v == nil {
  35749. return
  35750. }
  35751. return *v, true
  35752. }
  35753. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  35754. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35756. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  35757. if !m.op.Is(OpUpdateOne) {
  35758. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  35759. }
  35760. if m.id == nil || m.oldValue == nil {
  35761. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  35762. }
  35763. oldValue, err := m.oldValue(ctx)
  35764. if err != nil {
  35765. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  35766. }
  35767. return oldValue.ActiveUser, nil
  35768. }
  35769. // AddActiveUser adds u to the "active_user" field.
  35770. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  35771. if m.addactive_user != nil {
  35772. *m.addactive_user += u
  35773. } else {
  35774. m.addactive_user = &u
  35775. }
  35776. }
  35777. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  35778. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  35779. v := m.addactive_user
  35780. if v == nil {
  35781. return
  35782. }
  35783. return *v, true
  35784. }
  35785. // ResetActiveUser resets all changes to the "active_user" field.
  35786. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  35787. m.active_user = nil
  35788. m.addactive_user = nil
  35789. }
  35790. // SetNewUser sets the "new_user" field.
  35791. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  35792. m.new_user = &i
  35793. m.addnew_user = nil
  35794. }
  35795. // NewUser returns the value of the "new_user" field in the mutation.
  35796. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  35797. v := m.new_user
  35798. if v == nil {
  35799. return
  35800. }
  35801. return *v, true
  35802. }
  35803. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  35804. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35806. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  35807. if !m.op.Is(OpUpdateOne) {
  35808. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  35809. }
  35810. if m.id == nil || m.oldValue == nil {
  35811. return v, errors.New("OldNewUser requires an ID field in the mutation")
  35812. }
  35813. oldValue, err := m.oldValue(ctx)
  35814. if err != nil {
  35815. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  35816. }
  35817. return oldValue.NewUser, nil
  35818. }
  35819. // AddNewUser adds i to the "new_user" field.
  35820. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  35821. if m.addnew_user != nil {
  35822. *m.addnew_user += i
  35823. } else {
  35824. m.addnew_user = &i
  35825. }
  35826. }
  35827. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  35828. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  35829. v := m.addnew_user
  35830. if v == nil {
  35831. return
  35832. }
  35833. return *v, true
  35834. }
  35835. // ResetNewUser resets all changes to the "new_user" field.
  35836. func (m *UsageStatisticHourMutation) ResetNewUser() {
  35837. m.new_user = nil
  35838. m.addnew_user = nil
  35839. }
  35840. // SetLabelDist sets the "label_dist" field.
  35841. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  35842. m.label_dist = &ctd
  35843. m.appendlabel_dist = nil
  35844. }
  35845. // LabelDist returns the value of the "label_dist" field in the mutation.
  35846. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  35847. v := m.label_dist
  35848. if v == nil {
  35849. return
  35850. }
  35851. return *v, true
  35852. }
  35853. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  35854. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35856. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35857. if !m.op.Is(OpUpdateOne) {
  35858. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35859. }
  35860. if m.id == nil || m.oldValue == nil {
  35861. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35862. }
  35863. oldValue, err := m.oldValue(ctx)
  35864. if err != nil {
  35865. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35866. }
  35867. return oldValue.LabelDist, nil
  35868. }
  35869. // AppendLabelDist adds ctd to the "label_dist" field.
  35870. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35871. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35872. }
  35873. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35874. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35875. if len(m.appendlabel_dist) == 0 {
  35876. return nil, false
  35877. }
  35878. return m.appendlabel_dist, true
  35879. }
  35880. // ResetLabelDist resets all changes to the "label_dist" field.
  35881. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  35882. m.label_dist = nil
  35883. m.appendlabel_dist = nil
  35884. }
  35885. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  35886. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  35887. m.predicates = append(m.predicates, ps...)
  35888. }
  35889. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  35890. // users can use type-assertion to append predicates that do not depend on any generated package.
  35891. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  35892. p := make([]predicate.UsageStatisticHour, len(ps))
  35893. for i := range ps {
  35894. p[i] = ps[i]
  35895. }
  35896. m.Where(p...)
  35897. }
  35898. // Op returns the operation name.
  35899. func (m *UsageStatisticHourMutation) Op() Op {
  35900. return m.op
  35901. }
  35902. // SetOp allows setting the mutation operation.
  35903. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  35904. m.op = op
  35905. }
  35906. // Type returns the node type of this mutation (UsageStatisticHour).
  35907. func (m *UsageStatisticHourMutation) Type() string {
  35908. return m.typ
  35909. }
  35910. // Fields returns all fields that were changed during this mutation. Note that in
  35911. // order to get all numeric fields that were incremented/decremented, call
  35912. // AddedFields().
  35913. func (m *UsageStatisticHourMutation) Fields() []string {
  35914. fields := make([]string, 0, 17)
  35915. if m.created_at != nil {
  35916. fields = append(fields, usagestatistichour.FieldCreatedAt)
  35917. }
  35918. if m.updated_at != nil {
  35919. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  35920. }
  35921. if m.status != nil {
  35922. fields = append(fields, usagestatistichour.FieldStatus)
  35923. }
  35924. if m.deleted_at != nil {
  35925. fields = append(fields, usagestatistichour.FieldDeletedAt)
  35926. }
  35927. if m.addtime != nil {
  35928. fields = append(fields, usagestatistichour.FieldAddtime)
  35929. }
  35930. if m._type != nil {
  35931. fields = append(fields, usagestatistichour.FieldType)
  35932. }
  35933. if m.bot_id != nil {
  35934. fields = append(fields, usagestatistichour.FieldBotID)
  35935. }
  35936. if m.organization_id != nil {
  35937. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35938. }
  35939. if m.ai_response != nil {
  35940. fields = append(fields, usagestatistichour.FieldAiResponse)
  35941. }
  35942. if m.sop_run != nil {
  35943. fields = append(fields, usagestatistichour.FieldSopRun)
  35944. }
  35945. if m.total_friend != nil {
  35946. fields = append(fields, usagestatistichour.FieldTotalFriend)
  35947. }
  35948. if m.total_group != nil {
  35949. fields = append(fields, usagestatistichour.FieldTotalGroup)
  35950. }
  35951. if m.account_balance != nil {
  35952. fields = append(fields, usagestatistichour.FieldAccountBalance)
  35953. }
  35954. if m.consume_token != nil {
  35955. fields = append(fields, usagestatistichour.FieldConsumeToken)
  35956. }
  35957. if m.active_user != nil {
  35958. fields = append(fields, usagestatistichour.FieldActiveUser)
  35959. }
  35960. if m.new_user != nil {
  35961. fields = append(fields, usagestatistichour.FieldNewUser)
  35962. }
  35963. if m.label_dist != nil {
  35964. fields = append(fields, usagestatistichour.FieldLabelDist)
  35965. }
  35966. return fields
  35967. }
  35968. // Field returns the value of a field with the given name. The second boolean
  35969. // return value indicates that this field was not set, or was not defined in the
  35970. // schema.
  35971. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  35972. switch name {
  35973. case usagestatistichour.FieldCreatedAt:
  35974. return m.CreatedAt()
  35975. case usagestatistichour.FieldUpdatedAt:
  35976. return m.UpdatedAt()
  35977. case usagestatistichour.FieldStatus:
  35978. return m.Status()
  35979. case usagestatistichour.FieldDeletedAt:
  35980. return m.DeletedAt()
  35981. case usagestatistichour.FieldAddtime:
  35982. return m.Addtime()
  35983. case usagestatistichour.FieldType:
  35984. return m.GetType()
  35985. case usagestatistichour.FieldBotID:
  35986. return m.BotID()
  35987. case usagestatistichour.FieldOrganizationID:
  35988. return m.OrganizationID()
  35989. case usagestatistichour.FieldAiResponse:
  35990. return m.AiResponse()
  35991. case usagestatistichour.FieldSopRun:
  35992. return m.SopRun()
  35993. case usagestatistichour.FieldTotalFriend:
  35994. return m.TotalFriend()
  35995. case usagestatistichour.FieldTotalGroup:
  35996. return m.TotalGroup()
  35997. case usagestatistichour.FieldAccountBalance:
  35998. return m.AccountBalance()
  35999. case usagestatistichour.FieldConsumeToken:
  36000. return m.ConsumeToken()
  36001. case usagestatistichour.FieldActiveUser:
  36002. return m.ActiveUser()
  36003. case usagestatistichour.FieldNewUser:
  36004. return m.NewUser()
  36005. case usagestatistichour.FieldLabelDist:
  36006. return m.LabelDist()
  36007. }
  36008. return nil, false
  36009. }
  36010. // OldField returns the old value of the field from the database. An error is
  36011. // returned if the mutation operation is not UpdateOne, or the query to the
  36012. // database failed.
  36013. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36014. switch name {
  36015. case usagestatistichour.FieldCreatedAt:
  36016. return m.OldCreatedAt(ctx)
  36017. case usagestatistichour.FieldUpdatedAt:
  36018. return m.OldUpdatedAt(ctx)
  36019. case usagestatistichour.FieldStatus:
  36020. return m.OldStatus(ctx)
  36021. case usagestatistichour.FieldDeletedAt:
  36022. return m.OldDeletedAt(ctx)
  36023. case usagestatistichour.FieldAddtime:
  36024. return m.OldAddtime(ctx)
  36025. case usagestatistichour.FieldType:
  36026. return m.OldType(ctx)
  36027. case usagestatistichour.FieldBotID:
  36028. return m.OldBotID(ctx)
  36029. case usagestatistichour.FieldOrganizationID:
  36030. return m.OldOrganizationID(ctx)
  36031. case usagestatistichour.FieldAiResponse:
  36032. return m.OldAiResponse(ctx)
  36033. case usagestatistichour.FieldSopRun:
  36034. return m.OldSopRun(ctx)
  36035. case usagestatistichour.FieldTotalFriend:
  36036. return m.OldTotalFriend(ctx)
  36037. case usagestatistichour.FieldTotalGroup:
  36038. return m.OldTotalGroup(ctx)
  36039. case usagestatistichour.FieldAccountBalance:
  36040. return m.OldAccountBalance(ctx)
  36041. case usagestatistichour.FieldConsumeToken:
  36042. return m.OldConsumeToken(ctx)
  36043. case usagestatistichour.FieldActiveUser:
  36044. return m.OldActiveUser(ctx)
  36045. case usagestatistichour.FieldNewUser:
  36046. return m.OldNewUser(ctx)
  36047. case usagestatistichour.FieldLabelDist:
  36048. return m.OldLabelDist(ctx)
  36049. }
  36050. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36051. }
  36052. // SetField sets the value of a field with the given name. It returns an error if
  36053. // the field is not defined in the schema, or if the type mismatched the field
  36054. // type.
  36055. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  36056. switch name {
  36057. case usagestatistichour.FieldCreatedAt:
  36058. v, ok := value.(time.Time)
  36059. if !ok {
  36060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36061. }
  36062. m.SetCreatedAt(v)
  36063. return nil
  36064. case usagestatistichour.FieldUpdatedAt:
  36065. v, ok := value.(time.Time)
  36066. if !ok {
  36067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36068. }
  36069. m.SetUpdatedAt(v)
  36070. return nil
  36071. case usagestatistichour.FieldStatus:
  36072. v, ok := value.(uint8)
  36073. if !ok {
  36074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36075. }
  36076. m.SetStatus(v)
  36077. return nil
  36078. case usagestatistichour.FieldDeletedAt:
  36079. v, ok := value.(time.Time)
  36080. if !ok {
  36081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36082. }
  36083. m.SetDeletedAt(v)
  36084. return nil
  36085. case usagestatistichour.FieldAddtime:
  36086. v, ok := value.(uint64)
  36087. if !ok {
  36088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36089. }
  36090. m.SetAddtime(v)
  36091. return nil
  36092. case usagestatistichour.FieldType:
  36093. v, ok := value.(int)
  36094. if !ok {
  36095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36096. }
  36097. m.SetType(v)
  36098. return nil
  36099. case usagestatistichour.FieldBotID:
  36100. v, ok := value.(string)
  36101. if !ok {
  36102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36103. }
  36104. m.SetBotID(v)
  36105. return nil
  36106. case usagestatistichour.FieldOrganizationID:
  36107. v, ok := value.(uint64)
  36108. if !ok {
  36109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36110. }
  36111. m.SetOrganizationID(v)
  36112. return nil
  36113. case usagestatistichour.FieldAiResponse:
  36114. v, ok := value.(uint64)
  36115. if !ok {
  36116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36117. }
  36118. m.SetAiResponse(v)
  36119. return nil
  36120. case usagestatistichour.FieldSopRun:
  36121. v, ok := value.(uint64)
  36122. if !ok {
  36123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36124. }
  36125. m.SetSopRun(v)
  36126. return nil
  36127. case usagestatistichour.FieldTotalFriend:
  36128. v, ok := value.(uint64)
  36129. if !ok {
  36130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36131. }
  36132. m.SetTotalFriend(v)
  36133. return nil
  36134. case usagestatistichour.FieldTotalGroup:
  36135. v, ok := value.(uint64)
  36136. if !ok {
  36137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36138. }
  36139. m.SetTotalGroup(v)
  36140. return nil
  36141. case usagestatistichour.FieldAccountBalance:
  36142. v, ok := value.(uint64)
  36143. if !ok {
  36144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36145. }
  36146. m.SetAccountBalance(v)
  36147. return nil
  36148. case usagestatistichour.FieldConsumeToken:
  36149. v, ok := value.(uint64)
  36150. if !ok {
  36151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36152. }
  36153. m.SetConsumeToken(v)
  36154. return nil
  36155. case usagestatistichour.FieldActiveUser:
  36156. v, ok := value.(uint64)
  36157. if !ok {
  36158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36159. }
  36160. m.SetActiveUser(v)
  36161. return nil
  36162. case usagestatistichour.FieldNewUser:
  36163. v, ok := value.(int64)
  36164. if !ok {
  36165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36166. }
  36167. m.SetNewUser(v)
  36168. return nil
  36169. case usagestatistichour.FieldLabelDist:
  36170. v, ok := value.([]custom_types.LabelDist)
  36171. if !ok {
  36172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36173. }
  36174. m.SetLabelDist(v)
  36175. return nil
  36176. }
  36177. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36178. }
  36179. // AddedFields returns all numeric fields that were incremented/decremented during
  36180. // this mutation.
  36181. func (m *UsageStatisticHourMutation) AddedFields() []string {
  36182. var fields []string
  36183. if m.addstatus != nil {
  36184. fields = append(fields, usagestatistichour.FieldStatus)
  36185. }
  36186. if m.addaddtime != nil {
  36187. fields = append(fields, usagestatistichour.FieldAddtime)
  36188. }
  36189. if m.add_type != nil {
  36190. fields = append(fields, usagestatistichour.FieldType)
  36191. }
  36192. if m.addorganization_id != nil {
  36193. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36194. }
  36195. if m.addai_response != nil {
  36196. fields = append(fields, usagestatistichour.FieldAiResponse)
  36197. }
  36198. if m.addsop_run != nil {
  36199. fields = append(fields, usagestatistichour.FieldSopRun)
  36200. }
  36201. if m.addtotal_friend != nil {
  36202. fields = append(fields, usagestatistichour.FieldTotalFriend)
  36203. }
  36204. if m.addtotal_group != nil {
  36205. fields = append(fields, usagestatistichour.FieldTotalGroup)
  36206. }
  36207. if m.addaccount_balance != nil {
  36208. fields = append(fields, usagestatistichour.FieldAccountBalance)
  36209. }
  36210. if m.addconsume_token != nil {
  36211. fields = append(fields, usagestatistichour.FieldConsumeToken)
  36212. }
  36213. if m.addactive_user != nil {
  36214. fields = append(fields, usagestatistichour.FieldActiveUser)
  36215. }
  36216. if m.addnew_user != nil {
  36217. fields = append(fields, usagestatistichour.FieldNewUser)
  36218. }
  36219. return fields
  36220. }
  36221. // AddedField returns the numeric value that was incremented/decremented on a field
  36222. // with the given name. The second boolean return value indicates that this field
  36223. // was not set, or was not defined in the schema.
  36224. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  36225. switch name {
  36226. case usagestatistichour.FieldStatus:
  36227. return m.AddedStatus()
  36228. case usagestatistichour.FieldAddtime:
  36229. return m.AddedAddtime()
  36230. case usagestatistichour.FieldType:
  36231. return m.AddedType()
  36232. case usagestatistichour.FieldOrganizationID:
  36233. return m.AddedOrganizationID()
  36234. case usagestatistichour.FieldAiResponse:
  36235. return m.AddedAiResponse()
  36236. case usagestatistichour.FieldSopRun:
  36237. return m.AddedSopRun()
  36238. case usagestatistichour.FieldTotalFriend:
  36239. return m.AddedTotalFriend()
  36240. case usagestatistichour.FieldTotalGroup:
  36241. return m.AddedTotalGroup()
  36242. case usagestatistichour.FieldAccountBalance:
  36243. return m.AddedAccountBalance()
  36244. case usagestatistichour.FieldConsumeToken:
  36245. return m.AddedConsumeToken()
  36246. case usagestatistichour.FieldActiveUser:
  36247. return m.AddedActiveUser()
  36248. case usagestatistichour.FieldNewUser:
  36249. return m.AddedNewUser()
  36250. }
  36251. return nil, false
  36252. }
  36253. // AddField adds the value to the field with the given name. It returns an error if
  36254. // the field is not defined in the schema, or if the type mismatched the field
  36255. // type.
  36256. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  36257. switch name {
  36258. case usagestatistichour.FieldStatus:
  36259. v, ok := value.(int8)
  36260. if !ok {
  36261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36262. }
  36263. m.AddStatus(v)
  36264. return nil
  36265. case usagestatistichour.FieldAddtime:
  36266. v, ok := value.(int64)
  36267. if !ok {
  36268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36269. }
  36270. m.AddAddtime(v)
  36271. return nil
  36272. case usagestatistichour.FieldType:
  36273. v, ok := value.(int)
  36274. if !ok {
  36275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36276. }
  36277. m.AddType(v)
  36278. return nil
  36279. case usagestatistichour.FieldOrganizationID:
  36280. v, ok := value.(int64)
  36281. if !ok {
  36282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36283. }
  36284. m.AddOrganizationID(v)
  36285. return nil
  36286. case usagestatistichour.FieldAiResponse:
  36287. v, ok := value.(int64)
  36288. if !ok {
  36289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36290. }
  36291. m.AddAiResponse(v)
  36292. return nil
  36293. case usagestatistichour.FieldSopRun:
  36294. v, ok := value.(int64)
  36295. if !ok {
  36296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36297. }
  36298. m.AddSopRun(v)
  36299. return nil
  36300. case usagestatistichour.FieldTotalFriend:
  36301. v, ok := value.(int64)
  36302. if !ok {
  36303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36304. }
  36305. m.AddTotalFriend(v)
  36306. return nil
  36307. case usagestatistichour.FieldTotalGroup:
  36308. v, ok := value.(int64)
  36309. if !ok {
  36310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36311. }
  36312. m.AddTotalGroup(v)
  36313. return nil
  36314. case usagestatistichour.FieldAccountBalance:
  36315. v, ok := value.(int64)
  36316. if !ok {
  36317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36318. }
  36319. m.AddAccountBalance(v)
  36320. return nil
  36321. case usagestatistichour.FieldConsumeToken:
  36322. v, ok := value.(int64)
  36323. if !ok {
  36324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36325. }
  36326. m.AddConsumeToken(v)
  36327. return nil
  36328. case usagestatistichour.FieldActiveUser:
  36329. v, ok := value.(int64)
  36330. if !ok {
  36331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36332. }
  36333. m.AddActiveUser(v)
  36334. return nil
  36335. case usagestatistichour.FieldNewUser:
  36336. v, ok := value.(int64)
  36337. if !ok {
  36338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36339. }
  36340. m.AddNewUser(v)
  36341. return nil
  36342. }
  36343. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  36344. }
  36345. // ClearedFields returns all nullable fields that were cleared during this
  36346. // mutation.
  36347. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  36348. var fields []string
  36349. if m.FieldCleared(usagestatistichour.FieldStatus) {
  36350. fields = append(fields, usagestatistichour.FieldStatus)
  36351. }
  36352. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  36353. fields = append(fields, usagestatistichour.FieldDeletedAt)
  36354. }
  36355. if m.FieldCleared(usagestatistichour.FieldBotID) {
  36356. fields = append(fields, usagestatistichour.FieldBotID)
  36357. }
  36358. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  36359. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36360. }
  36361. return fields
  36362. }
  36363. // FieldCleared returns a boolean indicating if a field with the given name was
  36364. // cleared in this mutation.
  36365. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  36366. _, ok := m.clearedFields[name]
  36367. return ok
  36368. }
  36369. // ClearField clears the value of the field with the given name. It returns an
  36370. // error if the field is not defined in the schema.
  36371. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  36372. switch name {
  36373. case usagestatistichour.FieldStatus:
  36374. m.ClearStatus()
  36375. return nil
  36376. case usagestatistichour.FieldDeletedAt:
  36377. m.ClearDeletedAt()
  36378. return nil
  36379. case usagestatistichour.FieldBotID:
  36380. m.ClearBotID()
  36381. return nil
  36382. case usagestatistichour.FieldOrganizationID:
  36383. m.ClearOrganizationID()
  36384. return nil
  36385. }
  36386. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  36387. }
  36388. // ResetField resets all changes in the mutation for the field with the given name.
  36389. // It returns an error if the field is not defined in the schema.
  36390. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  36391. switch name {
  36392. case usagestatistichour.FieldCreatedAt:
  36393. m.ResetCreatedAt()
  36394. return nil
  36395. case usagestatistichour.FieldUpdatedAt:
  36396. m.ResetUpdatedAt()
  36397. return nil
  36398. case usagestatistichour.FieldStatus:
  36399. m.ResetStatus()
  36400. return nil
  36401. case usagestatistichour.FieldDeletedAt:
  36402. m.ResetDeletedAt()
  36403. return nil
  36404. case usagestatistichour.FieldAddtime:
  36405. m.ResetAddtime()
  36406. return nil
  36407. case usagestatistichour.FieldType:
  36408. m.ResetType()
  36409. return nil
  36410. case usagestatistichour.FieldBotID:
  36411. m.ResetBotID()
  36412. return nil
  36413. case usagestatistichour.FieldOrganizationID:
  36414. m.ResetOrganizationID()
  36415. return nil
  36416. case usagestatistichour.FieldAiResponse:
  36417. m.ResetAiResponse()
  36418. return nil
  36419. case usagestatistichour.FieldSopRun:
  36420. m.ResetSopRun()
  36421. return nil
  36422. case usagestatistichour.FieldTotalFriend:
  36423. m.ResetTotalFriend()
  36424. return nil
  36425. case usagestatistichour.FieldTotalGroup:
  36426. m.ResetTotalGroup()
  36427. return nil
  36428. case usagestatistichour.FieldAccountBalance:
  36429. m.ResetAccountBalance()
  36430. return nil
  36431. case usagestatistichour.FieldConsumeToken:
  36432. m.ResetConsumeToken()
  36433. return nil
  36434. case usagestatistichour.FieldActiveUser:
  36435. m.ResetActiveUser()
  36436. return nil
  36437. case usagestatistichour.FieldNewUser:
  36438. m.ResetNewUser()
  36439. return nil
  36440. case usagestatistichour.FieldLabelDist:
  36441. m.ResetLabelDist()
  36442. return nil
  36443. }
  36444. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36445. }
  36446. // AddedEdges returns all edge names that were set/added in this mutation.
  36447. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  36448. edges := make([]string, 0, 0)
  36449. return edges
  36450. }
  36451. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36452. // name in this mutation.
  36453. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  36454. return nil
  36455. }
  36456. // RemovedEdges returns all edge names that were removed in this mutation.
  36457. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  36458. edges := make([]string, 0, 0)
  36459. return edges
  36460. }
  36461. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36462. // the given name in this mutation.
  36463. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  36464. return nil
  36465. }
  36466. // ClearedEdges returns all edge names that were cleared in this mutation.
  36467. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  36468. edges := make([]string, 0, 0)
  36469. return edges
  36470. }
  36471. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36472. // was cleared in this mutation.
  36473. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  36474. return false
  36475. }
  36476. // ClearEdge clears the value of the edge with the given name. It returns an error
  36477. // if that edge is not defined in the schema.
  36478. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  36479. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  36480. }
  36481. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36482. // It returns an error if the edge is not defined in the schema.
  36483. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  36484. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  36485. }
  36486. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  36487. type UsageStatisticMonthMutation struct {
  36488. config
  36489. op Op
  36490. typ string
  36491. id *uint64
  36492. created_at *time.Time
  36493. updated_at *time.Time
  36494. status *uint8
  36495. addstatus *int8
  36496. deleted_at *time.Time
  36497. addtime *uint64
  36498. addaddtime *int64
  36499. _type *int
  36500. add_type *int
  36501. bot_id *string
  36502. organization_id *uint64
  36503. addorganization_id *int64
  36504. ai_response *uint64
  36505. addai_response *int64
  36506. sop_run *uint64
  36507. addsop_run *int64
  36508. total_friend *uint64
  36509. addtotal_friend *int64
  36510. total_group *uint64
  36511. addtotal_group *int64
  36512. account_balance *uint64
  36513. addaccount_balance *int64
  36514. consume_token *uint64
  36515. addconsume_token *int64
  36516. active_user *uint64
  36517. addactive_user *int64
  36518. new_user *int64
  36519. addnew_user *int64
  36520. label_dist *[]custom_types.LabelDist
  36521. appendlabel_dist []custom_types.LabelDist
  36522. clearedFields map[string]struct{}
  36523. done bool
  36524. oldValue func(context.Context) (*UsageStatisticMonth, error)
  36525. predicates []predicate.UsageStatisticMonth
  36526. }
  36527. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  36528. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  36529. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  36530. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  36531. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  36532. m := &UsageStatisticMonthMutation{
  36533. config: c,
  36534. op: op,
  36535. typ: TypeUsageStatisticMonth,
  36536. clearedFields: make(map[string]struct{}),
  36537. }
  36538. for _, opt := range opts {
  36539. opt(m)
  36540. }
  36541. return m
  36542. }
  36543. // withUsageStatisticMonthID sets the ID field of the mutation.
  36544. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  36545. return func(m *UsageStatisticMonthMutation) {
  36546. var (
  36547. err error
  36548. once sync.Once
  36549. value *UsageStatisticMonth
  36550. )
  36551. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  36552. once.Do(func() {
  36553. if m.done {
  36554. err = errors.New("querying old values post mutation is not allowed")
  36555. } else {
  36556. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  36557. }
  36558. })
  36559. return value, err
  36560. }
  36561. m.id = &id
  36562. }
  36563. }
  36564. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  36565. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  36566. return func(m *UsageStatisticMonthMutation) {
  36567. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  36568. return node, nil
  36569. }
  36570. m.id = &node.ID
  36571. }
  36572. }
  36573. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36574. // executed in a transaction (ent.Tx), a transactional client is returned.
  36575. func (m UsageStatisticMonthMutation) Client() *Client {
  36576. client := &Client{config: m.config}
  36577. client.init()
  36578. return client
  36579. }
  36580. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36581. // it returns an error otherwise.
  36582. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  36583. if _, ok := m.driver.(*txDriver); !ok {
  36584. return nil, errors.New("ent: mutation is not running in a transaction")
  36585. }
  36586. tx := &Tx{config: m.config}
  36587. tx.init()
  36588. return tx, nil
  36589. }
  36590. // SetID sets the value of the id field. Note that this
  36591. // operation is only accepted on creation of UsageStatisticMonth entities.
  36592. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  36593. m.id = &id
  36594. }
  36595. // ID returns the ID value in the mutation. Note that the ID is only available
  36596. // if it was provided to the builder or after it was returned from the database.
  36597. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  36598. if m.id == nil {
  36599. return
  36600. }
  36601. return *m.id, true
  36602. }
  36603. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36604. // That means, if the mutation is applied within a transaction with an isolation level such
  36605. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36606. // or updated by the mutation.
  36607. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  36608. switch {
  36609. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36610. id, exists := m.ID()
  36611. if exists {
  36612. return []uint64{id}, nil
  36613. }
  36614. fallthrough
  36615. case m.op.Is(OpUpdate | OpDelete):
  36616. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  36617. default:
  36618. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36619. }
  36620. }
  36621. // SetCreatedAt sets the "created_at" field.
  36622. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  36623. m.created_at = &t
  36624. }
  36625. // CreatedAt returns the value of the "created_at" field in the mutation.
  36626. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  36627. v := m.created_at
  36628. if v == nil {
  36629. return
  36630. }
  36631. return *v, true
  36632. }
  36633. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  36634. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36636. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36637. if !m.op.Is(OpUpdateOne) {
  36638. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36639. }
  36640. if m.id == nil || m.oldValue == nil {
  36641. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36642. }
  36643. oldValue, err := m.oldValue(ctx)
  36644. if err != nil {
  36645. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36646. }
  36647. return oldValue.CreatedAt, nil
  36648. }
  36649. // ResetCreatedAt resets all changes to the "created_at" field.
  36650. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  36651. m.created_at = nil
  36652. }
  36653. // SetUpdatedAt sets the "updated_at" field.
  36654. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  36655. m.updated_at = &t
  36656. }
  36657. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36658. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  36659. v := m.updated_at
  36660. if v == nil {
  36661. return
  36662. }
  36663. return *v, true
  36664. }
  36665. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  36666. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36668. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36669. if !m.op.Is(OpUpdateOne) {
  36670. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36671. }
  36672. if m.id == nil || m.oldValue == nil {
  36673. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36674. }
  36675. oldValue, err := m.oldValue(ctx)
  36676. if err != nil {
  36677. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36678. }
  36679. return oldValue.UpdatedAt, nil
  36680. }
  36681. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36682. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  36683. m.updated_at = nil
  36684. }
  36685. // SetStatus sets the "status" field.
  36686. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  36687. m.status = &u
  36688. m.addstatus = nil
  36689. }
  36690. // Status returns the value of the "status" field in the mutation.
  36691. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  36692. v := m.status
  36693. if v == nil {
  36694. return
  36695. }
  36696. return *v, true
  36697. }
  36698. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  36699. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36701. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36702. if !m.op.Is(OpUpdateOne) {
  36703. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36704. }
  36705. if m.id == nil || m.oldValue == nil {
  36706. return v, errors.New("OldStatus requires an ID field in the mutation")
  36707. }
  36708. oldValue, err := m.oldValue(ctx)
  36709. if err != nil {
  36710. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36711. }
  36712. return oldValue.Status, nil
  36713. }
  36714. // AddStatus adds u to the "status" field.
  36715. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  36716. if m.addstatus != nil {
  36717. *m.addstatus += u
  36718. } else {
  36719. m.addstatus = &u
  36720. }
  36721. }
  36722. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36723. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  36724. v := m.addstatus
  36725. if v == nil {
  36726. return
  36727. }
  36728. return *v, true
  36729. }
  36730. // ClearStatus clears the value of the "status" field.
  36731. func (m *UsageStatisticMonthMutation) ClearStatus() {
  36732. m.status = nil
  36733. m.addstatus = nil
  36734. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  36735. }
  36736. // StatusCleared returns if the "status" field was cleared in this mutation.
  36737. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  36738. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  36739. return ok
  36740. }
  36741. // ResetStatus resets all changes to the "status" field.
  36742. func (m *UsageStatisticMonthMutation) ResetStatus() {
  36743. m.status = nil
  36744. m.addstatus = nil
  36745. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  36746. }
  36747. // SetDeletedAt sets the "deleted_at" field.
  36748. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  36749. m.deleted_at = &t
  36750. }
  36751. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36752. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  36753. v := m.deleted_at
  36754. if v == nil {
  36755. return
  36756. }
  36757. return *v, true
  36758. }
  36759. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  36760. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36762. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36763. if !m.op.Is(OpUpdateOne) {
  36764. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36765. }
  36766. if m.id == nil || m.oldValue == nil {
  36767. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36768. }
  36769. oldValue, err := m.oldValue(ctx)
  36770. if err != nil {
  36771. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36772. }
  36773. return oldValue.DeletedAt, nil
  36774. }
  36775. // ClearDeletedAt clears the value of the "deleted_at" field.
  36776. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  36777. m.deleted_at = nil
  36778. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  36779. }
  36780. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36781. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  36782. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  36783. return ok
  36784. }
  36785. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36786. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  36787. m.deleted_at = nil
  36788. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  36789. }
  36790. // SetAddtime sets the "addtime" field.
  36791. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  36792. m.addtime = &u
  36793. m.addaddtime = nil
  36794. }
  36795. // Addtime returns the value of the "addtime" field in the mutation.
  36796. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  36797. v := m.addtime
  36798. if v == nil {
  36799. return
  36800. }
  36801. return *v, true
  36802. }
  36803. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  36804. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36806. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  36807. if !m.op.Is(OpUpdateOne) {
  36808. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  36809. }
  36810. if m.id == nil || m.oldValue == nil {
  36811. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36812. }
  36813. oldValue, err := m.oldValue(ctx)
  36814. if err != nil {
  36815. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36816. }
  36817. return oldValue.Addtime, nil
  36818. }
  36819. // AddAddtime adds u to the "addtime" field.
  36820. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  36821. if m.addaddtime != nil {
  36822. *m.addaddtime += u
  36823. } else {
  36824. m.addaddtime = &u
  36825. }
  36826. }
  36827. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36828. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  36829. v := m.addaddtime
  36830. if v == nil {
  36831. return
  36832. }
  36833. return *v, true
  36834. }
  36835. // ResetAddtime resets all changes to the "addtime" field.
  36836. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  36837. m.addtime = nil
  36838. m.addaddtime = nil
  36839. }
  36840. // SetType sets the "type" field.
  36841. func (m *UsageStatisticMonthMutation) SetType(i int) {
  36842. m._type = &i
  36843. m.add_type = nil
  36844. }
  36845. // GetType returns the value of the "type" field in the mutation.
  36846. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  36847. v := m._type
  36848. if v == nil {
  36849. return
  36850. }
  36851. return *v, true
  36852. }
  36853. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  36854. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36856. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  36857. if !m.op.Is(OpUpdateOne) {
  36858. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36859. }
  36860. if m.id == nil || m.oldValue == nil {
  36861. return v, errors.New("OldType requires an ID field in the mutation")
  36862. }
  36863. oldValue, err := m.oldValue(ctx)
  36864. if err != nil {
  36865. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36866. }
  36867. return oldValue.Type, nil
  36868. }
  36869. // AddType adds i to the "type" field.
  36870. func (m *UsageStatisticMonthMutation) AddType(i int) {
  36871. if m.add_type != nil {
  36872. *m.add_type += i
  36873. } else {
  36874. m.add_type = &i
  36875. }
  36876. }
  36877. // AddedType returns the value that was added to the "type" field in this mutation.
  36878. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  36879. v := m.add_type
  36880. if v == nil {
  36881. return
  36882. }
  36883. return *v, true
  36884. }
  36885. // ResetType resets all changes to the "type" field.
  36886. func (m *UsageStatisticMonthMutation) ResetType() {
  36887. m._type = nil
  36888. m.add_type = nil
  36889. }
  36890. // SetBotID sets the "bot_id" field.
  36891. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  36892. m.bot_id = &s
  36893. }
  36894. // BotID returns the value of the "bot_id" field in the mutation.
  36895. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  36896. v := m.bot_id
  36897. if v == nil {
  36898. return
  36899. }
  36900. return *v, true
  36901. }
  36902. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  36903. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36905. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  36906. if !m.op.Is(OpUpdateOne) {
  36907. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36908. }
  36909. if m.id == nil || m.oldValue == nil {
  36910. return v, errors.New("OldBotID requires an ID field in the mutation")
  36911. }
  36912. oldValue, err := m.oldValue(ctx)
  36913. if err != nil {
  36914. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36915. }
  36916. return oldValue.BotID, nil
  36917. }
  36918. // ClearBotID clears the value of the "bot_id" field.
  36919. func (m *UsageStatisticMonthMutation) ClearBotID() {
  36920. m.bot_id = nil
  36921. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  36922. }
  36923. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36924. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  36925. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  36926. return ok
  36927. }
  36928. // ResetBotID resets all changes to the "bot_id" field.
  36929. func (m *UsageStatisticMonthMutation) ResetBotID() {
  36930. m.bot_id = nil
  36931. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  36932. }
  36933. // SetOrganizationID sets the "organization_id" field.
  36934. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  36935. m.organization_id = &u
  36936. m.addorganization_id = nil
  36937. }
  36938. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36939. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  36940. v := m.organization_id
  36941. if v == nil {
  36942. return
  36943. }
  36944. return *v, true
  36945. }
  36946. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  36947. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36949. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36950. if !m.op.Is(OpUpdateOne) {
  36951. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36952. }
  36953. if m.id == nil || m.oldValue == nil {
  36954. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36955. }
  36956. oldValue, err := m.oldValue(ctx)
  36957. if err != nil {
  36958. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36959. }
  36960. return oldValue.OrganizationID, nil
  36961. }
  36962. // AddOrganizationID adds u to the "organization_id" field.
  36963. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  36964. if m.addorganization_id != nil {
  36965. *m.addorganization_id += u
  36966. } else {
  36967. m.addorganization_id = &u
  36968. }
  36969. }
  36970. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36971. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  36972. v := m.addorganization_id
  36973. if v == nil {
  36974. return
  36975. }
  36976. return *v, true
  36977. }
  36978. // ClearOrganizationID clears the value of the "organization_id" field.
  36979. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  36980. m.organization_id = nil
  36981. m.addorganization_id = nil
  36982. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  36983. }
  36984. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36985. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  36986. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  36987. return ok
  36988. }
  36989. // ResetOrganizationID resets all changes to the "organization_id" field.
  36990. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  36991. m.organization_id = nil
  36992. m.addorganization_id = nil
  36993. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  36994. }
  36995. // SetAiResponse sets the "ai_response" field.
  36996. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  36997. m.ai_response = &u
  36998. m.addai_response = nil
  36999. }
  37000. // AiResponse returns the value of the "ai_response" field in the mutation.
  37001. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  37002. v := m.ai_response
  37003. if v == nil {
  37004. return
  37005. }
  37006. return *v, true
  37007. }
  37008. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  37009. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37011. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  37012. if !m.op.Is(OpUpdateOne) {
  37013. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  37014. }
  37015. if m.id == nil || m.oldValue == nil {
  37016. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  37017. }
  37018. oldValue, err := m.oldValue(ctx)
  37019. if err != nil {
  37020. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  37021. }
  37022. return oldValue.AiResponse, nil
  37023. }
  37024. // AddAiResponse adds u to the "ai_response" field.
  37025. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  37026. if m.addai_response != nil {
  37027. *m.addai_response += u
  37028. } else {
  37029. m.addai_response = &u
  37030. }
  37031. }
  37032. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  37033. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  37034. v := m.addai_response
  37035. if v == nil {
  37036. return
  37037. }
  37038. return *v, true
  37039. }
  37040. // ResetAiResponse resets all changes to the "ai_response" field.
  37041. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  37042. m.ai_response = nil
  37043. m.addai_response = nil
  37044. }
  37045. // SetSopRun sets the "sop_run" field.
  37046. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  37047. m.sop_run = &u
  37048. m.addsop_run = nil
  37049. }
  37050. // SopRun returns the value of the "sop_run" field in the mutation.
  37051. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  37052. v := m.sop_run
  37053. if v == nil {
  37054. return
  37055. }
  37056. return *v, true
  37057. }
  37058. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  37059. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37061. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  37062. if !m.op.Is(OpUpdateOne) {
  37063. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  37064. }
  37065. if m.id == nil || m.oldValue == nil {
  37066. return v, errors.New("OldSopRun requires an ID field in the mutation")
  37067. }
  37068. oldValue, err := m.oldValue(ctx)
  37069. if err != nil {
  37070. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  37071. }
  37072. return oldValue.SopRun, nil
  37073. }
  37074. // AddSopRun adds u to the "sop_run" field.
  37075. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  37076. if m.addsop_run != nil {
  37077. *m.addsop_run += u
  37078. } else {
  37079. m.addsop_run = &u
  37080. }
  37081. }
  37082. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  37083. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  37084. v := m.addsop_run
  37085. if v == nil {
  37086. return
  37087. }
  37088. return *v, true
  37089. }
  37090. // ResetSopRun resets all changes to the "sop_run" field.
  37091. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  37092. m.sop_run = nil
  37093. m.addsop_run = nil
  37094. }
  37095. // SetTotalFriend sets the "total_friend" field.
  37096. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  37097. m.total_friend = &u
  37098. m.addtotal_friend = nil
  37099. }
  37100. // TotalFriend returns the value of the "total_friend" field in the mutation.
  37101. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  37102. v := m.total_friend
  37103. if v == nil {
  37104. return
  37105. }
  37106. return *v, true
  37107. }
  37108. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  37109. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37111. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  37112. if !m.op.Is(OpUpdateOne) {
  37113. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  37114. }
  37115. if m.id == nil || m.oldValue == nil {
  37116. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  37117. }
  37118. oldValue, err := m.oldValue(ctx)
  37119. if err != nil {
  37120. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  37121. }
  37122. return oldValue.TotalFriend, nil
  37123. }
  37124. // AddTotalFriend adds u to the "total_friend" field.
  37125. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  37126. if m.addtotal_friend != nil {
  37127. *m.addtotal_friend += u
  37128. } else {
  37129. m.addtotal_friend = &u
  37130. }
  37131. }
  37132. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  37133. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  37134. v := m.addtotal_friend
  37135. if v == nil {
  37136. return
  37137. }
  37138. return *v, true
  37139. }
  37140. // ResetTotalFriend resets all changes to the "total_friend" field.
  37141. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  37142. m.total_friend = nil
  37143. m.addtotal_friend = nil
  37144. }
  37145. // SetTotalGroup sets the "total_group" field.
  37146. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  37147. m.total_group = &u
  37148. m.addtotal_group = nil
  37149. }
  37150. // TotalGroup returns the value of the "total_group" field in the mutation.
  37151. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  37152. v := m.total_group
  37153. if v == nil {
  37154. return
  37155. }
  37156. return *v, true
  37157. }
  37158. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  37159. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37161. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  37162. if !m.op.Is(OpUpdateOne) {
  37163. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  37164. }
  37165. if m.id == nil || m.oldValue == nil {
  37166. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  37167. }
  37168. oldValue, err := m.oldValue(ctx)
  37169. if err != nil {
  37170. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  37171. }
  37172. return oldValue.TotalGroup, nil
  37173. }
  37174. // AddTotalGroup adds u to the "total_group" field.
  37175. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  37176. if m.addtotal_group != nil {
  37177. *m.addtotal_group += u
  37178. } else {
  37179. m.addtotal_group = &u
  37180. }
  37181. }
  37182. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  37183. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  37184. v := m.addtotal_group
  37185. if v == nil {
  37186. return
  37187. }
  37188. return *v, true
  37189. }
  37190. // ResetTotalGroup resets all changes to the "total_group" field.
  37191. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  37192. m.total_group = nil
  37193. m.addtotal_group = nil
  37194. }
  37195. // SetAccountBalance sets the "account_balance" field.
  37196. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  37197. m.account_balance = &u
  37198. m.addaccount_balance = nil
  37199. }
  37200. // AccountBalance returns the value of the "account_balance" field in the mutation.
  37201. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  37202. v := m.account_balance
  37203. if v == nil {
  37204. return
  37205. }
  37206. return *v, true
  37207. }
  37208. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  37209. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37211. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  37212. if !m.op.Is(OpUpdateOne) {
  37213. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  37214. }
  37215. if m.id == nil || m.oldValue == nil {
  37216. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  37217. }
  37218. oldValue, err := m.oldValue(ctx)
  37219. if err != nil {
  37220. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  37221. }
  37222. return oldValue.AccountBalance, nil
  37223. }
  37224. // AddAccountBalance adds u to the "account_balance" field.
  37225. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  37226. if m.addaccount_balance != nil {
  37227. *m.addaccount_balance += u
  37228. } else {
  37229. m.addaccount_balance = &u
  37230. }
  37231. }
  37232. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  37233. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  37234. v := m.addaccount_balance
  37235. if v == nil {
  37236. return
  37237. }
  37238. return *v, true
  37239. }
  37240. // ResetAccountBalance resets all changes to the "account_balance" field.
  37241. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  37242. m.account_balance = nil
  37243. m.addaccount_balance = nil
  37244. }
  37245. // SetConsumeToken sets the "consume_token" field.
  37246. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  37247. m.consume_token = &u
  37248. m.addconsume_token = nil
  37249. }
  37250. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  37251. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  37252. v := m.consume_token
  37253. if v == nil {
  37254. return
  37255. }
  37256. return *v, true
  37257. }
  37258. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  37259. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  37262. if !m.op.Is(OpUpdateOne) {
  37263. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  37264. }
  37265. if m.id == nil || m.oldValue == nil {
  37266. return v, errors.New("OldConsumeToken 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 OldConsumeToken: %w", err)
  37271. }
  37272. return oldValue.ConsumeToken, nil
  37273. }
  37274. // AddConsumeToken adds u to the "consume_token" field.
  37275. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  37276. if m.addconsume_token != nil {
  37277. *m.addconsume_token += u
  37278. } else {
  37279. m.addconsume_token = &u
  37280. }
  37281. }
  37282. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  37283. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  37284. v := m.addconsume_token
  37285. if v == nil {
  37286. return
  37287. }
  37288. return *v, true
  37289. }
  37290. // ResetConsumeToken resets all changes to the "consume_token" field.
  37291. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  37292. m.consume_token = nil
  37293. m.addconsume_token = nil
  37294. }
  37295. // SetActiveUser sets the "active_user" field.
  37296. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  37297. m.active_user = &u
  37298. m.addactive_user = nil
  37299. }
  37300. // ActiveUser returns the value of the "active_user" field in the mutation.
  37301. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  37302. v := m.active_user
  37303. if v == nil {
  37304. return
  37305. }
  37306. return *v, true
  37307. }
  37308. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  37309. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37311. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  37312. if !m.op.Is(OpUpdateOne) {
  37313. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  37314. }
  37315. if m.id == nil || m.oldValue == nil {
  37316. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  37317. }
  37318. oldValue, err := m.oldValue(ctx)
  37319. if err != nil {
  37320. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  37321. }
  37322. return oldValue.ActiveUser, nil
  37323. }
  37324. // AddActiveUser adds u to the "active_user" field.
  37325. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  37326. if m.addactive_user != nil {
  37327. *m.addactive_user += u
  37328. } else {
  37329. m.addactive_user = &u
  37330. }
  37331. }
  37332. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  37333. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  37334. v := m.addactive_user
  37335. if v == nil {
  37336. return
  37337. }
  37338. return *v, true
  37339. }
  37340. // ResetActiveUser resets all changes to the "active_user" field.
  37341. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  37342. m.active_user = nil
  37343. m.addactive_user = nil
  37344. }
  37345. // SetNewUser sets the "new_user" field.
  37346. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  37347. m.new_user = &i
  37348. m.addnew_user = nil
  37349. }
  37350. // NewUser returns the value of the "new_user" field in the mutation.
  37351. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  37352. v := m.new_user
  37353. if v == nil {
  37354. return
  37355. }
  37356. return *v, true
  37357. }
  37358. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  37359. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37361. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  37362. if !m.op.Is(OpUpdateOne) {
  37363. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  37364. }
  37365. if m.id == nil || m.oldValue == nil {
  37366. return v, errors.New("OldNewUser requires an ID field in the mutation")
  37367. }
  37368. oldValue, err := m.oldValue(ctx)
  37369. if err != nil {
  37370. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  37371. }
  37372. return oldValue.NewUser, nil
  37373. }
  37374. // AddNewUser adds i to the "new_user" field.
  37375. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  37376. if m.addnew_user != nil {
  37377. *m.addnew_user += i
  37378. } else {
  37379. m.addnew_user = &i
  37380. }
  37381. }
  37382. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  37383. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  37384. v := m.addnew_user
  37385. if v == nil {
  37386. return
  37387. }
  37388. return *v, true
  37389. }
  37390. // ResetNewUser resets all changes to the "new_user" field.
  37391. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  37392. m.new_user = nil
  37393. m.addnew_user = nil
  37394. }
  37395. // SetLabelDist sets the "label_dist" field.
  37396. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  37397. m.label_dist = &ctd
  37398. m.appendlabel_dist = nil
  37399. }
  37400. // LabelDist returns the value of the "label_dist" field in the mutation.
  37401. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  37402. v := m.label_dist
  37403. if v == nil {
  37404. return
  37405. }
  37406. return *v, true
  37407. }
  37408. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  37409. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37411. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  37412. if !m.op.Is(OpUpdateOne) {
  37413. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  37414. }
  37415. if m.id == nil || m.oldValue == nil {
  37416. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  37417. }
  37418. oldValue, err := m.oldValue(ctx)
  37419. if err != nil {
  37420. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  37421. }
  37422. return oldValue.LabelDist, nil
  37423. }
  37424. // AppendLabelDist adds ctd to the "label_dist" field.
  37425. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  37426. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  37427. }
  37428. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  37429. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  37430. if len(m.appendlabel_dist) == 0 {
  37431. return nil, false
  37432. }
  37433. return m.appendlabel_dist, true
  37434. }
  37435. // ResetLabelDist resets all changes to the "label_dist" field.
  37436. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  37437. m.label_dist = nil
  37438. m.appendlabel_dist = nil
  37439. }
  37440. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  37441. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  37442. m.predicates = append(m.predicates, ps...)
  37443. }
  37444. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  37445. // users can use type-assertion to append predicates that do not depend on any generated package.
  37446. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  37447. p := make([]predicate.UsageStatisticMonth, len(ps))
  37448. for i := range ps {
  37449. p[i] = ps[i]
  37450. }
  37451. m.Where(p...)
  37452. }
  37453. // Op returns the operation name.
  37454. func (m *UsageStatisticMonthMutation) Op() Op {
  37455. return m.op
  37456. }
  37457. // SetOp allows setting the mutation operation.
  37458. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  37459. m.op = op
  37460. }
  37461. // Type returns the node type of this mutation (UsageStatisticMonth).
  37462. func (m *UsageStatisticMonthMutation) Type() string {
  37463. return m.typ
  37464. }
  37465. // Fields returns all fields that were changed during this mutation. Note that in
  37466. // order to get all numeric fields that were incremented/decremented, call
  37467. // AddedFields().
  37468. func (m *UsageStatisticMonthMutation) Fields() []string {
  37469. fields := make([]string, 0, 17)
  37470. if m.created_at != nil {
  37471. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  37472. }
  37473. if m.updated_at != nil {
  37474. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  37475. }
  37476. if m.status != nil {
  37477. fields = append(fields, usagestatisticmonth.FieldStatus)
  37478. }
  37479. if m.deleted_at != nil {
  37480. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  37481. }
  37482. if m.addtime != nil {
  37483. fields = append(fields, usagestatisticmonth.FieldAddtime)
  37484. }
  37485. if m._type != nil {
  37486. fields = append(fields, usagestatisticmonth.FieldType)
  37487. }
  37488. if m.bot_id != nil {
  37489. fields = append(fields, usagestatisticmonth.FieldBotID)
  37490. }
  37491. if m.organization_id != nil {
  37492. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  37493. }
  37494. if m.ai_response != nil {
  37495. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  37496. }
  37497. if m.sop_run != nil {
  37498. fields = append(fields, usagestatisticmonth.FieldSopRun)
  37499. }
  37500. if m.total_friend != nil {
  37501. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  37502. }
  37503. if m.total_group != nil {
  37504. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  37505. }
  37506. if m.account_balance != nil {
  37507. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  37508. }
  37509. if m.consume_token != nil {
  37510. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  37511. }
  37512. if m.active_user != nil {
  37513. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  37514. }
  37515. if m.new_user != nil {
  37516. fields = append(fields, usagestatisticmonth.FieldNewUser)
  37517. }
  37518. if m.label_dist != nil {
  37519. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  37520. }
  37521. return fields
  37522. }
  37523. // Field returns the value of a field with the given name. The second boolean
  37524. // return value indicates that this field was not set, or was not defined in the
  37525. // schema.
  37526. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  37527. switch name {
  37528. case usagestatisticmonth.FieldCreatedAt:
  37529. return m.CreatedAt()
  37530. case usagestatisticmonth.FieldUpdatedAt:
  37531. return m.UpdatedAt()
  37532. case usagestatisticmonth.FieldStatus:
  37533. return m.Status()
  37534. case usagestatisticmonth.FieldDeletedAt:
  37535. return m.DeletedAt()
  37536. case usagestatisticmonth.FieldAddtime:
  37537. return m.Addtime()
  37538. case usagestatisticmonth.FieldType:
  37539. return m.GetType()
  37540. case usagestatisticmonth.FieldBotID:
  37541. return m.BotID()
  37542. case usagestatisticmonth.FieldOrganizationID:
  37543. return m.OrganizationID()
  37544. case usagestatisticmonth.FieldAiResponse:
  37545. return m.AiResponse()
  37546. case usagestatisticmonth.FieldSopRun:
  37547. return m.SopRun()
  37548. case usagestatisticmonth.FieldTotalFriend:
  37549. return m.TotalFriend()
  37550. case usagestatisticmonth.FieldTotalGroup:
  37551. return m.TotalGroup()
  37552. case usagestatisticmonth.FieldAccountBalance:
  37553. return m.AccountBalance()
  37554. case usagestatisticmonth.FieldConsumeToken:
  37555. return m.ConsumeToken()
  37556. case usagestatisticmonth.FieldActiveUser:
  37557. return m.ActiveUser()
  37558. case usagestatisticmonth.FieldNewUser:
  37559. return m.NewUser()
  37560. case usagestatisticmonth.FieldLabelDist:
  37561. return m.LabelDist()
  37562. }
  37563. return nil, false
  37564. }
  37565. // OldField returns the old value of the field from the database. An error is
  37566. // returned if the mutation operation is not UpdateOne, or the query to the
  37567. // database failed.
  37568. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37569. switch name {
  37570. case usagestatisticmonth.FieldCreatedAt:
  37571. return m.OldCreatedAt(ctx)
  37572. case usagestatisticmonth.FieldUpdatedAt:
  37573. return m.OldUpdatedAt(ctx)
  37574. case usagestatisticmonth.FieldStatus:
  37575. return m.OldStatus(ctx)
  37576. case usagestatisticmonth.FieldDeletedAt:
  37577. return m.OldDeletedAt(ctx)
  37578. case usagestatisticmonth.FieldAddtime:
  37579. return m.OldAddtime(ctx)
  37580. case usagestatisticmonth.FieldType:
  37581. return m.OldType(ctx)
  37582. case usagestatisticmonth.FieldBotID:
  37583. return m.OldBotID(ctx)
  37584. case usagestatisticmonth.FieldOrganizationID:
  37585. return m.OldOrganizationID(ctx)
  37586. case usagestatisticmonth.FieldAiResponse:
  37587. return m.OldAiResponse(ctx)
  37588. case usagestatisticmonth.FieldSopRun:
  37589. return m.OldSopRun(ctx)
  37590. case usagestatisticmonth.FieldTotalFriend:
  37591. return m.OldTotalFriend(ctx)
  37592. case usagestatisticmonth.FieldTotalGroup:
  37593. return m.OldTotalGroup(ctx)
  37594. case usagestatisticmonth.FieldAccountBalance:
  37595. return m.OldAccountBalance(ctx)
  37596. case usagestatisticmonth.FieldConsumeToken:
  37597. return m.OldConsumeToken(ctx)
  37598. case usagestatisticmonth.FieldActiveUser:
  37599. return m.OldActiveUser(ctx)
  37600. case usagestatisticmonth.FieldNewUser:
  37601. return m.OldNewUser(ctx)
  37602. case usagestatisticmonth.FieldLabelDist:
  37603. return m.OldLabelDist(ctx)
  37604. }
  37605. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  37606. }
  37607. // SetField sets the value of a field with the given name. It returns an error if
  37608. // the field is not defined in the schema, or if the type mismatched the field
  37609. // type.
  37610. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  37611. switch name {
  37612. case usagestatisticmonth.FieldCreatedAt:
  37613. v, ok := value.(time.Time)
  37614. if !ok {
  37615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37616. }
  37617. m.SetCreatedAt(v)
  37618. return nil
  37619. case usagestatisticmonth.FieldUpdatedAt:
  37620. v, ok := value.(time.Time)
  37621. if !ok {
  37622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37623. }
  37624. m.SetUpdatedAt(v)
  37625. return nil
  37626. case usagestatisticmonth.FieldStatus:
  37627. v, ok := value.(uint8)
  37628. if !ok {
  37629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37630. }
  37631. m.SetStatus(v)
  37632. return nil
  37633. case usagestatisticmonth.FieldDeletedAt:
  37634. v, ok := value.(time.Time)
  37635. if !ok {
  37636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37637. }
  37638. m.SetDeletedAt(v)
  37639. return nil
  37640. case usagestatisticmonth.FieldAddtime:
  37641. v, ok := value.(uint64)
  37642. if !ok {
  37643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37644. }
  37645. m.SetAddtime(v)
  37646. return nil
  37647. case usagestatisticmonth.FieldType:
  37648. v, ok := value.(int)
  37649. if !ok {
  37650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37651. }
  37652. m.SetType(v)
  37653. return nil
  37654. case usagestatisticmonth.FieldBotID:
  37655. v, ok := value.(string)
  37656. if !ok {
  37657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37658. }
  37659. m.SetBotID(v)
  37660. return nil
  37661. case usagestatisticmonth.FieldOrganizationID:
  37662. v, ok := value.(uint64)
  37663. if !ok {
  37664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37665. }
  37666. m.SetOrganizationID(v)
  37667. return nil
  37668. case usagestatisticmonth.FieldAiResponse:
  37669. v, ok := value.(uint64)
  37670. if !ok {
  37671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37672. }
  37673. m.SetAiResponse(v)
  37674. return nil
  37675. case usagestatisticmonth.FieldSopRun:
  37676. v, ok := value.(uint64)
  37677. if !ok {
  37678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37679. }
  37680. m.SetSopRun(v)
  37681. return nil
  37682. case usagestatisticmonth.FieldTotalFriend:
  37683. v, ok := value.(uint64)
  37684. if !ok {
  37685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37686. }
  37687. m.SetTotalFriend(v)
  37688. return nil
  37689. case usagestatisticmonth.FieldTotalGroup:
  37690. v, ok := value.(uint64)
  37691. if !ok {
  37692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37693. }
  37694. m.SetTotalGroup(v)
  37695. return nil
  37696. case usagestatisticmonth.FieldAccountBalance:
  37697. v, ok := value.(uint64)
  37698. if !ok {
  37699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37700. }
  37701. m.SetAccountBalance(v)
  37702. return nil
  37703. case usagestatisticmonth.FieldConsumeToken:
  37704. v, ok := value.(uint64)
  37705. if !ok {
  37706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37707. }
  37708. m.SetConsumeToken(v)
  37709. return nil
  37710. case usagestatisticmonth.FieldActiveUser:
  37711. v, ok := value.(uint64)
  37712. if !ok {
  37713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37714. }
  37715. m.SetActiveUser(v)
  37716. return nil
  37717. case usagestatisticmonth.FieldNewUser:
  37718. v, ok := value.(int64)
  37719. if !ok {
  37720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37721. }
  37722. m.SetNewUser(v)
  37723. return nil
  37724. case usagestatisticmonth.FieldLabelDist:
  37725. v, ok := value.([]custom_types.LabelDist)
  37726. if !ok {
  37727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37728. }
  37729. m.SetLabelDist(v)
  37730. return nil
  37731. }
  37732. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  37733. }
  37734. // AddedFields returns all numeric fields that were incremented/decremented during
  37735. // this mutation.
  37736. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  37737. var fields []string
  37738. if m.addstatus != nil {
  37739. fields = append(fields, usagestatisticmonth.FieldStatus)
  37740. }
  37741. if m.addaddtime != nil {
  37742. fields = append(fields, usagestatisticmonth.FieldAddtime)
  37743. }
  37744. if m.add_type != nil {
  37745. fields = append(fields, usagestatisticmonth.FieldType)
  37746. }
  37747. if m.addorganization_id != nil {
  37748. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  37749. }
  37750. if m.addai_response != nil {
  37751. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  37752. }
  37753. if m.addsop_run != nil {
  37754. fields = append(fields, usagestatisticmonth.FieldSopRun)
  37755. }
  37756. if m.addtotal_friend != nil {
  37757. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  37758. }
  37759. if m.addtotal_group != nil {
  37760. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  37761. }
  37762. if m.addaccount_balance != nil {
  37763. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  37764. }
  37765. if m.addconsume_token != nil {
  37766. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  37767. }
  37768. if m.addactive_user != nil {
  37769. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  37770. }
  37771. if m.addnew_user != nil {
  37772. fields = append(fields, usagestatisticmonth.FieldNewUser)
  37773. }
  37774. return fields
  37775. }
  37776. // AddedField returns the numeric value that was incremented/decremented on a field
  37777. // with the given name. The second boolean return value indicates that this field
  37778. // was not set, or was not defined in the schema.
  37779. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  37780. switch name {
  37781. case usagestatisticmonth.FieldStatus:
  37782. return m.AddedStatus()
  37783. case usagestatisticmonth.FieldAddtime:
  37784. return m.AddedAddtime()
  37785. case usagestatisticmonth.FieldType:
  37786. return m.AddedType()
  37787. case usagestatisticmonth.FieldOrganizationID:
  37788. return m.AddedOrganizationID()
  37789. case usagestatisticmonth.FieldAiResponse:
  37790. return m.AddedAiResponse()
  37791. case usagestatisticmonth.FieldSopRun:
  37792. return m.AddedSopRun()
  37793. case usagestatisticmonth.FieldTotalFriend:
  37794. return m.AddedTotalFriend()
  37795. case usagestatisticmonth.FieldTotalGroup:
  37796. return m.AddedTotalGroup()
  37797. case usagestatisticmonth.FieldAccountBalance:
  37798. return m.AddedAccountBalance()
  37799. case usagestatisticmonth.FieldConsumeToken:
  37800. return m.AddedConsumeToken()
  37801. case usagestatisticmonth.FieldActiveUser:
  37802. return m.AddedActiveUser()
  37803. case usagestatisticmonth.FieldNewUser:
  37804. return m.AddedNewUser()
  37805. }
  37806. return nil, false
  37807. }
  37808. // AddField adds the value to the field with the given name. It returns an error if
  37809. // the field is not defined in the schema, or if the type mismatched the field
  37810. // type.
  37811. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  37812. switch name {
  37813. case usagestatisticmonth.FieldStatus:
  37814. v, ok := value.(int8)
  37815. if !ok {
  37816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37817. }
  37818. m.AddStatus(v)
  37819. return nil
  37820. case usagestatisticmonth.FieldAddtime:
  37821. v, ok := value.(int64)
  37822. if !ok {
  37823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37824. }
  37825. m.AddAddtime(v)
  37826. return nil
  37827. case usagestatisticmonth.FieldType:
  37828. v, ok := value.(int)
  37829. if !ok {
  37830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37831. }
  37832. m.AddType(v)
  37833. return nil
  37834. case usagestatisticmonth.FieldOrganizationID:
  37835. v, ok := value.(int64)
  37836. if !ok {
  37837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37838. }
  37839. m.AddOrganizationID(v)
  37840. return nil
  37841. case usagestatisticmonth.FieldAiResponse:
  37842. v, ok := value.(int64)
  37843. if !ok {
  37844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37845. }
  37846. m.AddAiResponse(v)
  37847. return nil
  37848. case usagestatisticmonth.FieldSopRun:
  37849. v, ok := value.(int64)
  37850. if !ok {
  37851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37852. }
  37853. m.AddSopRun(v)
  37854. return nil
  37855. case usagestatisticmonth.FieldTotalFriend:
  37856. v, ok := value.(int64)
  37857. if !ok {
  37858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37859. }
  37860. m.AddTotalFriend(v)
  37861. return nil
  37862. case usagestatisticmonth.FieldTotalGroup:
  37863. v, ok := value.(int64)
  37864. if !ok {
  37865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37866. }
  37867. m.AddTotalGroup(v)
  37868. return nil
  37869. case usagestatisticmonth.FieldAccountBalance:
  37870. v, ok := value.(int64)
  37871. if !ok {
  37872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37873. }
  37874. m.AddAccountBalance(v)
  37875. return nil
  37876. case usagestatisticmonth.FieldConsumeToken:
  37877. v, ok := value.(int64)
  37878. if !ok {
  37879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37880. }
  37881. m.AddConsumeToken(v)
  37882. return nil
  37883. case usagestatisticmonth.FieldActiveUser:
  37884. v, ok := value.(int64)
  37885. if !ok {
  37886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37887. }
  37888. m.AddActiveUser(v)
  37889. return nil
  37890. case usagestatisticmonth.FieldNewUser:
  37891. v, ok := value.(int64)
  37892. if !ok {
  37893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37894. }
  37895. m.AddNewUser(v)
  37896. return nil
  37897. }
  37898. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  37899. }
  37900. // ClearedFields returns all nullable fields that were cleared during this
  37901. // mutation.
  37902. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  37903. var fields []string
  37904. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  37905. fields = append(fields, usagestatisticmonth.FieldStatus)
  37906. }
  37907. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  37908. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  37909. }
  37910. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  37911. fields = append(fields, usagestatisticmonth.FieldBotID)
  37912. }
  37913. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  37914. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  37915. }
  37916. return fields
  37917. }
  37918. // FieldCleared returns a boolean indicating if a field with the given name was
  37919. // cleared in this mutation.
  37920. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  37921. _, ok := m.clearedFields[name]
  37922. return ok
  37923. }
  37924. // ClearField clears the value of the field with the given name. It returns an
  37925. // error if the field is not defined in the schema.
  37926. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  37927. switch name {
  37928. case usagestatisticmonth.FieldStatus:
  37929. m.ClearStatus()
  37930. return nil
  37931. case usagestatisticmonth.FieldDeletedAt:
  37932. m.ClearDeletedAt()
  37933. return nil
  37934. case usagestatisticmonth.FieldBotID:
  37935. m.ClearBotID()
  37936. return nil
  37937. case usagestatisticmonth.FieldOrganizationID:
  37938. m.ClearOrganizationID()
  37939. return nil
  37940. }
  37941. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  37942. }
  37943. // ResetField resets all changes in the mutation for the field with the given name.
  37944. // It returns an error if the field is not defined in the schema.
  37945. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  37946. switch name {
  37947. case usagestatisticmonth.FieldCreatedAt:
  37948. m.ResetCreatedAt()
  37949. return nil
  37950. case usagestatisticmonth.FieldUpdatedAt:
  37951. m.ResetUpdatedAt()
  37952. return nil
  37953. case usagestatisticmonth.FieldStatus:
  37954. m.ResetStatus()
  37955. return nil
  37956. case usagestatisticmonth.FieldDeletedAt:
  37957. m.ResetDeletedAt()
  37958. return nil
  37959. case usagestatisticmonth.FieldAddtime:
  37960. m.ResetAddtime()
  37961. return nil
  37962. case usagestatisticmonth.FieldType:
  37963. m.ResetType()
  37964. return nil
  37965. case usagestatisticmonth.FieldBotID:
  37966. m.ResetBotID()
  37967. return nil
  37968. case usagestatisticmonth.FieldOrganizationID:
  37969. m.ResetOrganizationID()
  37970. return nil
  37971. case usagestatisticmonth.FieldAiResponse:
  37972. m.ResetAiResponse()
  37973. return nil
  37974. case usagestatisticmonth.FieldSopRun:
  37975. m.ResetSopRun()
  37976. return nil
  37977. case usagestatisticmonth.FieldTotalFriend:
  37978. m.ResetTotalFriend()
  37979. return nil
  37980. case usagestatisticmonth.FieldTotalGroup:
  37981. m.ResetTotalGroup()
  37982. return nil
  37983. case usagestatisticmonth.FieldAccountBalance:
  37984. m.ResetAccountBalance()
  37985. return nil
  37986. case usagestatisticmonth.FieldConsumeToken:
  37987. m.ResetConsumeToken()
  37988. return nil
  37989. case usagestatisticmonth.FieldActiveUser:
  37990. m.ResetActiveUser()
  37991. return nil
  37992. case usagestatisticmonth.FieldNewUser:
  37993. m.ResetNewUser()
  37994. return nil
  37995. case usagestatisticmonth.FieldLabelDist:
  37996. m.ResetLabelDist()
  37997. return nil
  37998. }
  37999. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38000. }
  38001. // AddedEdges returns all edge names that were set/added in this mutation.
  38002. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  38003. edges := make([]string, 0, 0)
  38004. return edges
  38005. }
  38006. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38007. // name in this mutation.
  38008. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  38009. return nil
  38010. }
  38011. // RemovedEdges returns all edge names that were removed in this mutation.
  38012. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  38013. edges := make([]string, 0, 0)
  38014. return edges
  38015. }
  38016. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38017. // the given name in this mutation.
  38018. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  38019. return nil
  38020. }
  38021. // ClearedEdges returns all edge names that were cleared in this mutation.
  38022. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  38023. edges := make([]string, 0, 0)
  38024. return edges
  38025. }
  38026. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38027. // was cleared in this mutation.
  38028. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  38029. return false
  38030. }
  38031. // ClearEdge clears the value of the edge with the given name. It returns an error
  38032. // if that edge is not defined in the schema.
  38033. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  38034. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  38035. }
  38036. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38037. // It returns an error if the edge is not defined in the schema.
  38038. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  38039. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  38040. }
  38041. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  38042. type UsageTotalMutation struct {
  38043. config
  38044. op Op
  38045. typ string
  38046. id *uint64
  38047. created_at *time.Time
  38048. updated_at *time.Time
  38049. status *uint8
  38050. addstatus *int8
  38051. _type *int
  38052. add_type *int
  38053. bot_id *string
  38054. total_tokens *uint64
  38055. addtotal_tokens *int64
  38056. start_index *uint64
  38057. addstart_index *int64
  38058. end_index *uint64
  38059. addend_index *int64
  38060. organization_id *uint64
  38061. addorganization_id *int64
  38062. clearedFields map[string]struct{}
  38063. done bool
  38064. oldValue func(context.Context) (*UsageTotal, error)
  38065. predicates []predicate.UsageTotal
  38066. }
  38067. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  38068. // usagetotalOption allows management of the mutation configuration using functional options.
  38069. type usagetotalOption func(*UsageTotalMutation)
  38070. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  38071. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  38072. m := &UsageTotalMutation{
  38073. config: c,
  38074. op: op,
  38075. typ: TypeUsageTotal,
  38076. clearedFields: make(map[string]struct{}),
  38077. }
  38078. for _, opt := range opts {
  38079. opt(m)
  38080. }
  38081. return m
  38082. }
  38083. // withUsageTotalID sets the ID field of the mutation.
  38084. func withUsageTotalID(id uint64) usagetotalOption {
  38085. return func(m *UsageTotalMutation) {
  38086. var (
  38087. err error
  38088. once sync.Once
  38089. value *UsageTotal
  38090. )
  38091. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  38092. once.Do(func() {
  38093. if m.done {
  38094. err = errors.New("querying old values post mutation is not allowed")
  38095. } else {
  38096. value, err = m.Client().UsageTotal.Get(ctx, id)
  38097. }
  38098. })
  38099. return value, err
  38100. }
  38101. m.id = &id
  38102. }
  38103. }
  38104. // withUsageTotal sets the old UsageTotal of the mutation.
  38105. func withUsageTotal(node *UsageTotal) usagetotalOption {
  38106. return func(m *UsageTotalMutation) {
  38107. m.oldValue = func(context.Context) (*UsageTotal, error) {
  38108. return node, nil
  38109. }
  38110. m.id = &node.ID
  38111. }
  38112. }
  38113. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38114. // executed in a transaction (ent.Tx), a transactional client is returned.
  38115. func (m UsageTotalMutation) Client() *Client {
  38116. client := &Client{config: m.config}
  38117. client.init()
  38118. return client
  38119. }
  38120. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38121. // it returns an error otherwise.
  38122. func (m UsageTotalMutation) Tx() (*Tx, error) {
  38123. if _, ok := m.driver.(*txDriver); !ok {
  38124. return nil, errors.New("ent: mutation is not running in a transaction")
  38125. }
  38126. tx := &Tx{config: m.config}
  38127. tx.init()
  38128. return tx, nil
  38129. }
  38130. // SetID sets the value of the id field. Note that this
  38131. // operation is only accepted on creation of UsageTotal entities.
  38132. func (m *UsageTotalMutation) SetID(id uint64) {
  38133. m.id = &id
  38134. }
  38135. // ID returns the ID value in the mutation. Note that the ID is only available
  38136. // if it was provided to the builder or after it was returned from the database.
  38137. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  38138. if m.id == nil {
  38139. return
  38140. }
  38141. return *m.id, true
  38142. }
  38143. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38144. // That means, if the mutation is applied within a transaction with an isolation level such
  38145. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38146. // or updated by the mutation.
  38147. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  38148. switch {
  38149. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38150. id, exists := m.ID()
  38151. if exists {
  38152. return []uint64{id}, nil
  38153. }
  38154. fallthrough
  38155. case m.op.Is(OpUpdate | OpDelete):
  38156. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  38157. default:
  38158. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38159. }
  38160. }
  38161. // SetCreatedAt sets the "created_at" field.
  38162. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  38163. m.created_at = &t
  38164. }
  38165. // CreatedAt returns the value of the "created_at" field in the mutation.
  38166. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  38167. v := m.created_at
  38168. if v == nil {
  38169. return
  38170. }
  38171. return *v, true
  38172. }
  38173. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  38174. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38176. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38177. if !m.op.Is(OpUpdateOne) {
  38178. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38179. }
  38180. if m.id == nil || m.oldValue == nil {
  38181. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38182. }
  38183. oldValue, err := m.oldValue(ctx)
  38184. if err != nil {
  38185. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38186. }
  38187. return oldValue.CreatedAt, nil
  38188. }
  38189. // ResetCreatedAt resets all changes to the "created_at" field.
  38190. func (m *UsageTotalMutation) ResetCreatedAt() {
  38191. m.created_at = nil
  38192. }
  38193. // SetUpdatedAt sets the "updated_at" field.
  38194. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  38195. m.updated_at = &t
  38196. }
  38197. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38198. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  38199. v := m.updated_at
  38200. if v == nil {
  38201. return
  38202. }
  38203. return *v, true
  38204. }
  38205. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  38206. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38208. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38209. if !m.op.Is(OpUpdateOne) {
  38210. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38211. }
  38212. if m.id == nil || m.oldValue == nil {
  38213. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38214. }
  38215. oldValue, err := m.oldValue(ctx)
  38216. if err != nil {
  38217. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38218. }
  38219. return oldValue.UpdatedAt, nil
  38220. }
  38221. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38222. func (m *UsageTotalMutation) ResetUpdatedAt() {
  38223. m.updated_at = nil
  38224. }
  38225. // SetStatus sets the "status" field.
  38226. func (m *UsageTotalMutation) SetStatus(u uint8) {
  38227. m.status = &u
  38228. m.addstatus = nil
  38229. }
  38230. // Status returns the value of the "status" field in the mutation.
  38231. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  38232. v := m.status
  38233. if v == nil {
  38234. return
  38235. }
  38236. return *v, true
  38237. }
  38238. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  38239. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38241. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38242. if !m.op.Is(OpUpdateOne) {
  38243. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38244. }
  38245. if m.id == nil || m.oldValue == nil {
  38246. return v, errors.New("OldStatus requires an ID field in the mutation")
  38247. }
  38248. oldValue, err := m.oldValue(ctx)
  38249. if err != nil {
  38250. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38251. }
  38252. return oldValue.Status, nil
  38253. }
  38254. // AddStatus adds u to the "status" field.
  38255. func (m *UsageTotalMutation) AddStatus(u int8) {
  38256. if m.addstatus != nil {
  38257. *m.addstatus += u
  38258. } else {
  38259. m.addstatus = &u
  38260. }
  38261. }
  38262. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38263. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  38264. v := m.addstatus
  38265. if v == nil {
  38266. return
  38267. }
  38268. return *v, true
  38269. }
  38270. // ClearStatus clears the value of the "status" field.
  38271. func (m *UsageTotalMutation) ClearStatus() {
  38272. m.status = nil
  38273. m.addstatus = nil
  38274. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  38275. }
  38276. // StatusCleared returns if the "status" field was cleared in this mutation.
  38277. func (m *UsageTotalMutation) StatusCleared() bool {
  38278. _, ok := m.clearedFields[usagetotal.FieldStatus]
  38279. return ok
  38280. }
  38281. // ResetStatus resets all changes to the "status" field.
  38282. func (m *UsageTotalMutation) ResetStatus() {
  38283. m.status = nil
  38284. m.addstatus = nil
  38285. delete(m.clearedFields, usagetotal.FieldStatus)
  38286. }
  38287. // SetType sets the "type" field.
  38288. func (m *UsageTotalMutation) SetType(i int) {
  38289. m._type = &i
  38290. m.add_type = nil
  38291. }
  38292. // GetType returns the value of the "type" field in the mutation.
  38293. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  38294. v := m._type
  38295. if v == nil {
  38296. return
  38297. }
  38298. return *v, true
  38299. }
  38300. // OldType returns the old "type" field's value of the UsageTotal entity.
  38301. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38303. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  38304. if !m.op.Is(OpUpdateOne) {
  38305. return v, errors.New("OldType is only allowed on UpdateOne operations")
  38306. }
  38307. if m.id == nil || m.oldValue == nil {
  38308. return v, errors.New("OldType requires an ID field in the mutation")
  38309. }
  38310. oldValue, err := m.oldValue(ctx)
  38311. if err != nil {
  38312. return v, fmt.Errorf("querying old value for OldType: %w", err)
  38313. }
  38314. return oldValue.Type, nil
  38315. }
  38316. // AddType adds i to the "type" field.
  38317. func (m *UsageTotalMutation) AddType(i int) {
  38318. if m.add_type != nil {
  38319. *m.add_type += i
  38320. } else {
  38321. m.add_type = &i
  38322. }
  38323. }
  38324. // AddedType returns the value that was added to the "type" field in this mutation.
  38325. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  38326. v := m.add_type
  38327. if v == nil {
  38328. return
  38329. }
  38330. return *v, true
  38331. }
  38332. // ClearType clears the value of the "type" field.
  38333. func (m *UsageTotalMutation) ClearType() {
  38334. m._type = nil
  38335. m.add_type = nil
  38336. m.clearedFields[usagetotal.FieldType] = struct{}{}
  38337. }
  38338. // TypeCleared returns if the "type" field was cleared in this mutation.
  38339. func (m *UsageTotalMutation) TypeCleared() bool {
  38340. _, ok := m.clearedFields[usagetotal.FieldType]
  38341. return ok
  38342. }
  38343. // ResetType resets all changes to the "type" field.
  38344. func (m *UsageTotalMutation) ResetType() {
  38345. m._type = nil
  38346. m.add_type = nil
  38347. delete(m.clearedFields, usagetotal.FieldType)
  38348. }
  38349. // SetBotID sets the "bot_id" field.
  38350. func (m *UsageTotalMutation) SetBotID(s string) {
  38351. m.bot_id = &s
  38352. }
  38353. // BotID returns the value of the "bot_id" field in the mutation.
  38354. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  38355. v := m.bot_id
  38356. if v == nil {
  38357. return
  38358. }
  38359. return *v, true
  38360. }
  38361. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  38362. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38364. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  38365. if !m.op.Is(OpUpdateOne) {
  38366. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  38367. }
  38368. if m.id == nil || m.oldValue == nil {
  38369. return v, errors.New("OldBotID requires an ID field in the mutation")
  38370. }
  38371. oldValue, err := m.oldValue(ctx)
  38372. if err != nil {
  38373. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  38374. }
  38375. return oldValue.BotID, nil
  38376. }
  38377. // ResetBotID resets all changes to the "bot_id" field.
  38378. func (m *UsageTotalMutation) ResetBotID() {
  38379. m.bot_id = nil
  38380. }
  38381. // SetTotalTokens sets the "total_tokens" field.
  38382. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  38383. m.total_tokens = &u
  38384. m.addtotal_tokens = nil
  38385. }
  38386. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  38387. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  38388. v := m.total_tokens
  38389. if v == nil {
  38390. return
  38391. }
  38392. return *v, true
  38393. }
  38394. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  38395. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38397. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  38398. if !m.op.Is(OpUpdateOne) {
  38399. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  38400. }
  38401. if m.id == nil || m.oldValue == nil {
  38402. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  38403. }
  38404. oldValue, err := m.oldValue(ctx)
  38405. if err != nil {
  38406. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  38407. }
  38408. return oldValue.TotalTokens, nil
  38409. }
  38410. // AddTotalTokens adds u to the "total_tokens" field.
  38411. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  38412. if m.addtotal_tokens != nil {
  38413. *m.addtotal_tokens += u
  38414. } else {
  38415. m.addtotal_tokens = &u
  38416. }
  38417. }
  38418. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  38419. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  38420. v := m.addtotal_tokens
  38421. if v == nil {
  38422. return
  38423. }
  38424. return *v, true
  38425. }
  38426. // ClearTotalTokens clears the value of the "total_tokens" field.
  38427. func (m *UsageTotalMutation) ClearTotalTokens() {
  38428. m.total_tokens = nil
  38429. m.addtotal_tokens = nil
  38430. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  38431. }
  38432. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  38433. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  38434. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  38435. return ok
  38436. }
  38437. // ResetTotalTokens resets all changes to the "total_tokens" field.
  38438. func (m *UsageTotalMutation) ResetTotalTokens() {
  38439. m.total_tokens = nil
  38440. m.addtotal_tokens = nil
  38441. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  38442. }
  38443. // SetStartIndex sets the "start_index" field.
  38444. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  38445. m.start_index = &u
  38446. m.addstart_index = nil
  38447. }
  38448. // StartIndex returns the value of the "start_index" field in the mutation.
  38449. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  38450. v := m.start_index
  38451. if v == nil {
  38452. return
  38453. }
  38454. return *v, true
  38455. }
  38456. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  38457. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38459. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  38460. if !m.op.Is(OpUpdateOne) {
  38461. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  38462. }
  38463. if m.id == nil || m.oldValue == nil {
  38464. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  38465. }
  38466. oldValue, err := m.oldValue(ctx)
  38467. if err != nil {
  38468. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  38469. }
  38470. return oldValue.StartIndex, nil
  38471. }
  38472. // AddStartIndex adds u to the "start_index" field.
  38473. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  38474. if m.addstart_index != nil {
  38475. *m.addstart_index += u
  38476. } else {
  38477. m.addstart_index = &u
  38478. }
  38479. }
  38480. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  38481. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  38482. v := m.addstart_index
  38483. if v == nil {
  38484. return
  38485. }
  38486. return *v, true
  38487. }
  38488. // ClearStartIndex clears the value of the "start_index" field.
  38489. func (m *UsageTotalMutation) ClearStartIndex() {
  38490. m.start_index = nil
  38491. m.addstart_index = nil
  38492. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  38493. }
  38494. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  38495. func (m *UsageTotalMutation) StartIndexCleared() bool {
  38496. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  38497. return ok
  38498. }
  38499. // ResetStartIndex resets all changes to the "start_index" field.
  38500. func (m *UsageTotalMutation) ResetStartIndex() {
  38501. m.start_index = nil
  38502. m.addstart_index = nil
  38503. delete(m.clearedFields, usagetotal.FieldStartIndex)
  38504. }
  38505. // SetEndIndex sets the "end_index" field.
  38506. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  38507. m.end_index = &u
  38508. m.addend_index = nil
  38509. }
  38510. // EndIndex returns the value of the "end_index" field in the mutation.
  38511. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  38512. v := m.end_index
  38513. if v == nil {
  38514. return
  38515. }
  38516. return *v, true
  38517. }
  38518. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  38519. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38521. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  38522. if !m.op.Is(OpUpdateOne) {
  38523. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  38524. }
  38525. if m.id == nil || m.oldValue == nil {
  38526. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  38527. }
  38528. oldValue, err := m.oldValue(ctx)
  38529. if err != nil {
  38530. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  38531. }
  38532. return oldValue.EndIndex, nil
  38533. }
  38534. // AddEndIndex adds u to the "end_index" field.
  38535. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  38536. if m.addend_index != nil {
  38537. *m.addend_index += u
  38538. } else {
  38539. m.addend_index = &u
  38540. }
  38541. }
  38542. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  38543. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  38544. v := m.addend_index
  38545. if v == nil {
  38546. return
  38547. }
  38548. return *v, true
  38549. }
  38550. // ClearEndIndex clears the value of the "end_index" field.
  38551. func (m *UsageTotalMutation) ClearEndIndex() {
  38552. m.end_index = nil
  38553. m.addend_index = nil
  38554. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  38555. }
  38556. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  38557. func (m *UsageTotalMutation) EndIndexCleared() bool {
  38558. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  38559. return ok
  38560. }
  38561. // ResetEndIndex resets all changes to the "end_index" field.
  38562. func (m *UsageTotalMutation) ResetEndIndex() {
  38563. m.end_index = nil
  38564. m.addend_index = nil
  38565. delete(m.clearedFields, usagetotal.FieldEndIndex)
  38566. }
  38567. // SetOrganizationID sets the "organization_id" field.
  38568. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  38569. m.organization_id = &u
  38570. m.addorganization_id = nil
  38571. }
  38572. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38573. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  38574. v := m.organization_id
  38575. if v == nil {
  38576. return
  38577. }
  38578. return *v, true
  38579. }
  38580. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  38581. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38583. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38584. if !m.op.Is(OpUpdateOne) {
  38585. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38586. }
  38587. if m.id == nil || m.oldValue == nil {
  38588. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38589. }
  38590. oldValue, err := m.oldValue(ctx)
  38591. if err != nil {
  38592. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38593. }
  38594. return oldValue.OrganizationID, nil
  38595. }
  38596. // AddOrganizationID adds u to the "organization_id" field.
  38597. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  38598. if m.addorganization_id != nil {
  38599. *m.addorganization_id += u
  38600. } else {
  38601. m.addorganization_id = &u
  38602. }
  38603. }
  38604. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38605. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  38606. v := m.addorganization_id
  38607. if v == nil {
  38608. return
  38609. }
  38610. return *v, true
  38611. }
  38612. // ClearOrganizationID clears the value of the "organization_id" field.
  38613. func (m *UsageTotalMutation) ClearOrganizationID() {
  38614. m.organization_id = nil
  38615. m.addorganization_id = nil
  38616. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  38617. }
  38618. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38619. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  38620. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  38621. return ok
  38622. }
  38623. // ResetOrganizationID resets all changes to the "organization_id" field.
  38624. func (m *UsageTotalMutation) ResetOrganizationID() {
  38625. m.organization_id = nil
  38626. m.addorganization_id = nil
  38627. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  38628. }
  38629. // Where appends a list predicates to the UsageTotalMutation builder.
  38630. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  38631. m.predicates = append(m.predicates, ps...)
  38632. }
  38633. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  38634. // users can use type-assertion to append predicates that do not depend on any generated package.
  38635. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  38636. p := make([]predicate.UsageTotal, len(ps))
  38637. for i := range ps {
  38638. p[i] = ps[i]
  38639. }
  38640. m.Where(p...)
  38641. }
  38642. // Op returns the operation name.
  38643. func (m *UsageTotalMutation) Op() Op {
  38644. return m.op
  38645. }
  38646. // SetOp allows setting the mutation operation.
  38647. func (m *UsageTotalMutation) SetOp(op Op) {
  38648. m.op = op
  38649. }
  38650. // Type returns the node type of this mutation (UsageTotal).
  38651. func (m *UsageTotalMutation) Type() string {
  38652. return m.typ
  38653. }
  38654. // Fields returns all fields that were changed during this mutation. Note that in
  38655. // order to get all numeric fields that were incremented/decremented, call
  38656. // AddedFields().
  38657. func (m *UsageTotalMutation) Fields() []string {
  38658. fields := make([]string, 0, 9)
  38659. if m.created_at != nil {
  38660. fields = append(fields, usagetotal.FieldCreatedAt)
  38661. }
  38662. if m.updated_at != nil {
  38663. fields = append(fields, usagetotal.FieldUpdatedAt)
  38664. }
  38665. if m.status != nil {
  38666. fields = append(fields, usagetotal.FieldStatus)
  38667. }
  38668. if m._type != nil {
  38669. fields = append(fields, usagetotal.FieldType)
  38670. }
  38671. if m.bot_id != nil {
  38672. fields = append(fields, usagetotal.FieldBotID)
  38673. }
  38674. if m.total_tokens != nil {
  38675. fields = append(fields, usagetotal.FieldTotalTokens)
  38676. }
  38677. if m.start_index != nil {
  38678. fields = append(fields, usagetotal.FieldStartIndex)
  38679. }
  38680. if m.end_index != nil {
  38681. fields = append(fields, usagetotal.FieldEndIndex)
  38682. }
  38683. if m.organization_id != nil {
  38684. fields = append(fields, usagetotal.FieldOrganizationID)
  38685. }
  38686. return fields
  38687. }
  38688. // Field returns the value of a field with the given name. The second boolean
  38689. // return value indicates that this field was not set, or was not defined in the
  38690. // schema.
  38691. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  38692. switch name {
  38693. case usagetotal.FieldCreatedAt:
  38694. return m.CreatedAt()
  38695. case usagetotal.FieldUpdatedAt:
  38696. return m.UpdatedAt()
  38697. case usagetotal.FieldStatus:
  38698. return m.Status()
  38699. case usagetotal.FieldType:
  38700. return m.GetType()
  38701. case usagetotal.FieldBotID:
  38702. return m.BotID()
  38703. case usagetotal.FieldTotalTokens:
  38704. return m.TotalTokens()
  38705. case usagetotal.FieldStartIndex:
  38706. return m.StartIndex()
  38707. case usagetotal.FieldEndIndex:
  38708. return m.EndIndex()
  38709. case usagetotal.FieldOrganizationID:
  38710. return m.OrganizationID()
  38711. }
  38712. return nil, false
  38713. }
  38714. // OldField returns the old value of the field from the database. An error is
  38715. // returned if the mutation operation is not UpdateOne, or the query to the
  38716. // database failed.
  38717. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38718. switch name {
  38719. case usagetotal.FieldCreatedAt:
  38720. return m.OldCreatedAt(ctx)
  38721. case usagetotal.FieldUpdatedAt:
  38722. return m.OldUpdatedAt(ctx)
  38723. case usagetotal.FieldStatus:
  38724. return m.OldStatus(ctx)
  38725. case usagetotal.FieldType:
  38726. return m.OldType(ctx)
  38727. case usagetotal.FieldBotID:
  38728. return m.OldBotID(ctx)
  38729. case usagetotal.FieldTotalTokens:
  38730. return m.OldTotalTokens(ctx)
  38731. case usagetotal.FieldStartIndex:
  38732. return m.OldStartIndex(ctx)
  38733. case usagetotal.FieldEndIndex:
  38734. return m.OldEndIndex(ctx)
  38735. case usagetotal.FieldOrganizationID:
  38736. return m.OldOrganizationID(ctx)
  38737. }
  38738. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  38739. }
  38740. // SetField sets the value of a field with the given name. It returns an error if
  38741. // the field is not defined in the schema, or if the type mismatched the field
  38742. // type.
  38743. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  38744. switch name {
  38745. case usagetotal.FieldCreatedAt:
  38746. v, ok := value.(time.Time)
  38747. if !ok {
  38748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38749. }
  38750. m.SetCreatedAt(v)
  38751. return nil
  38752. case usagetotal.FieldUpdatedAt:
  38753. v, ok := value.(time.Time)
  38754. if !ok {
  38755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38756. }
  38757. m.SetUpdatedAt(v)
  38758. return nil
  38759. case usagetotal.FieldStatus:
  38760. v, ok := value.(uint8)
  38761. if !ok {
  38762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38763. }
  38764. m.SetStatus(v)
  38765. return nil
  38766. case usagetotal.FieldType:
  38767. v, ok := value.(int)
  38768. if !ok {
  38769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38770. }
  38771. m.SetType(v)
  38772. return nil
  38773. case usagetotal.FieldBotID:
  38774. v, ok := value.(string)
  38775. if !ok {
  38776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38777. }
  38778. m.SetBotID(v)
  38779. return nil
  38780. case usagetotal.FieldTotalTokens:
  38781. v, ok := value.(uint64)
  38782. if !ok {
  38783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38784. }
  38785. m.SetTotalTokens(v)
  38786. return nil
  38787. case usagetotal.FieldStartIndex:
  38788. v, ok := value.(uint64)
  38789. if !ok {
  38790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38791. }
  38792. m.SetStartIndex(v)
  38793. return nil
  38794. case usagetotal.FieldEndIndex:
  38795. v, ok := value.(uint64)
  38796. if !ok {
  38797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38798. }
  38799. m.SetEndIndex(v)
  38800. return nil
  38801. case usagetotal.FieldOrganizationID:
  38802. v, ok := value.(uint64)
  38803. if !ok {
  38804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38805. }
  38806. m.SetOrganizationID(v)
  38807. return nil
  38808. }
  38809. return fmt.Errorf("unknown UsageTotal field %s", name)
  38810. }
  38811. // AddedFields returns all numeric fields that were incremented/decremented during
  38812. // this mutation.
  38813. func (m *UsageTotalMutation) AddedFields() []string {
  38814. var fields []string
  38815. if m.addstatus != nil {
  38816. fields = append(fields, usagetotal.FieldStatus)
  38817. }
  38818. if m.add_type != nil {
  38819. fields = append(fields, usagetotal.FieldType)
  38820. }
  38821. if m.addtotal_tokens != nil {
  38822. fields = append(fields, usagetotal.FieldTotalTokens)
  38823. }
  38824. if m.addstart_index != nil {
  38825. fields = append(fields, usagetotal.FieldStartIndex)
  38826. }
  38827. if m.addend_index != nil {
  38828. fields = append(fields, usagetotal.FieldEndIndex)
  38829. }
  38830. if m.addorganization_id != nil {
  38831. fields = append(fields, usagetotal.FieldOrganizationID)
  38832. }
  38833. return fields
  38834. }
  38835. // AddedField returns the numeric value that was incremented/decremented on a field
  38836. // with the given name. The second boolean return value indicates that this field
  38837. // was not set, or was not defined in the schema.
  38838. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  38839. switch name {
  38840. case usagetotal.FieldStatus:
  38841. return m.AddedStatus()
  38842. case usagetotal.FieldType:
  38843. return m.AddedType()
  38844. case usagetotal.FieldTotalTokens:
  38845. return m.AddedTotalTokens()
  38846. case usagetotal.FieldStartIndex:
  38847. return m.AddedStartIndex()
  38848. case usagetotal.FieldEndIndex:
  38849. return m.AddedEndIndex()
  38850. case usagetotal.FieldOrganizationID:
  38851. return m.AddedOrganizationID()
  38852. }
  38853. return nil, false
  38854. }
  38855. // AddField adds the value to the field with the given name. It returns an error if
  38856. // the field is not defined in the schema, or if the type mismatched the field
  38857. // type.
  38858. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  38859. switch name {
  38860. case usagetotal.FieldStatus:
  38861. v, ok := value.(int8)
  38862. if !ok {
  38863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38864. }
  38865. m.AddStatus(v)
  38866. return nil
  38867. case usagetotal.FieldType:
  38868. v, ok := value.(int)
  38869. if !ok {
  38870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38871. }
  38872. m.AddType(v)
  38873. return nil
  38874. case usagetotal.FieldTotalTokens:
  38875. v, ok := value.(int64)
  38876. if !ok {
  38877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38878. }
  38879. m.AddTotalTokens(v)
  38880. return nil
  38881. case usagetotal.FieldStartIndex:
  38882. v, ok := value.(int64)
  38883. if !ok {
  38884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38885. }
  38886. m.AddStartIndex(v)
  38887. return nil
  38888. case usagetotal.FieldEndIndex:
  38889. v, ok := value.(int64)
  38890. if !ok {
  38891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38892. }
  38893. m.AddEndIndex(v)
  38894. return nil
  38895. case usagetotal.FieldOrganizationID:
  38896. v, ok := value.(int64)
  38897. if !ok {
  38898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38899. }
  38900. m.AddOrganizationID(v)
  38901. return nil
  38902. }
  38903. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  38904. }
  38905. // ClearedFields returns all nullable fields that were cleared during this
  38906. // mutation.
  38907. func (m *UsageTotalMutation) ClearedFields() []string {
  38908. var fields []string
  38909. if m.FieldCleared(usagetotal.FieldStatus) {
  38910. fields = append(fields, usagetotal.FieldStatus)
  38911. }
  38912. if m.FieldCleared(usagetotal.FieldType) {
  38913. fields = append(fields, usagetotal.FieldType)
  38914. }
  38915. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  38916. fields = append(fields, usagetotal.FieldTotalTokens)
  38917. }
  38918. if m.FieldCleared(usagetotal.FieldStartIndex) {
  38919. fields = append(fields, usagetotal.FieldStartIndex)
  38920. }
  38921. if m.FieldCleared(usagetotal.FieldEndIndex) {
  38922. fields = append(fields, usagetotal.FieldEndIndex)
  38923. }
  38924. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  38925. fields = append(fields, usagetotal.FieldOrganizationID)
  38926. }
  38927. return fields
  38928. }
  38929. // FieldCleared returns a boolean indicating if a field with the given name was
  38930. // cleared in this mutation.
  38931. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  38932. _, ok := m.clearedFields[name]
  38933. return ok
  38934. }
  38935. // ClearField clears the value of the field with the given name. It returns an
  38936. // error if the field is not defined in the schema.
  38937. func (m *UsageTotalMutation) ClearField(name string) error {
  38938. switch name {
  38939. case usagetotal.FieldStatus:
  38940. m.ClearStatus()
  38941. return nil
  38942. case usagetotal.FieldType:
  38943. m.ClearType()
  38944. return nil
  38945. case usagetotal.FieldTotalTokens:
  38946. m.ClearTotalTokens()
  38947. return nil
  38948. case usagetotal.FieldStartIndex:
  38949. m.ClearStartIndex()
  38950. return nil
  38951. case usagetotal.FieldEndIndex:
  38952. m.ClearEndIndex()
  38953. return nil
  38954. case usagetotal.FieldOrganizationID:
  38955. m.ClearOrganizationID()
  38956. return nil
  38957. }
  38958. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  38959. }
  38960. // ResetField resets all changes in the mutation for the field with the given name.
  38961. // It returns an error if the field is not defined in the schema.
  38962. func (m *UsageTotalMutation) ResetField(name string) error {
  38963. switch name {
  38964. case usagetotal.FieldCreatedAt:
  38965. m.ResetCreatedAt()
  38966. return nil
  38967. case usagetotal.FieldUpdatedAt:
  38968. m.ResetUpdatedAt()
  38969. return nil
  38970. case usagetotal.FieldStatus:
  38971. m.ResetStatus()
  38972. return nil
  38973. case usagetotal.FieldType:
  38974. m.ResetType()
  38975. return nil
  38976. case usagetotal.FieldBotID:
  38977. m.ResetBotID()
  38978. return nil
  38979. case usagetotal.FieldTotalTokens:
  38980. m.ResetTotalTokens()
  38981. return nil
  38982. case usagetotal.FieldStartIndex:
  38983. m.ResetStartIndex()
  38984. return nil
  38985. case usagetotal.FieldEndIndex:
  38986. m.ResetEndIndex()
  38987. return nil
  38988. case usagetotal.FieldOrganizationID:
  38989. m.ResetOrganizationID()
  38990. return nil
  38991. }
  38992. return fmt.Errorf("unknown UsageTotal field %s", name)
  38993. }
  38994. // AddedEdges returns all edge names that were set/added in this mutation.
  38995. func (m *UsageTotalMutation) AddedEdges() []string {
  38996. edges := make([]string, 0, 0)
  38997. return edges
  38998. }
  38999. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39000. // name in this mutation.
  39001. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  39002. return nil
  39003. }
  39004. // RemovedEdges returns all edge names that were removed in this mutation.
  39005. func (m *UsageTotalMutation) RemovedEdges() []string {
  39006. edges := make([]string, 0, 0)
  39007. return edges
  39008. }
  39009. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39010. // the given name in this mutation.
  39011. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  39012. return nil
  39013. }
  39014. // ClearedEdges returns all edge names that were cleared in this mutation.
  39015. func (m *UsageTotalMutation) ClearedEdges() []string {
  39016. edges := make([]string, 0, 0)
  39017. return edges
  39018. }
  39019. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39020. // was cleared in this mutation.
  39021. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  39022. return false
  39023. }
  39024. // ClearEdge clears the value of the edge with the given name. It returns an error
  39025. // if that edge is not defined in the schema.
  39026. func (m *UsageTotalMutation) ClearEdge(name string) error {
  39027. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  39028. }
  39029. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39030. // It returns an error if the edge is not defined in the schema.
  39031. func (m *UsageTotalMutation) ResetEdge(name string) error {
  39032. return fmt.Errorf("unknown UsageTotal edge %s", name)
  39033. }
  39034. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  39035. type WhatsappMutation struct {
  39036. config
  39037. op Op
  39038. typ string
  39039. id *uint64
  39040. created_at *time.Time
  39041. updated_at *time.Time
  39042. status *uint8
  39043. addstatus *int8
  39044. deleted_at *time.Time
  39045. wa_id *string
  39046. wa_name *string
  39047. callback *string
  39048. account *string
  39049. cc *string
  39050. phone *string
  39051. cc_phone *string
  39052. phone_name *string
  39053. phone_status *int8
  39054. addphone_status *int8
  39055. organization_id *uint64
  39056. addorganization_id *int64
  39057. api_base *string
  39058. api_key *string
  39059. allow_list *[]string
  39060. appendallow_list []string
  39061. group_allow_list *[]string
  39062. appendgroup_allow_list []string
  39063. block_list *[]string
  39064. appendblock_list []string
  39065. group_block_list *[]string
  39066. appendgroup_block_list []string
  39067. clearedFields map[string]struct{}
  39068. agent *uint64
  39069. clearedagent bool
  39070. done bool
  39071. oldValue func(context.Context) (*Whatsapp, error)
  39072. predicates []predicate.Whatsapp
  39073. }
  39074. var _ ent.Mutation = (*WhatsappMutation)(nil)
  39075. // whatsappOption allows management of the mutation configuration using functional options.
  39076. type whatsappOption func(*WhatsappMutation)
  39077. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  39078. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  39079. m := &WhatsappMutation{
  39080. config: c,
  39081. op: op,
  39082. typ: TypeWhatsapp,
  39083. clearedFields: make(map[string]struct{}),
  39084. }
  39085. for _, opt := range opts {
  39086. opt(m)
  39087. }
  39088. return m
  39089. }
  39090. // withWhatsappID sets the ID field of the mutation.
  39091. func withWhatsappID(id uint64) whatsappOption {
  39092. return func(m *WhatsappMutation) {
  39093. var (
  39094. err error
  39095. once sync.Once
  39096. value *Whatsapp
  39097. )
  39098. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  39099. once.Do(func() {
  39100. if m.done {
  39101. err = errors.New("querying old values post mutation is not allowed")
  39102. } else {
  39103. value, err = m.Client().Whatsapp.Get(ctx, id)
  39104. }
  39105. })
  39106. return value, err
  39107. }
  39108. m.id = &id
  39109. }
  39110. }
  39111. // withWhatsapp sets the old Whatsapp of the mutation.
  39112. func withWhatsapp(node *Whatsapp) whatsappOption {
  39113. return func(m *WhatsappMutation) {
  39114. m.oldValue = func(context.Context) (*Whatsapp, error) {
  39115. return node, nil
  39116. }
  39117. m.id = &node.ID
  39118. }
  39119. }
  39120. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39121. // executed in a transaction (ent.Tx), a transactional client is returned.
  39122. func (m WhatsappMutation) Client() *Client {
  39123. client := &Client{config: m.config}
  39124. client.init()
  39125. return client
  39126. }
  39127. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39128. // it returns an error otherwise.
  39129. func (m WhatsappMutation) Tx() (*Tx, error) {
  39130. if _, ok := m.driver.(*txDriver); !ok {
  39131. return nil, errors.New("ent: mutation is not running in a transaction")
  39132. }
  39133. tx := &Tx{config: m.config}
  39134. tx.init()
  39135. return tx, nil
  39136. }
  39137. // SetID sets the value of the id field. Note that this
  39138. // operation is only accepted on creation of Whatsapp entities.
  39139. func (m *WhatsappMutation) SetID(id uint64) {
  39140. m.id = &id
  39141. }
  39142. // ID returns the ID value in the mutation. Note that the ID is only available
  39143. // if it was provided to the builder or after it was returned from the database.
  39144. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  39145. if m.id == nil {
  39146. return
  39147. }
  39148. return *m.id, true
  39149. }
  39150. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39151. // That means, if the mutation is applied within a transaction with an isolation level such
  39152. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39153. // or updated by the mutation.
  39154. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  39155. switch {
  39156. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39157. id, exists := m.ID()
  39158. if exists {
  39159. return []uint64{id}, nil
  39160. }
  39161. fallthrough
  39162. case m.op.Is(OpUpdate | OpDelete):
  39163. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  39164. default:
  39165. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39166. }
  39167. }
  39168. // SetCreatedAt sets the "created_at" field.
  39169. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  39170. m.created_at = &t
  39171. }
  39172. // CreatedAt returns the value of the "created_at" field in the mutation.
  39173. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  39174. v := m.created_at
  39175. if v == nil {
  39176. return
  39177. }
  39178. return *v, true
  39179. }
  39180. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  39181. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39183. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39184. if !m.op.Is(OpUpdateOne) {
  39185. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39186. }
  39187. if m.id == nil || m.oldValue == nil {
  39188. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39189. }
  39190. oldValue, err := m.oldValue(ctx)
  39191. if err != nil {
  39192. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39193. }
  39194. return oldValue.CreatedAt, nil
  39195. }
  39196. // ResetCreatedAt resets all changes to the "created_at" field.
  39197. func (m *WhatsappMutation) ResetCreatedAt() {
  39198. m.created_at = nil
  39199. }
  39200. // SetUpdatedAt sets the "updated_at" field.
  39201. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  39202. m.updated_at = &t
  39203. }
  39204. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39205. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  39206. v := m.updated_at
  39207. if v == nil {
  39208. return
  39209. }
  39210. return *v, true
  39211. }
  39212. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  39213. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39215. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39216. if !m.op.Is(OpUpdateOne) {
  39217. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39218. }
  39219. if m.id == nil || m.oldValue == nil {
  39220. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39221. }
  39222. oldValue, err := m.oldValue(ctx)
  39223. if err != nil {
  39224. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39225. }
  39226. return oldValue.UpdatedAt, nil
  39227. }
  39228. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39229. func (m *WhatsappMutation) ResetUpdatedAt() {
  39230. m.updated_at = nil
  39231. }
  39232. // SetStatus sets the "status" field.
  39233. func (m *WhatsappMutation) SetStatus(u uint8) {
  39234. m.status = &u
  39235. m.addstatus = nil
  39236. }
  39237. // Status returns the value of the "status" field in the mutation.
  39238. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  39239. v := m.status
  39240. if v == nil {
  39241. return
  39242. }
  39243. return *v, true
  39244. }
  39245. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  39246. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39248. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39249. if !m.op.Is(OpUpdateOne) {
  39250. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39251. }
  39252. if m.id == nil || m.oldValue == nil {
  39253. return v, errors.New("OldStatus requires an ID field in the mutation")
  39254. }
  39255. oldValue, err := m.oldValue(ctx)
  39256. if err != nil {
  39257. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39258. }
  39259. return oldValue.Status, nil
  39260. }
  39261. // AddStatus adds u to the "status" field.
  39262. func (m *WhatsappMutation) AddStatus(u int8) {
  39263. if m.addstatus != nil {
  39264. *m.addstatus += u
  39265. } else {
  39266. m.addstatus = &u
  39267. }
  39268. }
  39269. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39270. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  39271. v := m.addstatus
  39272. if v == nil {
  39273. return
  39274. }
  39275. return *v, true
  39276. }
  39277. // ClearStatus clears the value of the "status" field.
  39278. func (m *WhatsappMutation) ClearStatus() {
  39279. m.status = nil
  39280. m.addstatus = nil
  39281. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  39282. }
  39283. // StatusCleared returns if the "status" field was cleared in this mutation.
  39284. func (m *WhatsappMutation) StatusCleared() bool {
  39285. _, ok := m.clearedFields[whatsapp.FieldStatus]
  39286. return ok
  39287. }
  39288. // ResetStatus resets all changes to the "status" field.
  39289. func (m *WhatsappMutation) ResetStatus() {
  39290. m.status = nil
  39291. m.addstatus = nil
  39292. delete(m.clearedFields, whatsapp.FieldStatus)
  39293. }
  39294. // SetDeletedAt sets the "deleted_at" field.
  39295. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  39296. m.deleted_at = &t
  39297. }
  39298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39299. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  39300. v := m.deleted_at
  39301. if v == nil {
  39302. return
  39303. }
  39304. return *v, true
  39305. }
  39306. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  39307. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39309. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39310. if !m.op.Is(OpUpdateOne) {
  39311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39312. }
  39313. if m.id == nil || m.oldValue == nil {
  39314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39315. }
  39316. oldValue, err := m.oldValue(ctx)
  39317. if err != nil {
  39318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39319. }
  39320. return oldValue.DeletedAt, nil
  39321. }
  39322. // ClearDeletedAt clears the value of the "deleted_at" field.
  39323. func (m *WhatsappMutation) ClearDeletedAt() {
  39324. m.deleted_at = nil
  39325. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  39326. }
  39327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39328. func (m *WhatsappMutation) DeletedAtCleared() bool {
  39329. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  39330. return ok
  39331. }
  39332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39333. func (m *WhatsappMutation) ResetDeletedAt() {
  39334. m.deleted_at = nil
  39335. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  39336. }
  39337. // SetWaID sets the "wa_id" field.
  39338. func (m *WhatsappMutation) SetWaID(s string) {
  39339. m.wa_id = &s
  39340. }
  39341. // WaID returns the value of the "wa_id" field in the mutation.
  39342. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  39343. v := m.wa_id
  39344. if v == nil {
  39345. return
  39346. }
  39347. return *v, true
  39348. }
  39349. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  39350. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39352. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  39353. if !m.op.Is(OpUpdateOne) {
  39354. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39355. }
  39356. if m.id == nil || m.oldValue == nil {
  39357. return v, errors.New("OldWaID requires an ID field in the mutation")
  39358. }
  39359. oldValue, err := m.oldValue(ctx)
  39360. if err != nil {
  39361. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39362. }
  39363. return oldValue.WaID, nil
  39364. }
  39365. // ClearWaID clears the value of the "wa_id" field.
  39366. func (m *WhatsappMutation) ClearWaID() {
  39367. m.wa_id = nil
  39368. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  39369. }
  39370. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39371. func (m *WhatsappMutation) WaIDCleared() bool {
  39372. _, ok := m.clearedFields[whatsapp.FieldWaID]
  39373. return ok
  39374. }
  39375. // ResetWaID resets all changes to the "wa_id" field.
  39376. func (m *WhatsappMutation) ResetWaID() {
  39377. m.wa_id = nil
  39378. delete(m.clearedFields, whatsapp.FieldWaID)
  39379. }
  39380. // SetWaName sets the "wa_name" field.
  39381. func (m *WhatsappMutation) SetWaName(s string) {
  39382. m.wa_name = &s
  39383. }
  39384. // WaName returns the value of the "wa_name" field in the mutation.
  39385. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  39386. v := m.wa_name
  39387. if v == nil {
  39388. return
  39389. }
  39390. return *v, true
  39391. }
  39392. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  39393. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39395. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  39396. if !m.op.Is(OpUpdateOne) {
  39397. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  39398. }
  39399. if m.id == nil || m.oldValue == nil {
  39400. return v, errors.New("OldWaName requires an ID field in the mutation")
  39401. }
  39402. oldValue, err := m.oldValue(ctx)
  39403. if err != nil {
  39404. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  39405. }
  39406. return oldValue.WaName, nil
  39407. }
  39408. // ClearWaName clears the value of the "wa_name" field.
  39409. func (m *WhatsappMutation) ClearWaName() {
  39410. m.wa_name = nil
  39411. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  39412. }
  39413. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  39414. func (m *WhatsappMutation) WaNameCleared() bool {
  39415. _, ok := m.clearedFields[whatsapp.FieldWaName]
  39416. return ok
  39417. }
  39418. // ResetWaName resets all changes to the "wa_name" field.
  39419. func (m *WhatsappMutation) ResetWaName() {
  39420. m.wa_name = nil
  39421. delete(m.clearedFields, whatsapp.FieldWaName)
  39422. }
  39423. // SetCallback sets the "callback" field.
  39424. func (m *WhatsappMutation) SetCallback(s string) {
  39425. m.callback = &s
  39426. }
  39427. // Callback returns the value of the "callback" field in the mutation.
  39428. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  39429. v := m.callback
  39430. if v == nil {
  39431. return
  39432. }
  39433. return *v, true
  39434. }
  39435. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  39436. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39438. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  39439. if !m.op.Is(OpUpdateOne) {
  39440. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  39441. }
  39442. if m.id == nil || m.oldValue == nil {
  39443. return v, errors.New("OldCallback requires an ID field in the mutation")
  39444. }
  39445. oldValue, err := m.oldValue(ctx)
  39446. if err != nil {
  39447. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  39448. }
  39449. return oldValue.Callback, nil
  39450. }
  39451. // ClearCallback clears the value of the "callback" field.
  39452. func (m *WhatsappMutation) ClearCallback() {
  39453. m.callback = nil
  39454. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  39455. }
  39456. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  39457. func (m *WhatsappMutation) CallbackCleared() bool {
  39458. _, ok := m.clearedFields[whatsapp.FieldCallback]
  39459. return ok
  39460. }
  39461. // ResetCallback resets all changes to the "callback" field.
  39462. func (m *WhatsappMutation) ResetCallback() {
  39463. m.callback = nil
  39464. delete(m.clearedFields, whatsapp.FieldCallback)
  39465. }
  39466. // SetAgentID sets the "agent_id" field.
  39467. func (m *WhatsappMutation) SetAgentID(u uint64) {
  39468. m.agent = &u
  39469. }
  39470. // AgentID returns the value of the "agent_id" field in the mutation.
  39471. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  39472. v := m.agent
  39473. if v == nil {
  39474. return
  39475. }
  39476. return *v, true
  39477. }
  39478. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  39479. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39481. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  39482. if !m.op.Is(OpUpdateOne) {
  39483. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  39484. }
  39485. if m.id == nil || m.oldValue == nil {
  39486. return v, errors.New("OldAgentID requires an ID field in the mutation")
  39487. }
  39488. oldValue, err := m.oldValue(ctx)
  39489. if err != nil {
  39490. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  39491. }
  39492. return oldValue.AgentID, nil
  39493. }
  39494. // ResetAgentID resets all changes to the "agent_id" field.
  39495. func (m *WhatsappMutation) ResetAgentID() {
  39496. m.agent = nil
  39497. }
  39498. // SetAccount sets the "account" field.
  39499. func (m *WhatsappMutation) SetAccount(s string) {
  39500. m.account = &s
  39501. }
  39502. // Account returns the value of the "account" field in the mutation.
  39503. func (m *WhatsappMutation) Account() (r string, exists bool) {
  39504. v := m.account
  39505. if v == nil {
  39506. return
  39507. }
  39508. return *v, true
  39509. }
  39510. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  39511. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39513. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  39514. if !m.op.Is(OpUpdateOne) {
  39515. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39516. }
  39517. if m.id == nil || m.oldValue == nil {
  39518. return v, errors.New("OldAccount requires an ID field in the mutation")
  39519. }
  39520. oldValue, err := m.oldValue(ctx)
  39521. if err != nil {
  39522. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39523. }
  39524. return oldValue.Account, nil
  39525. }
  39526. // ClearAccount clears the value of the "account" field.
  39527. func (m *WhatsappMutation) ClearAccount() {
  39528. m.account = nil
  39529. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  39530. }
  39531. // AccountCleared returns if the "account" field was cleared in this mutation.
  39532. func (m *WhatsappMutation) AccountCleared() bool {
  39533. _, ok := m.clearedFields[whatsapp.FieldAccount]
  39534. return ok
  39535. }
  39536. // ResetAccount resets all changes to the "account" field.
  39537. func (m *WhatsappMutation) ResetAccount() {
  39538. m.account = nil
  39539. delete(m.clearedFields, whatsapp.FieldAccount)
  39540. }
  39541. // SetCc sets the "cc" field.
  39542. func (m *WhatsappMutation) SetCc(s string) {
  39543. m.cc = &s
  39544. }
  39545. // Cc returns the value of the "cc" field in the mutation.
  39546. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  39547. v := m.cc
  39548. if v == nil {
  39549. return
  39550. }
  39551. return *v, true
  39552. }
  39553. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  39554. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39556. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  39557. if !m.op.Is(OpUpdateOne) {
  39558. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  39559. }
  39560. if m.id == nil || m.oldValue == nil {
  39561. return v, errors.New("OldCc requires an ID field in the mutation")
  39562. }
  39563. oldValue, err := m.oldValue(ctx)
  39564. if err != nil {
  39565. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  39566. }
  39567. return oldValue.Cc, nil
  39568. }
  39569. // ResetCc resets all changes to the "cc" field.
  39570. func (m *WhatsappMutation) ResetCc() {
  39571. m.cc = nil
  39572. }
  39573. // SetPhone sets the "phone" field.
  39574. func (m *WhatsappMutation) SetPhone(s string) {
  39575. m.phone = &s
  39576. }
  39577. // Phone returns the value of the "phone" field in the mutation.
  39578. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  39579. v := m.phone
  39580. if v == nil {
  39581. return
  39582. }
  39583. return *v, true
  39584. }
  39585. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  39586. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39588. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  39589. if !m.op.Is(OpUpdateOne) {
  39590. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39591. }
  39592. if m.id == nil || m.oldValue == nil {
  39593. return v, errors.New("OldPhone requires an ID field in the mutation")
  39594. }
  39595. oldValue, err := m.oldValue(ctx)
  39596. if err != nil {
  39597. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39598. }
  39599. return oldValue.Phone, nil
  39600. }
  39601. // ResetPhone resets all changes to the "phone" field.
  39602. func (m *WhatsappMutation) ResetPhone() {
  39603. m.phone = nil
  39604. }
  39605. // SetCcPhone sets the "cc_phone" field.
  39606. func (m *WhatsappMutation) SetCcPhone(s string) {
  39607. m.cc_phone = &s
  39608. }
  39609. // CcPhone returns the value of the "cc_phone" field in the mutation.
  39610. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  39611. v := m.cc_phone
  39612. if v == nil {
  39613. return
  39614. }
  39615. return *v, true
  39616. }
  39617. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  39618. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39620. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  39621. if !m.op.Is(OpUpdateOne) {
  39622. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  39623. }
  39624. if m.id == nil || m.oldValue == nil {
  39625. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  39626. }
  39627. oldValue, err := m.oldValue(ctx)
  39628. if err != nil {
  39629. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  39630. }
  39631. return oldValue.CcPhone, nil
  39632. }
  39633. // ResetCcPhone resets all changes to the "cc_phone" field.
  39634. func (m *WhatsappMutation) ResetCcPhone() {
  39635. m.cc_phone = nil
  39636. }
  39637. // SetPhoneName sets the "phone_name" field.
  39638. func (m *WhatsappMutation) SetPhoneName(s string) {
  39639. m.phone_name = &s
  39640. }
  39641. // PhoneName returns the value of the "phone_name" field in the mutation.
  39642. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  39643. v := m.phone_name
  39644. if v == nil {
  39645. return
  39646. }
  39647. return *v, true
  39648. }
  39649. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  39650. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39652. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  39653. if !m.op.Is(OpUpdateOne) {
  39654. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  39655. }
  39656. if m.id == nil || m.oldValue == nil {
  39657. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  39658. }
  39659. oldValue, err := m.oldValue(ctx)
  39660. if err != nil {
  39661. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  39662. }
  39663. return oldValue.PhoneName, nil
  39664. }
  39665. // ResetPhoneName resets all changes to the "phone_name" field.
  39666. func (m *WhatsappMutation) ResetPhoneName() {
  39667. m.phone_name = nil
  39668. }
  39669. // SetPhoneStatus sets the "phone_status" field.
  39670. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  39671. m.phone_status = &i
  39672. m.addphone_status = nil
  39673. }
  39674. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  39675. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  39676. v := m.phone_status
  39677. if v == nil {
  39678. return
  39679. }
  39680. return *v, true
  39681. }
  39682. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  39683. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39685. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  39686. if !m.op.Is(OpUpdateOne) {
  39687. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  39688. }
  39689. if m.id == nil || m.oldValue == nil {
  39690. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  39691. }
  39692. oldValue, err := m.oldValue(ctx)
  39693. if err != nil {
  39694. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  39695. }
  39696. return oldValue.PhoneStatus, nil
  39697. }
  39698. // AddPhoneStatus adds i to the "phone_status" field.
  39699. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  39700. if m.addphone_status != nil {
  39701. *m.addphone_status += i
  39702. } else {
  39703. m.addphone_status = &i
  39704. }
  39705. }
  39706. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  39707. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  39708. v := m.addphone_status
  39709. if v == nil {
  39710. return
  39711. }
  39712. return *v, true
  39713. }
  39714. // ResetPhoneStatus resets all changes to the "phone_status" field.
  39715. func (m *WhatsappMutation) ResetPhoneStatus() {
  39716. m.phone_status = nil
  39717. m.addphone_status = nil
  39718. }
  39719. // SetOrganizationID sets the "organization_id" field.
  39720. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  39721. m.organization_id = &u
  39722. m.addorganization_id = nil
  39723. }
  39724. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39725. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  39726. v := m.organization_id
  39727. if v == nil {
  39728. return
  39729. }
  39730. return *v, true
  39731. }
  39732. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  39733. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39735. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39736. if !m.op.Is(OpUpdateOne) {
  39737. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39738. }
  39739. if m.id == nil || m.oldValue == nil {
  39740. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39741. }
  39742. oldValue, err := m.oldValue(ctx)
  39743. if err != nil {
  39744. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39745. }
  39746. return oldValue.OrganizationID, nil
  39747. }
  39748. // AddOrganizationID adds u to the "organization_id" field.
  39749. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  39750. if m.addorganization_id != nil {
  39751. *m.addorganization_id += u
  39752. } else {
  39753. m.addorganization_id = &u
  39754. }
  39755. }
  39756. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39757. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  39758. v := m.addorganization_id
  39759. if v == nil {
  39760. return
  39761. }
  39762. return *v, true
  39763. }
  39764. // ClearOrganizationID clears the value of the "organization_id" field.
  39765. func (m *WhatsappMutation) ClearOrganizationID() {
  39766. m.organization_id = nil
  39767. m.addorganization_id = nil
  39768. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  39769. }
  39770. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39771. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  39772. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  39773. return ok
  39774. }
  39775. // ResetOrganizationID resets all changes to the "organization_id" field.
  39776. func (m *WhatsappMutation) ResetOrganizationID() {
  39777. m.organization_id = nil
  39778. m.addorganization_id = nil
  39779. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  39780. }
  39781. // SetAPIBase sets the "api_base" field.
  39782. func (m *WhatsappMutation) SetAPIBase(s string) {
  39783. m.api_base = &s
  39784. }
  39785. // APIBase returns the value of the "api_base" field in the mutation.
  39786. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  39787. v := m.api_base
  39788. if v == nil {
  39789. return
  39790. }
  39791. return *v, true
  39792. }
  39793. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  39794. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39796. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39797. if !m.op.Is(OpUpdateOne) {
  39798. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39799. }
  39800. if m.id == nil || m.oldValue == nil {
  39801. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39802. }
  39803. oldValue, err := m.oldValue(ctx)
  39804. if err != nil {
  39805. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39806. }
  39807. return oldValue.APIBase, nil
  39808. }
  39809. // ClearAPIBase clears the value of the "api_base" field.
  39810. func (m *WhatsappMutation) ClearAPIBase() {
  39811. m.api_base = nil
  39812. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  39813. }
  39814. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39815. func (m *WhatsappMutation) APIBaseCleared() bool {
  39816. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  39817. return ok
  39818. }
  39819. // ResetAPIBase resets all changes to the "api_base" field.
  39820. func (m *WhatsappMutation) ResetAPIBase() {
  39821. m.api_base = nil
  39822. delete(m.clearedFields, whatsapp.FieldAPIBase)
  39823. }
  39824. // SetAPIKey sets the "api_key" field.
  39825. func (m *WhatsappMutation) SetAPIKey(s string) {
  39826. m.api_key = &s
  39827. }
  39828. // APIKey returns the value of the "api_key" field in the mutation.
  39829. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  39830. v := m.api_key
  39831. if v == nil {
  39832. return
  39833. }
  39834. return *v, true
  39835. }
  39836. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  39837. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39839. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39840. if !m.op.Is(OpUpdateOne) {
  39841. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39842. }
  39843. if m.id == nil || m.oldValue == nil {
  39844. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39845. }
  39846. oldValue, err := m.oldValue(ctx)
  39847. if err != nil {
  39848. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39849. }
  39850. return oldValue.APIKey, nil
  39851. }
  39852. // ClearAPIKey clears the value of the "api_key" field.
  39853. func (m *WhatsappMutation) ClearAPIKey() {
  39854. m.api_key = nil
  39855. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  39856. }
  39857. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39858. func (m *WhatsappMutation) APIKeyCleared() bool {
  39859. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  39860. return ok
  39861. }
  39862. // ResetAPIKey resets all changes to the "api_key" field.
  39863. func (m *WhatsappMutation) ResetAPIKey() {
  39864. m.api_key = nil
  39865. delete(m.clearedFields, whatsapp.FieldAPIKey)
  39866. }
  39867. // SetAllowList sets the "allow_list" field.
  39868. func (m *WhatsappMutation) SetAllowList(s []string) {
  39869. m.allow_list = &s
  39870. m.appendallow_list = nil
  39871. }
  39872. // AllowList returns the value of the "allow_list" field in the mutation.
  39873. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  39874. v := m.allow_list
  39875. if v == nil {
  39876. return
  39877. }
  39878. return *v, true
  39879. }
  39880. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  39881. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39883. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  39884. if !m.op.Is(OpUpdateOne) {
  39885. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  39886. }
  39887. if m.id == nil || m.oldValue == nil {
  39888. return v, errors.New("OldAllowList requires an ID field in the mutation")
  39889. }
  39890. oldValue, err := m.oldValue(ctx)
  39891. if err != nil {
  39892. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  39893. }
  39894. return oldValue.AllowList, nil
  39895. }
  39896. // AppendAllowList adds s to the "allow_list" field.
  39897. func (m *WhatsappMutation) AppendAllowList(s []string) {
  39898. m.appendallow_list = append(m.appendallow_list, s...)
  39899. }
  39900. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  39901. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  39902. if len(m.appendallow_list) == 0 {
  39903. return nil, false
  39904. }
  39905. return m.appendallow_list, true
  39906. }
  39907. // ClearAllowList clears the value of the "allow_list" field.
  39908. func (m *WhatsappMutation) ClearAllowList() {
  39909. m.allow_list = nil
  39910. m.appendallow_list = nil
  39911. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  39912. }
  39913. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  39914. func (m *WhatsappMutation) AllowListCleared() bool {
  39915. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  39916. return ok
  39917. }
  39918. // ResetAllowList resets all changes to the "allow_list" field.
  39919. func (m *WhatsappMutation) ResetAllowList() {
  39920. m.allow_list = nil
  39921. m.appendallow_list = nil
  39922. delete(m.clearedFields, whatsapp.FieldAllowList)
  39923. }
  39924. // SetGroupAllowList sets the "group_allow_list" field.
  39925. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  39926. m.group_allow_list = &s
  39927. m.appendgroup_allow_list = nil
  39928. }
  39929. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  39930. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  39931. v := m.group_allow_list
  39932. if v == nil {
  39933. return
  39934. }
  39935. return *v, true
  39936. }
  39937. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  39938. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39940. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  39941. if !m.op.Is(OpUpdateOne) {
  39942. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  39943. }
  39944. if m.id == nil || m.oldValue == nil {
  39945. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  39946. }
  39947. oldValue, err := m.oldValue(ctx)
  39948. if err != nil {
  39949. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  39950. }
  39951. return oldValue.GroupAllowList, nil
  39952. }
  39953. // AppendGroupAllowList adds s to the "group_allow_list" field.
  39954. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  39955. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  39956. }
  39957. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  39958. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  39959. if len(m.appendgroup_allow_list) == 0 {
  39960. return nil, false
  39961. }
  39962. return m.appendgroup_allow_list, true
  39963. }
  39964. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  39965. func (m *WhatsappMutation) ClearGroupAllowList() {
  39966. m.group_allow_list = nil
  39967. m.appendgroup_allow_list = nil
  39968. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  39969. }
  39970. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  39971. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  39972. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  39973. return ok
  39974. }
  39975. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  39976. func (m *WhatsappMutation) ResetGroupAllowList() {
  39977. m.group_allow_list = nil
  39978. m.appendgroup_allow_list = nil
  39979. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  39980. }
  39981. // SetBlockList sets the "block_list" field.
  39982. func (m *WhatsappMutation) SetBlockList(s []string) {
  39983. m.block_list = &s
  39984. m.appendblock_list = nil
  39985. }
  39986. // BlockList returns the value of the "block_list" field in the mutation.
  39987. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  39988. v := m.block_list
  39989. if v == nil {
  39990. return
  39991. }
  39992. return *v, true
  39993. }
  39994. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  39995. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39997. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  39998. if !m.op.Is(OpUpdateOne) {
  39999. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40000. }
  40001. if m.id == nil || m.oldValue == nil {
  40002. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40003. }
  40004. oldValue, err := m.oldValue(ctx)
  40005. if err != nil {
  40006. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40007. }
  40008. return oldValue.BlockList, nil
  40009. }
  40010. // AppendBlockList adds s to the "block_list" field.
  40011. func (m *WhatsappMutation) AppendBlockList(s []string) {
  40012. m.appendblock_list = append(m.appendblock_list, s...)
  40013. }
  40014. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40015. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  40016. if len(m.appendblock_list) == 0 {
  40017. return nil, false
  40018. }
  40019. return m.appendblock_list, true
  40020. }
  40021. // ClearBlockList clears the value of the "block_list" field.
  40022. func (m *WhatsappMutation) ClearBlockList() {
  40023. m.block_list = nil
  40024. m.appendblock_list = nil
  40025. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  40026. }
  40027. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  40028. func (m *WhatsappMutation) BlockListCleared() bool {
  40029. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  40030. return ok
  40031. }
  40032. // ResetBlockList resets all changes to the "block_list" field.
  40033. func (m *WhatsappMutation) ResetBlockList() {
  40034. m.block_list = nil
  40035. m.appendblock_list = nil
  40036. delete(m.clearedFields, whatsapp.FieldBlockList)
  40037. }
  40038. // SetGroupBlockList sets the "group_block_list" field.
  40039. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  40040. m.group_block_list = &s
  40041. m.appendgroup_block_list = nil
  40042. }
  40043. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40044. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  40045. v := m.group_block_list
  40046. if v == nil {
  40047. return
  40048. }
  40049. return *v, true
  40050. }
  40051. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  40052. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40054. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40055. if !m.op.Is(OpUpdateOne) {
  40056. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40057. }
  40058. if m.id == nil || m.oldValue == nil {
  40059. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40060. }
  40061. oldValue, err := m.oldValue(ctx)
  40062. if err != nil {
  40063. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40064. }
  40065. return oldValue.GroupBlockList, nil
  40066. }
  40067. // AppendGroupBlockList adds s to the "group_block_list" field.
  40068. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  40069. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40070. }
  40071. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40072. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  40073. if len(m.appendgroup_block_list) == 0 {
  40074. return nil, false
  40075. }
  40076. return m.appendgroup_block_list, true
  40077. }
  40078. // ClearGroupBlockList clears the value of the "group_block_list" field.
  40079. func (m *WhatsappMutation) ClearGroupBlockList() {
  40080. m.group_block_list = nil
  40081. m.appendgroup_block_list = nil
  40082. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  40083. }
  40084. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  40085. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  40086. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  40087. return ok
  40088. }
  40089. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40090. func (m *WhatsappMutation) ResetGroupBlockList() {
  40091. m.group_block_list = nil
  40092. m.appendgroup_block_list = nil
  40093. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  40094. }
  40095. // ClearAgent clears the "agent" edge to the Agent entity.
  40096. func (m *WhatsappMutation) ClearAgent() {
  40097. m.clearedagent = true
  40098. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  40099. }
  40100. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40101. func (m *WhatsappMutation) AgentCleared() bool {
  40102. return m.clearedagent
  40103. }
  40104. // AgentIDs returns the "agent" edge IDs in the mutation.
  40105. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40106. // AgentID instead. It exists only for internal usage by the builders.
  40107. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  40108. if id := m.agent; id != nil {
  40109. ids = append(ids, *id)
  40110. }
  40111. return
  40112. }
  40113. // ResetAgent resets all changes to the "agent" edge.
  40114. func (m *WhatsappMutation) ResetAgent() {
  40115. m.agent = nil
  40116. m.clearedagent = false
  40117. }
  40118. // Where appends a list predicates to the WhatsappMutation builder.
  40119. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  40120. m.predicates = append(m.predicates, ps...)
  40121. }
  40122. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  40123. // users can use type-assertion to append predicates that do not depend on any generated package.
  40124. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  40125. p := make([]predicate.Whatsapp, len(ps))
  40126. for i := range ps {
  40127. p[i] = ps[i]
  40128. }
  40129. m.Where(p...)
  40130. }
  40131. // Op returns the operation name.
  40132. func (m *WhatsappMutation) Op() Op {
  40133. return m.op
  40134. }
  40135. // SetOp allows setting the mutation operation.
  40136. func (m *WhatsappMutation) SetOp(op Op) {
  40137. m.op = op
  40138. }
  40139. // Type returns the node type of this mutation (Whatsapp).
  40140. func (m *WhatsappMutation) Type() string {
  40141. return m.typ
  40142. }
  40143. // Fields returns all fields that were changed during this mutation. Note that in
  40144. // order to get all numeric fields that were incremented/decremented, call
  40145. // AddedFields().
  40146. func (m *WhatsappMutation) Fields() []string {
  40147. fields := make([]string, 0, 21)
  40148. if m.created_at != nil {
  40149. fields = append(fields, whatsapp.FieldCreatedAt)
  40150. }
  40151. if m.updated_at != nil {
  40152. fields = append(fields, whatsapp.FieldUpdatedAt)
  40153. }
  40154. if m.status != nil {
  40155. fields = append(fields, whatsapp.FieldStatus)
  40156. }
  40157. if m.deleted_at != nil {
  40158. fields = append(fields, whatsapp.FieldDeletedAt)
  40159. }
  40160. if m.wa_id != nil {
  40161. fields = append(fields, whatsapp.FieldWaID)
  40162. }
  40163. if m.wa_name != nil {
  40164. fields = append(fields, whatsapp.FieldWaName)
  40165. }
  40166. if m.callback != nil {
  40167. fields = append(fields, whatsapp.FieldCallback)
  40168. }
  40169. if m.agent != nil {
  40170. fields = append(fields, whatsapp.FieldAgentID)
  40171. }
  40172. if m.account != nil {
  40173. fields = append(fields, whatsapp.FieldAccount)
  40174. }
  40175. if m.cc != nil {
  40176. fields = append(fields, whatsapp.FieldCc)
  40177. }
  40178. if m.phone != nil {
  40179. fields = append(fields, whatsapp.FieldPhone)
  40180. }
  40181. if m.cc_phone != nil {
  40182. fields = append(fields, whatsapp.FieldCcPhone)
  40183. }
  40184. if m.phone_name != nil {
  40185. fields = append(fields, whatsapp.FieldPhoneName)
  40186. }
  40187. if m.phone_status != nil {
  40188. fields = append(fields, whatsapp.FieldPhoneStatus)
  40189. }
  40190. if m.organization_id != nil {
  40191. fields = append(fields, whatsapp.FieldOrganizationID)
  40192. }
  40193. if m.api_base != nil {
  40194. fields = append(fields, whatsapp.FieldAPIBase)
  40195. }
  40196. if m.api_key != nil {
  40197. fields = append(fields, whatsapp.FieldAPIKey)
  40198. }
  40199. if m.allow_list != nil {
  40200. fields = append(fields, whatsapp.FieldAllowList)
  40201. }
  40202. if m.group_allow_list != nil {
  40203. fields = append(fields, whatsapp.FieldGroupAllowList)
  40204. }
  40205. if m.block_list != nil {
  40206. fields = append(fields, whatsapp.FieldBlockList)
  40207. }
  40208. if m.group_block_list != nil {
  40209. fields = append(fields, whatsapp.FieldGroupBlockList)
  40210. }
  40211. return fields
  40212. }
  40213. // Field returns the value of a field with the given name. The second boolean
  40214. // return value indicates that this field was not set, or was not defined in the
  40215. // schema.
  40216. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  40217. switch name {
  40218. case whatsapp.FieldCreatedAt:
  40219. return m.CreatedAt()
  40220. case whatsapp.FieldUpdatedAt:
  40221. return m.UpdatedAt()
  40222. case whatsapp.FieldStatus:
  40223. return m.Status()
  40224. case whatsapp.FieldDeletedAt:
  40225. return m.DeletedAt()
  40226. case whatsapp.FieldWaID:
  40227. return m.WaID()
  40228. case whatsapp.FieldWaName:
  40229. return m.WaName()
  40230. case whatsapp.FieldCallback:
  40231. return m.Callback()
  40232. case whatsapp.FieldAgentID:
  40233. return m.AgentID()
  40234. case whatsapp.FieldAccount:
  40235. return m.Account()
  40236. case whatsapp.FieldCc:
  40237. return m.Cc()
  40238. case whatsapp.FieldPhone:
  40239. return m.Phone()
  40240. case whatsapp.FieldCcPhone:
  40241. return m.CcPhone()
  40242. case whatsapp.FieldPhoneName:
  40243. return m.PhoneName()
  40244. case whatsapp.FieldPhoneStatus:
  40245. return m.PhoneStatus()
  40246. case whatsapp.FieldOrganizationID:
  40247. return m.OrganizationID()
  40248. case whatsapp.FieldAPIBase:
  40249. return m.APIBase()
  40250. case whatsapp.FieldAPIKey:
  40251. return m.APIKey()
  40252. case whatsapp.FieldAllowList:
  40253. return m.AllowList()
  40254. case whatsapp.FieldGroupAllowList:
  40255. return m.GroupAllowList()
  40256. case whatsapp.FieldBlockList:
  40257. return m.BlockList()
  40258. case whatsapp.FieldGroupBlockList:
  40259. return m.GroupBlockList()
  40260. }
  40261. return nil, false
  40262. }
  40263. // OldField returns the old value of the field from the database. An error is
  40264. // returned if the mutation operation is not UpdateOne, or the query to the
  40265. // database failed.
  40266. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40267. switch name {
  40268. case whatsapp.FieldCreatedAt:
  40269. return m.OldCreatedAt(ctx)
  40270. case whatsapp.FieldUpdatedAt:
  40271. return m.OldUpdatedAt(ctx)
  40272. case whatsapp.FieldStatus:
  40273. return m.OldStatus(ctx)
  40274. case whatsapp.FieldDeletedAt:
  40275. return m.OldDeletedAt(ctx)
  40276. case whatsapp.FieldWaID:
  40277. return m.OldWaID(ctx)
  40278. case whatsapp.FieldWaName:
  40279. return m.OldWaName(ctx)
  40280. case whatsapp.FieldCallback:
  40281. return m.OldCallback(ctx)
  40282. case whatsapp.FieldAgentID:
  40283. return m.OldAgentID(ctx)
  40284. case whatsapp.FieldAccount:
  40285. return m.OldAccount(ctx)
  40286. case whatsapp.FieldCc:
  40287. return m.OldCc(ctx)
  40288. case whatsapp.FieldPhone:
  40289. return m.OldPhone(ctx)
  40290. case whatsapp.FieldCcPhone:
  40291. return m.OldCcPhone(ctx)
  40292. case whatsapp.FieldPhoneName:
  40293. return m.OldPhoneName(ctx)
  40294. case whatsapp.FieldPhoneStatus:
  40295. return m.OldPhoneStatus(ctx)
  40296. case whatsapp.FieldOrganizationID:
  40297. return m.OldOrganizationID(ctx)
  40298. case whatsapp.FieldAPIBase:
  40299. return m.OldAPIBase(ctx)
  40300. case whatsapp.FieldAPIKey:
  40301. return m.OldAPIKey(ctx)
  40302. case whatsapp.FieldAllowList:
  40303. return m.OldAllowList(ctx)
  40304. case whatsapp.FieldGroupAllowList:
  40305. return m.OldGroupAllowList(ctx)
  40306. case whatsapp.FieldBlockList:
  40307. return m.OldBlockList(ctx)
  40308. case whatsapp.FieldGroupBlockList:
  40309. return m.OldGroupBlockList(ctx)
  40310. }
  40311. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  40312. }
  40313. // SetField sets the value of a field with the given name. It returns an error if
  40314. // the field is not defined in the schema, or if the type mismatched the field
  40315. // type.
  40316. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  40317. switch name {
  40318. case whatsapp.FieldCreatedAt:
  40319. v, ok := value.(time.Time)
  40320. if !ok {
  40321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40322. }
  40323. m.SetCreatedAt(v)
  40324. return nil
  40325. case whatsapp.FieldUpdatedAt:
  40326. v, ok := value.(time.Time)
  40327. if !ok {
  40328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40329. }
  40330. m.SetUpdatedAt(v)
  40331. return nil
  40332. case whatsapp.FieldStatus:
  40333. v, ok := value.(uint8)
  40334. if !ok {
  40335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40336. }
  40337. m.SetStatus(v)
  40338. return nil
  40339. case whatsapp.FieldDeletedAt:
  40340. v, ok := value.(time.Time)
  40341. if !ok {
  40342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40343. }
  40344. m.SetDeletedAt(v)
  40345. return nil
  40346. case whatsapp.FieldWaID:
  40347. v, ok := value.(string)
  40348. if !ok {
  40349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40350. }
  40351. m.SetWaID(v)
  40352. return nil
  40353. case whatsapp.FieldWaName:
  40354. v, ok := value.(string)
  40355. if !ok {
  40356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40357. }
  40358. m.SetWaName(v)
  40359. return nil
  40360. case whatsapp.FieldCallback:
  40361. v, ok := value.(string)
  40362. if !ok {
  40363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40364. }
  40365. m.SetCallback(v)
  40366. return nil
  40367. case whatsapp.FieldAgentID:
  40368. v, ok := value.(uint64)
  40369. if !ok {
  40370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40371. }
  40372. m.SetAgentID(v)
  40373. return nil
  40374. case whatsapp.FieldAccount:
  40375. v, ok := value.(string)
  40376. if !ok {
  40377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40378. }
  40379. m.SetAccount(v)
  40380. return nil
  40381. case whatsapp.FieldCc:
  40382. v, ok := value.(string)
  40383. if !ok {
  40384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40385. }
  40386. m.SetCc(v)
  40387. return nil
  40388. case whatsapp.FieldPhone:
  40389. v, ok := value.(string)
  40390. if !ok {
  40391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40392. }
  40393. m.SetPhone(v)
  40394. return nil
  40395. case whatsapp.FieldCcPhone:
  40396. v, ok := value.(string)
  40397. if !ok {
  40398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40399. }
  40400. m.SetCcPhone(v)
  40401. return nil
  40402. case whatsapp.FieldPhoneName:
  40403. v, ok := value.(string)
  40404. if !ok {
  40405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40406. }
  40407. m.SetPhoneName(v)
  40408. return nil
  40409. case whatsapp.FieldPhoneStatus:
  40410. v, ok := value.(int8)
  40411. if !ok {
  40412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40413. }
  40414. m.SetPhoneStatus(v)
  40415. return nil
  40416. case whatsapp.FieldOrganizationID:
  40417. v, ok := value.(uint64)
  40418. if !ok {
  40419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40420. }
  40421. m.SetOrganizationID(v)
  40422. return nil
  40423. case whatsapp.FieldAPIBase:
  40424. v, ok := value.(string)
  40425. if !ok {
  40426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40427. }
  40428. m.SetAPIBase(v)
  40429. return nil
  40430. case whatsapp.FieldAPIKey:
  40431. v, ok := value.(string)
  40432. if !ok {
  40433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40434. }
  40435. m.SetAPIKey(v)
  40436. return nil
  40437. case whatsapp.FieldAllowList:
  40438. v, ok := value.([]string)
  40439. if !ok {
  40440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40441. }
  40442. m.SetAllowList(v)
  40443. return nil
  40444. case whatsapp.FieldGroupAllowList:
  40445. v, ok := value.([]string)
  40446. if !ok {
  40447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40448. }
  40449. m.SetGroupAllowList(v)
  40450. return nil
  40451. case whatsapp.FieldBlockList:
  40452. v, ok := value.([]string)
  40453. if !ok {
  40454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40455. }
  40456. m.SetBlockList(v)
  40457. return nil
  40458. case whatsapp.FieldGroupBlockList:
  40459. v, ok := value.([]string)
  40460. if !ok {
  40461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40462. }
  40463. m.SetGroupBlockList(v)
  40464. return nil
  40465. }
  40466. return fmt.Errorf("unknown Whatsapp field %s", name)
  40467. }
  40468. // AddedFields returns all numeric fields that were incremented/decremented during
  40469. // this mutation.
  40470. func (m *WhatsappMutation) AddedFields() []string {
  40471. var fields []string
  40472. if m.addstatus != nil {
  40473. fields = append(fields, whatsapp.FieldStatus)
  40474. }
  40475. if m.addphone_status != nil {
  40476. fields = append(fields, whatsapp.FieldPhoneStatus)
  40477. }
  40478. if m.addorganization_id != nil {
  40479. fields = append(fields, whatsapp.FieldOrganizationID)
  40480. }
  40481. return fields
  40482. }
  40483. // AddedField returns the numeric value that was incremented/decremented on a field
  40484. // with the given name. The second boolean return value indicates that this field
  40485. // was not set, or was not defined in the schema.
  40486. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  40487. switch name {
  40488. case whatsapp.FieldStatus:
  40489. return m.AddedStatus()
  40490. case whatsapp.FieldPhoneStatus:
  40491. return m.AddedPhoneStatus()
  40492. case whatsapp.FieldOrganizationID:
  40493. return m.AddedOrganizationID()
  40494. }
  40495. return nil, false
  40496. }
  40497. // AddField adds the value to the field with the given name. It returns an error if
  40498. // the field is not defined in the schema, or if the type mismatched the field
  40499. // type.
  40500. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  40501. switch name {
  40502. case whatsapp.FieldStatus:
  40503. v, ok := value.(int8)
  40504. if !ok {
  40505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40506. }
  40507. m.AddStatus(v)
  40508. return nil
  40509. case whatsapp.FieldPhoneStatus:
  40510. v, ok := value.(int8)
  40511. if !ok {
  40512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40513. }
  40514. m.AddPhoneStatus(v)
  40515. return nil
  40516. case whatsapp.FieldOrganizationID:
  40517. v, ok := value.(int64)
  40518. if !ok {
  40519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40520. }
  40521. m.AddOrganizationID(v)
  40522. return nil
  40523. }
  40524. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  40525. }
  40526. // ClearedFields returns all nullable fields that were cleared during this
  40527. // mutation.
  40528. func (m *WhatsappMutation) ClearedFields() []string {
  40529. var fields []string
  40530. if m.FieldCleared(whatsapp.FieldStatus) {
  40531. fields = append(fields, whatsapp.FieldStatus)
  40532. }
  40533. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  40534. fields = append(fields, whatsapp.FieldDeletedAt)
  40535. }
  40536. if m.FieldCleared(whatsapp.FieldWaID) {
  40537. fields = append(fields, whatsapp.FieldWaID)
  40538. }
  40539. if m.FieldCleared(whatsapp.FieldWaName) {
  40540. fields = append(fields, whatsapp.FieldWaName)
  40541. }
  40542. if m.FieldCleared(whatsapp.FieldCallback) {
  40543. fields = append(fields, whatsapp.FieldCallback)
  40544. }
  40545. if m.FieldCleared(whatsapp.FieldAccount) {
  40546. fields = append(fields, whatsapp.FieldAccount)
  40547. }
  40548. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  40549. fields = append(fields, whatsapp.FieldOrganizationID)
  40550. }
  40551. if m.FieldCleared(whatsapp.FieldAPIBase) {
  40552. fields = append(fields, whatsapp.FieldAPIBase)
  40553. }
  40554. if m.FieldCleared(whatsapp.FieldAPIKey) {
  40555. fields = append(fields, whatsapp.FieldAPIKey)
  40556. }
  40557. if m.FieldCleared(whatsapp.FieldAllowList) {
  40558. fields = append(fields, whatsapp.FieldAllowList)
  40559. }
  40560. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  40561. fields = append(fields, whatsapp.FieldGroupAllowList)
  40562. }
  40563. if m.FieldCleared(whatsapp.FieldBlockList) {
  40564. fields = append(fields, whatsapp.FieldBlockList)
  40565. }
  40566. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  40567. fields = append(fields, whatsapp.FieldGroupBlockList)
  40568. }
  40569. return fields
  40570. }
  40571. // FieldCleared returns a boolean indicating if a field with the given name was
  40572. // cleared in this mutation.
  40573. func (m *WhatsappMutation) FieldCleared(name string) bool {
  40574. _, ok := m.clearedFields[name]
  40575. return ok
  40576. }
  40577. // ClearField clears the value of the field with the given name. It returns an
  40578. // error if the field is not defined in the schema.
  40579. func (m *WhatsappMutation) ClearField(name string) error {
  40580. switch name {
  40581. case whatsapp.FieldStatus:
  40582. m.ClearStatus()
  40583. return nil
  40584. case whatsapp.FieldDeletedAt:
  40585. m.ClearDeletedAt()
  40586. return nil
  40587. case whatsapp.FieldWaID:
  40588. m.ClearWaID()
  40589. return nil
  40590. case whatsapp.FieldWaName:
  40591. m.ClearWaName()
  40592. return nil
  40593. case whatsapp.FieldCallback:
  40594. m.ClearCallback()
  40595. return nil
  40596. case whatsapp.FieldAccount:
  40597. m.ClearAccount()
  40598. return nil
  40599. case whatsapp.FieldOrganizationID:
  40600. m.ClearOrganizationID()
  40601. return nil
  40602. case whatsapp.FieldAPIBase:
  40603. m.ClearAPIBase()
  40604. return nil
  40605. case whatsapp.FieldAPIKey:
  40606. m.ClearAPIKey()
  40607. return nil
  40608. case whatsapp.FieldAllowList:
  40609. m.ClearAllowList()
  40610. return nil
  40611. case whatsapp.FieldGroupAllowList:
  40612. m.ClearGroupAllowList()
  40613. return nil
  40614. case whatsapp.FieldBlockList:
  40615. m.ClearBlockList()
  40616. return nil
  40617. case whatsapp.FieldGroupBlockList:
  40618. m.ClearGroupBlockList()
  40619. return nil
  40620. }
  40621. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  40622. }
  40623. // ResetField resets all changes in the mutation for the field with the given name.
  40624. // It returns an error if the field is not defined in the schema.
  40625. func (m *WhatsappMutation) ResetField(name string) error {
  40626. switch name {
  40627. case whatsapp.FieldCreatedAt:
  40628. m.ResetCreatedAt()
  40629. return nil
  40630. case whatsapp.FieldUpdatedAt:
  40631. m.ResetUpdatedAt()
  40632. return nil
  40633. case whatsapp.FieldStatus:
  40634. m.ResetStatus()
  40635. return nil
  40636. case whatsapp.FieldDeletedAt:
  40637. m.ResetDeletedAt()
  40638. return nil
  40639. case whatsapp.FieldWaID:
  40640. m.ResetWaID()
  40641. return nil
  40642. case whatsapp.FieldWaName:
  40643. m.ResetWaName()
  40644. return nil
  40645. case whatsapp.FieldCallback:
  40646. m.ResetCallback()
  40647. return nil
  40648. case whatsapp.FieldAgentID:
  40649. m.ResetAgentID()
  40650. return nil
  40651. case whatsapp.FieldAccount:
  40652. m.ResetAccount()
  40653. return nil
  40654. case whatsapp.FieldCc:
  40655. m.ResetCc()
  40656. return nil
  40657. case whatsapp.FieldPhone:
  40658. m.ResetPhone()
  40659. return nil
  40660. case whatsapp.FieldCcPhone:
  40661. m.ResetCcPhone()
  40662. return nil
  40663. case whatsapp.FieldPhoneName:
  40664. m.ResetPhoneName()
  40665. return nil
  40666. case whatsapp.FieldPhoneStatus:
  40667. m.ResetPhoneStatus()
  40668. return nil
  40669. case whatsapp.FieldOrganizationID:
  40670. m.ResetOrganizationID()
  40671. return nil
  40672. case whatsapp.FieldAPIBase:
  40673. m.ResetAPIBase()
  40674. return nil
  40675. case whatsapp.FieldAPIKey:
  40676. m.ResetAPIKey()
  40677. return nil
  40678. case whatsapp.FieldAllowList:
  40679. m.ResetAllowList()
  40680. return nil
  40681. case whatsapp.FieldGroupAllowList:
  40682. m.ResetGroupAllowList()
  40683. return nil
  40684. case whatsapp.FieldBlockList:
  40685. m.ResetBlockList()
  40686. return nil
  40687. case whatsapp.FieldGroupBlockList:
  40688. m.ResetGroupBlockList()
  40689. return nil
  40690. }
  40691. return fmt.Errorf("unknown Whatsapp field %s", name)
  40692. }
  40693. // AddedEdges returns all edge names that were set/added in this mutation.
  40694. func (m *WhatsappMutation) AddedEdges() []string {
  40695. edges := make([]string, 0, 1)
  40696. if m.agent != nil {
  40697. edges = append(edges, whatsapp.EdgeAgent)
  40698. }
  40699. return edges
  40700. }
  40701. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40702. // name in this mutation.
  40703. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  40704. switch name {
  40705. case whatsapp.EdgeAgent:
  40706. if id := m.agent; id != nil {
  40707. return []ent.Value{*id}
  40708. }
  40709. }
  40710. return nil
  40711. }
  40712. // RemovedEdges returns all edge names that were removed in this mutation.
  40713. func (m *WhatsappMutation) RemovedEdges() []string {
  40714. edges := make([]string, 0, 1)
  40715. return edges
  40716. }
  40717. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40718. // the given name in this mutation.
  40719. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  40720. return nil
  40721. }
  40722. // ClearedEdges returns all edge names that were cleared in this mutation.
  40723. func (m *WhatsappMutation) ClearedEdges() []string {
  40724. edges := make([]string, 0, 1)
  40725. if m.clearedagent {
  40726. edges = append(edges, whatsapp.EdgeAgent)
  40727. }
  40728. return edges
  40729. }
  40730. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40731. // was cleared in this mutation.
  40732. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  40733. switch name {
  40734. case whatsapp.EdgeAgent:
  40735. return m.clearedagent
  40736. }
  40737. return false
  40738. }
  40739. // ClearEdge clears the value of the edge with the given name. It returns an error
  40740. // if that edge is not defined in the schema.
  40741. func (m *WhatsappMutation) ClearEdge(name string) error {
  40742. switch name {
  40743. case whatsapp.EdgeAgent:
  40744. m.ClearAgent()
  40745. return nil
  40746. }
  40747. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  40748. }
  40749. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40750. // It returns an error if the edge is not defined in the schema.
  40751. func (m *WhatsappMutation) ResetEdge(name string) error {
  40752. switch name {
  40753. case whatsapp.EdgeAgent:
  40754. m.ResetAgent()
  40755. return nil
  40756. }
  40757. return fmt.Errorf("unknown Whatsapp edge %s", name)
  40758. }
  40759. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  40760. type WhatsappChannelMutation struct {
  40761. config
  40762. op Op
  40763. typ string
  40764. id *uint64
  40765. created_at *time.Time
  40766. updated_at *time.Time
  40767. status *uint8
  40768. addstatus *int8
  40769. deleted_at *time.Time
  40770. ak *string
  40771. sk *string
  40772. wa_id *string
  40773. wa_name *string
  40774. waba_id *uint64
  40775. addwaba_id *int64
  40776. business_id *uint64
  40777. addbusiness_id *int64
  40778. organization_id *uint64
  40779. addorganization_id *int64
  40780. verify_account *string
  40781. clearedFields map[string]struct{}
  40782. done bool
  40783. oldValue func(context.Context) (*WhatsappChannel, error)
  40784. predicates []predicate.WhatsappChannel
  40785. }
  40786. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  40787. // whatsappchannelOption allows management of the mutation configuration using functional options.
  40788. type whatsappchannelOption func(*WhatsappChannelMutation)
  40789. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  40790. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  40791. m := &WhatsappChannelMutation{
  40792. config: c,
  40793. op: op,
  40794. typ: TypeWhatsappChannel,
  40795. clearedFields: make(map[string]struct{}),
  40796. }
  40797. for _, opt := range opts {
  40798. opt(m)
  40799. }
  40800. return m
  40801. }
  40802. // withWhatsappChannelID sets the ID field of the mutation.
  40803. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  40804. return func(m *WhatsappChannelMutation) {
  40805. var (
  40806. err error
  40807. once sync.Once
  40808. value *WhatsappChannel
  40809. )
  40810. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  40811. once.Do(func() {
  40812. if m.done {
  40813. err = errors.New("querying old values post mutation is not allowed")
  40814. } else {
  40815. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  40816. }
  40817. })
  40818. return value, err
  40819. }
  40820. m.id = &id
  40821. }
  40822. }
  40823. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  40824. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  40825. return func(m *WhatsappChannelMutation) {
  40826. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  40827. return node, nil
  40828. }
  40829. m.id = &node.ID
  40830. }
  40831. }
  40832. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40833. // executed in a transaction (ent.Tx), a transactional client is returned.
  40834. func (m WhatsappChannelMutation) Client() *Client {
  40835. client := &Client{config: m.config}
  40836. client.init()
  40837. return client
  40838. }
  40839. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40840. // it returns an error otherwise.
  40841. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  40842. if _, ok := m.driver.(*txDriver); !ok {
  40843. return nil, errors.New("ent: mutation is not running in a transaction")
  40844. }
  40845. tx := &Tx{config: m.config}
  40846. tx.init()
  40847. return tx, nil
  40848. }
  40849. // SetID sets the value of the id field. Note that this
  40850. // operation is only accepted on creation of WhatsappChannel entities.
  40851. func (m *WhatsappChannelMutation) SetID(id uint64) {
  40852. m.id = &id
  40853. }
  40854. // ID returns the ID value in the mutation. Note that the ID is only available
  40855. // if it was provided to the builder or after it was returned from the database.
  40856. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  40857. if m.id == nil {
  40858. return
  40859. }
  40860. return *m.id, true
  40861. }
  40862. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40863. // That means, if the mutation is applied within a transaction with an isolation level such
  40864. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40865. // or updated by the mutation.
  40866. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  40867. switch {
  40868. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40869. id, exists := m.ID()
  40870. if exists {
  40871. return []uint64{id}, nil
  40872. }
  40873. fallthrough
  40874. case m.op.Is(OpUpdate | OpDelete):
  40875. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  40876. default:
  40877. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40878. }
  40879. }
  40880. // SetCreatedAt sets the "created_at" field.
  40881. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  40882. m.created_at = &t
  40883. }
  40884. // CreatedAt returns the value of the "created_at" field in the mutation.
  40885. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  40886. v := m.created_at
  40887. if v == nil {
  40888. return
  40889. }
  40890. return *v, true
  40891. }
  40892. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  40893. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40895. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40896. if !m.op.Is(OpUpdateOne) {
  40897. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40898. }
  40899. if m.id == nil || m.oldValue == nil {
  40900. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40901. }
  40902. oldValue, err := m.oldValue(ctx)
  40903. if err != nil {
  40904. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40905. }
  40906. return oldValue.CreatedAt, nil
  40907. }
  40908. // ResetCreatedAt resets all changes to the "created_at" field.
  40909. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  40910. m.created_at = nil
  40911. }
  40912. // SetUpdatedAt sets the "updated_at" field.
  40913. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  40914. m.updated_at = &t
  40915. }
  40916. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40917. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  40918. v := m.updated_at
  40919. if v == nil {
  40920. return
  40921. }
  40922. return *v, true
  40923. }
  40924. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  40925. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40927. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40928. if !m.op.Is(OpUpdateOne) {
  40929. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40930. }
  40931. if m.id == nil || m.oldValue == nil {
  40932. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40933. }
  40934. oldValue, err := m.oldValue(ctx)
  40935. if err != nil {
  40936. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40937. }
  40938. return oldValue.UpdatedAt, nil
  40939. }
  40940. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40941. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  40942. m.updated_at = nil
  40943. }
  40944. // SetStatus sets the "status" field.
  40945. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  40946. m.status = &u
  40947. m.addstatus = nil
  40948. }
  40949. // Status returns the value of the "status" field in the mutation.
  40950. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  40951. v := m.status
  40952. if v == nil {
  40953. return
  40954. }
  40955. return *v, true
  40956. }
  40957. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  40958. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40960. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40961. if !m.op.Is(OpUpdateOne) {
  40962. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40963. }
  40964. if m.id == nil || m.oldValue == nil {
  40965. return v, errors.New("OldStatus requires an ID field in the mutation")
  40966. }
  40967. oldValue, err := m.oldValue(ctx)
  40968. if err != nil {
  40969. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40970. }
  40971. return oldValue.Status, nil
  40972. }
  40973. // AddStatus adds u to the "status" field.
  40974. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  40975. if m.addstatus != nil {
  40976. *m.addstatus += u
  40977. } else {
  40978. m.addstatus = &u
  40979. }
  40980. }
  40981. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40982. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  40983. v := m.addstatus
  40984. if v == nil {
  40985. return
  40986. }
  40987. return *v, true
  40988. }
  40989. // ClearStatus clears the value of the "status" field.
  40990. func (m *WhatsappChannelMutation) ClearStatus() {
  40991. m.status = nil
  40992. m.addstatus = nil
  40993. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  40994. }
  40995. // StatusCleared returns if the "status" field was cleared in this mutation.
  40996. func (m *WhatsappChannelMutation) StatusCleared() bool {
  40997. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  40998. return ok
  40999. }
  41000. // ResetStatus resets all changes to the "status" field.
  41001. func (m *WhatsappChannelMutation) ResetStatus() {
  41002. m.status = nil
  41003. m.addstatus = nil
  41004. delete(m.clearedFields, whatsappchannel.FieldStatus)
  41005. }
  41006. // SetDeletedAt sets the "deleted_at" field.
  41007. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  41008. m.deleted_at = &t
  41009. }
  41010. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41011. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  41012. v := m.deleted_at
  41013. if v == nil {
  41014. return
  41015. }
  41016. return *v, true
  41017. }
  41018. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  41019. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41021. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41022. if !m.op.Is(OpUpdateOne) {
  41023. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41024. }
  41025. if m.id == nil || m.oldValue == nil {
  41026. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41027. }
  41028. oldValue, err := m.oldValue(ctx)
  41029. if err != nil {
  41030. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41031. }
  41032. return oldValue.DeletedAt, nil
  41033. }
  41034. // ClearDeletedAt clears the value of the "deleted_at" field.
  41035. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  41036. m.deleted_at = nil
  41037. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  41038. }
  41039. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41040. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  41041. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  41042. return ok
  41043. }
  41044. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41045. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  41046. m.deleted_at = nil
  41047. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  41048. }
  41049. // SetAk sets the "ak" field.
  41050. func (m *WhatsappChannelMutation) SetAk(s string) {
  41051. m.ak = &s
  41052. }
  41053. // Ak returns the value of the "ak" field in the mutation.
  41054. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  41055. v := m.ak
  41056. if v == nil {
  41057. return
  41058. }
  41059. return *v, true
  41060. }
  41061. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  41062. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41064. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  41065. if !m.op.Is(OpUpdateOne) {
  41066. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  41067. }
  41068. if m.id == nil || m.oldValue == nil {
  41069. return v, errors.New("OldAk requires an ID field in the mutation")
  41070. }
  41071. oldValue, err := m.oldValue(ctx)
  41072. if err != nil {
  41073. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  41074. }
  41075. return oldValue.Ak, nil
  41076. }
  41077. // ClearAk clears the value of the "ak" field.
  41078. func (m *WhatsappChannelMutation) ClearAk() {
  41079. m.ak = nil
  41080. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  41081. }
  41082. // AkCleared returns if the "ak" field was cleared in this mutation.
  41083. func (m *WhatsappChannelMutation) AkCleared() bool {
  41084. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  41085. return ok
  41086. }
  41087. // ResetAk resets all changes to the "ak" field.
  41088. func (m *WhatsappChannelMutation) ResetAk() {
  41089. m.ak = nil
  41090. delete(m.clearedFields, whatsappchannel.FieldAk)
  41091. }
  41092. // SetSk sets the "sk" field.
  41093. func (m *WhatsappChannelMutation) SetSk(s string) {
  41094. m.sk = &s
  41095. }
  41096. // Sk returns the value of the "sk" field in the mutation.
  41097. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  41098. v := m.sk
  41099. if v == nil {
  41100. return
  41101. }
  41102. return *v, true
  41103. }
  41104. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  41105. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41107. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  41108. if !m.op.Is(OpUpdateOne) {
  41109. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  41110. }
  41111. if m.id == nil || m.oldValue == nil {
  41112. return v, errors.New("OldSk requires an ID field in the mutation")
  41113. }
  41114. oldValue, err := m.oldValue(ctx)
  41115. if err != nil {
  41116. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  41117. }
  41118. return oldValue.Sk, nil
  41119. }
  41120. // ResetSk resets all changes to the "sk" field.
  41121. func (m *WhatsappChannelMutation) ResetSk() {
  41122. m.sk = nil
  41123. }
  41124. // SetWaID sets the "wa_id" field.
  41125. func (m *WhatsappChannelMutation) SetWaID(s string) {
  41126. m.wa_id = &s
  41127. }
  41128. // WaID returns the value of the "wa_id" field in the mutation.
  41129. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  41130. v := m.wa_id
  41131. if v == nil {
  41132. return
  41133. }
  41134. return *v, true
  41135. }
  41136. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  41137. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41139. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  41140. if !m.op.Is(OpUpdateOne) {
  41141. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41142. }
  41143. if m.id == nil || m.oldValue == nil {
  41144. return v, errors.New("OldWaID requires an ID field in the mutation")
  41145. }
  41146. oldValue, err := m.oldValue(ctx)
  41147. if err != nil {
  41148. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  41149. }
  41150. return oldValue.WaID, nil
  41151. }
  41152. // ClearWaID clears the value of the "wa_id" field.
  41153. func (m *WhatsappChannelMutation) ClearWaID() {
  41154. m.wa_id = nil
  41155. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  41156. }
  41157. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  41158. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  41159. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  41160. return ok
  41161. }
  41162. // ResetWaID resets all changes to the "wa_id" field.
  41163. func (m *WhatsappChannelMutation) ResetWaID() {
  41164. m.wa_id = nil
  41165. delete(m.clearedFields, whatsappchannel.FieldWaID)
  41166. }
  41167. // SetWaName sets the "wa_name" field.
  41168. func (m *WhatsappChannelMutation) SetWaName(s string) {
  41169. m.wa_name = &s
  41170. }
  41171. // WaName returns the value of the "wa_name" field in the mutation.
  41172. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  41173. v := m.wa_name
  41174. if v == nil {
  41175. return
  41176. }
  41177. return *v, true
  41178. }
  41179. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  41180. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41182. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  41183. if !m.op.Is(OpUpdateOne) {
  41184. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  41185. }
  41186. if m.id == nil || m.oldValue == nil {
  41187. return v, errors.New("OldWaName requires an ID field in the mutation")
  41188. }
  41189. oldValue, err := m.oldValue(ctx)
  41190. if err != nil {
  41191. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  41192. }
  41193. return oldValue.WaName, nil
  41194. }
  41195. // ClearWaName clears the value of the "wa_name" field.
  41196. func (m *WhatsappChannelMutation) ClearWaName() {
  41197. m.wa_name = nil
  41198. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  41199. }
  41200. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  41201. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  41202. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  41203. return ok
  41204. }
  41205. // ResetWaName resets all changes to the "wa_name" field.
  41206. func (m *WhatsappChannelMutation) ResetWaName() {
  41207. m.wa_name = nil
  41208. delete(m.clearedFields, whatsappchannel.FieldWaName)
  41209. }
  41210. // SetWabaID sets the "waba_id" field.
  41211. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  41212. m.waba_id = &u
  41213. m.addwaba_id = nil
  41214. }
  41215. // WabaID returns the value of the "waba_id" field in the mutation.
  41216. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  41217. v := m.waba_id
  41218. if v == nil {
  41219. return
  41220. }
  41221. return *v, true
  41222. }
  41223. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  41224. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41226. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  41227. if !m.op.Is(OpUpdateOne) {
  41228. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  41229. }
  41230. if m.id == nil || m.oldValue == nil {
  41231. return v, errors.New("OldWabaID requires an ID field in the mutation")
  41232. }
  41233. oldValue, err := m.oldValue(ctx)
  41234. if err != nil {
  41235. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  41236. }
  41237. return oldValue.WabaID, nil
  41238. }
  41239. // AddWabaID adds u to the "waba_id" field.
  41240. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  41241. if m.addwaba_id != nil {
  41242. *m.addwaba_id += u
  41243. } else {
  41244. m.addwaba_id = &u
  41245. }
  41246. }
  41247. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  41248. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  41249. v := m.addwaba_id
  41250. if v == nil {
  41251. return
  41252. }
  41253. return *v, true
  41254. }
  41255. // ResetWabaID resets all changes to the "waba_id" field.
  41256. func (m *WhatsappChannelMutation) ResetWabaID() {
  41257. m.waba_id = nil
  41258. m.addwaba_id = nil
  41259. }
  41260. // SetBusinessID sets the "business_id" field.
  41261. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  41262. m.business_id = &u
  41263. m.addbusiness_id = nil
  41264. }
  41265. // BusinessID returns the value of the "business_id" field in the mutation.
  41266. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  41267. v := m.business_id
  41268. if v == nil {
  41269. return
  41270. }
  41271. return *v, true
  41272. }
  41273. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  41274. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41276. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  41277. if !m.op.Is(OpUpdateOne) {
  41278. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  41279. }
  41280. if m.id == nil || m.oldValue == nil {
  41281. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  41282. }
  41283. oldValue, err := m.oldValue(ctx)
  41284. if err != nil {
  41285. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  41286. }
  41287. return oldValue.BusinessID, nil
  41288. }
  41289. // AddBusinessID adds u to the "business_id" field.
  41290. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  41291. if m.addbusiness_id != nil {
  41292. *m.addbusiness_id += u
  41293. } else {
  41294. m.addbusiness_id = &u
  41295. }
  41296. }
  41297. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  41298. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  41299. v := m.addbusiness_id
  41300. if v == nil {
  41301. return
  41302. }
  41303. return *v, true
  41304. }
  41305. // ResetBusinessID resets all changes to the "business_id" field.
  41306. func (m *WhatsappChannelMutation) ResetBusinessID() {
  41307. m.business_id = nil
  41308. m.addbusiness_id = nil
  41309. }
  41310. // SetOrganizationID sets the "organization_id" field.
  41311. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  41312. m.organization_id = &u
  41313. m.addorganization_id = nil
  41314. }
  41315. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41316. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  41317. v := m.organization_id
  41318. if v == nil {
  41319. return
  41320. }
  41321. return *v, true
  41322. }
  41323. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  41324. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41326. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41327. if !m.op.Is(OpUpdateOne) {
  41328. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41329. }
  41330. if m.id == nil || m.oldValue == nil {
  41331. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41332. }
  41333. oldValue, err := m.oldValue(ctx)
  41334. if err != nil {
  41335. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41336. }
  41337. return oldValue.OrganizationID, nil
  41338. }
  41339. // AddOrganizationID adds u to the "organization_id" field.
  41340. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  41341. if m.addorganization_id != nil {
  41342. *m.addorganization_id += u
  41343. } else {
  41344. m.addorganization_id = &u
  41345. }
  41346. }
  41347. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41348. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  41349. v := m.addorganization_id
  41350. if v == nil {
  41351. return
  41352. }
  41353. return *v, true
  41354. }
  41355. // ClearOrganizationID clears the value of the "organization_id" field.
  41356. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  41357. m.organization_id = nil
  41358. m.addorganization_id = nil
  41359. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  41360. }
  41361. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41362. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  41363. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  41364. return ok
  41365. }
  41366. // ResetOrganizationID resets all changes to the "organization_id" field.
  41367. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  41368. m.organization_id = nil
  41369. m.addorganization_id = nil
  41370. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  41371. }
  41372. // SetVerifyAccount sets the "verify_account" field.
  41373. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  41374. m.verify_account = &s
  41375. }
  41376. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  41377. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  41378. v := m.verify_account
  41379. if v == nil {
  41380. return
  41381. }
  41382. return *v, true
  41383. }
  41384. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  41385. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41387. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  41388. if !m.op.Is(OpUpdateOne) {
  41389. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  41390. }
  41391. if m.id == nil || m.oldValue == nil {
  41392. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  41393. }
  41394. oldValue, err := m.oldValue(ctx)
  41395. if err != nil {
  41396. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  41397. }
  41398. return oldValue.VerifyAccount, nil
  41399. }
  41400. // ResetVerifyAccount resets all changes to the "verify_account" field.
  41401. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  41402. m.verify_account = nil
  41403. }
  41404. // Where appends a list predicates to the WhatsappChannelMutation builder.
  41405. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  41406. m.predicates = append(m.predicates, ps...)
  41407. }
  41408. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  41409. // users can use type-assertion to append predicates that do not depend on any generated package.
  41410. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  41411. p := make([]predicate.WhatsappChannel, len(ps))
  41412. for i := range ps {
  41413. p[i] = ps[i]
  41414. }
  41415. m.Where(p...)
  41416. }
  41417. // Op returns the operation name.
  41418. func (m *WhatsappChannelMutation) Op() Op {
  41419. return m.op
  41420. }
  41421. // SetOp allows setting the mutation operation.
  41422. func (m *WhatsappChannelMutation) SetOp(op Op) {
  41423. m.op = op
  41424. }
  41425. // Type returns the node type of this mutation (WhatsappChannel).
  41426. func (m *WhatsappChannelMutation) Type() string {
  41427. return m.typ
  41428. }
  41429. // Fields returns all fields that were changed during this mutation. Note that in
  41430. // order to get all numeric fields that were incremented/decremented, call
  41431. // AddedFields().
  41432. func (m *WhatsappChannelMutation) Fields() []string {
  41433. fields := make([]string, 0, 12)
  41434. if m.created_at != nil {
  41435. fields = append(fields, whatsappchannel.FieldCreatedAt)
  41436. }
  41437. if m.updated_at != nil {
  41438. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  41439. }
  41440. if m.status != nil {
  41441. fields = append(fields, whatsappchannel.FieldStatus)
  41442. }
  41443. if m.deleted_at != nil {
  41444. fields = append(fields, whatsappchannel.FieldDeletedAt)
  41445. }
  41446. if m.ak != nil {
  41447. fields = append(fields, whatsappchannel.FieldAk)
  41448. }
  41449. if m.sk != nil {
  41450. fields = append(fields, whatsappchannel.FieldSk)
  41451. }
  41452. if m.wa_id != nil {
  41453. fields = append(fields, whatsappchannel.FieldWaID)
  41454. }
  41455. if m.wa_name != nil {
  41456. fields = append(fields, whatsappchannel.FieldWaName)
  41457. }
  41458. if m.waba_id != nil {
  41459. fields = append(fields, whatsappchannel.FieldWabaID)
  41460. }
  41461. if m.business_id != nil {
  41462. fields = append(fields, whatsappchannel.FieldBusinessID)
  41463. }
  41464. if m.organization_id != nil {
  41465. fields = append(fields, whatsappchannel.FieldOrganizationID)
  41466. }
  41467. if m.verify_account != nil {
  41468. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  41469. }
  41470. return fields
  41471. }
  41472. // Field returns the value of a field with the given name. The second boolean
  41473. // return value indicates that this field was not set, or was not defined in the
  41474. // schema.
  41475. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  41476. switch name {
  41477. case whatsappchannel.FieldCreatedAt:
  41478. return m.CreatedAt()
  41479. case whatsappchannel.FieldUpdatedAt:
  41480. return m.UpdatedAt()
  41481. case whatsappchannel.FieldStatus:
  41482. return m.Status()
  41483. case whatsappchannel.FieldDeletedAt:
  41484. return m.DeletedAt()
  41485. case whatsappchannel.FieldAk:
  41486. return m.Ak()
  41487. case whatsappchannel.FieldSk:
  41488. return m.Sk()
  41489. case whatsappchannel.FieldWaID:
  41490. return m.WaID()
  41491. case whatsappchannel.FieldWaName:
  41492. return m.WaName()
  41493. case whatsappchannel.FieldWabaID:
  41494. return m.WabaID()
  41495. case whatsappchannel.FieldBusinessID:
  41496. return m.BusinessID()
  41497. case whatsappchannel.FieldOrganizationID:
  41498. return m.OrganizationID()
  41499. case whatsappchannel.FieldVerifyAccount:
  41500. return m.VerifyAccount()
  41501. }
  41502. return nil, false
  41503. }
  41504. // OldField returns the old value of the field from the database. An error is
  41505. // returned if the mutation operation is not UpdateOne, or the query to the
  41506. // database failed.
  41507. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41508. switch name {
  41509. case whatsappchannel.FieldCreatedAt:
  41510. return m.OldCreatedAt(ctx)
  41511. case whatsappchannel.FieldUpdatedAt:
  41512. return m.OldUpdatedAt(ctx)
  41513. case whatsappchannel.FieldStatus:
  41514. return m.OldStatus(ctx)
  41515. case whatsappchannel.FieldDeletedAt:
  41516. return m.OldDeletedAt(ctx)
  41517. case whatsappchannel.FieldAk:
  41518. return m.OldAk(ctx)
  41519. case whatsappchannel.FieldSk:
  41520. return m.OldSk(ctx)
  41521. case whatsappchannel.FieldWaID:
  41522. return m.OldWaID(ctx)
  41523. case whatsappchannel.FieldWaName:
  41524. return m.OldWaName(ctx)
  41525. case whatsappchannel.FieldWabaID:
  41526. return m.OldWabaID(ctx)
  41527. case whatsappchannel.FieldBusinessID:
  41528. return m.OldBusinessID(ctx)
  41529. case whatsappchannel.FieldOrganizationID:
  41530. return m.OldOrganizationID(ctx)
  41531. case whatsappchannel.FieldVerifyAccount:
  41532. return m.OldVerifyAccount(ctx)
  41533. }
  41534. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  41535. }
  41536. // SetField sets the value of a field with the given name. It returns an error if
  41537. // the field is not defined in the schema, or if the type mismatched the field
  41538. // type.
  41539. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  41540. switch name {
  41541. case whatsappchannel.FieldCreatedAt:
  41542. v, ok := value.(time.Time)
  41543. if !ok {
  41544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41545. }
  41546. m.SetCreatedAt(v)
  41547. return nil
  41548. case whatsappchannel.FieldUpdatedAt:
  41549. v, ok := value.(time.Time)
  41550. if !ok {
  41551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41552. }
  41553. m.SetUpdatedAt(v)
  41554. return nil
  41555. case whatsappchannel.FieldStatus:
  41556. v, ok := value.(uint8)
  41557. if !ok {
  41558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41559. }
  41560. m.SetStatus(v)
  41561. return nil
  41562. case whatsappchannel.FieldDeletedAt:
  41563. v, ok := value.(time.Time)
  41564. if !ok {
  41565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41566. }
  41567. m.SetDeletedAt(v)
  41568. return nil
  41569. case whatsappchannel.FieldAk:
  41570. v, ok := value.(string)
  41571. if !ok {
  41572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41573. }
  41574. m.SetAk(v)
  41575. return nil
  41576. case whatsappchannel.FieldSk:
  41577. v, ok := value.(string)
  41578. if !ok {
  41579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41580. }
  41581. m.SetSk(v)
  41582. return nil
  41583. case whatsappchannel.FieldWaID:
  41584. v, ok := value.(string)
  41585. if !ok {
  41586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41587. }
  41588. m.SetWaID(v)
  41589. return nil
  41590. case whatsappchannel.FieldWaName:
  41591. v, ok := value.(string)
  41592. if !ok {
  41593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41594. }
  41595. m.SetWaName(v)
  41596. return nil
  41597. case whatsappchannel.FieldWabaID:
  41598. v, ok := value.(uint64)
  41599. if !ok {
  41600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41601. }
  41602. m.SetWabaID(v)
  41603. return nil
  41604. case whatsappchannel.FieldBusinessID:
  41605. v, ok := value.(uint64)
  41606. if !ok {
  41607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41608. }
  41609. m.SetBusinessID(v)
  41610. return nil
  41611. case whatsappchannel.FieldOrganizationID:
  41612. v, ok := value.(uint64)
  41613. if !ok {
  41614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41615. }
  41616. m.SetOrganizationID(v)
  41617. return nil
  41618. case whatsappchannel.FieldVerifyAccount:
  41619. v, ok := value.(string)
  41620. if !ok {
  41621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41622. }
  41623. m.SetVerifyAccount(v)
  41624. return nil
  41625. }
  41626. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  41627. }
  41628. // AddedFields returns all numeric fields that were incremented/decremented during
  41629. // this mutation.
  41630. func (m *WhatsappChannelMutation) AddedFields() []string {
  41631. var fields []string
  41632. if m.addstatus != nil {
  41633. fields = append(fields, whatsappchannel.FieldStatus)
  41634. }
  41635. if m.addwaba_id != nil {
  41636. fields = append(fields, whatsappchannel.FieldWabaID)
  41637. }
  41638. if m.addbusiness_id != nil {
  41639. fields = append(fields, whatsappchannel.FieldBusinessID)
  41640. }
  41641. if m.addorganization_id != nil {
  41642. fields = append(fields, whatsappchannel.FieldOrganizationID)
  41643. }
  41644. return fields
  41645. }
  41646. // AddedField returns the numeric value that was incremented/decremented on a field
  41647. // with the given name. The second boolean return value indicates that this field
  41648. // was not set, or was not defined in the schema.
  41649. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  41650. switch name {
  41651. case whatsappchannel.FieldStatus:
  41652. return m.AddedStatus()
  41653. case whatsappchannel.FieldWabaID:
  41654. return m.AddedWabaID()
  41655. case whatsappchannel.FieldBusinessID:
  41656. return m.AddedBusinessID()
  41657. case whatsappchannel.FieldOrganizationID:
  41658. return m.AddedOrganizationID()
  41659. }
  41660. return nil, false
  41661. }
  41662. // AddField adds the value to the field with the given name. It returns an error if
  41663. // the field is not defined in the schema, or if the type mismatched the field
  41664. // type.
  41665. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  41666. switch name {
  41667. case whatsappchannel.FieldStatus:
  41668. v, ok := value.(int8)
  41669. if !ok {
  41670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41671. }
  41672. m.AddStatus(v)
  41673. return nil
  41674. case whatsappchannel.FieldWabaID:
  41675. v, ok := value.(int64)
  41676. if !ok {
  41677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41678. }
  41679. m.AddWabaID(v)
  41680. return nil
  41681. case whatsappchannel.FieldBusinessID:
  41682. v, ok := value.(int64)
  41683. if !ok {
  41684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41685. }
  41686. m.AddBusinessID(v)
  41687. return nil
  41688. case whatsappchannel.FieldOrganizationID:
  41689. v, ok := value.(int64)
  41690. if !ok {
  41691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41692. }
  41693. m.AddOrganizationID(v)
  41694. return nil
  41695. }
  41696. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  41697. }
  41698. // ClearedFields returns all nullable fields that were cleared during this
  41699. // mutation.
  41700. func (m *WhatsappChannelMutation) ClearedFields() []string {
  41701. var fields []string
  41702. if m.FieldCleared(whatsappchannel.FieldStatus) {
  41703. fields = append(fields, whatsappchannel.FieldStatus)
  41704. }
  41705. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  41706. fields = append(fields, whatsappchannel.FieldDeletedAt)
  41707. }
  41708. if m.FieldCleared(whatsappchannel.FieldAk) {
  41709. fields = append(fields, whatsappchannel.FieldAk)
  41710. }
  41711. if m.FieldCleared(whatsappchannel.FieldWaID) {
  41712. fields = append(fields, whatsappchannel.FieldWaID)
  41713. }
  41714. if m.FieldCleared(whatsappchannel.FieldWaName) {
  41715. fields = append(fields, whatsappchannel.FieldWaName)
  41716. }
  41717. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  41718. fields = append(fields, whatsappchannel.FieldOrganizationID)
  41719. }
  41720. return fields
  41721. }
  41722. // FieldCleared returns a boolean indicating if a field with the given name was
  41723. // cleared in this mutation.
  41724. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  41725. _, ok := m.clearedFields[name]
  41726. return ok
  41727. }
  41728. // ClearField clears the value of the field with the given name. It returns an
  41729. // error if the field is not defined in the schema.
  41730. func (m *WhatsappChannelMutation) ClearField(name string) error {
  41731. switch name {
  41732. case whatsappchannel.FieldStatus:
  41733. m.ClearStatus()
  41734. return nil
  41735. case whatsappchannel.FieldDeletedAt:
  41736. m.ClearDeletedAt()
  41737. return nil
  41738. case whatsappchannel.FieldAk:
  41739. m.ClearAk()
  41740. return nil
  41741. case whatsappchannel.FieldWaID:
  41742. m.ClearWaID()
  41743. return nil
  41744. case whatsappchannel.FieldWaName:
  41745. m.ClearWaName()
  41746. return nil
  41747. case whatsappchannel.FieldOrganizationID:
  41748. m.ClearOrganizationID()
  41749. return nil
  41750. }
  41751. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  41752. }
  41753. // ResetField resets all changes in the mutation for the field with the given name.
  41754. // It returns an error if the field is not defined in the schema.
  41755. func (m *WhatsappChannelMutation) ResetField(name string) error {
  41756. switch name {
  41757. case whatsappchannel.FieldCreatedAt:
  41758. m.ResetCreatedAt()
  41759. return nil
  41760. case whatsappchannel.FieldUpdatedAt:
  41761. m.ResetUpdatedAt()
  41762. return nil
  41763. case whatsappchannel.FieldStatus:
  41764. m.ResetStatus()
  41765. return nil
  41766. case whatsappchannel.FieldDeletedAt:
  41767. m.ResetDeletedAt()
  41768. return nil
  41769. case whatsappchannel.FieldAk:
  41770. m.ResetAk()
  41771. return nil
  41772. case whatsappchannel.FieldSk:
  41773. m.ResetSk()
  41774. return nil
  41775. case whatsappchannel.FieldWaID:
  41776. m.ResetWaID()
  41777. return nil
  41778. case whatsappchannel.FieldWaName:
  41779. m.ResetWaName()
  41780. return nil
  41781. case whatsappchannel.FieldWabaID:
  41782. m.ResetWabaID()
  41783. return nil
  41784. case whatsappchannel.FieldBusinessID:
  41785. m.ResetBusinessID()
  41786. return nil
  41787. case whatsappchannel.FieldOrganizationID:
  41788. m.ResetOrganizationID()
  41789. return nil
  41790. case whatsappchannel.FieldVerifyAccount:
  41791. m.ResetVerifyAccount()
  41792. return nil
  41793. }
  41794. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  41795. }
  41796. // AddedEdges returns all edge names that were set/added in this mutation.
  41797. func (m *WhatsappChannelMutation) AddedEdges() []string {
  41798. edges := make([]string, 0, 0)
  41799. return edges
  41800. }
  41801. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41802. // name in this mutation.
  41803. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  41804. return nil
  41805. }
  41806. // RemovedEdges returns all edge names that were removed in this mutation.
  41807. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  41808. edges := make([]string, 0, 0)
  41809. return edges
  41810. }
  41811. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41812. // the given name in this mutation.
  41813. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  41814. return nil
  41815. }
  41816. // ClearedEdges returns all edge names that were cleared in this mutation.
  41817. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  41818. edges := make([]string, 0, 0)
  41819. return edges
  41820. }
  41821. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41822. // was cleared in this mutation.
  41823. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  41824. return false
  41825. }
  41826. // ClearEdge clears the value of the edge with the given name. It returns an error
  41827. // if that edge is not defined in the schema.
  41828. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  41829. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  41830. }
  41831. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41832. // It returns an error if the edge is not defined in the schema.
  41833. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  41834. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  41835. }
  41836. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  41837. type WorkExperienceMutation struct {
  41838. config
  41839. op Op
  41840. typ string
  41841. id *uint64
  41842. created_at *time.Time
  41843. updated_at *time.Time
  41844. deleted_at *time.Time
  41845. start_date *time.Time
  41846. end_date *time.Time
  41847. company *string
  41848. experience *string
  41849. organization_id *uint64
  41850. addorganization_id *int64
  41851. clearedFields map[string]struct{}
  41852. employee *uint64
  41853. clearedemployee bool
  41854. done bool
  41855. oldValue func(context.Context) (*WorkExperience, error)
  41856. predicates []predicate.WorkExperience
  41857. }
  41858. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  41859. // workexperienceOption allows management of the mutation configuration using functional options.
  41860. type workexperienceOption func(*WorkExperienceMutation)
  41861. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  41862. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  41863. m := &WorkExperienceMutation{
  41864. config: c,
  41865. op: op,
  41866. typ: TypeWorkExperience,
  41867. clearedFields: make(map[string]struct{}),
  41868. }
  41869. for _, opt := range opts {
  41870. opt(m)
  41871. }
  41872. return m
  41873. }
  41874. // withWorkExperienceID sets the ID field of the mutation.
  41875. func withWorkExperienceID(id uint64) workexperienceOption {
  41876. return func(m *WorkExperienceMutation) {
  41877. var (
  41878. err error
  41879. once sync.Once
  41880. value *WorkExperience
  41881. )
  41882. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  41883. once.Do(func() {
  41884. if m.done {
  41885. err = errors.New("querying old values post mutation is not allowed")
  41886. } else {
  41887. value, err = m.Client().WorkExperience.Get(ctx, id)
  41888. }
  41889. })
  41890. return value, err
  41891. }
  41892. m.id = &id
  41893. }
  41894. }
  41895. // withWorkExperience sets the old WorkExperience of the mutation.
  41896. func withWorkExperience(node *WorkExperience) workexperienceOption {
  41897. return func(m *WorkExperienceMutation) {
  41898. m.oldValue = func(context.Context) (*WorkExperience, error) {
  41899. return node, nil
  41900. }
  41901. m.id = &node.ID
  41902. }
  41903. }
  41904. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41905. // executed in a transaction (ent.Tx), a transactional client is returned.
  41906. func (m WorkExperienceMutation) Client() *Client {
  41907. client := &Client{config: m.config}
  41908. client.init()
  41909. return client
  41910. }
  41911. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41912. // it returns an error otherwise.
  41913. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  41914. if _, ok := m.driver.(*txDriver); !ok {
  41915. return nil, errors.New("ent: mutation is not running in a transaction")
  41916. }
  41917. tx := &Tx{config: m.config}
  41918. tx.init()
  41919. return tx, nil
  41920. }
  41921. // SetID sets the value of the id field. Note that this
  41922. // operation is only accepted on creation of WorkExperience entities.
  41923. func (m *WorkExperienceMutation) SetID(id uint64) {
  41924. m.id = &id
  41925. }
  41926. // ID returns the ID value in the mutation. Note that the ID is only available
  41927. // if it was provided to the builder or after it was returned from the database.
  41928. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  41929. if m.id == nil {
  41930. return
  41931. }
  41932. return *m.id, true
  41933. }
  41934. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41935. // That means, if the mutation is applied within a transaction with an isolation level such
  41936. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41937. // or updated by the mutation.
  41938. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  41939. switch {
  41940. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41941. id, exists := m.ID()
  41942. if exists {
  41943. return []uint64{id}, nil
  41944. }
  41945. fallthrough
  41946. case m.op.Is(OpUpdate | OpDelete):
  41947. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  41948. default:
  41949. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41950. }
  41951. }
  41952. // SetCreatedAt sets the "created_at" field.
  41953. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  41954. m.created_at = &t
  41955. }
  41956. // CreatedAt returns the value of the "created_at" field in the mutation.
  41957. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  41958. v := m.created_at
  41959. if v == nil {
  41960. return
  41961. }
  41962. return *v, true
  41963. }
  41964. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  41965. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41967. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41968. if !m.op.Is(OpUpdateOne) {
  41969. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41970. }
  41971. if m.id == nil || m.oldValue == nil {
  41972. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41973. }
  41974. oldValue, err := m.oldValue(ctx)
  41975. if err != nil {
  41976. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41977. }
  41978. return oldValue.CreatedAt, nil
  41979. }
  41980. // ResetCreatedAt resets all changes to the "created_at" field.
  41981. func (m *WorkExperienceMutation) ResetCreatedAt() {
  41982. m.created_at = nil
  41983. }
  41984. // SetUpdatedAt sets the "updated_at" field.
  41985. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  41986. m.updated_at = &t
  41987. }
  41988. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41989. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  41990. v := m.updated_at
  41991. if v == nil {
  41992. return
  41993. }
  41994. return *v, true
  41995. }
  41996. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  41997. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41999. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42000. if !m.op.Is(OpUpdateOne) {
  42001. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42002. }
  42003. if m.id == nil || m.oldValue == nil {
  42004. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42005. }
  42006. oldValue, err := m.oldValue(ctx)
  42007. if err != nil {
  42008. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42009. }
  42010. return oldValue.UpdatedAt, nil
  42011. }
  42012. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42013. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  42014. m.updated_at = nil
  42015. }
  42016. // SetDeletedAt sets the "deleted_at" field.
  42017. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  42018. m.deleted_at = &t
  42019. }
  42020. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42021. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  42022. v := m.deleted_at
  42023. if v == nil {
  42024. return
  42025. }
  42026. return *v, true
  42027. }
  42028. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  42029. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42031. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42032. if !m.op.Is(OpUpdateOne) {
  42033. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42034. }
  42035. if m.id == nil || m.oldValue == nil {
  42036. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42037. }
  42038. oldValue, err := m.oldValue(ctx)
  42039. if err != nil {
  42040. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42041. }
  42042. return oldValue.DeletedAt, nil
  42043. }
  42044. // ClearDeletedAt clears the value of the "deleted_at" field.
  42045. func (m *WorkExperienceMutation) ClearDeletedAt() {
  42046. m.deleted_at = nil
  42047. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  42048. }
  42049. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42050. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  42051. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  42052. return ok
  42053. }
  42054. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42055. func (m *WorkExperienceMutation) ResetDeletedAt() {
  42056. m.deleted_at = nil
  42057. delete(m.clearedFields, workexperience.FieldDeletedAt)
  42058. }
  42059. // SetEmployeeID sets the "employee_id" field.
  42060. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  42061. m.employee = &u
  42062. }
  42063. // EmployeeID returns the value of the "employee_id" field in the mutation.
  42064. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  42065. v := m.employee
  42066. if v == nil {
  42067. return
  42068. }
  42069. return *v, true
  42070. }
  42071. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  42072. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42074. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  42075. if !m.op.Is(OpUpdateOne) {
  42076. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  42077. }
  42078. if m.id == nil || m.oldValue == nil {
  42079. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  42080. }
  42081. oldValue, err := m.oldValue(ctx)
  42082. if err != nil {
  42083. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  42084. }
  42085. return oldValue.EmployeeID, nil
  42086. }
  42087. // ResetEmployeeID resets all changes to the "employee_id" field.
  42088. func (m *WorkExperienceMutation) ResetEmployeeID() {
  42089. m.employee = nil
  42090. }
  42091. // SetStartDate sets the "start_date" field.
  42092. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  42093. m.start_date = &t
  42094. }
  42095. // StartDate returns the value of the "start_date" field in the mutation.
  42096. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  42097. v := m.start_date
  42098. if v == nil {
  42099. return
  42100. }
  42101. return *v, true
  42102. }
  42103. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  42104. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42106. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  42107. if !m.op.Is(OpUpdateOne) {
  42108. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  42109. }
  42110. if m.id == nil || m.oldValue == nil {
  42111. return v, errors.New("OldStartDate requires an ID field in the mutation")
  42112. }
  42113. oldValue, err := m.oldValue(ctx)
  42114. if err != nil {
  42115. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  42116. }
  42117. return oldValue.StartDate, nil
  42118. }
  42119. // ResetStartDate resets all changes to the "start_date" field.
  42120. func (m *WorkExperienceMutation) ResetStartDate() {
  42121. m.start_date = nil
  42122. }
  42123. // SetEndDate sets the "end_date" field.
  42124. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  42125. m.end_date = &t
  42126. }
  42127. // EndDate returns the value of the "end_date" field in the mutation.
  42128. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  42129. v := m.end_date
  42130. if v == nil {
  42131. return
  42132. }
  42133. return *v, true
  42134. }
  42135. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  42136. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42138. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  42139. if !m.op.Is(OpUpdateOne) {
  42140. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  42141. }
  42142. if m.id == nil || m.oldValue == nil {
  42143. return v, errors.New("OldEndDate requires an ID field in the mutation")
  42144. }
  42145. oldValue, err := m.oldValue(ctx)
  42146. if err != nil {
  42147. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  42148. }
  42149. return oldValue.EndDate, nil
  42150. }
  42151. // ResetEndDate resets all changes to the "end_date" field.
  42152. func (m *WorkExperienceMutation) ResetEndDate() {
  42153. m.end_date = nil
  42154. }
  42155. // SetCompany sets the "company" field.
  42156. func (m *WorkExperienceMutation) SetCompany(s string) {
  42157. m.company = &s
  42158. }
  42159. // Company returns the value of the "company" field in the mutation.
  42160. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  42161. v := m.company
  42162. if v == nil {
  42163. return
  42164. }
  42165. return *v, true
  42166. }
  42167. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  42168. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42170. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  42171. if !m.op.Is(OpUpdateOne) {
  42172. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  42173. }
  42174. if m.id == nil || m.oldValue == nil {
  42175. return v, errors.New("OldCompany requires an ID field in the mutation")
  42176. }
  42177. oldValue, err := m.oldValue(ctx)
  42178. if err != nil {
  42179. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  42180. }
  42181. return oldValue.Company, nil
  42182. }
  42183. // ResetCompany resets all changes to the "company" field.
  42184. func (m *WorkExperienceMutation) ResetCompany() {
  42185. m.company = nil
  42186. }
  42187. // SetExperience sets the "experience" field.
  42188. func (m *WorkExperienceMutation) SetExperience(s string) {
  42189. m.experience = &s
  42190. }
  42191. // Experience returns the value of the "experience" field in the mutation.
  42192. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  42193. v := m.experience
  42194. if v == nil {
  42195. return
  42196. }
  42197. return *v, true
  42198. }
  42199. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  42200. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42202. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  42203. if !m.op.Is(OpUpdateOne) {
  42204. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  42205. }
  42206. if m.id == nil || m.oldValue == nil {
  42207. return v, errors.New("OldExperience requires an ID field in the mutation")
  42208. }
  42209. oldValue, err := m.oldValue(ctx)
  42210. if err != nil {
  42211. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  42212. }
  42213. return oldValue.Experience, nil
  42214. }
  42215. // ResetExperience resets all changes to the "experience" field.
  42216. func (m *WorkExperienceMutation) ResetExperience() {
  42217. m.experience = nil
  42218. }
  42219. // SetOrganizationID sets the "organization_id" field.
  42220. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  42221. m.organization_id = &u
  42222. m.addorganization_id = nil
  42223. }
  42224. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42225. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  42226. v := m.organization_id
  42227. if v == nil {
  42228. return
  42229. }
  42230. return *v, true
  42231. }
  42232. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  42233. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42235. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42236. if !m.op.Is(OpUpdateOne) {
  42237. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42238. }
  42239. if m.id == nil || m.oldValue == nil {
  42240. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42241. }
  42242. oldValue, err := m.oldValue(ctx)
  42243. if err != nil {
  42244. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42245. }
  42246. return oldValue.OrganizationID, nil
  42247. }
  42248. // AddOrganizationID adds u to the "organization_id" field.
  42249. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  42250. if m.addorganization_id != nil {
  42251. *m.addorganization_id += u
  42252. } else {
  42253. m.addorganization_id = &u
  42254. }
  42255. }
  42256. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42257. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  42258. v := m.addorganization_id
  42259. if v == nil {
  42260. return
  42261. }
  42262. return *v, true
  42263. }
  42264. // ResetOrganizationID resets all changes to the "organization_id" field.
  42265. func (m *WorkExperienceMutation) ResetOrganizationID() {
  42266. m.organization_id = nil
  42267. m.addorganization_id = nil
  42268. }
  42269. // ClearEmployee clears the "employee" edge to the Employee entity.
  42270. func (m *WorkExperienceMutation) ClearEmployee() {
  42271. m.clearedemployee = true
  42272. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  42273. }
  42274. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  42275. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  42276. return m.clearedemployee
  42277. }
  42278. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  42279. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42280. // EmployeeID instead. It exists only for internal usage by the builders.
  42281. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  42282. if id := m.employee; id != nil {
  42283. ids = append(ids, *id)
  42284. }
  42285. return
  42286. }
  42287. // ResetEmployee resets all changes to the "employee" edge.
  42288. func (m *WorkExperienceMutation) ResetEmployee() {
  42289. m.employee = nil
  42290. m.clearedemployee = false
  42291. }
  42292. // Where appends a list predicates to the WorkExperienceMutation builder.
  42293. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  42294. m.predicates = append(m.predicates, ps...)
  42295. }
  42296. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  42297. // users can use type-assertion to append predicates that do not depend on any generated package.
  42298. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  42299. p := make([]predicate.WorkExperience, len(ps))
  42300. for i := range ps {
  42301. p[i] = ps[i]
  42302. }
  42303. m.Where(p...)
  42304. }
  42305. // Op returns the operation name.
  42306. func (m *WorkExperienceMutation) Op() Op {
  42307. return m.op
  42308. }
  42309. // SetOp allows setting the mutation operation.
  42310. func (m *WorkExperienceMutation) SetOp(op Op) {
  42311. m.op = op
  42312. }
  42313. // Type returns the node type of this mutation (WorkExperience).
  42314. func (m *WorkExperienceMutation) Type() string {
  42315. return m.typ
  42316. }
  42317. // Fields returns all fields that were changed during this mutation. Note that in
  42318. // order to get all numeric fields that were incremented/decremented, call
  42319. // AddedFields().
  42320. func (m *WorkExperienceMutation) Fields() []string {
  42321. fields := make([]string, 0, 9)
  42322. if m.created_at != nil {
  42323. fields = append(fields, workexperience.FieldCreatedAt)
  42324. }
  42325. if m.updated_at != nil {
  42326. fields = append(fields, workexperience.FieldUpdatedAt)
  42327. }
  42328. if m.deleted_at != nil {
  42329. fields = append(fields, workexperience.FieldDeletedAt)
  42330. }
  42331. if m.employee != nil {
  42332. fields = append(fields, workexperience.FieldEmployeeID)
  42333. }
  42334. if m.start_date != nil {
  42335. fields = append(fields, workexperience.FieldStartDate)
  42336. }
  42337. if m.end_date != nil {
  42338. fields = append(fields, workexperience.FieldEndDate)
  42339. }
  42340. if m.company != nil {
  42341. fields = append(fields, workexperience.FieldCompany)
  42342. }
  42343. if m.experience != nil {
  42344. fields = append(fields, workexperience.FieldExperience)
  42345. }
  42346. if m.organization_id != nil {
  42347. fields = append(fields, workexperience.FieldOrganizationID)
  42348. }
  42349. return fields
  42350. }
  42351. // Field returns the value of a field with the given name. The second boolean
  42352. // return value indicates that this field was not set, or was not defined in the
  42353. // schema.
  42354. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  42355. switch name {
  42356. case workexperience.FieldCreatedAt:
  42357. return m.CreatedAt()
  42358. case workexperience.FieldUpdatedAt:
  42359. return m.UpdatedAt()
  42360. case workexperience.FieldDeletedAt:
  42361. return m.DeletedAt()
  42362. case workexperience.FieldEmployeeID:
  42363. return m.EmployeeID()
  42364. case workexperience.FieldStartDate:
  42365. return m.StartDate()
  42366. case workexperience.FieldEndDate:
  42367. return m.EndDate()
  42368. case workexperience.FieldCompany:
  42369. return m.Company()
  42370. case workexperience.FieldExperience:
  42371. return m.Experience()
  42372. case workexperience.FieldOrganizationID:
  42373. return m.OrganizationID()
  42374. }
  42375. return nil, false
  42376. }
  42377. // OldField returns the old value of the field from the database. An error is
  42378. // returned if the mutation operation is not UpdateOne, or the query to the
  42379. // database failed.
  42380. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42381. switch name {
  42382. case workexperience.FieldCreatedAt:
  42383. return m.OldCreatedAt(ctx)
  42384. case workexperience.FieldUpdatedAt:
  42385. return m.OldUpdatedAt(ctx)
  42386. case workexperience.FieldDeletedAt:
  42387. return m.OldDeletedAt(ctx)
  42388. case workexperience.FieldEmployeeID:
  42389. return m.OldEmployeeID(ctx)
  42390. case workexperience.FieldStartDate:
  42391. return m.OldStartDate(ctx)
  42392. case workexperience.FieldEndDate:
  42393. return m.OldEndDate(ctx)
  42394. case workexperience.FieldCompany:
  42395. return m.OldCompany(ctx)
  42396. case workexperience.FieldExperience:
  42397. return m.OldExperience(ctx)
  42398. case workexperience.FieldOrganizationID:
  42399. return m.OldOrganizationID(ctx)
  42400. }
  42401. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  42402. }
  42403. // SetField sets the value of a field with the given name. It returns an error if
  42404. // the field is not defined in the schema, or if the type mismatched the field
  42405. // type.
  42406. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  42407. switch name {
  42408. case workexperience.FieldCreatedAt:
  42409. v, ok := value.(time.Time)
  42410. if !ok {
  42411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42412. }
  42413. m.SetCreatedAt(v)
  42414. return nil
  42415. case workexperience.FieldUpdatedAt:
  42416. v, ok := value.(time.Time)
  42417. if !ok {
  42418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42419. }
  42420. m.SetUpdatedAt(v)
  42421. return nil
  42422. case workexperience.FieldDeletedAt:
  42423. v, ok := value.(time.Time)
  42424. if !ok {
  42425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42426. }
  42427. m.SetDeletedAt(v)
  42428. return nil
  42429. case workexperience.FieldEmployeeID:
  42430. v, ok := value.(uint64)
  42431. if !ok {
  42432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42433. }
  42434. m.SetEmployeeID(v)
  42435. return nil
  42436. case workexperience.FieldStartDate:
  42437. v, ok := value.(time.Time)
  42438. if !ok {
  42439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42440. }
  42441. m.SetStartDate(v)
  42442. return nil
  42443. case workexperience.FieldEndDate:
  42444. v, ok := value.(time.Time)
  42445. if !ok {
  42446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42447. }
  42448. m.SetEndDate(v)
  42449. return nil
  42450. case workexperience.FieldCompany:
  42451. v, ok := value.(string)
  42452. if !ok {
  42453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42454. }
  42455. m.SetCompany(v)
  42456. return nil
  42457. case workexperience.FieldExperience:
  42458. v, ok := value.(string)
  42459. if !ok {
  42460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42461. }
  42462. m.SetExperience(v)
  42463. return nil
  42464. case workexperience.FieldOrganizationID:
  42465. v, ok := value.(uint64)
  42466. if !ok {
  42467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42468. }
  42469. m.SetOrganizationID(v)
  42470. return nil
  42471. }
  42472. return fmt.Errorf("unknown WorkExperience field %s", name)
  42473. }
  42474. // AddedFields returns all numeric fields that were incremented/decremented during
  42475. // this mutation.
  42476. func (m *WorkExperienceMutation) AddedFields() []string {
  42477. var fields []string
  42478. if m.addorganization_id != nil {
  42479. fields = append(fields, workexperience.FieldOrganizationID)
  42480. }
  42481. return fields
  42482. }
  42483. // AddedField returns the numeric value that was incremented/decremented on a field
  42484. // with the given name. The second boolean return value indicates that this field
  42485. // was not set, or was not defined in the schema.
  42486. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  42487. switch name {
  42488. case workexperience.FieldOrganizationID:
  42489. return m.AddedOrganizationID()
  42490. }
  42491. return nil, false
  42492. }
  42493. // AddField adds the value to the field with the given name. It returns an error if
  42494. // the field is not defined in the schema, or if the type mismatched the field
  42495. // type.
  42496. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  42497. switch name {
  42498. case workexperience.FieldOrganizationID:
  42499. v, ok := value.(int64)
  42500. if !ok {
  42501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42502. }
  42503. m.AddOrganizationID(v)
  42504. return nil
  42505. }
  42506. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  42507. }
  42508. // ClearedFields returns all nullable fields that were cleared during this
  42509. // mutation.
  42510. func (m *WorkExperienceMutation) ClearedFields() []string {
  42511. var fields []string
  42512. if m.FieldCleared(workexperience.FieldDeletedAt) {
  42513. fields = append(fields, workexperience.FieldDeletedAt)
  42514. }
  42515. return fields
  42516. }
  42517. // FieldCleared returns a boolean indicating if a field with the given name was
  42518. // cleared in this mutation.
  42519. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  42520. _, ok := m.clearedFields[name]
  42521. return ok
  42522. }
  42523. // ClearField clears the value of the field with the given name. It returns an
  42524. // error if the field is not defined in the schema.
  42525. func (m *WorkExperienceMutation) ClearField(name string) error {
  42526. switch name {
  42527. case workexperience.FieldDeletedAt:
  42528. m.ClearDeletedAt()
  42529. return nil
  42530. }
  42531. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  42532. }
  42533. // ResetField resets all changes in the mutation for the field with the given name.
  42534. // It returns an error if the field is not defined in the schema.
  42535. func (m *WorkExperienceMutation) ResetField(name string) error {
  42536. switch name {
  42537. case workexperience.FieldCreatedAt:
  42538. m.ResetCreatedAt()
  42539. return nil
  42540. case workexperience.FieldUpdatedAt:
  42541. m.ResetUpdatedAt()
  42542. return nil
  42543. case workexperience.FieldDeletedAt:
  42544. m.ResetDeletedAt()
  42545. return nil
  42546. case workexperience.FieldEmployeeID:
  42547. m.ResetEmployeeID()
  42548. return nil
  42549. case workexperience.FieldStartDate:
  42550. m.ResetStartDate()
  42551. return nil
  42552. case workexperience.FieldEndDate:
  42553. m.ResetEndDate()
  42554. return nil
  42555. case workexperience.FieldCompany:
  42556. m.ResetCompany()
  42557. return nil
  42558. case workexperience.FieldExperience:
  42559. m.ResetExperience()
  42560. return nil
  42561. case workexperience.FieldOrganizationID:
  42562. m.ResetOrganizationID()
  42563. return nil
  42564. }
  42565. return fmt.Errorf("unknown WorkExperience field %s", name)
  42566. }
  42567. // AddedEdges returns all edge names that were set/added in this mutation.
  42568. func (m *WorkExperienceMutation) AddedEdges() []string {
  42569. edges := make([]string, 0, 1)
  42570. if m.employee != nil {
  42571. edges = append(edges, workexperience.EdgeEmployee)
  42572. }
  42573. return edges
  42574. }
  42575. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42576. // name in this mutation.
  42577. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  42578. switch name {
  42579. case workexperience.EdgeEmployee:
  42580. if id := m.employee; id != nil {
  42581. return []ent.Value{*id}
  42582. }
  42583. }
  42584. return nil
  42585. }
  42586. // RemovedEdges returns all edge names that were removed in this mutation.
  42587. func (m *WorkExperienceMutation) RemovedEdges() []string {
  42588. edges := make([]string, 0, 1)
  42589. return edges
  42590. }
  42591. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42592. // the given name in this mutation.
  42593. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  42594. return nil
  42595. }
  42596. // ClearedEdges returns all edge names that were cleared in this mutation.
  42597. func (m *WorkExperienceMutation) ClearedEdges() []string {
  42598. edges := make([]string, 0, 1)
  42599. if m.clearedemployee {
  42600. edges = append(edges, workexperience.EdgeEmployee)
  42601. }
  42602. return edges
  42603. }
  42604. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42605. // was cleared in this mutation.
  42606. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  42607. switch name {
  42608. case workexperience.EdgeEmployee:
  42609. return m.clearedemployee
  42610. }
  42611. return false
  42612. }
  42613. // ClearEdge clears the value of the edge with the given name. It returns an error
  42614. // if that edge is not defined in the schema.
  42615. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  42616. switch name {
  42617. case workexperience.EdgeEmployee:
  42618. m.ClearEmployee()
  42619. return nil
  42620. }
  42621. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  42622. }
  42623. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42624. // It returns an error if the edge is not defined in the schema.
  42625. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  42626. switch name {
  42627. case workexperience.EdgeEmployee:
  42628. m.ResetEmployee()
  42629. return nil
  42630. }
  42631. return fmt.Errorf("unknown WorkExperience edge %s", name)
  42632. }
  42633. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  42634. type WpChatroomMutation struct {
  42635. config
  42636. op Op
  42637. typ string
  42638. id *uint64
  42639. created_at *time.Time
  42640. updated_at *time.Time
  42641. status *uint8
  42642. addstatus *int8
  42643. wx_wxid *string
  42644. chatroom_id *string
  42645. nickname *string
  42646. owner *string
  42647. avatar *string
  42648. member_list *[]string
  42649. appendmember_list []string
  42650. clearedFields map[string]struct{}
  42651. done bool
  42652. oldValue func(context.Context) (*WpChatroom, error)
  42653. predicates []predicate.WpChatroom
  42654. }
  42655. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  42656. // wpchatroomOption allows management of the mutation configuration using functional options.
  42657. type wpchatroomOption func(*WpChatroomMutation)
  42658. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  42659. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  42660. m := &WpChatroomMutation{
  42661. config: c,
  42662. op: op,
  42663. typ: TypeWpChatroom,
  42664. clearedFields: make(map[string]struct{}),
  42665. }
  42666. for _, opt := range opts {
  42667. opt(m)
  42668. }
  42669. return m
  42670. }
  42671. // withWpChatroomID sets the ID field of the mutation.
  42672. func withWpChatroomID(id uint64) wpchatroomOption {
  42673. return func(m *WpChatroomMutation) {
  42674. var (
  42675. err error
  42676. once sync.Once
  42677. value *WpChatroom
  42678. )
  42679. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  42680. once.Do(func() {
  42681. if m.done {
  42682. err = errors.New("querying old values post mutation is not allowed")
  42683. } else {
  42684. value, err = m.Client().WpChatroom.Get(ctx, id)
  42685. }
  42686. })
  42687. return value, err
  42688. }
  42689. m.id = &id
  42690. }
  42691. }
  42692. // withWpChatroom sets the old WpChatroom of the mutation.
  42693. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  42694. return func(m *WpChatroomMutation) {
  42695. m.oldValue = func(context.Context) (*WpChatroom, error) {
  42696. return node, nil
  42697. }
  42698. m.id = &node.ID
  42699. }
  42700. }
  42701. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42702. // executed in a transaction (ent.Tx), a transactional client is returned.
  42703. func (m WpChatroomMutation) Client() *Client {
  42704. client := &Client{config: m.config}
  42705. client.init()
  42706. return client
  42707. }
  42708. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42709. // it returns an error otherwise.
  42710. func (m WpChatroomMutation) Tx() (*Tx, error) {
  42711. if _, ok := m.driver.(*txDriver); !ok {
  42712. return nil, errors.New("ent: mutation is not running in a transaction")
  42713. }
  42714. tx := &Tx{config: m.config}
  42715. tx.init()
  42716. return tx, nil
  42717. }
  42718. // SetID sets the value of the id field. Note that this
  42719. // operation is only accepted on creation of WpChatroom entities.
  42720. func (m *WpChatroomMutation) SetID(id uint64) {
  42721. m.id = &id
  42722. }
  42723. // ID returns the ID value in the mutation. Note that the ID is only available
  42724. // if it was provided to the builder or after it was returned from the database.
  42725. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  42726. if m.id == nil {
  42727. return
  42728. }
  42729. return *m.id, true
  42730. }
  42731. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42732. // That means, if the mutation is applied within a transaction with an isolation level such
  42733. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42734. // or updated by the mutation.
  42735. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  42736. switch {
  42737. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42738. id, exists := m.ID()
  42739. if exists {
  42740. return []uint64{id}, nil
  42741. }
  42742. fallthrough
  42743. case m.op.Is(OpUpdate | OpDelete):
  42744. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  42745. default:
  42746. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42747. }
  42748. }
  42749. // SetCreatedAt sets the "created_at" field.
  42750. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  42751. m.created_at = &t
  42752. }
  42753. // CreatedAt returns the value of the "created_at" field in the mutation.
  42754. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  42755. v := m.created_at
  42756. if v == nil {
  42757. return
  42758. }
  42759. return *v, true
  42760. }
  42761. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  42762. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42764. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42765. if !m.op.Is(OpUpdateOne) {
  42766. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42767. }
  42768. if m.id == nil || m.oldValue == nil {
  42769. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42770. }
  42771. oldValue, err := m.oldValue(ctx)
  42772. if err != nil {
  42773. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42774. }
  42775. return oldValue.CreatedAt, nil
  42776. }
  42777. // ResetCreatedAt resets all changes to the "created_at" field.
  42778. func (m *WpChatroomMutation) ResetCreatedAt() {
  42779. m.created_at = nil
  42780. }
  42781. // SetUpdatedAt sets the "updated_at" field.
  42782. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  42783. m.updated_at = &t
  42784. }
  42785. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42786. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  42787. v := m.updated_at
  42788. if v == nil {
  42789. return
  42790. }
  42791. return *v, true
  42792. }
  42793. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  42794. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42796. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42797. if !m.op.Is(OpUpdateOne) {
  42798. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42799. }
  42800. if m.id == nil || m.oldValue == nil {
  42801. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42802. }
  42803. oldValue, err := m.oldValue(ctx)
  42804. if err != nil {
  42805. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42806. }
  42807. return oldValue.UpdatedAt, nil
  42808. }
  42809. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42810. func (m *WpChatroomMutation) ResetUpdatedAt() {
  42811. m.updated_at = nil
  42812. }
  42813. // SetStatus sets the "status" field.
  42814. func (m *WpChatroomMutation) SetStatus(u uint8) {
  42815. m.status = &u
  42816. m.addstatus = nil
  42817. }
  42818. // Status returns the value of the "status" field in the mutation.
  42819. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  42820. v := m.status
  42821. if v == nil {
  42822. return
  42823. }
  42824. return *v, true
  42825. }
  42826. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  42827. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42829. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42830. if !m.op.Is(OpUpdateOne) {
  42831. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42832. }
  42833. if m.id == nil || m.oldValue == nil {
  42834. return v, errors.New("OldStatus requires an ID field in the mutation")
  42835. }
  42836. oldValue, err := m.oldValue(ctx)
  42837. if err != nil {
  42838. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42839. }
  42840. return oldValue.Status, nil
  42841. }
  42842. // AddStatus adds u to the "status" field.
  42843. func (m *WpChatroomMutation) AddStatus(u int8) {
  42844. if m.addstatus != nil {
  42845. *m.addstatus += u
  42846. } else {
  42847. m.addstatus = &u
  42848. }
  42849. }
  42850. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42851. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  42852. v := m.addstatus
  42853. if v == nil {
  42854. return
  42855. }
  42856. return *v, true
  42857. }
  42858. // ClearStatus clears the value of the "status" field.
  42859. func (m *WpChatroomMutation) ClearStatus() {
  42860. m.status = nil
  42861. m.addstatus = nil
  42862. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  42863. }
  42864. // StatusCleared returns if the "status" field was cleared in this mutation.
  42865. func (m *WpChatroomMutation) StatusCleared() bool {
  42866. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  42867. return ok
  42868. }
  42869. // ResetStatus resets all changes to the "status" field.
  42870. func (m *WpChatroomMutation) ResetStatus() {
  42871. m.status = nil
  42872. m.addstatus = nil
  42873. delete(m.clearedFields, wpchatroom.FieldStatus)
  42874. }
  42875. // SetWxWxid sets the "wx_wxid" field.
  42876. func (m *WpChatroomMutation) SetWxWxid(s string) {
  42877. m.wx_wxid = &s
  42878. }
  42879. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  42880. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  42881. v := m.wx_wxid
  42882. if v == nil {
  42883. return
  42884. }
  42885. return *v, true
  42886. }
  42887. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  42888. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42890. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42891. if !m.op.Is(OpUpdateOne) {
  42892. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42893. }
  42894. if m.id == nil || m.oldValue == nil {
  42895. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42896. }
  42897. oldValue, err := m.oldValue(ctx)
  42898. if err != nil {
  42899. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42900. }
  42901. return oldValue.WxWxid, nil
  42902. }
  42903. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42904. func (m *WpChatroomMutation) ResetWxWxid() {
  42905. m.wx_wxid = nil
  42906. }
  42907. // SetChatroomID sets the "chatroom_id" field.
  42908. func (m *WpChatroomMutation) SetChatroomID(s string) {
  42909. m.chatroom_id = &s
  42910. }
  42911. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  42912. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  42913. v := m.chatroom_id
  42914. if v == nil {
  42915. return
  42916. }
  42917. return *v, true
  42918. }
  42919. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  42920. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42922. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  42923. if !m.op.Is(OpUpdateOne) {
  42924. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  42925. }
  42926. if m.id == nil || m.oldValue == nil {
  42927. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  42928. }
  42929. oldValue, err := m.oldValue(ctx)
  42930. if err != nil {
  42931. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  42932. }
  42933. return oldValue.ChatroomID, nil
  42934. }
  42935. // ResetChatroomID resets all changes to the "chatroom_id" field.
  42936. func (m *WpChatroomMutation) ResetChatroomID() {
  42937. m.chatroom_id = nil
  42938. }
  42939. // SetNickname sets the "nickname" field.
  42940. func (m *WpChatroomMutation) SetNickname(s string) {
  42941. m.nickname = &s
  42942. }
  42943. // Nickname returns the value of the "nickname" field in the mutation.
  42944. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  42945. v := m.nickname
  42946. if v == nil {
  42947. return
  42948. }
  42949. return *v, true
  42950. }
  42951. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  42952. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42954. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  42955. if !m.op.Is(OpUpdateOne) {
  42956. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42957. }
  42958. if m.id == nil || m.oldValue == nil {
  42959. return v, errors.New("OldNickname requires an ID field in the mutation")
  42960. }
  42961. oldValue, err := m.oldValue(ctx)
  42962. if err != nil {
  42963. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42964. }
  42965. return oldValue.Nickname, nil
  42966. }
  42967. // ResetNickname resets all changes to the "nickname" field.
  42968. func (m *WpChatroomMutation) ResetNickname() {
  42969. m.nickname = nil
  42970. }
  42971. // SetOwner sets the "owner" field.
  42972. func (m *WpChatroomMutation) SetOwner(s string) {
  42973. m.owner = &s
  42974. }
  42975. // Owner returns the value of the "owner" field in the mutation.
  42976. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  42977. v := m.owner
  42978. if v == nil {
  42979. return
  42980. }
  42981. return *v, true
  42982. }
  42983. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  42984. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42986. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  42987. if !m.op.Is(OpUpdateOne) {
  42988. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  42989. }
  42990. if m.id == nil || m.oldValue == nil {
  42991. return v, errors.New("OldOwner requires an ID field in the mutation")
  42992. }
  42993. oldValue, err := m.oldValue(ctx)
  42994. if err != nil {
  42995. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  42996. }
  42997. return oldValue.Owner, nil
  42998. }
  42999. // ResetOwner resets all changes to the "owner" field.
  43000. func (m *WpChatroomMutation) ResetOwner() {
  43001. m.owner = nil
  43002. }
  43003. // SetAvatar sets the "avatar" field.
  43004. func (m *WpChatroomMutation) SetAvatar(s string) {
  43005. m.avatar = &s
  43006. }
  43007. // Avatar returns the value of the "avatar" field in the mutation.
  43008. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  43009. v := m.avatar
  43010. if v == nil {
  43011. return
  43012. }
  43013. return *v, true
  43014. }
  43015. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  43016. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43018. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43019. if !m.op.Is(OpUpdateOne) {
  43020. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43021. }
  43022. if m.id == nil || m.oldValue == nil {
  43023. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43024. }
  43025. oldValue, err := m.oldValue(ctx)
  43026. if err != nil {
  43027. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43028. }
  43029. return oldValue.Avatar, nil
  43030. }
  43031. // ResetAvatar resets all changes to the "avatar" field.
  43032. func (m *WpChatroomMutation) ResetAvatar() {
  43033. m.avatar = nil
  43034. }
  43035. // SetMemberList sets the "member_list" field.
  43036. func (m *WpChatroomMutation) SetMemberList(s []string) {
  43037. m.member_list = &s
  43038. m.appendmember_list = nil
  43039. }
  43040. // MemberList returns the value of the "member_list" field in the mutation.
  43041. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  43042. v := m.member_list
  43043. if v == nil {
  43044. return
  43045. }
  43046. return *v, true
  43047. }
  43048. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  43049. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43051. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  43052. if !m.op.Is(OpUpdateOne) {
  43053. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  43054. }
  43055. if m.id == nil || m.oldValue == nil {
  43056. return v, errors.New("OldMemberList requires an ID field in the mutation")
  43057. }
  43058. oldValue, err := m.oldValue(ctx)
  43059. if err != nil {
  43060. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  43061. }
  43062. return oldValue.MemberList, nil
  43063. }
  43064. // AppendMemberList adds s to the "member_list" field.
  43065. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  43066. m.appendmember_list = append(m.appendmember_list, s...)
  43067. }
  43068. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  43069. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  43070. if len(m.appendmember_list) == 0 {
  43071. return nil, false
  43072. }
  43073. return m.appendmember_list, true
  43074. }
  43075. // ResetMemberList resets all changes to the "member_list" field.
  43076. func (m *WpChatroomMutation) ResetMemberList() {
  43077. m.member_list = nil
  43078. m.appendmember_list = nil
  43079. }
  43080. // Where appends a list predicates to the WpChatroomMutation builder.
  43081. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  43082. m.predicates = append(m.predicates, ps...)
  43083. }
  43084. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  43085. // users can use type-assertion to append predicates that do not depend on any generated package.
  43086. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  43087. p := make([]predicate.WpChatroom, len(ps))
  43088. for i := range ps {
  43089. p[i] = ps[i]
  43090. }
  43091. m.Where(p...)
  43092. }
  43093. // Op returns the operation name.
  43094. func (m *WpChatroomMutation) Op() Op {
  43095. return m.op
  43096. }
  43097. // SetOp allows setting the mutation operation.
  43098. func (m *WpChatroomMutation) SetOp(op Op) {
  43099. m.op = op
  43100. }
  43101. // Type returns the node type of this mutation (WpChatroom).
  43102. func (m *WpChatroomMutation) Type() string {
  43103. return m.typ
  43104. }
  43105. // Fields returns all fields that were changed during this mutation. Note that in
  43106. // order to get all numeric fields that were incremented/decremented, call
  43107. // AddedFields().
  43108. func (m *WpChatroomMutation) Fields() []string {
  43109. fields := make([]string, 0, 9)
  43110. if m.created_at != nil {
  43111. fields = append(fields, wpchatroom.FieldCreatedAt)
  43112. }
  43113. if m.updated_at != nil {
  43114. fields = append(fields, wpchatroom.FieldUpdatedAt)
  43115. }
  43116. if m.status != nil {
  43117. fields = append(fields, wpchatroom.FieldStatus)
  43118. }
  43119. if m.wx_wxid != nil {
  43120. fields = append(fields, wpchatroom.FieldWxWxid)
  43121. }
  43122. if m.chatroom_id != nil {
  43123. fields = append(fields, wpchatroom.FieldChatroomID)
  43124. }
  43125. if m.nickname != nil {
  43126. fields = append(fields, wpchatroom.FieldNickname)
  43127. }
  43128. if m.owner != nil {
  43129. fields = append(fields, wpchatroom.FieldOwner)
  43130. }
  43131. if m.avatar != nil {
  43132. fields = append(fields, wpchatroom.FieldAvatar)
  43133. }
  43134. if m.member_list != nil {
  43135. fields = append(fields, wpchatroom.FieldMemberList)
  43136. }
  43137. return fields
  43138. }
  43139. // Field returns the value of a field with the given name. The second boolean
  43140. // return value indicates that this field was not set, or was not defined in the
  43141. // schema.
  43142. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  43143. switch name {
  43144. case wpchatroom.FieldCreatedAt:
  43145. return m.CreatedAt()
  43146. case wpchatroom.FieldUpdatedAt:
  43147. return m.UpdatedAt()
  43148. case wpchatroom.FieldStatus:
  43149. return m.Status()
  43150. case wpchatroom.FieldWxWxid:
  43151. return m.WxWxid()
  43152. case wpchatroom.FieldChatroomID:
  43153. return m.ChatroomID()
  43154. case wpchatroom.FieldNickname:
  43155. return m.Nickname()
  43156. case wpchatroom.FieldOwner:
  43157. return m.Owner()
  43158. case wpchatroom.FieldAvatar:
  43159. return m.Avatar()
  43160. case wpchatroom.FieldMemberList:
  43161. return m.MemberList()
  43162. }
  43163. return nil, false
  43164. }
  43165. // OldField returns the old value of the field from the database. An error is
  43166. // returned if the mutation operation is not UpdateOne, or the query to the
  43167. // database failed.
  43168. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43169. switch name {
  43170. case wpchatroom.FieldCreatedAt:
  43171. return m.OldCreatedAt(ctx)
  43172. case wpchatroom.FieldUpdatedAt:
  43173. return m.OldUpdatedAt(ctx)
  43174. case wpchatroom.FieldStatus:
  43175. return m.OldStatus(ctx)
  43176. case wpchatroom.FieldWxWxid:
  43177. return m.OldWxWxid(ctx)
  43178. case wpchatroom.FieldChatroomID:
  43179. return m.OldChatroomID(ctx)
  43180. case wpchatroom.FieldNickname:
  43181. return m.OldNickname(ctx)
  43182. case wpchatroom.FieldOwner:
  43183. return m.OldOwner(ctx)
  43184. case wpchatroom.FieldAvatar:
  43185. return m.OldAvatar(ctx)
  43186. case wpchatroom.FieldMemberList:
  43187. return m.OldMemberList(ctx)
  43188. }
  43189. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  43190. }
  43191. // SetField sets the value of a field with the given name. It returns an error if
  43192. // the field is not defined in the schema, or if the type mismatched the field
  43193. // type.
  43194. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  43195. switch name {
  43196. case wpchatroom.FieldCreatedAt:
  43197. v, ok := value.(time.Time)
  43198. if !ok {
  43199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43200. }
  43201. m.SetCreatedAt(v)
  43202. return nil
  43203. case wpchatroom.FieldUpdatedAt:
  43204. v, ok := value.(time.Time)
  43205. if !ok {
  43206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43207. }
  43208. m.SetUpdatedAt(v)
  43209. return nil
  43210. case wpchatroom.FieldStatus:
  43211. v, ok := value.(uint8)
  43212. if !ok {
  43213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43214. }
  43215. m.SetStatus(v)
  43216. return nil
  43217. case wpchatroom.FieldWxWxid:
  43218. v, ok := value.(string)
  43219. if !ok {
  43220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43221. }
  43222. m.SetWxWxid(v)
  43223. return nil
  43224. case wpchatroom.FieldChatroomID:
  43225. v, ok := value.(string)
  43226. if !ok {
  43227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43228. }
  43229. m.SetChatroomID(v)
  43230. return nil
  43231. case wpchatroom.FieldNickname:
  43232. v, ok := value.(string)
  43233. if !ok {
  43234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43235. }
  43236. m.SetNickname(v)
  43237. return nil
  43238. case wpchatroom.FieldOwner:
  43239. v, ok := value.(string)
  43240. if !ok {
  43241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43242. }
  43243. m.SetOwner(v)
  43244. return nil
  43245. case wpchatroom.FieldAvatar:
  43246. v, ok := value.(string)
  43247. if !ok {
  43248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43249. }
  43250. m.SetAvatar(v)
  43251. return nil
  43252. case wpchatroom.FieldMemberList:
  43253. v, ok := value.([]string)
  43254. if !ok {
  43255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43256. }
  43257. m.SetMemberList(v)
  43258. return nil
  43259. }
  43260. return fmt.Errorf("unknown WpChatroom field %s", name)
  43261. }
  43262. // AddedFields returns all numeric fields that were incremented/decremented during
  43263. // this mutation.
  43264. func (m *WpChatroomMutation) AddedFields() []string {
  43265. var fields []string
  43266. if m.addstatus != nil {
  43267. fields = append(fields, wpchatroom.FieldStatus)
  43268. }
  43269. return fields
  43270. }
  43271. // AddedField returns the numeric value that was incremented/decremented on a field
  43272. // with the given name. The second boolean return value indicates that this field
  43273. // was not set, or was not defined in the schema.
  43274. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  43275. switch name {
  43276. case wpchatroom.FieldStatus:
  43277. return m.AddedStatus()
  43278. }
  43279. return nil, false
  43280. }
  43281. // AddField adds the value to the field with the given name. It returns an error if
  43282. // the field is not defined in the schema, or if the type mismatched the field
  43283. // type.
  43284. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  43285. switch name {
  43286. case wpchatroom.FieldStatus:
  43287. v, ok := value.(int8)
  43288. if !ok {
  43289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43290. }
  43291. m.AddStatus(v)
  43292. return nil
  43293. }
  43294. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  43295. }
  43296. // ClearedFields returns all nullable fields that were cleared during this
  43297. // mutation.
  43298. func (m *WpChatroomMutation) ClearedFields() []string {
  43299. var fields []string
  43300. if m.FieldCleared(wpchatroom.FieldStatus) {
  43301. fields = append(fields, wpchatroom.FieldStatus)
  43302. }
  43303. return fields
  43304. }
  43305. // FieldCleared returns a boolean indicating if a field with the given name was
  43306. // cleared in this mutation.
  43307. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  43308. _, ok := m.clearedFields[name]
  43309. return ok
  43310. }
  43311. // ClearField clears the value of the field with the given name. It returns an
  43312. // error if the field is not defined in the schema.
  43313. func (m *WpChatroomMutation) ClearField(name string) error {
  43314. switch name {
  43315. case wpchatroom.FieldStatus:
  43316. m.ClearStatus()
  43317. return nil
  43318. }
  43319. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  43320. }
  43321. // ResetField resets all changes in the mutation for the field with the given name.
  43322. // It returns an error if the field is not defined in the schema.
  43323. func (m *WpChatroomMutation) ResetField(name string) error {
  43324. switch name {
  43325. case wpchatroom.FieldCreatedAt:
  43326. m.ResetCreatedAt()
  43327. return nil
  43328. case wpchatroom.FieldUpdatedAt:
  43329. m.ResetUpdatedAt()
  43330. return nil
  43331. case wpchatroom.FieldStatus:
  43332. m.ResetStatus()
  43333. return nil
  43334. case wpchatroom.FieldWxWxid:
  43335. m.ResetWxWxid()
  43336. return nil
  43337. case wpchatroom.FieldChatroomID:
  43338. m.ResetChatroomID()
  43339. return nil
  43340. case wpchatroom.FieldNickname:
  43341. m.ResetNickname()
  43342. return nil
  43343. case wpchatroom.FieldOwner:
  43344. m.ResetOwner()
  43345. return nil
  43346. case wpchatroom.FieldAvatar:
  43347. m.ResetAvatar()
  43348. return nil
  43349. case wpchatroom.FieldMemberList:
  43350. m.ResetMemberList()
  43351. return nil
  43352. }
  43353. return fmt.Errorf("unknown WpChatroom field %s", name)
  43354. }
  43355. // AddedEdges returns all edge names that were set/added in this mutation.
  43356. func (m *WpChatroomMutation) AddedEdges() []string {
  43357. edges := make([]string, 0, 0)
  43358. return edges
  43359. }
  43360. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43361. // name in this mutation.
  43362. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  43363. return nil
  43364. }
  43365. // RemovedEdges returns all edge names that were removed in this mutation.
  43366. func (m *WpChatroomMutation) RemovedEdges() []string {
  43367. edges := make([]string, 0, 0)
  43368. return edges
  43369. }
  43370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43371. // the given name in this mutation.
  43372. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  43373. return nil
  43374. }
  43375. // ClearedEdges returns all edge names that were cleared in this mutation.
  43376. func (m *WpChatroomMutation) ClearedEdges() []string {
  43377. edges := make([]string, 0, 0)
  43378. return edges
  43379. }
  43380. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43381. // was cleared in this mutation.
  43382. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  43383. return false
  43384. }
  43385. // ClearEdge clears the value of the edge with the given name. It returns an error
  43386. // if that edge is not defined in the schema.
  43387. func (m *WpChatroomMutation) ClearEdge(name string) error {
  43388. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  43389. }
  43390. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43391. // It returns an error if the edge is not defined in the schema.
  43392. func (m *WpChatroomMutation) ResetEdge(name string) error {
  43393. return fmt.Errorf("unknown WpChatroom edge %s", name)
  43394. }
  43395. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  43396. type WpChatroomMemberMutation struct {
  43397. config
  43398. op Op
  43399. typ string
  43400. id *uint64
  43401. created_at *time.Time
  43402. updated_at *time.Time
  43403. status *uint8
  43404. addstatus *int8
  43405. wx_wxid *string
  43406. wxid *string
  43407. nickname *string
  43408. avatar *string
  43409. clearedFields map[string]struct{}
  43410. done bool
  43411. oldValue func(context.Context) (*WpChatroomMember, error)
  43412. predicates []predicate.WpChatroomMember
  43413. }
  43414. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  43415. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  43416. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  43417. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  43418. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  43419. m := &WpChatroomMemberMutation{
  43420. config: c,
  43421. op: op,
  43422. typ: TypeWpChatroomMember,
  43423. clearedFields: make(map[string]struct{}),
  43424. }
  43425. for _, opt := range opts {
  43426. opt(m)
  43427. }
  43428. return m
  43429. }
  43430. // withWpChatroomMemberID sets the ID field of the mutation.
  43431. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  43432. return func(m *WpChatroomMemberMutation) {
  43433. var (
  43434. err error
  43435. once sync.Once
  43436. value *WpChatroomMember
  43437. )
  43438. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  43439. once.Do(func() {
  43440. if m.done {
  43441. err = errors.New("querying old values post mutation is not allowed")
  43442. } else {
  43443. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  43444. }
  43445. })
  43446. return value, err
  43447. }
  43448. m.id = &id
  43449. }
  43450. }
  43451. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  43452. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  43453. return func(m *WpChatroomMemberMutation) {
  43454. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  43455. return node, nil
  43456. }
  43457. m.id = &node.ID
  43458. }
  43459. }
  43460. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43461. // executed in a transaction (ent.Tx), a transactional client is returned.
  43462. func (m WpChatroomMemberMutation) Client() *Client {
  43463. client := &Client{config: m.config}
  43464. client.init()
  43465. return client
  43466. }
  43467. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43468. // it returns an error otherwise.
  43469. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  43470. if _, ok := m.driver.(*txDriver); !ok {
  43471. return nil, errors.New("ent: mutation is not running in a transaction")
  43472. }
  43473. tx := &Tx{config: m.config}
  43474. tx.init()
  43475. return tx, nil
  43476. }
  43477. // SetID sets the value of the id field. Note that this
  43478. // operation is only accepted on creation of WpChatroomMember entities.
  43479. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  43480. m.id = &id
  43481. }
  43482. // ID returns the ID value in the mutation. Note that the ID is only available
  43483. // if it was provided to the builder or after it was returned from the database.
  43484. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  43485. if m.id == nil {
  43486. return
  43487. }
  43488. return *m.id, true
  43489. }
  43490. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43491. // That means, if the mutation is applied within a transaction with an isolation level such
  43492. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43493. // or updated by the mutation.
  43494. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  43495. switch {
  43496. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43497. id, exists := m.ID()
  43498. if exists {
  43499. return []uint64{id}, nil
  43500. }
  43501. fallthrough
  43502. case m.op.Is(OpUpdate | OpDelete):
  43503. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  43504. default:
  43505. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43506. }
  43507. }
  43508. // SetCreatedAt sets the "created_at" field.
  43509. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  43510. m.created_at = &t
  43511. }
  43512. // CreatedAt returns the value of the "created_at" field in the mutation.
  43513. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  43514. v := m.created_at
  43515. if v == nil {
  43516. return
  43517. }
  43518. return *v, true
  43519. }
  43520. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  43521. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43523. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43524. if !m.op.Is(OpUpdateOne) {
  43525. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43526. }
  43527. if m.id == nil || m.oldValue == nil {
  43528. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43529. }
  43530. oldValue, err := m.oldValue(ctx)
  43531. if err != nil {
  43532. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43533. }
  43534. return oldValue.CreatedAt, nil
  43535. }
  43536. // ResetCreatedAt resets all changes to the "created_at" field.
  43537. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  43538. m.created_at = nil
  43539. }
  43540. // SetUpdatedAt sets the "updated_at" field.
  43541. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  43542. m.updated_at = &t
  43543. }
  43544. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43545. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  43546. v := m.updated_at
  43547. if v == nil {
  43548. return
  43549. }
  43550. return *v, true
  43551. }
  43552. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  43553. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43555. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43556. if !m.op.Is(OpUpdateOne) {
  43557. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43558. }
  43559. if m.id == nil || m.oldValue == nil {
  43560. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43561. }
  43562. oldValue, err := m.oldValue(ctx)
  43563. if err != nil {
  43564. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43565. }
  43566. return oldValue.UpdatedAt, nil
  43567. }
  43568. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43569. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  43570. m.updated_at = nil
  43571. }
  43572. // SetStatus sets the "status" field.
  43573. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  43574. m.status = &u
  43575. m.addstatus = nil
  43576. }
  43577. // Status returns the value of the "status" field in the mutation.
  43578. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  43579. v := m.status
  43580. if v == nil {
  43581. return
  43582. }
  43583. return *v, true
  43584. }
  43585. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  43586. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43588. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43589. if !m.op.Is(OpUpdateOne) {
  43590. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43591. }
  43592. if m.id == nil || m.oldValue == nil {
  43593. return v, errors.New("OldStatus requires an ID field in the mutation")
  43594. }
  43595. oldValue, err := m.oldValue(ctx)
  43596. if err != nil {
  43597. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43598. }
  43599. return oldValue.Status, nil
  43600. }
  43601. // AddStatus adds u to the "status" field.
  43602. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  43603. if m.addstatus != nil {
  43604. *m.addstatus += u
  43605. } else {
  43606. m.addstatus = &u
  43607. }
  43608. }
  43609. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43610. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  43611. v := m.addstatus
  43612. if v == nil {
  43613. return
  43614. }
  43615. return *v, true
  43616. }
  43617. // ClearStatus clears the value of the "status" field.
  43618. func (m *WpChatroomMemberMutation) ClearStatus() {
  43619. m.status = nil
  43620. m.addstatus = nil
  43621. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  43622. }
  43623. // StatusCleared returns if the "status" field was cleared in this mutation.
  43624. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  43625. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  43626. return ok
  43627. }
  43628. // ResetStatus resets all changes to the "status" field.
  43629. func (m *WpChatroomMemberMutation) ResetStatus() {
  43630. m.status = nil
  43631. m.addstatus = nil
  43632. delete(m.clearedFields, wpchatroommember.FieldStatus)
  43633. }
  43634. // SetWxWxid sets the "wx_wxid" field.
  43635. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  43636. m.wx_wxid = &s
  43637. }
  43638. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  43639. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  43640. v := m.wx_wxid
  43641. if v == nil {
  43642. return
  43643. }
  43644. return *v, true
  43645. }
  43646. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  43647. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43649. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  43650. if !m.op.Is(OpUpdateOne) {
  43651. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  43652. }
  43653. if m.id == nil || m.oldValue == nil {
  43654. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  43655. }
  43656. oldValue, err := m.oldValue(ctx)
  43657. if err != nil {
  43658. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  43659. }
  43660. return oldValue.WxWxid, nil
  43661. }
  43662. // ResetWxWxid resets all changes to the "wx_wxid" field.
  43663. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  43664. m.wx_wxid = nil
  43665. }
  43666. // SetWxid sets the "wxid" field.
  43667. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  43668. m.wxid = &s
  43669. }
  43670. // Wxid returns the value of the "wxid" field in the mutation.
  43671. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  43672. v := m.wxid
  43673. if v == nil {
  43674. return
  43675. }
  43676. return *v, true
  43677. }
  43678. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  43679. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43681. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  43682. if !m.op.Is(OpUpdateOne) {
  43683. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43684. }
  43685. if m.id == nil || m.oldValue == nil {
  43686. return v, errors.New("OldWxid requires an ID field in the mutation")
  43687. }
  43688. oldValue, err := m.oldValue(ctx)
  43689. if err != nil {
  43690. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43691. }
  43692. return oldValue.Wxid, nil
  43693. }
  43694. // ResetWxid resets all changes to the "wxid" field.
  43695. func (m *WpChatroomMemberMutation) ResetWxid() {
  43696. m.wxid = nil
  43697. }
  43698. // SetNickname sets the "nickname" field.
  43699. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  43700. m.nickname = &s
  43701. }
  43702. // Nickname returns the value of the "nickname" field in the mutation.
  43703. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  43704. v := m.nickname
  43705. if v == nil {
  43706. return
  43707. }
  43708. return *v, true
  43709. }
  43710. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  43711. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43713. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  43714. if !m.op.Is(OpUpdateOne) {
  43715. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43716. }
  43717. if m.id == nil || m.oldValue == nil {
  43718. return v, errors.New("OldNickname requires an ID field in the mutation")
  43719. }
  43720. oldValue, err := m.oldValue(ctx)
  43721. if err != nil {
  43722. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43723. }
  43724. return oldValue.Nickname, nil
  43725. }
  43726. // ResetNickname resets all changes to the "nickname" field.
  43727. func (m *WpChatroomMemberMutation) ResetNickname() {
  43728. m.nickname = nil
  43729. }
  43730. // SetAvatar sets the "avatar" field.
  43731. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  43732. m.avatar = &s
  43733. }
  43734. // Avatar returns the value of the "avatar" field in the mutation.
  43735. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  43736. v := m.avatar
  43737. if v == nil {
  43738. return
  43739. }
  43740. return *v, true
  43741. }
  43742. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  43743. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43745. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43746. if !m.op.Is(OpUpdateOne) {
  43747. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43748. }
  43749. if m.id == nil || m.oldValue == nil {
  43750. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43751. }
  43752. oldValue, err := m.oldValue(ctx)
  43753. if err != nil {
  43754. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43755. }
  43756. return oldValue.Avatar, nil
  43757. }
  43758. // ResetAvatar resets all changes to the "avatar" field.
  43759. func (m *WpChatroomMemberMutation) ResetAvatar() {
  43760. m.avatar = nil
  43761. }
  43762. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  43763. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  43764. m.predicates = append(m.predicates, ps...)
  43765. }
  43766. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  43767. // users can use type-assertion to append predicates that do not depend on any generated package.
  43768. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  43769. p := make([]predicate.WpChatroomMember, len(ps))
  43770. for i := range ps {
  43771. p[i] = ps[i]
  43772. }
  43773. m.Where(p...)
  43774. }
  43775. // Op returns the operation name.
  43776. func (m *WpChatroomMemberMutation) Op() Op {
  43777. return m.op
  43778. }
  43779. // SetOp allows setting the mutation operation.
  43780. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  43781. m.op = op
  43782. }
  43783. // Type returns the node type of this mutation (WpChatroomMember).
  43784. func (m *WpChatroomMemberMutation) Type() string {
  43785. return m.typ
  43786. }
  43787. // Fields returns all fields that were changed during this mutation. Note that in
  43788. // order to get all numeric fields that were incremented/decremented, call
  43789. // AddedFields().
  43790. func (m *WpChatroomMemberMutation) Fields() []string {
  43791. fields := make([]string, 0, 7)
  43792. if m.created_at != nil {
  43793. fields = append(fields, wpchatroommember.FieldCreatedAt)
  43794. }
  43795. if m.updated_at != nil {
  43796. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  43797. }
  43798. if m.status != nil {
  43799. fields = append(fields, wpchatroommember.FieldStatus)
  43800. }
  43801. if m.wx_wxid != nil {
  43802. fields = append(fields, wpchatroommember.FieldWxWxid)
  43803. }
  43804. if m.wxid != nil {
  43805. fields = append(fields, wpchatroommember.FieldWxid)
  43806. }
  43807. if m.nickname != nil {
  43808. fields = append(fields, wpchatroommember.FieldNickname)
  43809. }
  43810. if m.avatar != nil {
  43811. fields = append(fields, wpchatroommember.FieldAvatar)
  43812. }
  43813. return fields
  43814. }
  43815. // Field returns the value of a field with the given name. The second boolean
  43816. // return value indicates that this field was not set, or was not defined in the
  43817. // schema.
  43818. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  43819. switch name {
  43820. case wpchatroommember.FieldCreatedAt:
  43821. return m.CreatedAt()
  43822. case wpchatroommember.FieldUpdatedAt:
  43823. return m.UpdatedAt()
  43824. case wpchatroommember.FieldStatus:
  43825. return m.Status()
  43826. case wpchatroommember.FieldWxWxid:
  43827. return m.WxWxid()
  43828. case wpchatroommember.FieldWxid:
  43829. return m.Wxid()
  43830. case wpchatroommember.FieldNickname:
  43831. return m.Nickname()
  43832. case wpchatroommember.FieldAvatar:
  43833. return m.Avatar()
  43834. }
  43835. return nil, false
  43836. }
  43837. // OldField returns the old value of the field from the database. An error is
  43838. // returned if the mutation operation is not UpdateOne, or the query to the
  43839. // database failed.
  43840. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43841. switch name {
  43842. case wpchatroommember.FieldCreatedAt:
  43843. return m.OldCreatedAt(ctx)
  43844. case wpchatroommember.FieldUpdatedAt:
  43845. return m.OldUpdatedAt(ctx)
  43846. case wpchatroommember.FieldStatus:
  43847. return m.OldStatus(ctx)
  43848. case wpchatroommember.FieldWxWxid:
  43849. return m.OldWxWxid(ctx)
  43850. case wpchatroommember.FieldWxid:
  43851. return m.OldWxid(ctx)
  43852. case wpchatroommember.FieldNickname:
  43853. return m.OldNickname(ctx)
  43854. case wpchatroommember.FieldAvatar:
  43855. return m.OldAvatar(ctx)
  43856. }
  43857. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  43858. }
  43859. // SetField sets the value of a field with the given name. It returns an error if
  43860. // the field is not defined in the schema, or if the type mismatched the field
  43861. // type.
  43862. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  43863. switch name {
  43864. case wpchatroommember.FieldCreatedAt:
  43865. v, ok := value.(time.Time)
  43866. if !ok {
  43867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43868. }
  43869. m.SetCreatedAt(v)
  43870. return nil
  43871. case wpchatroommember.FieldUpdatedAt:
  43872. v, ok := value.(time.Time)
  43873. if !ok {
  43874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43875. }
  43876. m.SetUpdatedAt(v)
  43877. return nil
  43878. case wpchatroommember.FieldStatus:
  43879. v, ok := value.(uint8)
  43880. if !ok {
  43881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43882. }
  43883. m.SetStatus(v)
  43884. return nil
  43885. case wpchatroommember.FieldWxWxid:
  43886. v, ok := value.(string)
  43887. if !ok {
  43888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43889. }
  43890. m.SetWxWxid(v)
  43891. return nil
  43892. case wpchatroommember.FieldWxid:
  43893. v, ok := value.(string)
  43894. if !ok {
  43895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43896. }
  43897. m.SetWxid(v)
  43898. return nil
  43899. case wpchatroommember.FieldNickname:
  43900. v, ok := value.(string)
  43901. if !ok {
  43902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43903. }
  43904. m.SetNickname(v)
  43905. return nil
  43906. case wpchatroommember.FieldAvatar:
  43907. v, ok := value.(string)
  43908. if !ok {
  43909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43910. }
  43911. m.SetAvatar(v)
  43912. return nil
  43913. }
  43914. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  43915. }
  43916. // AddedFields returns all numeric fields that were incremented/decremented during
  43917. // this mutation.
  43918. func (m *WpChatroomMemberMutation) AddedFields() []string {
  43919. var fields []string
  43920. if m.addstatus != nil {
  43921. fields = append(fields, wpchatroommember.FieldStatus)
  43922. }
  43923. return fields
  43924. }
  43925. // AddedField returns the numeric value that was incremented/decremented on a field
  43926. // with the given name. The second boolean return value indicates that this field
  43927. // was not set, or was not defined in the schema.
  43928. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  43929. switch name {
  43930. case wpchatroommember.FieldStatus:
  43931. return m.AddedStatus()
  43932. }
  43933. return nil, false
  43934. }
  43935. // AddField adds the value to the field with the given name. It returns an error if
  43936. // the field is not defined in the schema, or if the type mismatched the field
  43937. // type.
  43938. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  43939. switch name {
  43940. case wpchatroommember.FieldStatus:
  43941. v, ok := value.(int8)
  43942. if !ok {
  43943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43944. }
  43945. m.AddStatus(v)
  43946. return nil
  43947. }
  43948. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  43949. }
  43950. // ClearedFields returns all nullable fields that were cleared during this
  43951. // mutation.
  43952. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  43953. var fields []string
  43954. if m.FieldCleared(wpchatroommember.FieldStatus) {
  43955. fields = append(fields, wpchatroommember.FieldStatus)
  43956. }
  43957. return fields
  43958. }
  43959. // FieldCleared returns a boolean indicating if a field with the given name was
  43960. // cleared in this mutation.
  43961. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  43962. _, ok := m.clearedFields[name]
  43963. return ok
  43964. }
  43965. // ClearField clears the value of the field with the given name. It returns an
  43966. // error if the field is not defined in the schema.
  43967. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  43968. switch name {
  43969. case wpchatroommember.FieldStatus:
  43970. m.ClearStatus()
  43971. return nil
  43972. }
  43973. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  43974. }
  43975. // ResetField resets all changes in the mutation for the field with the given name.
  43976. // It returns an error if the field is not defined in the schema.
  43977. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  43978. switch name {
  43979. case wpchatroommember.FieldCreatedAt:
  43980. m.ResetCreatedAt()
  43981. return nil
  43982. case wpchatroommember.FieldUpdatedAt:
  43983. m.ResetUpdatedAt()
  43984. return nil
  43985. case wpchatroommember.FieldStatus:
  43986. m.ResetStatus()
  43987. return nil
  43988. case wpchatroommember.FieldWxWxid:
  43989. m.ResetWxWxid()
  43990. return nil
  43991. case wpchatroommember.FieldWxid:
  43992. m.ResetWxid()
  43993. return nil
  43994. case wpchatroommember.FieldNickname:
  43995. m.ResetNickname()
  43996. return nil
  43997. case wpchatroommember.FieldAvatar:
  43998. m.ResetAvatar()
  43999. return nil
  44000. }
  44001. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  44002. }
  44003. // AddedEdges returns all edge names that were set/added in this mutation.
  44004. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  44005. edges := make([]string, 0, 0)
  44006. return edges
  44007. }
  44008. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44009. // name in this mutation.
  44010. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  44011. return nil
  44012. }
  44013. // RemovedEdges returns all edge names that were removed in this mutation.
  44014. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  44015. edges := make([]string, 0, 0)
  44016. return edges
  44017. }
  44018. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44019. // the given name in this mutation.
  44020. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  44021. return nil
  44022. }
  44023. // ClearedEdges returns all edge names that were cleared in this mutation.
  44024. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  44025. edges := make([]string, 0, 0)
  44026. return edges
  44027. }
  44028. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44029. // was cleared in this mutation.
  44030. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  44031. return false
  44032. }
  44033. // ClearEdge clears the value of the edge with the given name. It returns an error
  44034. // if that edge is not defined in the schema.
  44035. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  44036. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  44037. }
  44038. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44039. // It returns an error if the edge is not defined in the schema.
  44040. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  44041. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  44042. }
  44043. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  44044. type WxMutation struct {
  44045. config
  44046. op Op
  44047. typ string
  44048. id *uint64
  44049. created_at *time.Time
  44050. updated_at *time.Time
  44051. status *uint8
  44052. addstatus *int8
  44053. deleted_at *time.Time
  44054. port *string
  44055. process_id *string
  44056. callback *string
  44057. wxid *string
  44058. account *string
  44059. nickname *string
  44060. tel *string
  44061. head_big *string
  44062. organization_id *uint64
  44063. addorganization_id *int64
  44064. api_base *string
  44065. api_key *string
  44066. allow_list *[]string
  44067. appendallow_list []string
  44068. group_allow_list *[]string
  44069. appendgroup_allow_list []string
  44070. block_list *[]string
  44071. appendblock_list []string
  44072. group_block_list *[]string
  44073. appendgroup_block_list []string
  44074. ctype *uint64
  44075. addctype *int64
  44076. clearedFields map[string]struct{}
  44077. server *uint64
  44078. clearedserver bool
  44079. agent *uint64
  44080. clearedagent bool
  44081. done bool
  44082. oldValue func(context.Context) (*Wx, error)
  44083. predicates []predicate.Wx
  44084. }
  44085. var _ ent.Mutation = (*WxMutation)(nil)
  44086. // wxOption allows management of the mutation configuration using functional options.
  44087. type wxOption func(*WxMutation)
  44088. // newWxMutation creates new mutation for the Wx entity.
  44089. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  44090. m := &WxMutation{
  44091. config: c,
  44092. op: op,
  44093. typ: TypeWx,
  44094. clearedFields: make(map[string]struct{}),
  44095. }
  44096. for _, opt := range opts {
  44097. opt(m)
  44098. }
  44099. return m
  44100. }
  44101. // withWxID sets the ID field of the mutation.
  44102. func withWxID(id uint64) wxOption {
  44103. return func(m *WxMutation) {
  44104. var (
  44105. err error
  44106. once sync.Once
  44107. value *Wx
  44108. )
  44109. m.oldValue = func(ctx context.Context) (*Wx, error) {
  44110. once.Do(func() {
  44111. if m.done {
  44112. err = errors.New("querying old values post mutation is not allowed")
  44113. } else {
  44114. value, err = m.Client().Wx.Get(ctx, id)
  44115. }
  44116. })
  44117. return value, err
  44118. }
  44119. m.id = &id
  44120. }
  44121. }
  44122. // withWx sets the old Wx of the mutation.
  44123. func withWx(node *Wx) wxOption {
  44124. return func(m *WxMutation) {
  44125. m.oldValue = func(context.Context) (*Wx, error) {
  44126. return node, nil
  44127. }
  44128. m.id = &node.ID
  44129. }
  44130. }
  44131. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44132. // executed in a transaction (ent.Tx), a transactional client is returned.
  44133. func (m WxMutation) Client() *Client {
  44134. client := &Client{config: m.config}
  44135. client.init()
  44136. return client
  44137. }
  44138. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44139. // it returns an error otherwise.
  44140. func (m WxMutation) Tx() (*Tx, error) {
  44141. if _, ok := m.driver.(*txDriver); !ok {
  44142. return nil, errors.New("ent: mutation is not running in a transaction")
  44143. }
  44144. tx := &Tx{config: m.config}
  44145. tx.init()
  44146. return tx, nil
  44147. }
  44148. // SetID sets the value of the id field. Note that this
  44149. // operation is only accepted on creation of Wx entities.
  44150. func (m *WxMutation) SetID(id uint64) {
  44151. m.id = &id
  44152. }
  44153. // ID returns the ID value in the mutation. Note that the ID is only available
  44154. // if it was provided to the builder or after it was returned from the database.
  44155. func (m *WxMutation) ID() (id uint64, exists bool) {
  44156. if m.id == nil {
  44157. return
  44158. }
  44159. return *m.id, true
  44160. }
  44161. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44162. // That means, if the mutation is applied within a transaction with an isolation level such
  44163. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44164. // or updated by the mutation.
  44165. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  44166. switch {
  44167. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44168. id, exists := m.ID()
  44169. if exists {
  44170. return []uint64{id}, nil
  44171. }
  44172. fallthrough
  44173. case m.op.Is(OpUpdate | OpDelete):
  44174. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  44175. default:
  44176. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44177. }
  44178. }
  44179. // SetCreatedAt sets the "created_at" field.
  44180. func (m *WxMutation) SetCreatedAt(t time.Time) {
  44181. m.created_at = &t
  44182. }
  44183. // CreatedAt returns the value of the "created_at" field in the mutation.
  44184. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  44185. v := m.created_at
  44186. if v == nil {
  44187. return
  44188. }
  44189. return *v, true
  44190. }
  44191. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  44192. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44194. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44195. if !m.op.Is(OpUpdateOne) {
  44196. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44197. }
  44198. if m.id == nil || m.oldValue == nil {
  44199. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44200. }
  44201. oldValue, err := m.oldValue(ctx)
  44202. if err != nil {
  44203. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44204. }
  44205. return oldValue.CreatedAt, nil
  44206. }
  44207. // ResetCreatedAt resets all changes to the "created_at" field.
  44208. func (m *WxMutation) ResetCreatedAt() {
  44209. m.created_at = nil
  44210. }
  44211. // SetUpdatedAt sets the "updated_at" field.
  44212. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  44213. m.updated_at = &t
  44214. }
  44215. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44216. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  44217. v := m.updated_at
  44218. if v == nil {
  44219. return
  44220. }
  44221. return *v, true
  44222. }
  44223. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  44224. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44226. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44227. if !m.op.Is(OpUpdateOne) {
  44228. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44229. }
  44230. if m.id == nil || m.oldValue == nil {
  44231. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44232. }
  44233. oldValue, err := m.oldValue(ctx)
  44234. if err != nil {
  44235. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44236. }
  44237. return oldValue.UpdatedAt, nil
  44238. }
  44239. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44240. func (m *WxMutation) ResetUpdatedAt() {
  44241. m.updated_at = nil
  44242. }
  44243. // SetStatus sets the "status" field.
  44244. func (m *WxMutation) SetStatus(u uint8) {
  44245. m.status = &u
  44246. m.addstatus = nil
  44247. }
  44248. // Status returns the value of the "status" field in the mutation.
  44249. func (m *WxMutation) Status() (r uint8, exists bool) {
  44250. v := m.status
  44251. if v == nil {
  44252. return
  44253. }
  44254. return *v, true
  44255. }
  44256. // OldStatus returns the old "status" field's value of the Wx entity.
  44257. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44259. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44260. if !m.op.Is(OpUpdateOne) {
  44261. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44262. }
  44263. if m.id == nil || m.oldValue == nil {
  44264. return v, errors.New("OldStatus requires an ID field in the mutation")
  44265. }
  44266. oldValue, err := m.oldValue(ctx)
  44267. if err != nil {
  44268. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44269. }
  44270. return oldValue.Status, nil
  44271. }
  44272. // AddStatus adds u to the "status" field.
  44273. func (m *WxMutation) AddStatus(u int8) {
  44274. if m.addstatus != nil {
  44275. *m.addstatus += u
  44276. } else {
  44277. m.addstatus = &u
  44278. }
  44279. }
  44280. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44281. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  44282. v := m.addstatus
  44283. if v == nil {
  44284. return
  44285. }
  44286. return *v, true
  44287. }
  44288. // ClearStatus clears the value of the "status" field.
  44289. func (m *WxMutation) ClearStatus() {
  44290. m.status = nil
  44291. m.addstatus = nil
  44292. m.clearedFields[wx.FieldStatus] = struct{}{}
  44293. }
  44294. // StatusCleared returns if the "status" field was cleared in this mutation.
  44295. func (m *WxMutation) StatusCleared() bool {
  44296. _, ok := m.clearedFields[wx.FieldStatus]
  44297. return ok
  44298. }
  44299. // ResetStatus resets all changes to the "status" field.
  44300. func (m *WxMutation) ResetStatus() {
  44301. m.status = nil
  44302. m.addstatus = nil
  44303. delete(m.clearedFields, wx.FieldStatus)
  44304. }
  44305. // SetDeletedAt sets the "deleted_at" field.
  44306. func (m *WxMutation) SetDeletedAt(t time.Time) {
  44307. m.deleted_at = &t
  44308. }
  44309. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44310. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  44311. v := m.deleted_at
  44312. if v == nil {
  44313. return
  44314. }
  44315. return *v, true
  44316. }
  44317. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  44318. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44320. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44321. if !m.op.Is(OpUpdateOne) {
  44322. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44323. }
  44324. if m.id == nil || m.oldValue == nil {
  44325. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44326. }
  44327. oldValue, err := m.oldValue(ctx)
  44328. if err != nil {
  44329. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44330. }
  44331. return oldValue.DeletedAt, nil
  44332. }
  44333. // ClearDeletedAt clears the value of the "deleted_at" field.
  44334. func (m *WxMutation) ClearDeletedAt() {
  44335. m.deleted_at = nil
  44336. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  44337. }
  44338. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44339. func (m *WxMutation) DeletedAtCleared() bool {
  44340. _, ok := m.clearedFields[wx.FieldDeletedAt]
  44341. return ok
  44342. }
  44343. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44344. func (m *WxMutation) ResetDeletedAt() {
  44345. m.deleted_at = nil
  44346. delete(m.clearedFields, wx.FieldDeletedAt)
  44347. }
  44348. // SetServerID sets the "server_id" field.
  44349. func (m *WxMutation) SetServerID(u uint64) {
  44350. m.server = &u
  44351. }
  44352. // ServerID returns the value of the "server_id" field in the mutation.
  44353. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  44354. v := m.server
  44355. if v == nil {
  44356. return
  44357. }
  44358. return *v, true
  44359. }
  44360. // OldServerID returns the old "server_id" field's value of the Wx entity.
  44361. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44363. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  44364. if !m.op.Is(OpUpdateOne) {
  44365. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  44366. }
  44367. if m.id == nil || m.oldValue == nil {
  44368. return v, errors.New("OldServerID requires an ID field in the mutation")
  44369. }
  44370. oldValue, err := m.oldValue(ctx)
  44371. if err != nil {
  44372. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  44373. }
  44374. return oldValue.ServerID, nil
  44375. }
  44376. // ClearServerID clears the value of the "server_id" field.
  44377. func (m *WxMutation) ClearServerID() {
  44378. m.server = nil
  44379. m.clearedFields[wx.FieldServerID] = struct{}{}
  44380. }
  44381. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  44382. func (m *WxMutation) ServerIDCleared() bool {
  44383. _, ok := m.clearedFields[wx.FieldServerID]
  44384. return ok
  44385. }
  44386. // ResetServerID resets all changes to the "server_id" field.
  44387. func (m *WxMutation) ResetServerID() {
  44388. m.server = nil
  44389. delete(m.clearedFields, wx.FieldServerID)
  44390. }
  44391. // SetPort sets the "port" field.
  44392. func (m *WxMutation) SetPort(s string) {
  44393. m.port = &s
  44394. }
  44395. // Port returns the value of the "port" field in the mutation.
  44396. func (m *WxMutation) Port() (r string, exists bool) {
  44397. v := m.port
  44398. if v == nil {
  44399. return
  44400. }
  44401. return *v, true
  44402. }
  44403. // OldPort returns the old "port" field's value of the Wx entity.
  44404. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44406. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  44407. if !m.op.Is(OpUpdateOne) {
  44408. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  44409. }
  44410. if m.id == nil || m.oldValue == nil {
  44411. return v, errors.New("OldPort requires an ID field in the mutation")
  44412. }
  44413. oldValue, err := m.oldValue(ctx)
  44414. if err != nil {
  44415. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  44416. }
  44417. return oldValue.Port, nil
  44418. }
  44419. // ResetPort resets all changes to the "port" field.
  44420. func (m *WxMutation) ResetPort() {
  44421. m.port = nil
  44422. }
  44423. // SetProcessID sets the "process_id" field.
  44424. func (m *WxMutation) SetProcessID(s string) {
  44425. m.process_id = &s
  44426. }
  44427. // ProcessID returns the value of the "process_id" field in the mutation.
  44428. func (m *WxMutation) ProcessID() (r string, exists bool) {
  44429. v := m.process_id
  44430. if v == nil {
  44431. return
  44432. }
  44433. return *v, true
  44434. }
  44435. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  44436. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44438. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  44439. if !m.op.Is(OpUpdateOne) {
  44440. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  44441. }
  44442. if m.id == nil || m.oldValue == nil {
  44443. return v, errors.New("OldProcessID requires an ID field in the mutation")
  44444. }
  44445. oldValue, err := m.oldValue(ctx)
  44446. if err != nil {
  44447. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  44448. }
  44449. return oldValue.ProcessID, nil
  44450. }
  44451. // ResetProcessID resets all changes to the "process_id" field.
  44452. func (m *WxMutation) ResetProcessID() {
  44453. m.process_id = nil
  44454. }
  44455. // SetCallback sets the "callback" field.
  44456. func (m *WxMutation) SetCallback(s string) {
  44457. m.callback = &s
  44458. }
  44459. // Callback returns the value of the "callback" field in the mutation.
  44460. func (m *WxMutation) Callback() (r string, exists bool) {
  44461. v := m.callback
  44462. if v == nil {
  44463. return
  44464. }
  44465. return *v, true
  44466. }
  44467. // OldCallback returns the old "callback" field's value of the Wx entity.
  44468. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44470. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  44471. if !m.op.Is(OpUpdateOne) {
  44472. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  44473. }
  44474. if m.id == nil || m.oldValue == nil {
  44475. return v, errors.New("OldCallback requires an ID field in the mutation")
  44476. }
  44477. oldValue, err := m.oldValue(ctx)
  44478. if err != nil {
  44479. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  44480. }
  44481. return oldValue.Callback, nil
  44482. }
  44483. // ResetCallback resets all changes to the "callback" field.
  44484. func (m *WxMutation) ResetCallback() {
  44485. m.callback = nil
  44486. }
  44487. // SetWxid sets the "wxid" field.
  44488. func (m *WxMutation) SetWxid(s string) {
  44489. m.wxid = &s
  44490. }
  44491. // Wxid returns the value of the "wxid" field in the mutation.
  44492. func (m *WxMutation) Wxid() (r string, exists bool) {
  44493. v := m.wxid
  44494. if v == nil {
  44495. return
  44496. }
  44497. return *v, true
  44498. }
  44499. // OldWxid returns the old "wxid" field's value of the Wx entity.
  44500. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44502. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  44503. if !m.op.Is(OpUpdateOne) {
  44504. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44505. }
  44506. if m.id == nil || m.oldValue == nil {
  44507. return v, errors.New("OldWxid requires an ID field in the mutation")
  44508. }
  44509. oldValue, err := m.oldValue(ctx)
  44510. if err != nil {
  44511. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44512. }
  44513. return oldValue.Wxid, nil
  44514. }
  44515. // ResetWxid resets all changes to the "wxid" field.
  44516. func (m *WxMutation) ResetWxid() {
  44517. m.wxid = nil
  44518. }
  44519. // SetAccount sets the "account" field.
  44520. func (m *WxMutation) SetAccount(s string) {
  44521. m.account = &s
  44522. }
  44523. // Account returns the value of the "account" field in the mutation.
  44524. func (m *WxMutation) Account() (r string, exists bool) {
  44525. v := m.account
  44526. if v == nil {
  44527. return
  44528. }
  44529. return *v, true
  44530. }
  44531. // OldAccount returns the old "account" field's value of the Wx entity.
  44532. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44534. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  44535. if !m.op.Is(OpUpdateOne) {
  44536. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44537. }
  44538. if m.id == nil || m.oldValue == nil {
  44539. return v, errors.New("OldAccount requires an ID field in the mutation")
  44540. }
  44541. oldValue, err := m.oldValue(ctx)
  44542. if err != nil {
  44543. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44544. }
  44545. return oldValue.Account, nil
  44546. }
  44547. // ResetAccount resets all changes to the "account" field.
  44548. func (m *WxMutation) ResetAccount() {
  44549. m.account = nil
  44550. }
  44551. // SetNickname sets the "nickname" field.
  44552. func (m *WxMutation) SetNickname(s string) {
  44553. m.nickname = &s
  44554. }
  44555. // Nickname returns the value of the "nickname" field in the mutation.
  44556. func (m *WxMutation) Nickname() (r string, exists bool) {
  44557. v := m.nickname
  44558. if v == nil {
  44559. return
  44560. }
  44561. return *v, true
  44562. }
  44563. // OldNickname returns the old "nickname" field's value of the Wx entity.
  44564. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44566. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  44567. if !m.op.Is(OpUpdateOne) {
  44568. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44569. }
  44570. if m.id == nil || m.oldValue == nil {
  44571. return v, errors.New("OldNickname requires an ID field in the mutation")
  44572. }
  44573. oldValue, err := m.oldValue(ctx)
  44574. if err != nil {
  44575. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44576. }
  44577. return oldValue.Nickname, nil
  44578. }
  44579. // ResetNickname resets all changes to the "nickname" field.
  44580. func (m *WxMutation) ResetNickname() {
  44581. m.nickname = nil
  44582. }
  44583. // SetTel sets the "tel" field.
  44584. func (m *WxMutation) SetTel(s string) {
  44585. m.tel = &s
  44586. }
  44587. // Tel returns the value of the "tel" field in the mutation.
  44588. func (m *WxMutation) Tel() (r string, exists bool) {
  44589. v := m.tel
  44590. if v == nil {
  44591. return
  44592. }
  44593. return *v, true
  44594. }
  44595. // OldTel returns the old "tel" field's value of the Wx entity.
  44596. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44598. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  44599. if !m.op.Is(OpUpdateOne) {
  44600. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  44601. }
  44602. if m.id == nil || m.oldValue == nil {
  44603. return v, errors.New("OldTel requires an ID field in the mutation")
  44604. }
  44605. oldValue, err := m.oldValue(ctx)
  44606. if err != nil {
  44607. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  44608. }
  44609. return oldValue.Tel, nil
  44610. }
  44611. // ResetTel resets all changes to the "tel" field.
  44612. func (m *WxMutation) ResetTel() {
  44613. m.tel = nil
  44614. }
  44615. // SetHeadBig sets the "head_big" field.
  44616. func (m *WxMutation) SetHeadBig(s string) {
  44617. m.head_big = &s
  44618. }
  44619. // HeadBig returns the value of the "head_big" field in the mutation.
  44620. func (m *WxMutation) HeadBig() (r string, exists bool) {
  44621. v := m.head_big
  44622. if v == nil {
  44623. return
  44624. }
  44625. return *v, true
  44626. }
  44627. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  44628. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44630. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  44631. if !m.op.Is(OpUpdateOne) {
  44632. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  44633. }
  44634. if m.id == nil || m.oldValue == nil {
  44635. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  44636. }
  44637. oldValue, err := m.oldValue(ctx)
  44638. if err != nil {
  44639. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  44640. }
  44641. return oldValue.HeadBig, nil
  44642. }
  44643. // ResetHeadBig resets all changes to the "head_big" field.
  44644. func (m *WxMutation) ResetHeadBig() {
  44645. m.head_big = nil
  44646. }
  44647. // SetOrganizationID sets the "organization_id" field.
  44648. func (m *WxMutation) SetOrganizationID(u uint64) {
  44649. m.organization_id = &u
  44650. m.addorganization_id = nil
  44651. }
  44652. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44653. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  44654. v := m.organization_id
  44655. if v == nil {
  44656. return
  44657. }
  44658. return *v, true
  44659. }
  44660. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  44661. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44663. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44664. if !m.op.Is(OpUpdateOne) {
  44665. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44666. }
  44667. if m.id == nil || m.oldValue == nil {
  44668. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44669. }
  44670. oldValue, err := m.oldValue(ctx)
  44671. if err != nil {
  44672. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44673. }
  44674. return oldValue.OrganizationID, nil
  44675. }
  44676. // AddOrganizationID adds u to the "organization_id" field.
  44677. func (m *WxMutation) AddOrganizationID(u int64) {
  44678. if m.addorganization_id != nil {
  44679. *m.addorganization_id += u
  44680. } else {
  44681. m.addorganization_id = &u
  44682. }
  44683. }
  44684. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44685. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  44686. v := m.addorganization_id
  44687. if v == nil {
  44688. return
  44689. }
  44690. return *v, true
  44691. }
  44692. // ClearOrganizationID clears the value of the "organization_id" field.
  44693. func (m *WxMutation) ClearOrganizationID() {
  44694. m.organization_id = nil
  44695. m.addorganization_id = nil
  44696. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  44697. }
  44698. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  44699. func (m *WxMutation) OrganizationIDCleared() bool {
  44700. _, ok := m.clearedFields[wx.FieldOrganizationID]
  44701. return ok
  44702. }
  44703. // ResetOrganizationID resets all changes to the "organization_id" field.
  44704. func (m *WxMutation) ResetOrganizationID() {
  44705. m.organization_id = nil
  44706. m.addorganization_id = nil
  44707. delete(m.clearedFields, wx.FieldOrganizationID)
  44708. }
  44709. // SetAgentID sets the "agent_id" field.
  44710. func (m *WxMutation) SetAgentID(u uint64) {
  44711. m.agent = &u
  44712. }
  44713. // AgentID returns the value of the "agent_id" field in the mutation.
  44714. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  44715. v := m.agent
  44716. if v == nil {
  44717. return
  44718. }
  44719. return *v, true
  44720. }
  44721. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  44722. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44724. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  44725. if !m.op.Is(OpUpdateOne) {
  44726. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  44727. }
  44728. if m.id == nil || m.oldValue == nil {
  44729. return v, errors.New("OldAgentID requires an ID field in the mutation")
  44730. }
  44731. oldValue, err := m.oldValue(ctx)
  44732. if err != nil {
  44733. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  44734. }
  44735. return oldValue.AgentID, nil
  44736. }
  44737. // ResetAgentID resets all changes to the "agent_id" field.
  44738. func (m *WxMutation) ResetAgentID() {
  44739. m.agent = nil
  44740. }
  44741. // SetAPIBase sets the "api_base" field.
  44742. func (m *WxMutation) SetAPIBase(s string) {
  44743. m.api_base = &s
  44744. }
  44745. // APIBase returns the value of the "api_base" field in the mutation.
  44746. func (m *WxMutation) APIBase() (r string, exists bool) {
  44747. v := m.api_base
  44748. if v == nil {
  44749. return
  44750. }
  44751. return *v, true
  44752. }
  44753. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  44754. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44756. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  44757. if !m.op.Is(OpUpdateOne) {
  44758. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  44759. }
  44760. if m.id == nil || m.oldValue == nil {
  44761. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  44762. }
  44763. oldValue, err := m.oldValue(ctx)
  44764. if err != nil {
  44765. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  44766. }
  44767. return oldValue.APIBase, nil
  44768. }
  44769. // ClearAPIBase clears the value of the "api_base" field.
  44770. func (m *WxMutation) ClearAPIBase() {
  44771. m.api_base = nil
  44772. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  44773. }
  44774. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  44775. func (m *WxMutation) APIBaseCleared() bool {
  44776. _, ok := m.clearedFields[wx.FieldAPIBase]
  44777. return ok
  44778. }
  44779. // ResetAPIBase resets all changes to the "api_base" field.
  44780. func (m *WxMutation) ResetAPIBase() {
  44781. m.api_base = nil
  44782. delete(m.clearedFields, wx.FieldAPIBase)
  44783. }
  44784. // SetAPIKey sets the "api_key" field.
  44785. func (m *WxMutation) SetAPIKey(s string) {
  44786. m.api_key = &s
  44787. }
  44788. // APIKey returns the value of the "api_key" field in the mutation.
  44789. func (m *WxMutation) APIKey() (r string, exists bool) {
  44790. v := m.api_key
  44791. if v == nil {
  44792. return
  44793. }
  44794. return *v, true
  44795. }
  44796. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  44797. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44799. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  44800. if !m.op.Is(OpUpdateOne) {
  44801. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  44802. }
  44803. if m.id == nil || m.oldValue == nil {
  44804. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  44805. }
  44806. oldValue, err := m.oldValue(ctx)
  44807. if err != nil {
  44808. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  44809. }
  44810. return oldValue.APIKey, nil
  44811. }
  44812. // ClearAPIKey clears the value of the "api_key" field.
  44813. func (m *WxMutation) ClearAPIKey() {
  44814. m.api_key = nil
  44815. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  44816. }
  44817. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  44818. func (m *WxMutation) APIKeyCleared() bool {
  44819. _, ok := m.clearedFields[wx.FieldAPIKey]
  44820. return ok
  44821. }
  44822. // ResetAPIKey resets all changes to the "api_key" field.
  44823. func (m *WxMutation) ResetAPIKey() {
  44824. m.api_key = nil
  44825. delete(m.clearedFields, wx.FieldAPIKey)
  44826. }
  44827. // SetAllowList sets the "allow_list" field.
  44828. func (m *WxMutation) SetAllowList(s []string) {
  44829. m.allow_list = &s
  44830. m.appendallow_list = nil
  44831. }
  44832. // AllowList returns the value of the "allow_list" field in the mutation.
  44833. func (m *WxMutation) AllowList() (r []string, exists bool) {
  44834. v := m.allow_list
  44835. if v == nil {
  44836. return
  44837. }
  44838. return *v, true
  44839. }
  44840. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  44841. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44843. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  44844. if !m.op.Is(OpUpdateOne) {
  44845. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  44846. }
  44847. if m.id == nil || m.oldValue == nil {
  44848. return v, errors.New("OldAllowList requires an ID field in the mutation")
  44849. }
  44850. oldValue, err := m.oldValue(ctx)
  44851. if err != nil {
  44852. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  44853. }
  44854. return oldValue.AllowList, nil
  44855. }
  44856. // AppendAllowList adds s to the "allow_list" field.
  44857. func (m *WxMutation) AppendAllowList(s []string) {
  44858. m.appendallow_list = append(m.appendallow_list, s...)
  44859. }
  44860. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  44861. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  44862. if len(m.appendallow_list) == 0 {
  44863. return nil, false
  44864. }
  44865. return m.appendallow_list, true
  44866. }
  44867. // ResetAllowList resets all changes to the "allow_list" field.
  44868. func (m *WxMutation) ResetAllowList() {
  44869. m.allow_list = nil
  44870. m.appendallow_list = nil
  44871. }
  44872. // SetGroupAllowList sets the "group_allow_list" field.
  44873. func (m *WxMutation) SetGroupAllowList(s []string) {
  44874. m.group_allow_list = &s
  44875. m.appendgroup_allow_list = nil
  44876. }
  44877. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  44878. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  44879. v := m.group_allow_list
  44880. if v == nil {
  44881. return
  44882. }
  44883. return *v, true
  44884. }
  44885. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  44886. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44888. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  44889. if !m.op.Is(OpUpdateOne) {
  44890. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  44891. }
  44892. if m.id == nil || m.oldValue == nil {
  44893. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  44894. }
  44895. oldValue, err := m.oldValue(ctx)
  44896. if err != nil {
  44897. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  44898. }
  44899. return oldValue.GroupAllowList, nil
  44900. }
  44901. // AppendGroupAllowList adds s to the "group_allow_list" field.
  44902. func (m *WxMutation) AppendGroupAllowList(s []string) {
  44903. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  44904. }
  44905. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  44906. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  44907. if len(m.appendgroup_allow_list) == 0 {
  44908. return nil, false
  44909. }
  44910. return m.appendgroup_allow_list, true
  44911. }
  44912. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  44913. func (m *WxMutation) ResetGroupAllowList() {
  44914. m.group_allow_list = nil
  44915. m.appendgroup_allow_list = nil
  44916. }
  44917. // SetBlockList sets the "block_list" field.
  44918. func (m *WxMutation) SetBlockList(s []string) {
  44919. m.block_list = &s
  44920. m.appendblock_list = nil
  44921. }
  44922. // BlockList returns the value of the "block_list" field in the mutation.
  44923. func (m *WxMutation) BlockList() (r []string, exists bool) {
  44924. v := m.block_list
  44925. if v == nil {
  44926. return
  44927. }
  44928. return *v, true
  44929. }
  44930. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  44931. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44933. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  44934. if !m.op.Is(OpUpdateOne) {
  44935. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  44936. }
  44937. if m.id == nil || m.oldValue == nil {
  44938. return v, errors.New("OldBlockList requires an ID field in the mutation")
  44939. }
  44940. oldValue, err := m.oldValue(ctx)
  44941. if err != nil {
  44942. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  44943. }
  44944. return oldValue.BlockList, nil
  44945. }
  44946. // AppendBlockList adds s to the "block_list" field.
  44947. func (m *WxMutation) AppendBlockList(s []string) {
  44948. m.appendblock_list = append(m.appendblock_list, s...)
  44949. }
  44950. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  44951. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  44952. if len(m.appendblock_list) == 0 {
  44953. return nil, false
  44954. }
  44955. return m.appendblock_list, true
  44956. }
  44957. // ResetBlockList resets all changes to the "block_list" field.
  44958. func (m *WxMutation) ResetBlockList() {
  44959. m.block_list = nil
  44960. m.appendblock_list = nil
  44961. }
  44962. // SetGroupBlockList sets the "group_block_list" field.
  44963. func (m *WxMutation) SetGroupBlockList(s []string) {
  44964. m.group_block_list = &s
  44965. m.appendgroup_block_list = nil
  44966. }
  44967. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  44968. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  44969. v := m.group_block_list
  44970. if v == nil {
  44971. return
  44972. }
  44973. return *v, true
  44974. }
  44975. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  44976. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44978. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  44979. if !m.op.Is(OpUpdateOne) {
  44980. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  44981. }
  44982. if m.id == nil || m.oldValue == nil {
  44983. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  44984. }
  44985. oldValue, err := m.oldValue(ctx)
  44986. if err != nil {
  44987. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  44988. }
  44989. return oldValue.GroupBlockList, nil
  44990. }
  44991. // AppendGroupBlockList adds s to the "group_block_list" field.
  44992. func (m *WxMutation) AppendGroupBlockList(s []string) {
  44993. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  44994. }
  44995. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  44996. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  44997. if len(m.appendgroup_block_list) == 0 {
  44998. return nil, false
  44999. }
  45000. return m.appendgroup_block_list, true
  45001. }
  45002. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  45003. func (m *WxMutation) ResetGroupBlockList() {
  45004. m.group_block_list = nil
  45005. m.appendgroup_block_list = nil
  45006. }
  45007. // SetCtype sets the "ctype" field.
  45008. func (m *WxMutation) SetCtype(u uint64) {
  45009. m.ctype = &u
  45010. m.addctype = nil
  45011. }
  45012. // Ctype returns the value of the "ctype" field in the mutation.
  45013. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  45014. v := m.ctype
  45015. if v == nil {
  45016. return
  45017. }
  45018. return *v, true
  45019. }
  45020. // OldCtype returns the old "ctype" field's value of the Wx entity.
  45021. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45023. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  45024. if !m.op.Is(OpUpdateOne) {
  45025. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  45026. }
  45027. if m.id == nil || m.oldValue == nil {
  45028. return v, errors.New("OldCtype requires an ID field in the mutation")
  45029. }
  45030. oldValue, err := m.oldValue(ctx)
  45031. if err != nil {
  45032. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  45033. }
  45034. return oldValue.Ctype, nil
  45035. }
  45036. // AddCtype adds u to the "ctype" field.
  45037. func (m *WxMutation) AddCtype(u int64) {
  45038. if m.addctype != nil {
  45039. *m.addctype += u
  45040. } else {
  45041. m.addctype = &u
  45042. }
  45043. }
  45044. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  45045. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  45046. v := m.addctype
  45047. if v == nil {
  45048. return
  45049. }
  45050. return *v, true
  45051. }
  45052. // ClearCtype clears the value of the "ctype" field.
  45053. func (m *WxMutation) ClearCtype() {
  45054. m.ctype = nil
  45055. m.addctype = nil
  45056. m.clearedFields[wx.FieldCtype] = struct{}{}
  45057. }
  45058. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  45059. func (m *WxMutation) CtypeCleared() bool {
  45060. _, ok := m.clearedFields[wx.FieldCtype]
  45061. return ok
  45062. }
  45063. // ResetCtype resets all changes to the "ctype" field.
  45064. func (m *WxMutation) ResetCtype() {
  45065. m.ctype = nil
  45066. m.addctype = nil
  45067. delete(m.clearedFields, wx.FieldCtype)
  45068. }
  45069. // ClearServer clears the "server" edge to the Server entity.
  45070. func (m *WxMutation) ClearServer() {
  45071. m.clearedserver = true
  45072. m.clearedFields[wx.FieldServerID] = struct{}{}
  45073. }
  45074. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  45075. func (m *WxMutation) ServerCleared() bool {
  45076. return m.ServerIDCleared() || m.clearedserver
  45077. }
  45078. // ServerIDs returns the "server" edge IDs in the mutation.
  45079. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45080. // ServerID instead. It exists only for internal usage by the builders.
  45081. func (m *WxMutation) ServerIDs() (ids []uint64) {
  45082. if id := m.server; id != nil {
  45083. ids = append(ids, *id)
  45084. }
  45085. return
  45086. }
  45087. // ResetServer resets all changes to the "server" edge.
  45088. func (m *WxMutation) ResetServer() {
  45089. m.server = nil
  45090. m.clearedserver = false
  45091. }
  45092. // ClearAgent clears the "agent" edge to the Agent entity.
  45093. func (m *WxMutation) ClearAgent() {
  45094. m.clearedagent = true
  45095. m.clearedFields[wx.FieldAgentID] = struct{}{}
  45096. }
  45097. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  45098. func (m *WxMutation) AgentCleared() bool {
  45099. return m.clearedagent
  45100. }
  45101. // AgentIDs returns the "agent" edge IDs in the mutation.
  45102. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45103. // AgentID instead. It exists only for internal usage by the builders.
  45104. func (m *WxMutation) AgentIDs() (ids []uint64) {
  45105. if id := m.agent; id != nil {
  45106. ids = append(ids, *id)
  45107. }
  45108. return
  45109. }
  45110. // ResetAgent resets all changes to the "agent" edge.
  45111. func (m *WxMutation) ResetAgent() {
  45112. m.agent = nil
  45113. m.clearedagent = false
  45114. }
  45115. // Where appends a list predicates to the WxMutation builder.
  45116. func (m *WxMutation) Where(ps ...predicate.Wx) {
  45117. m.predicates = append(m.predicates, ps...)
  45118. }
  45119. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  45120. // users can use type-assertion to append predicates that do not depend on any generated package.
  45121. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  45122. p := make([]predicate.Wx, len(ps))
  45123. for i := range ps {
  45124. p[i] = ps[i]
  45125. }
  45126. m.Where(p...)
  45127. }
  45128. // Op returns the operation name.
  45129. func (m *WxMutation) Op() Op {
  45130. return m.op
  45131. }
  45132. // SetOp allows setting the mutation operation.
  45133. func (m *WxMutation) SetOp(op Op) {
  45134. m.op = op
  45135. }
  45136. // Type returns the node type of this mutation (Wx).
  45137. func (m *WxMutation) Type() string {
  45138. return m.typ
  45139. }
  45140. // Fields returns all fields that were changed during this mutation. Note that in
  45141. // order to get all numeric fields that were incremented/decremented, call
  45142. // AddedFields().
  45143. func (m *WxMutation) Fields() []string {
  45144. fields := make([]string, 0, 22)
  45145. if m.created_at != nil {
  45146. fields = append(fields, wx.FieldCreatedAt)
  45147. }
  45148. if m.updated_at != nil {
  45149. fields = append(fields, wx.FieldUpdatedAt)
  45150. }
  45151. if m.status != nil {
  45152. fields = append(fields, wx.FieldStatus)
  45153. }
  45154. if m.deleted_at != nil {
  45155. fields = append(fields, wx.FieldDeletedAt)
  45156. }
  45157. if m.server != nil {
  45158. fields = append(fields, wx.FieldServerID)
  45159. }
  45160. if m.port != nil {
  45161. fields = append(fields, wx.FieldPort)
  45162. }
  45163. if m.process_id != nil {
  45164. fields = append(fields, wx.FieldProcessID)
  45165. }
  45166. if m.callback != nil {
  45167. fields = append(fields, wx.FieldCallback)
  45168. }
  45169. if m.wxid != nil {
  45170. fields = append(fields, wx.FieldWxid)
  45171. }
  45172. if m.account != nil {
  45173. fields = append(fields, wx.FieldAccount)
  45174. }
  45175. if m.nickname != nil {
  45176. fields = append(fields, wx.FieldNickname)
  45177. }
  45178. if m.tel != nil {
  45179. fields = append(fields, wx.FieldTel)
  45180. }
  45181. if m.head_big != nil {
  45182. fields = append(fields, wx.FieldHeadBig)
  45183. }
  45184. if m.organization_id != nil {
  45185. fields = append(fields, wx.FieldOrganizationID)
  45186. }
  45187. if m.agent != nil {
  45188. fields = append(fields, wx.FieldAgentID)
  45189. }
  45190. if m.api_base != nil {
  45191. fields = append(fields, wx.FieldAPIBase)
  45192. }
  45193. if m.api_key != nil {
  45194. fields = append(fields, wx.FieldAPIKey)
  45195. }
  45196. if m.allow_list != nil {
  45197. fields = append(fields, wx.FieldAllowList)
  45198. }
  45199. if m.group_allow_list != nil {
  45200. fields = append(fields, wx.FieldGroupAllowList)
  45201. }
  45202. if m.block_list != nil {
  45203. fields = append(fields, wx.FieldBlockList)
  45204. }
  45205. if m.group_block_list != nil {
  45206. fields = append(fields, wx.FieldGroupBlockList)
  45207. }
  45208. if m.ctype != nil {
  45209. fields = append(fields, wx.FieldCtype)
  45210. }
  45211. return fields
  45212. }
  45213. // Field returns the value of a field with the given name. The second boolean
  45214. // return value indicates that this field was not set, or was not defined in the
  45215. // schema.
  45216. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  45217. switch name {
  45218. case wx.FieldCreatedAt:
  45219. return m.CreatedAt()
  45220. case wx.FieldUpdatedAt:
  45221. return m.UpdatedAt()
  45222. case wx.FieldStatus:
  45223. return m.Status()
  45224. case wx.FieldDeletedAt:
  45225. return m.DeletedAt()
  45226. case wx.FieldServerID:
  45227. return m.ServerID()
  45228. case wx.FieldPort:
  45229. return m.Port()
  45230. case wx.FieldProcessID:
  45231. return m.ProcessID()
  45232. case wx.FieldCallback:
  45233. return m.Callback()
  45234. case wx.FieldWxid:
  45235. return m.Wxid()
  45236. case wx.FieldAccount:
  45237. return m.Account()
  45238. case wx.FieldNickname:
  45239. return m.Nickname()
  45240. case wx.FieldTel:
  45241. return m.Tel()
  45242. case wx.FieldHeadBig:
  45243. return m.HeadBig()
  45244. case wx.FieldOrganizationID:
  45245. return m.OrganizationID()
  45246. case wx.FieldAgentID:
  45247. return m.AgentID()
  45248. case wx.FieldAPIBase:
  45249. return m.APIBase()
  45250. case wx.FieldAPIKey:
  45251. return m.APIKey()
  45252. case wx.FieldAllowList:
  45253. return m.AllowList()
  45254. case wx.FieldGroupAllowList:
  45255. return m.GroupAllowList()
  45256. case wx.FieldBlockList:
  45257. return m.BlockList()
  45258. case wx.FieldGroupBlockList:
  45259. return m.GroupBlockList()
  45260. case wx.FieldCtype:
  45261. return m.Ctype()
  45262. }
  45263. return nil, false
  45264. }
  45265. // OldField returns the old value of the field from the database. An error is
  45266. // returned if the mutation operation is not UpdateOne, or the query to the
  45267. // database failed.
  45268. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45269. switch name {
  45270. case wx.FieldCreatedAt:
  45271. return m.OldCreatedAt(ctx)
  45272. case wx.FieldUpdatedAt:
  45273. return m.OldUpdatedAt(ctx)
  45274. case wx.FieldStatus:
  45275. return m.OldStatus(ctx)
  45276. case wx.FieldDeletedAt:
  45277. return m.OldDeletedAt(ctx)
  45278. case wx.FieldServerID:
  45279. return m.OldServerID(ctx)
  45280. case wx.FieldPort:
  45281. return m.OldPort(ctx)
  45282. case wx.FieldProcessID:
  45283. return m.OldProcessID(ctx)
  45284. case wx.FieldCallback:
  45285. return m.OldCallback(ctx)
  45286. case wx.FieldWxid:
  45287. return m.OldWxid(ctx)
  45288. case wx.FieldAccount:
  45289. return m.OldAccount(ctx)
  45290. case wx.FieldNickname:
  45291. return m.OldNickname(ctx)
  45292. case wx.FieldTel:
  45293. return m.OldTel(ctx)
  45294. case wx.FieldHeadBig:
  45295. return m.OldHeadBig(ctx)
  45296. case wx.FieldOrganizationID:
  45297. return m.OldOrganizationID(ctx)
  45298. case wx.FieldAgentID:
  45299. return m.OldAgentID(ctx)
  45300. case wx.FieldAPIBase:
  45301. return m.OldAPIBase(ctx)
  45302. case wx.FieldAPIKey:
  45303. return m.OldAPIKey(ctx)
  45304. case wx.FieldAllowList:
  45305. return m.OldAllowList(ctx)
  45306. case wx.FieldGroupAllowList:
  45307. return m.OldGroupAllowList(ctx)
  45308. case wx.FieldBlockList:
  45309. return m.OldBlockList(ctx)
  45310. case wx.FieldGroupBlockList:
  45311. return m.OldGroupBlockList(ctx)
  45312. case wx.FieldCtype:
  45313. return m.OldCtype(ctx)
  45314. }
  45315. return nil, fmt.Errorf("unknown Wx field %s", name)
  45316. }
  45317. // SetField sets the value of a field with the given name. It returns an error if
  45318. // the field is not defined in the schema, or if the type mismatched the field
  45319. // type.
  45320. func (m *WxMutation) SetField(name string, value ent.Value) error {
  45321. switch name {
  45322. case wx.FieldCreatedAt:
  45323. v, ok := value.(time.Time)
  45324. if !ok {
  45325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45326. }
  45327. m.SetCreatedAt(v)
  45328. return nil
  45329. case wx.FieldUpdatedAt:
  45330. v, ok := value.(time.Time)
  45331. if !ok {
  45332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45333. }
  45334. m.SetUpdatedAt(v)
  45335. return nil
  45336. case wx.FieldStatus:
  45337. v, ok := value.(uint8)
  45338. if !ok {
  45339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45340. }
  45341. m.SetStatus(v)
  45342. return nil
  45343. case wx.FieldDeletedAt:
  45344. v, ok := value.(time.Time)
  45345. if !ok {
  45346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45347. }
  45348. m.SetDeletedAt(v)
  45349. return nil
  45350. case wx.FieldServerID:
  45351. v, ok := value.(uint64)
  45352. if !ok {
  45353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45354. }
  45355. m.SetServerID(v)
  45356. return nil
  45357. case wx.FieldPort:
  45358. v, ok := value.(string)
  45359. if !ok {
  45360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45361. }
  45362. m.SetPort(v)
  45363. return nil
  45364. case wx.FieldProcessID:
  45365. v, ok := value.(string)
  45366. if !ok {
  45367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45368. }
  45369. m.SetProcessID(v)
  45370. return nil
  45371. case wx.FieldCallback:
  45372. v, ok := value.(string)
  45373. if !ok {
  45374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45375. }
  45376. m.SetCallback(v)
  45377. return nil
  45378. case wx.FieldWxid:
  45379. v, ok := value.(string)
  45380. if !ok {
  45381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45382. }
  45383. m.SetWxid(v)
  45384. return nil
  45385. case wx.FieldAccount:
  45386. v, ok := value.(string)
  45387. if !ok {
  45388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45389. }
  45390. m.SetAccount(v)
  45391. return nil
  45392. case wx.FieldNickname:
  45393. v, ok := value.(string)
  45394. if !ok {
  45395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45396. }
  45397. m.SetNickname(v)
  45398. return nil
  45399. case wx.FieldTel:
  45400. v, ok := value.(string)
  45401. if !ok {
  45402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45403. }
  45404. m.SetTel(v)
  45405. return nil
  45406. case wx.FieldHeadBig:
  45407. v, ok := value.(string)
  45408. if !ok {
  45409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45410. }
  45411. m.SetHeadBig(v)
  45412. return nil
  45413. case wx.FieldOrganizationID:
  45414. v, ok := value.(uint64)
  45415. if !ok {
  45416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45417. }
  45418. m.SetOrganizationID(v)
  45419. return nil
  45420. case wx.FieldAgentID:
  45421. v, ok := value.(uint64)
  45422. if !ok {
  45423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45424. }
  45425. m.SetAgentID(v)
  45426. return nil
  45427. case wx.FieldAPIBase:
  45428. v, ok := value.(string)
  45429. if !ok {
  45430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45431. }
  45432. m.SetAPIBase(v)
  45433. return nil
  45434. case wx.FieldAPIKey:
  45435. v, ok := value.(string)
  45436. if !ok {
  45437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45438. }
  45439. m.SetAPIKey(v)
  45440. return nil
  45441. case wx.FieldAllowList:
  45442. v, ok := value.([]string)
  45443. if !ok {
  45444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45445. }
  45446. m.SetAllowList(v)
  45447. return nil
  45448. case wx.FieldGroupAllowList:
  45449. v, ok := value.([]string)
  45450. if !ok {
  45451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45452. }
  45453. m.SetGroupAllowList(v)
  45454. return nil
  45455. case wx.FieldBlockList:
  45456. v, ok := value.([]string)
  45457. if !ok {
  45458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45459. }
  45460. m.SetBlockList(v)
  45461. return nil
  45462. case wx.FieldGroupBlockList:
  45463. v, ok := value.([]string)
  45464. if !ok {
  45465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45466. }
  45467. m.SetGroupBlockList(v)
  45468. return nil
  45469. case wx.FieldCtype:
  45470. v, ok := value.(uint64)
  45471. if !ok {
  45472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45473. }
  45474. m.SetCtype(v)
  45475. return nil
  45476. }
  45477. return fmt.Errorf("unknown Wx field %s", name)
  45478. }
  45479. // AddedFields returns all numeric fields that were incremented/decremented during
  45480. // this mutation.
  45481. func (m *WxMutation) AddedFields() []string {
  45482. var fields []string
  45483. if m.addstatus != nil {
  45484. fields = append(fields, wx.FieldStatus)
  45485. }
  45486. if m.addorganization_id != nil {
  45487. fields = append(fields, wx.FieldOrganizationID)
  45488. }
  45489. if m.addctype != nil {
  45490. fields = append(fields, wx.FieldCtype)
  45491. }
  45492. return fields
  45493. }
  45494. // AddedField returns the numeric value that was incremented/decremented on a field
  45495. // with the given name. The second boolean return value indicates that this field
  45496. // was not set, or was not defined in the schema.
  45497. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  45498. switch name {
  45499. case wx.FieldStatus:
  45500. return m.AddedStatus()
  45501. case wx.FieldOrganizationID:
  45502. return m.AddedOrganizationID()
  45503. case wx.FieldCtype:
  45504. return m.AddedCtype()
  45505. }
  45506. return nil, false
  45507. }
  45508. // AddField adds the value to the field with the given name. It returns an error if
  45509. // the field is not defined in the schema, or if the type mismatched the field
  45510. // type.
  45511. func (m *WxMutation) AddField(name string, value ent.Value) error {
  45512. switch name {
  45513. case wx.FieldStatus:
  45514. v, ok := value.(int8)
  45515. if !ok {
  45516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45517. }
  45518. m.AddStatus(v)
  45519. return nil
  45520. case wx.FieldOrganizationID:
  45521. v, ok := value.(int64)
  45522. if !ok {
  45523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45524. }
  45525. m.AddOrganizationID(v)
  45526. return nil
  45527. case wx.FieldCtype:
  45528. v, ok := value.(int64)
  45529. if !ok {
  45530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45531. }
  45532. m.AddCtype(v)
  45533. return nil
  45534. }
  45535. return fmt.Errorf("unknown Wx numeric field %s", name)
  45536. }
  45537. // ClearedFields returns all nullable fields that were cleared during this
  45538. // mutation.
  45539. func (m *WxMutation) ClearedFields() []string {
  45540. var fields []string
  45541. if m.FieldCleared(wx.FieldStatus) {
  45542. fields = append(fields, wx.FieldStatus)
  45543. }
  45544. if m.FieldCleared(wx.FieldDeletedAt) {
  45545. fields = append(fields, wx.FieldDeletedAt)
  45546. }
  45547. if m.FieldCleared(wx.FieldServerID) {
  45548. fields = append(fields, wx.FieldServerID)
  45549. }
  45550. if m.FieldCleared(wx.FieldOrganizationID) {
  45551. fields = append(fields, wx.FieldOrganizationID)
  45552. }
  45553. if m.FieldCleared(wx.FieldAPIBase) {
  45554. fields = append(fields, wx.FieldAPIBase)
  45555. }
  45556. if m.FieldCleared(wx.FieldAPIKey) {
  45557. fields = append(fields, wx.FieldAPIKey)
  45558. }
  45559. if m.FieldCleared(wx.FieldCtype) {
  45560. fields = append(fields, wx.FieldCtype)
  45561. }
  45562. return fields
  45563. }
  45564. // FieldCleared returns a boolean indicating if a field with the given name was
  45565. // cleared in this mutation.
  45566. func (m *WxMutation) FieldCleared(name string) bool {
  45567. _, ok := m.clearedFields[name]
  45568. return ok
  45569. }
  45570. // ClearField clears the value of the field with the given name. It returns an
  45571. // error if the field is not defined in the schema.
  45572. func (m *WxMutation) ClearField(name string) error {
  45573. switch name {
  45574. case wx.FieldStatus:
  45575. m.ClearStatus()
  45576. return nil
  45577. case wx.FieldDeletedAt:
  45578. m.ClearDeletedAt()
  45579. return nil
  45580. case wx.FieldServerID:
  45581. m.ClearServerID()
  45582. return nil
  45583. case wx.FieldOrganizationID:
  45584. m.ClearOrganizationID()
  45585. return nil
  45586. case wx.FieldAPIBase:
  45587. m.ClearAPIBase()
  45588. return nil
  45589. case wx.FieldAPIKey:
  45590. m.ClearAPIKey()
  45591. return nil
  45592. case wx.FieldCtype:
  45593. m.ClearCtype()
  45594. return nil
  45595. }
  45596. return fmt.Errorf("unknown Wx nullable field %s", name)
  45597. }
  45598. // ResetField resets all changes in the mutation for the field with the given name.
  45599. // It returns an error if the field is not defined in the schema.
  45600. func (m *WxMutation) ResetField(name string) error {
  45601. switch name {
  45602. case wx.FieldCreatedAt:
  45603. m.ResetCreatedAt()
  45604. return nil
  45605. case wx.FieldUpdatedAt:
  45606. m.ResetUpdatedAt()
  45607. return nil
  45608. case wx.FieldStatus:
  45609. m.ResetStatus()
  45610. return nil
  45611. case wx.FieldDeletedAt:
  45612. m.ResetDeletedAt()
  45613. return nil
  45614. case wx.FieldServerID:
  45615. m.ResetServerID()
  45616. return nil
  45617. case wx.FieldPort:
  45618. m.ResetPort()
  45619. return nil
  45620. case wx.FieldProcessID:
  45621. m.ResetProcessID()
  45622. return nil
  45623. case wx.FieldCallback:
  45624. m.ResetCallback()
  45625. return nil
  45626. case wx.FieldWxid:
  45627. m.ResetWxid()
  45628. return nil
  45629. case wx.FieldAccount:
  45630. m.ResetAccount()
  45631. return nil
  45632. case wx.FieldNickname:
  45633. m.ResetNickname()
  45634. return nil
  45635. case wx.FieldTel:
  45636. m.ResetTel()
  45637. return nil
  45638. case wx.FieldHeadBig:
  45639. m.ResetHeadBig()
  45640. return nil
  45641. case wx.FieldOrganizationID:
  45642. m.ResetOrganizationID()
  45643. return nil
  45644. case wx.FieldAgentID:
  45645. m.ResetAgentID()
  45646. return nil
  45647. case wx.FieldAPIBase:
  45648. m.ResetAPIBase()
  45649. return nil
  45650. case wx.FieldAPIKey:
  45651. m.ResetAPIKey()
  45652. return nil
  45653. case wx.FieldAllowList:
  45654. m.ResetAllowList()
  45655. return nil
  45656. case wx.FieldGroupAllowList:
  45657. m.ResetGroupAllowList()
  45658. return nil
  45659. case wx.FieldBlockList:
  45660. m.ResetBlockList()
  45661. return nil
  45662. case wx.FieldGroupBlockList:
  45663. m.ResetGroupBlockList()
  45664. return nil
  45665. case wx.FieldCtype:
  45666. m.ResetCtype()
  45667. return nil
  45668. }
  45669. return fmt.Errorf("unknown Wx field %s", name)
  45670. }
  45671. // AddedEdges returns all edge names that were set/added in this mutation.
  45672. func (m *WxMutation) AddedEdges() []string {
  45673. edges := make([]string, 0, 2)
  45674. if m.server != nil {
  45675. edges = append(edges, wx.EdgeServer)
  45676. }
  45677. if m.agent != nil {
  45678. edges = append(edges, wx.EdgeAgent)
  45679. }
  45680. return edges
  45681. }
  45682. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45683. // name in this mutation.
  45684. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  45685. switch name {
  45686. case wx.EdgeServer:
  45687. if id := m.server; id != nil {
  45688. return []ent.Value{*id}
  45689. }
  45690. case wx.EdgeAgent:
  45691. if id := m.agent; id != nil {
  45692. return []ent.Value{*id}
  45693. }
  45694. }
  45695. return nil
  45696. }
  45697. // RemovedEdges returns all edge names that were removed in this mutation.
  45698. func (m *WxMutation) RemovedEdges() []string {
  45699. edges := make([]string, 0, 2)
  45700. return edges
  45701. }
  45702. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45703. // the given name in this mutation.
  45704. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  45705. return nil
  45706. }
  45707. // ClearedEdges returns all edge names that were cleared in this mutation.
  45708. func (m *WxMutation) ClearedEdges() []string {
  45709. edges := make([]string, 0, 2)
  45710. if m.clearedserver {
  45711. edges = append(edges, wx.EdgeServer)
  45712. }
  45713. if m.clearedagent {
  45714. edges = append(edges, wx.EdgeAgent)
  45715. }
  45716. return edges
  45717. }
  45718. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45719. // was cleared in this mutation.
  45720. func (m *WxMutation) EdgeCleared(name string) bool {
  45721. switch name {
  45722. case wx.EdgeServer:
  45723. return m.clearedserver
  45724. case wx.EdgeAgent:
  45725. return m.clearedagent
  45726. }
  45727. return false
  45728. }
  45729. // ClearEdge clears the value of the edge with the given name. It returns an error
  45730. // if that edge is not defined in the schema.
  45731. func (m *WxMutation) ClearEdge(name string) error {
  45732. switch name {
  45733. case wx.EdgeServer:
  45734. m.ClearServer()
  45735. return nil
  45736. case wx.EdgeAgent:
  45737. m.ClearAgent()
  45738. return nil
  45739. }
  45740. return fmt.Errorf("unknown Wx unique edge %s", name)
  45741. }
  45742. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45743. // It returns an error if the edge is not defined in the schema.
  45744. func (m *WxMutation) ResetEdge(name string) error {
  45745. switch name {
  45746. case wx.EdgeServer:
  45747. m.ResetServer()
  45748. return nil
  45749. case wx.EdgeAgent:
  45750. m.ResetAgent()
  45751. return nil
  45752. }
  45753. return fmt.Errorf("unknown Wx edge %s", name)
  45754. }
  45755. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  45756. type WxCardMutation struct {
  45757. config
  45758. op Op
  45759. typ string
  45760. id *uint64
  45761. created_at *time.Time
  45762. updated_at *time.Time
  45763. deleted_at *time.Time
  45764. user_id *uint64
  45765. adduser_id *int64
  45766. wx_user_id *uint64
  45767. addwx_user_id *int64
  45768. avatar *string
  45769. logo *string
  45770. name *string
  45771. company *string
  45772. address *string
  45773. phone *string
  45774. official_account *string
  45775. wechat_account *string
  45776. email *string
  45777. api_base *string
  45778. api_key *string
  45779. ai_info *string
  45780. intro *string
  45781. clearedFields map[string]struct{}
  45782. done bool
  45783. oldValue func(context.Context) (*WxCard, error)
  45784. predicates []predicate.WxCard
  45785. }
  45786. var _ ent.Mutation = (*WxCardMutation)(nil)
  45787. // wxcardOption allows management of the mutation configuration using functional options.
  45788. type wxcardOption func(*WxCardMutation)
  45789. // newWxCardMutation creates new mutation for the WxCard entity.
  45790. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  45791. m := &WxCardMutation{
  45792. config: c,
  45793. op: op,
  45794. typ: TypeWxCard,
  45795. clearedFields: make(map[string]struct{}),
  45796. }
  45797. for _, opt := range opts {
  45798. opt(m)
  45799. }
  45800. return m
  45801. }
  45802. // withWxCardID sets the ID field of the mutation.
  45803. func withWxCardID(id uint64) wxcardOption {
  45804. return func(m *WxCardMutation) {
  45805. var (
  45806. err error
  45807. once sync.Once
  45808. value *WxCard
  45809. )
  45810. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  45811. once.Do(func() {
  45812. if m.done {
  45813. err = errors.New("querying old values post mutation is not allowed")
  45814. } else {
  45815. value, err = m.Client().WxCard.Get(ctx, id)
  45816. }
  45817. })
  45818. return value, err
  45819. }
  45820. m.id = &id
  45821. }
  45822. }
  45823. // withWxCard sets the old WxCard of the mutation.
  45824. func withWxCard(node *WxCard) wxcardOption {
  45825. return func(m *WxCardMutation) {
  45826. m.oldValue = func(context.Context) (*WxCard, error) {
  45827. return node, nil
  45828. }
  45829. m.id = &node.ID
  45830. }
  45831. }
  45832. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45833. // executed in a transaction (ent.Tx), a transactional client is returned.
  45834. func (m WxCardMutation) Client() *Client {
  45835. client := &Client{config: m.config}
  45836. client.init()
  45837. return client
  45838. }
  45839. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45840. // it returns an error otherwise.
  45841. func (m WxCardMutation) Tx() (*Tx, error) {
  45842. if _, ok := m.driver.(*txDriver); !ok {
  45843. return nil, errors.New("ent: mutation is not running in a transaction")
  45844. }
  45845. tx := &Tx{config: m.config}
  45846. tx.init()
  45847. return tx, nil
  45848. }
  45849. // SetID sets the value of the id field. Note that this
  45850. // operation is only accepted on creation of WxCard entities.
  45851. func (m *WxCardMutation) SetID(id uint64) {
  45852. m.id = &id
  45853. }
  45854. // ID returns the ID value in the mutation. Note that the ID is only available
  45855. // if it was provided to the builder or after it was returned from the database.
  45856. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  45857. if m.id == nil {
  45858. return
  45859. }
  45860. return *m.id, true
  45861. }
  45862. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45863. // That means, if the mutation is applied within a transaction with an isolation level such
  45864. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45865. // or updated by the mutation.
  45866. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  45867. switch {
  45868. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45869. id, exists := m.ID()
  45870. if exists {
  45871. return []uint64{id}, nil
  45872. }
  45873. fallthrough
  45874. case m.op.Is(OpUpdate | OpDelete):
  45875. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  45876. default:
  45877. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45878. }
  45879. }
  45880. // SetCreatedAt sets the "created_at" field.
  45881. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  45882. m.created_at = &t
  45883. }
  45884. // CreatedAt returns the value of the "created_at" field in the mutation.
  45885. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  45886. v := m.created_at
  45887. if v == nil {
  45888. return
  45889. }
  45890. return *v, true
  45891. }
  45892. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  45893. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45895. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45896. if !m.op.Is(OpUpdateOne) {
  45897. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45898. }
  45899. if m.id == nil || m.oldValue == nil {
  45900. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45901. }
  45902. oldValue, err := m.oldValue(ctx)
  45903. if err != nil {
  45904. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45905. }
  45906. return oldValue.CreatedAt, nil
  45907. }
  45908. // ResetCreatedAt resets all changes to the "created_at" field.
  45909. func (m *WxCardMutation) ResetCreatedAt() {
  45910. m.created_at = nil
  45911. }
  45912. // SetUpdatedAt sets the "updated_at" field.
  45913. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  45914. m.updated_at = &t
  45915. }
  45916. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45917. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  45918. v := m.updated_at
  45919. if v == nil {
  45920. return
  45921. }
  45922. return *v, true
  45923. }
  45924. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  45925. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45927. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45928. if !m.op.Is(OpUpdateOne) {
  45929. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45930. }
  45931. if m.id == nil || m.oldValue == nil {
  45932. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45933. }
  45934. oldValue, err := m.oldValue(ctx)
  45935. if err != nil {
  45936. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45937. }
  45938. return oldValue.UpdatedAt, nil
  45939. }
  45940. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45941. func (m *WxCardMutation) ResetUpdatedAt() {
  45942. m.updated_at = nil
  45943. }
  45944. // SetDeletedAt sets the "deleted_at" field.
  45945. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  45946. m.deleted_at = &t
  45947. }
  45948. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45949. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  45950. v := m.deleted_at
  45951. if v == nil {
  45952. return
  45953. }
  45954. return *v, true
  45955. }
  45956. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  45957. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45959. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45960. if !m.op.Is(OpUpdateOne) {
  45961. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45962. }
  45963. if m.id == nil || m.oldValue == nil {
  45964. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45965. }
  45966. oldValue, err := m.oldValue(ctx)
  45967. if err != nil {
  45968. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45969. }
  45970. return oldValue.DeletedAt, nil
  45971. }
  45972. // ClearDeletedAt clears the value of the "deleted_at" field.
  45973. func (m *WxCardMutation) ClearDeletedAt() {
  45974. m.deleted_at = nil
  45975. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  45976. }
  45977. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45978. func (m *WxCardMutation) DeletedAtCleared() bool {
  45979. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  45980. return ok
  45981. }
  45982. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45983. func (m *WxCardMutation) ResetDeletedAt() {
  45984. m.deleted_at = nil
  45985. delete(m.clearedFields, wxcard.FieldDeletedAt)
  45986. }
  45987. // SetUserID sets the "user_id" field.
  45988. func (m *WxCardMutation) SetUserID(u uint64) {
  45989. m.user_id = &u
  45990. m.adduser_id = nil
  45991. }
  45992. // UserID returns the value of the "user_id" field in the mutation.
  45993. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  45994. v := m.user_id
  45995. if v == nil {
  45996. return
  45997. }
  45998. return *v, true
  45999. }
  46000. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  46001. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46003. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46004. if !m.op.Is(OpUpdateOne) {
  46005. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46006. }
  46007. if m.id == nil || m.oldValue == nil {
  46008. return v, errors.New("OldUserID requires an ID field in the mutation")
  46009. }
  46010. oldValue, err := m.oldValue(ctx)
  46011. if err != nil {
  46012. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46013. }
  46014. return oldValue.UserID, nil
  46015. }
  46016. // AddUserID adds u to the "user_id" field.
  46017. func (m *WxCardMutation) AddUserID(u int64) {
  46018. if m.adduser_id != nil {
  46019. *m.adduser_id += u
  46020. } else {
  46021. m.adduser_id = &u
  46022. }
  46023. }
  46024. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46025. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  46026. v := m.adduser_id
  46027. if v == nil {
  46028. return
  46029. }
  46030. return *v, true
  46031. }
  46032. // ClearUserID clears the value of the "user_id" field.
  46033. func (m *WxCardMutation) ClearUserID() {
  46034. m.user_id = nil
  46035. m.adduser_id = nil
  46036. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  46037. }
  46038. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46039. func (m *WxCardMutation) UserIDCleared() bool {
  46040. _, ok := m.clearedFields[wxcard.FieldUserID]
  46041. return ok
  46042. }
  46043. // ResetUserID resets all changes to the "user_id" field.
  46044. func (m *WxCardMutation) ResetUserID() {
  46045. m.user_id = nil
  46046. m.adduser_id = nil
  46047. delete(m.clearedFields, wxcard.FieldUserID)
  46048. }
  46049. // SetWxUserID sets the "wx_user_id" field.
  46050. func (m *WxCardMutation) SetWxUserID(u uint64) {
  46051. m.wx_user_id = &u
  46052. m.addwx_user_id = nil
  46053. }
  46054. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  46055. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  46056. v := m.wx_user_id
  46057. if v == nil {
  46058. return
  46059. }
  46060. return *v, true
  46061. }
  46062. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  46063. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46065. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  46066. if !m.op.Is(OpUpdateOne) {
  46067. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  46068. }
  46069. if m.id == nil || m.oldValue == nil {
  46070. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  46071. }
  46072. oldValue, err := m.oldValue(ctx)
  46073. if err != nil {
  46074. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  46075. }
  46076. return oldValue.WxUserID, nil
  46077. }
  46078. // AddWxUserID adds u to the "wx_user_id" field.
  46079. func (m *WxCardMutation) AddWxUserID(u int64) {
  46080. if m.addwx_user_id != nil {
  46081. *m.addwx_user_id += u
  46082. } else {
  46083. m.addwx_user_id = &u
  46084. }
  46085. }
  46086. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  46087. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  46088. v := m.addwx_user_id
  46089. if v == nil {
  46090. return
  46091. }
  46092. return *v, true
  46093. }
  46094. // ClearWxUserID clears the value of the "wx_user_id" field.
  46095. func (m *WxCardMutation) ClearWxUserID() {
  46096. m.wx_user_id = nil
  46097. m.addwx_user_id = nil
  46098. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  46099. }
  46100. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  46101. func (m *WxCardMutation) WxUserIDCleared() bool {
  46102. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  46103. return ok
  46104. }
  46105. // ResetWxUserID resets all changes to the "wx_user_id" field.
  46106. func (m *WxCardMutation) ResetWxUserID() {
  46107. m.wx_user_id = nil
  46108. m.addwx_user_id = nil
  46109. delete(m.clearedFields, wxcard.FieldWxUserID)
  46110. }
  46111. // SetAvatar sets the "avatar" field.
  46112. func (m *WxCardMutation) SetAvatar(s string) {
  46113. m.avatar = &s
  46114. }
  46115. // Avatar returns the value of the "avatar" field in the mutation.
  46116. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  46117. v := m.avatar
  46118. if v == nil {
  46119. return
  46120. }
  46121. return *v, true
  46122. }
  46123. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  46124. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46126. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46127. if !m.op.Is(OpUpdateOne) {
  46128. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46129. }
  46130. if m.id == nil || m.oldValue == nil {
  46131. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46132. }
  46133. oldValue, err := m.oldValue(ctx)
  46134. if err != nil {
  46135. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46136. }
  46137. return oldValue.Avatar, nil
  46138. }
  46139. // ResetAvatar resets all changes to the "avatar" field.
  46140. func (m *WxCardMutation) ResetAvatar() {
  46141. m.avatar = nil
  46142. }
  46143. // SetLogo sets the "logo" field.
  46144. func (m *WxCardMutation) SetLogo(s string) {
  46145. m.logo = &s
  46146. }
  46147. // Logo returns the value of the "logo" field in the mutation.
  46148. func (m *WxCardMutation) Logo() (r string, exists bool) {
  46149. v := m.logo
  46150. if v == nil {
  46151. return
  46152. }
  46153. return *v, true
  46154. }
  46155. // OldLogo returns the old "logo" field's value of the WxCard entity.
  46156. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46158. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  46159. if !m.op.Is(OpUpdateOne) {
  46160. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  46161. }
  46162. if m.id == nil || m.oldValue == nil {
  46163. return v, errors.New("OldLogo requires an ID field in the mutation")
  46164. }
  46165. oldValue, err := m.oldValue(ctx)
  46166. if err != nil {
  46167. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  46168. }
  46169. return oldValue.Logo, nil
  46170. }
  46171. // ResetLogo resets all changes to the "logo" field.
  46172. func (m *WxCardMutation) ResetLogo() {
  46173. m.logo = nil
  46174. }
  46175. // SetName sets the "name" field.
  46176. func (m *WxCardMutation) SetName(s string) {
  46177. m.name = &s
  46178. }
  46179. // Name returns the value of the "name" field in the mutation.
  46180. func (m *WxCardMutation) Name() (r string, exists bool) {
  46181. v := m.name
  46182. if v == nil {
  46183. return
  46184. }
  46185. return *v, true
  46186. }
  46187. // OldName returns the old "name" field's value of the WxCard entity.
  46188. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46190. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  46191. if !m.op.Is(OpUpdateOne) {
  46192. return v, errors.New("OldName is only allowed on UpdateOne operations")
  46193. }
  46194. if m.id == nil || m.oldValue == nil {
  46195. return v, errors.New("OldName requires an ID field in the mutation")
  46196. }
  46197. oldValue, err := m.oldValue(ctx)
  46198. if err != nil {
  46199. return v, fmt.Errorf("querying old value for OldName: %w", err)
  46200. }
  46201. return oldValue.Name, nil
  46202. }
  46203. // ResetName resets all changes to the "name" field.
  46204. func (m *WxCardMutation) ResetName() {
  46205. m.name = nil
  46206. }
  46207. // SetCompany sets the "company" field.
  46208. func (m *WxCardMutation) SetCompany(s string) {
  46209. m.company = &s
  46210. }
  46211. // Company returns the value of the "company" field in the mutation.
  46212. func (m *WxCardMutation) Company() (r string, exists bool) {
  46213. v := m.company
  46214. if v == nil {
  46215. return
  46216. }
  46217. return *v, true
  46218. }
  46219. // OldCompany returns the old "company" field's value of the WxCard entity.
  46220. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46222. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  46223. if !m.op.Is(OpUpdateOne) {
  46224. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  46225. }
  46226. if m.id == nil || m.oldValue == nil {
  46227. return v, errors.New("OldCompany requires an ID field in the mutation")
  46228. }
  46229. oldValue, err := m.oldValue(ctx)
  46230. if err != nil {
  46231. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  46232. }
  46233. return oldValue.Company, nil
  46234. }
  46235. // ResetCompany resets all changes to the "company" field.
  46236. func (m *WxCardMutation) ResetCompany() {
  46237. m.company = nil
  46238. }
  46239. // SetAddress sets the "address" field.
  46240. func (m *WxCardMutation) SetAddress(s string) {
  46241. m.address = &s
  46242. }
  46243. // Address returns the value of the "address" field in the mutation.
  46244. func (m *WxCardMutation) Address() (r string, exists bool) {
  46245. v := m.address
  46246. if v == nil {
  46247. return
  46248. }
  46249. return *v, true
  46250. }
  46251. // OldAddress returns the old "address" field's value of the WxCard entity.
  46252. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46254. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  46255. if !m.op.Is(OpUpdateOne) {
  46256. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  46257. }
  46258. if m.id == nil || m.oldValue == nil {
  46259. return v, errors.New("OldAddress requires an ID field in the mutation")
  46260. }
  46261. oldValue, err := m.oldValue(ctx)
  46262. if err != nil {
  46263. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  46264. }
  46265. return oldValue.Address, nil
  46266. }
  46267. // ResetAddress resets all changes to the "address" field.
  46268. func (m *WxCardMutation) ResetAddress() {
  46269. m.address = nil
  46270. }
  46271. // SetPhone sets the "phone" field.
  46272. func (m *WxCardMutation) SetPhone(s string) {
  46273. m.phone = &s
  46274. }
  46275. // Phone returns the value of the "phone" field in the mutation.
  46276. func (m *WxCardMutation) Phone() (r string, exists bool) {
  46277. v := m.phone
  46278. if v == nil {
  46279. return
  46280. }
  46281. return *v, true
  46282. }
  46283. // OldPhone returns the old "phone" field's value of the WxCard entity.
  46284. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46286. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  46287. if !m.op.Is(OpUpdateOne) {
  46288. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46289. }
  46290. if m.id == nil || m.oldValue == nil {
  46291. return v, errors.New("OldPhone requires an ID field in the mutation")
  46292. }
  46293. oldValue, err := m.oldValue(ctx)
  46294. if err != nil {
  46295. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  46296. }
  46297. return oldValue.Phone, nil
  46298. }
  46299. // ResetPhone resets all changes to the "phone" field.
  46300. func (m *WxCardMutation) ResetPhone() {
  46301. m.phone = nil
  46302. }
  46303. // SetOfficialAccount sets the "official_account" field.
  46304. func (m *WxCardMutation) SetOfficialAccount(s string) {
  46305. m.official_account = &s
  46306. }
  46307. // OfficialAccount returns the value of the "official_account" field in the mutation.
  46308. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  46309. v := m.official_account
  46310. if v == nil {
  46311. return
  46312. }
  46313. return *v, true
  46314. }
  46315. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  46316. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46318. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  46319. if !m.op.Is(OpUpdateOne) {
  46320. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  46321. }
  46322. if m.id == nil || m.oldValue == nil {
  46323. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  46324. }
  46325. oldValue, err := m.oldValue(ctx)
  46326. if err != nil {
  46327. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  46328. }
  46329. return oldValue.OfficialAccount, nil
  46330. }
  46331. // ResetOfficialAccount resets all changes to the "official_account" field.
  46332. func (m *WxCardMutation) ResetOfficialAccount() {
  46333. m.official_account = nil
  46334. }
  46335. // SetWechatAccount sets the "wechat_account" field.
  46336. func (m *WxCardMutation) SetWechatAccount(s string) {
  46337. m.wechat_account = &s
  46338. }
  46339. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  46340. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  46341. v := m.wechat_account
  46342. if v == nil {
  46343. return
  46344. }
  46345. return *v, true
  46346. }
  46347. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  46348. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46350. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  46351. if !m.op.Is(OpUpdateOne) {
  46352. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  46353. }
  46354. if m.id == nil || m.oldValue == nil {
  46355. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  46356. }
  46357. oldValue, err := m.oldValue(ctx)
  46358. if err != nil {
  46359. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  46360. }
  46361. return oldValue.WechatAccount, nil
  46362. }
  46363. // ResetWechatAccount resets all changes to the "wechat_account" field.
  46364. func (m *WxCardMutation) ResetWechatAccount() {
  46365. m.wechat_account = nil
  46366. }
  46367. // SetEmail sets the "email" field.
  46368. func (m *WxCardMutation) SetEmail(s string) {
  46369. m.email = &s
  46370. }
  46371. // Email returns the value of the "email" field in the mutation.
  46372. func (m *WxCardMutation) Email() (r string, exists bool) {
  46373. v := m.email
  46374. if v == nil {
  46375. return
  46376. }
  46377. return *v, true
  46378. }
  46379. // OldEmail returns the old "email" field's value of the WxCard entity.
  46380. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46382. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  46383. if !m.op.Is(OpUpdateOne) {
  46384. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  46385. }
  46386. if m.id == nil || m.oldValue == nil {
  46387. return v, errors.New("OldEmail requires an ID field in the mutation")
  46388. }
  46389. oldValue, err := m.oldValue(ctx)
  46390. if err != nil {
  46391. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  46392. }
  46393. return oldValue.Email, nil
  46394. }
  46395. // ClearEmail clears the value of the "email" field.
  46396. func (m *WxCardMutation) ClearEmail() {
  46397. m.email = nil
  46398. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  46399. }
  46400. // EmailCleared returns if the "email" field was cleared in this mutation.
  46401. func (m *WxCardMutation) EmailCleared() bool {
  46402. _, ok := m.clearedFields[wxcard.FieldEmail]
  46403. return ok
  46404. }
  46405. // ResetEmail resets all changes to the "email" field.
  46406. func (m *WxCardMutation) ResetEmail() {
  46407. m.email = nil
  46408. delete(m.clearedFields, wxcard.FieldEmail)
  46409. }
  46410. // SetAPIBase sets the "api_base" field.
  46411. func (m *WxCardMutation) SetAPIBase(s string) {
  46412. m.api_base = &s
  46413. }
  46414. // APIBase returns the value of the "api_base" field in the mutation.
  46415. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  46416. v := m.api_base
  46417. if v == nil {
  46418. return
  46419. }
  46420. return *v, true
  46421. }
  46422. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  46423. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46425. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  46426. if !m.op.Is(OpUpdateOne) {
  46427. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  46428. }
  46429. if m.id == nil || m.oldValue == nil {
  46430. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  46431. }
  46432. oldValue, err := m.oldValue(ctx)
  46433. if err != nil {
  46434. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  46435. }
  46436. return oldValue.APIBase, nil
  46437. }
  46438. // ClearAPIBase clears the value of the "api_base" field.
  46439. func (m *WxCardMutation) ClearAPIBase() {
  46440. m.api_base = nil
  46441. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  46442. }
  46443. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  46444. func (m *WxCardMutation) APIBaseCleared() bool {
  46445. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  46446. return ok
  46447. }
  46448. // ResetAPIBase resets all changes to the "api_base" field.
  46449. func (m *WxCardMutation) ResetAPIBase() {
  46450. m.api_base = nil
  46451. delete(m.clearedFields, wxcard.FieldAPIBase)
  46452. }
  46453. // SetAPIKey sets the "api_key" field.
  46454. func (m *WxCardMutation) SetAPIKey(s string) {
  46455. m.api_key = &s
  46456. }
  46457. // APIKey returns the value of the "api_key" field in the mutation.
  46458. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  46459. v := m.api_key
  46460. if v == nil {
  46461. return
  46462. }
  46463. return *v, true
  46464. }
  46465. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  46466. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46468. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  46469. if !m.op.Is(OpUpdateOne) {
  46470. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  46471. }
  46472. if m.id == nil || m.oldValue == nil {
  46473. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  46474. }
  46475. oldValue, err := m.oldValue(ctx)
  46476. if err != nil {
  46477. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  46478. }
  46479. return oldValue.APIKey, nil
  46480. }
  46481. // ClearAPIKey clears the value of the "api_key" field.
  46482. func (m *WxCardMutation) ClearAPIKey() {
  46483. m.api_key = nil
  46484. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  46485. }
  46486. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  46487. func (m *WxCardMutation) APIKeyCleared() bool {
  46488. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  46489. return ok
  46490. }
  46491. // ResetAPIKey resets all changes to the "api_key" field.
  46492. func (m *WxCardMutation) ResetAPIKey() {
  46493. m.api_key = nil
  46494. delete(m.clearedFields, wxcard.FieldAPIKey)
  46495. }
  46496. // SetAiInfo sets the "ai_info" field.
  46497. func (m *WxCardMutation) SetAiInfo(s string) {
  46498. m.ai_info = &s
  46499. }
  46500. // AiInfo returns the value of the "ai_info" field in the mutation.
  46501. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  46502. v := m.ai_info
  46503. if v == nil {
  46504. return
  46505. }
  46506. return *v, true
  46507. }
  46508. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  46509. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46511. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  46512. if !m.op.Is(OpUpdateOne) {
  46513. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  46514. }
  46515. if m.id == nil || m.oldValue == nil {
  46516. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  46517. }
  46518. oldValue, err := m.oldValue(ctx)
  46519. if err != nil {
  46520. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  46521. }
  46522. return oldValue.AiInfo, nil
  46523. }
  46524. // ClearAiInfo clears the value of the "ai_info" field.
  46525. func (m *WxCardMutation) ClearAiInfo() {
  46526. m.ai_info = nil
  46527. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  46528. }
  46529. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  46530. func (m *WxCardMutation) AiInfoCleared() bool {
  46531. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  46532. return ok
  46533. }
  46534. // ResetAiInfo resets all changes to the "ai_info" field.
  46535. func (m *WxCardMutation) ResetAiInfo() {
  46536. m.ai_info = nil
  46537. delete(m.clearedFields, wxcard.FieldAiInfo)
  46538. }
  46539. // SetIntro sets the "intro" field.
  46540. func (m *WxCardMutation) SetIntro(s string) {
  46541. m.intro = &s
  46542. }
  46543. // Intro returns the value of the "intro" field in the mutation.
  46544. func (m *WxCardMutation) Intro() (r string, exists bool) {
  46545. v := m.intro
  46546. if v == nil {
  46547. return
  46548. }
  46549. return *v, true
  46550. }
  46551. // OldIntro returns the old "intro" field's value of the WxCard entity.
  46552. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46554. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  46555. if !m.op.Is(OpUpdateOne) {
  46556. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  46557. }
  46558. if m.id == nil || m.oldValue == nil {
  46559. return v, errors.New("OldIntro requires an ID field in the mutation")
  46560. }
  46561. oldValue, err := m.oldValue(ctx)
  46562. if err != nil {
  46563. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  46564. }
  46565. return oldValue.Intro, nil
  46566. }
  46567. // ClearIntro clears the value of the "intro" field.
  46568. func (m *WxCardMutation) ClearIntro() {
  46569. m.intro = nil
  46570. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  46571. }
  46572. // IntroCleared returns if the "intro" field was cleared in this mutation.
  46573. func (m *WxCardMutation) IntroCleared() bool {
  46574. _, ok := m.clearedFields[wxcard.FieldIntro]
  46575. return ok
  46576. }
  46577. // ResetIntro resets all changes to the "intro" field.
  46578. func (m *WxCardMutation) ResetIntro() {
  46579. m.intro = nil
  46580. delete(m.clearedFields, wxcard.FieldIntro)
  46581. }
  46582. // Where appends a list predicates to the WxCardMutation builder.
  46583. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  46584. m.predicates = append(m.predicates, ps...)
  46585. }
  46586. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  46587. // users can use type-assertion to append predicates that do not depend on any generated package.
  46588. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  46589. p := make([]predicate.WxCard, len(ps))
  46590. for i := range ps {
  46591. p[i] = ps[i]
  46592. }
  46593. m.Where(p...)
  46594. }
  46595. // Op returns the operation name.
  46596. func (m *WxCardMutation) Op() Op {
  46597. return m.op
  46598. }
  46599. // SetOp allows setting the mutation operation.
  46600. func (m *WxCardMutation) SetOp(op Op) {
  46601. m.op = op
  46602. }
  46603. // Type returns the node type of this mutation (WxCard).
  46604. func (m *WxCardMutation) Type() string {
  46605. return m.typ
  46606. }
  46607. // Fields returns all fields that were changed during this mutation. Note that in
  46608. // order to get all numeric fields that were incremented/decremented, call
  46609. // AddedFields().
  46610. func (m *WxCardMutation) Fields() []string {
  46611. fields := make([]string, 0, 18)
  46612. if m.created_at != nil {
  46613. fields = append(fields, wxcard.FieldCreatedAt)
  46614. }
  46615. if m.updated_at != nil {
  46616. fields = append(fields, wxcard.FieldUpdatedAt)
  46617. }
  46618. if m.deleted_at != nil {
  46619. fields = append(fields, wxcard.FieldDeletedAt)
  46620. }
  46621. if m.user_id != nil {
  46622. fields = append(fields, wxcard.FieldUserID)
  46623. }
  46624. if m.wx_user_id != nil {
  46625. fields = append(fields, wxcard.FieldWxUserID)
  46626. }
  46627. if m.avatar != nil {
  46628. fields = append(fields, wxcard.FieldAvatar)
  46629. }
  46630. if m.logo != nil {
  46631. fields = append(fields, wxcard.FieldLogo)
  46632. }
  46633. if m.name != nil {
  46634. fields = append(fields, wxcard.FieldName)
  46635. }
  46636. if m.company != nil {
  46637. fields = append(fields, wxcard.FieldCompany)
  46638. }
  46639. if m.address != nil {
  46640. fields = append(fields, wxcard.FieldAddress)
  46641. }
  46642. if m.phone != nil {
  46643. fields = append(fields, wxcard.FieldPhone)
  46644. }
  46645. if m.official_account != nil {
  46646. fields = append(fields, wxcard.FieldOfficialAccount)
  46647. }
  46648. if m.wechat_account != nil {
  46649. fields = append(fields, wxcard.FieldWechatAccount)
  46650. }
  46651. if m.email != nil {
  46652. fields = append(fields, wxcard.FieldEmail)
  46653. }
  46654. if m.api_base != nil {
  46655. fields = append(fields, wxcard.FieldAPIBase)
  46656. }
  46657. if m.api_key != nil {
  46658. fields = append(fields, wxcard.FieldAPIKey)
  46659. }
  46660. if m.ai_info != nil {
  46661. fields = append(fields, wxcard.FieldAiInfo)
  46662. }
  46663. if m.intro != nil {
  46664. fields = append(fields, wxcard.FieldIntro)
  46665. }
  46666. return fields
  46667. }
  46668. // Field returns the value of a field with the given name. The second boolean
  46669. // return value indicates that this field was not set, or was not defined in the
  46670. // schema.
  46671. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  46672. switch name {
  46673. case wxcard.FieldCreatedAt:
  46674. return m.CreatedAt()
  46675. case wxcard.FieldUpdatedAt:
  46676. return m.UpdatedAt()
  46677. case wxcard.FieldDeletedAt:
  46678. return m.DeletedAt()
  46679. case wxcard.FieldUserID:
  46680. return m.UserID()
  46681. case wxcard.FieldWxUserID:
  46682. return m.WxUserID()
  46683. case wxcard.FieldAvatar:
  46684. return m.Avatar()
  46685. case wxcard.FieldLogo:
  46686. return m.Logo()
  46687. case wxcard.FieldName:
  46688. return m.Name()
  46689. case wxcard.FieldCompany:
  46690. return m.Company()
  46691. case wxcard.FieldAddress:
  46692. return m.Address()
  46693. case wxcard.FieldPhone:
  46694. return m.Phone()
  46695. case wxcard.FieldOfficialAccount:
  46696. return m.OfficialAccount()
  46697. case wxcard.FieldWechatAccount:
  46698. return m.WechatAccount()
  46699. case wxcard.FieldEmail:
  46700. return m.Email()
  46701. case wxcard.FieldAPIBase:
  46702. return m.APIBase()
  46703. case wxcard.FieldAPIKey:
  46704. return m.APIKey()
  46705. case wxcard.FieldAiInfo:
  46706. return m.AiInfo()
  46707. case wxcard.FieldIntro:
  46708. return m.Intro()
  46709. }
  46710. return nil, false
  46711. }
  46712. // OldField returns the old value of the field from the database. An error is
  46713. // returned if the mutation operation is not UpdateOne, or the query to the
  46714. // database failed.
  46715. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46716. switch name {
  46717. case wxcard.FieldCreatedAt:
  46718. return m.OldCreatedAt(ctx)
  46719. case wxcard.FieldUpdatedAt:
  46720. return m.OldUpdatedAt(ctx)
  46721. case wxcard.FieldDeletedAt:
  46722. return m.OldDeletedAt(ctx)
  46723. case wxcard.FieldUserID:
  46724. return m.OldUserID(ctx)
  46725. case wxcard.FieldWxUserID:
  46726. return m.OldWxUserID(ctx)
  46727. case wxcard.FieldAvatar:
  46728. return m.OldAvatar(ctx)
  46729. case wxcard.FieldLogo:
  46730. return m.OldLogo(ctx)
  46731. case wxcard.FieldName:
  46732. return m.OldName(ctx)
  46733. case wxcard.FieldCompany:
  46734. return m.OldCompany(ctx)
  46735. case wxcard.FieldAddress:
  46736. return m.OldAddress(ctx)
  46737. case wxcard.FieldPhone:
  46738. return m.OldPhone(ctx)
  46739. case wxcard.FieldOfficialAccount:
  46740. return m.OldOfficialAccount(ctx)
  46741. case wxcard.FieldWechatAccount:
  46742. return m.OldWechatAccount(ctx)
  46743. case wxcard.FieldEmail:
  46744. return m.OldEmail(ctx)
  46745. case wxcard.FieldAPIBase:
  46746. return m.OldAPIBase(ctx)
  46747. case wxcard.FieldAPIKey:
  46748. return m.OldAPIKey(ctx)
  46749. case wxcard.FieldAiInfo:
  46750. return m.OldAiInfo(ctx)
  46751. case wxcard.FieldIntro:
  46752. return m.OldIntro(ctx)
  46753. }
  46754. return nil, fmt.Errorf("unknown WxCard field %s", name)
  46755. }
  46756. // SetField sets the value of a field with the given name. It returns an error if
  46757. // the field is not defined in the schema, or if the type mismatched the field
  46758. // type.
  46759. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  46760. switch name {
  46761. case wxcard.FieldCreatedAt:
  46762. v, ok := value.(time.Time)
  46763. if !ok {
  46764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46765. }
  46766. m.SetCreatedAt(v)
  46767. return nil
  46768. case wxcard.FieldUpdatedAt:
  46769. v, ok := value.(time.Time)
  46770. if !ok {
  46771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46772. }
  46773. m.SetUpdatedAt(v)
  46774. return nil
  46775. case wxcard.FieldDeletedAt:
  46776. v, ok := value.(time.Time)
  46777. if !ok {
  46778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46779. }
  46780. m.SetDeletedAt(v)
  46781. return nil
  46782. case wxcard.FieldUserID:
  46783. v, ok := value.(uint64)
  46784. if !ok {
  46785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46786. }
  46787. m.SetUserID(v)
  46788. return nil
  46789. case wxcard.FieldWxUserID:
  46790. v, ok := value.(uint64)
  46791. if !ok {
  46792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46793. }
  46794. m.SetWxUserID(v)
  46795. return nil
  46796. case wxcard.FieldAvatar:
  46797. v, ok := value.(string)
  46798. if !ok {
  46799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46800. }
  46801. m.SetAvatar(v)
  46802. return nil
  46803. case wxcard.FieldLogo:
  46804. v, ok := value.(string)
  46805. if !ok {
  46806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46807. }
  46808. m.SetLogo(v)
  46809. return nil
  46810. case wxcard.FieldName:
  46811. v, ok := value.(string)
  46812. if !ok {
  46813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46814. }
  46815. m.SetName(v)
  46816. return nil
  46817. case wxcard.FieldCompany:
  46818. v, ok := value.(string)
  46819. if !ok {
  46820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46821. }
  46822. m.SetCompany(v)
  46823. return nil
  46824. case wxcard.FieldAddress:
  46825. v, ok := value.(string)
  46826. if !ok {
  46827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46828. }
  46829. m.SetAddress(v)
  46830. return nil
  46831. case wxcard.FieldPhone:
  46832. v, ok := value.(string)
  46833. if !ok {
  46834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46835. }
  46836. m.SetPhone(v)
  46837. return nil
  46838. case wxcard.FieldOfficialAccount:
  46839. v, ok := value.(string)
  46840. if !ok {
  46841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46842. }
  46843. m.SetOfficialAccount(v)
  46844. return nil
  46845. case wxcard.FieldWechatAccount:
  46846. v, ok := value.(string)
  46847. if !ok {
  46848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46849. }
  46850. m.SetWechatAccount(v)
  46851. return nil
  46852. case wxcard.FieldEmail:
  46853. v, ok := value.(string)
  46854. if !ok {
  46855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46856. }
  46857. m.SetEmail(v)
  46858. return nil
  46859. case wxcard.FieldAPIBase:
  46860. v, ok := value.(string)
  46861. if !ok {
  46862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46863. }
  46864. m.SetAPIBase(v)
  46865. return nil
  46866. case wxcard.FieldAPIKey:
  46867. v, ok := value.(string)
  46868. if !ok {
  46869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46870. }
  46871. m.SetAPIKey(v)
  46872. return nil
  46873. case wxcard.FieldAiInfo:
  46874. v, ok := value.(string)
  46875. if !ok {
  46876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46877. }
  46878. m.SetAiInfo(v)
  46879. return nil
  46880. case wxcard.FieldIntro:
  46881. v, ok := value.(string)
  46882. if !ok {
  46883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46884. }
  46885. m.SetIntro(v)
  46886. return nil
  46887. }
  46888. return fmt.Errorf("unknown WxCard field %s", name)
  46889. }
  46890. // AddedFields returns all numeric fields that were incremented/decremented during
  46891. // this mutation.
  46892. func (m *WxCardMutation) AddedFields() []string {
  46893. var fields []string
  46894. if m.adduser_id != nil {
  46895. fields = append(fields, wxcard.FieldUserID)
  46896. }
  46897. if m.addwx_user_id != nil {
  46898. fields = append(fields, wxcard.FieldWxUserID)
  46899. }
  46900. return fields
  46901. }
  46902. // AddedField returns the numeric value that was incremented/decremented on a field
  46903. // with the given name. The second boolean return value indicates that this field
  46904. // was not set, or was not defined in the schema.
  46905. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  46906. switch name {
  46907. case wxcard.FieldUserID:
  46908. return m.AddedUserID()
  46909. case wxcard.FieldWxUserID:
  46910. return m.AddedWxUserID()
  46911. }
  46912. return nil, false
  46913. }
  46914. // AddField adds the value to the field with the given name. It returns an error if
  46915. // the field is not defined in the schema, or if the type mismatched the field
  46916. // type.
  46917. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  46918. switch name {
  46919. case wxcard.FieldUserID:
  46920. v, ok := value.(int64)
  46921. if !ok {
  46922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46923. }
  46924. m.AddUserID(v)
  46925. return nil
  46926. case wxcard.FieldWxUserID:
  46927. v, ok := value.(int64)
  46928. if !ok {
  46929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46930. }
  46931. m.AddWxUserID(v)
  46932. return nil
  46933. }
  46934. return fmt.Errorf("unknown WxCard numeric field %s", name)
  46935. }
  46936. // ClearedFields returns all nullable fields that were cleared during this
  46937. // mutation.
  46938. func (m *WxCardMutation) ClearedFields() []string {
  46939. var fields []string
  46940. if m.FieldCleared(wxcard.FieldDeletedAt) {
  46941. fields = append(fields, wxcard.FieldDeletedAt)
  46942. }
  46943. if m.FieldCleared(wxcard.FieldUserID) {
  46944. fields = append(fields, wxcard.FieldUserID)
  46945. }
  46946. if m.FieldCleared(wxcard.FieldWxUserID) {
  46947. fields = append(fields, wxcard.FieldWxUserID)
  46948. }
  46949. if m.FieldCleared(wxcard.FieldEmail) {
  46950. fields = append(fields, wxcard.FieldEmail)
  46951. }
  46952. if m.FieldCleared(wxcard.FieldAPIBase) {
  46953. fields = append(fields, wxcard.FieldAPIBase)
  46954. }
  46955. if m.FieldCleared(wxcard.FieldAPIKey) {
  46956. fields = append(fields, wxcard.FieldAPIKey)
  46957. }
  46958. if m.FieldCleared(wxcard.FieldAiInfo) {
  46959. fields = append(fields, wxcard.FieldAiInfo)
  46960. }
  46961. if m.FieldCleared(wxcard.FieldIntro) {
  46962. fields = append(fields, wxcard.FieldIntro)
  46963. }
  46964. return fields
  46965. }
  46966. // FieldCleared returns a boolean indicating if a field with the given name was
  46967. // cleared in this mutation.
  46968. func (m *WxCardMutation) FieldCleared(name string) bool {
  46969. _, ok := m.clearedFields[name]
  46970. return ok
  46971. }
  46972. // ClearField clears the value of the field with the given name. It returns an
  46973. // error if the field is not defined in the schema.
  46974. func (m *WxCardMutation) ClearField(name string) error {
  46975. switch name {
  46976. case wxcard.FieldDeletedAt:
  46977. m.ClearDeletedAt()
  46978. return nil
  46979. case wxcard.FieldUserID:
  46980. m.ClearUserID()
  46981. return nil
  46982. case wxcard.FieldWxUserID:
  46983. m.ClearWxUserID()
  46984. return nil
  46985. case wxcard.FieldEmail:
  46986. m.ClearEmail()
  46987. return nil
  46988. case wxcard.FieldAPIBase:
  46989. m.ClearAPIBase()
  46990. return nil
  46991. case wxcard.FieldAPIKey:
  46992. m.ClearAPIKey()
  46993. return nil
  46994. case wxcard.FieldAiInfo:
  46995. m.ClearAiInfo()
  46996. return nil
  46997. case wxcard.FieldIntro:
  46998. m.ClearIntro()
  46999. return nil
  47000. }
  47001. return fmt.Errorf("unknown WxCard nullable field %s", name)
  47002. }
  47003. // ResetField resets all changes in the mutation for the field with the given name.
  47004. // It returns an error if the field is not defined in the schema.
  47005. func (m *WxCardMutation) ResetField(name string) error {
  47006. switch name {
  47007. case wxcard.FieldCreatedAt:
  47008. m.ResetCreatedAt()
  47009. return nil
  47010. case wxcard.FieldUpdatedAt:
  47011. m.ResetUpdatedAt()
  47012. return nil
  47013. case wxcard.FieldDeletedAt:
  47014. m.ResetDeletedAt()
  47015. return nil
  47016. case wxcard.FieldUserID:
  47017. m.ResetUserID()
  47018. return nil
  47019. case wxcard.FieldWxUserID:
  47020. m.ResetWxUserID()
  47021. return nil
  47022. case wxcard.FieldAvatar:
  47023. m.ResetAvatar()
  47024. return nil
  47025. case wxcard.FieldLogo:
  47026. m.ResetLogo()
  47027. return nil
  47028. case wxcard.FieldName:
  47029. m.ResetName()
  47030. return nil
  47031. case wxcard.FieldCompany:
  47032. m.ResetCompany()
  47033. return nil
  47034. case wxcard.FieldAddress:
  47035. m.ResetAddress()
  47036. return nil
  47037. case wxcard.FieldPhone:
  47038. m.ResetPhone()
  47039. return nil
  47040. case wxcard.FieldOfficialAccount:
  47041. m.ResetOfficialAccount()
  47042. return nil
  47043. case wxcard.FieldWechatAccount:
  47044. m.ResetWechatAccount()
  47045. return nil
  47046. case wxcard.FieldEmail:
  47047. m.ResetEmail()
  47048. return nil
  47049. case wxcard.FieldAPIBase:
  47050. m.ResetAPIBase()
  47051. return nil
  47052. case wxcard.FieldAPIKey:
  47053. m.ResetAPIKey()
  47054. return nil
  47055. case wxcard.FieldAiInfo:
  47056. m.ResetAiInfo()
  47057. return nil
  47058. case wxcard.FieldIntro:
  47059. m.ResetIntro()
  47060. return nil
  47061. }
  47062. return fmt.Errorf("unknown WxCard field %s", name)
  47063. }
  47064. // AddedEdges returns all edge names that were set/added in this mutation.
  47065. func (m *WxCardMutation) AddedEdges() []string {
  47066. edges := make([]string, 0, 0)
  47067. return edges
  47068. }
  47069. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47070. // name in this mutation.
  47071. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  47072. return nil
  47073. }
  47074. // RemovedEdges returns all edge names that were removed in this mutation.
  47075. func (m *WxCardMutation) RemovedEdges() []string {
  47076. edges := make([]string, 0, 0)
  47077. return edges
  47078. }
  47079. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47080. // the given name in this mutation.
  47081. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  47082. return nil
  47083. }
  47084. // ClearedEdges returns all edge names that were cleared in this mutation.
  47085. func (m *WxCardMutation) ClearedEdges() []string {
  47086. edges := make([]string, 0, 0)
  47087. return edges
  47088. }
  47089. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47090. // was cleared in this mutation.
  47091. func (m *WxCardMutation) EdgeCleared(name string) bool {
  47092. return false
  47093. }
  47094. // ClearEdge clears the value of the edge with the given name. It returns an error
  47095. // if that edge is not defined in the schema.
  47096. func (m *WxCardMutation) ClearEdge(name string) error {
  47097. return fmt.Errorf("unknown WxCard unique edge %s", name)
  47098. }
  47099. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47100. // It returns an error if the edge is not defined in the schema.
  47101. func (m *WxCardMutation) ResetEdge(name string) error {
  47102. return fmt.Errorf("unknown WxCard edge %s", name)
  47103. }
  47104. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  47105. type WxCardUserMutation struct {
  47106. config
  47107. op Op
  47108. typ string
  47109. id *uint64
  47110. created_at *time.Time
  47111. updated_at *time.Time
  47112. deleted_at *time.Time
  47113. wxid *string
  47114. account *string
  47115. avatar *string
  47116. nickname *string
  47117. remark *string
  47118. phone *string
  47119. open_id *string
  47120. union_id *string
  47121. session_key *string
  47122. is_vip *int
  47123. addis_vip *int
  47124. clearedFields map[string]struct{}
  47125. done bool
  47126. oldValue func(context.Context) (*WxCardUser, error)
  47127. predicates []predicate.WxCardUser
  47128. }
  47129. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  47130. // wxcarduserOption allows management of the mutation configuration using functional options.
  47131. type wxcarduserOption func(*WxCardUserMutation)
  47132. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  47133. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  47134. m := &WxCardUserMutation{
  47135. config: c,
  47136. op: op,
  47137. typ: TypeWxCardUser,
  47138. clearedFields: make(map[string]struct{}),
  47139. }
  47140. for _, opt := range opts {
  47141. opt(m)
  47142. }
  47143. return m
  47144. }
  47145. // withWxCardUserID sets the ID field of the mutation.
  47146. func withWxCardUserID(id uint64) wxcarduserOption {
  47147. return func(m *WxCardUserMutation) {
  47148. var (
  47149. err error
  47150. once sync.Once
  47151. value *WxCardUser
  47152. )
  47153. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  47154. once.Do(func() {
  47155. if m.done {
  47156. err = errors.New("querying old values post mutation is not allowed")
  47157. } else {
  47158. value, err = m.Client().WxCardUser.Get(ctx, id)
  47159. }
  47160. })
  47161. return value, err
  47162. }
  47163. m.id = &id
  47164. }
  47165. }
  47166. // withWxCardUser sets the old WxCardUser of the mutation.
  47167. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  47168. return func(m *WxCardUserMutation) {
  47169. m.oldValue = func(context.Context) (*WxCardUser, error) {
  47170. return node, nil
  47171. }
  47172. m.id = &node.ID
  47173. }
  47174. }
  47175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47176. // executed in a transaction (ent.Tx), a transactional client is returned.
  47177. func (m WxCardUserMutation) Client() *Client {
  47178. client := &Client{config: m.config}
  47179. client.init()
  47180. return client
  47181. }
  47182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47183. // it returns an error otherwise.
  47184. func (m WxCardUserMutation) Tx() (*Tx, error) {
  47185. if _, ok := m.driver.(*txDriver); !ok {
  47186. return nil, errors.New("ent: mutation is not running in a transaction")
  47187. }
  47188. tx := &Tx{config: m.config}
  47189. tx.init()
  47190. return tx, nil
  47191. }
  47192. // SetID sets the value of the id field. Note that this
  47193. // operation is only accepted on creation of WxCardUser entities.
  47194. func (m *WxCardUserMutation) SetID(id uint64) {
  47195. m.id = &id
  47196. }
  47197. // ID returns the ID value in the mutation. Note that the ID is only available
  47198. // if it was provided to the builder or after it was returned from the database.
  47199. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  47200. if m.id == nil {
  47201. return
  47202. }
  47203. return *m.id, true
  47204. }
  47205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47206. // That means, if the mutation is applied within a transaction with an isolation level such
  47207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47208. // or updated by the mutation.
  47209. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  47210. switch {
  47211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47212. id, exists := m.ID()
  47213. if exists {
  47214. return []uint64{id}, nil
  47215. }
  47216. fallthrough
  47217. case m.op.Is(OpUpdate | OpDelete):
  47218. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  47219. default:
  47220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47221. }
  47222. }
  47223. // SetCreatedAt sets the "created_at" field.
  47224. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  47225. m.created_at = &t
  47226. }
  47227. // CreatedAt returns the value of the "created_at" field in the mutation.
  47228. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  47229. v := m.created_at
  47230. if v == nil {
  47231. return
  47232. }
  47233. return *v, true
  47234. }
  47235. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  47236. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47238. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47239. if !m.op.Is(OpUpdateOne) {
  47240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47241. }
  47242. if m.id == nil || m.oldValue == nil {
  47243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47244. }
  47245. oldValue, err := m.oldValue(ctx)
  47246. if err != nil {
  47247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47248. }
  47249. return oldValue.CreatedAt, nil
  47250. }
  47251. // ResetCreatedAt resets all changes to the "created_at" field.
  47252. func (m *WxCardUserMutation) ResetCreatedAt() {
  47253. m.created_at = nil
  47254. }
  47255. // SetUpdatedAt sets the "updated_at" field.
  47256. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  47257. m.updated_at = &t
  47258. }
  47259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47260. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  47261. v := m.updated_at
  47262. if v == nil {
  47263. return
  47264. }
  47265. return *v, true
  47266. }
  47267. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  47268. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47270. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47271. if !m.op.Is(OpUpdateOne) {
  47272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47273. }
  47274. if m.id == nil || m.oldValue == nil {
  47275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47276. }
  47277. oldValue, err := m.oldValue(ctx)
  47278. if err != nil {
  47279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47280. }
  47281. return oldValue.UpdatedAt, nil
  47282. }
  47283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47284. func (m *WxCardUserMutation) ResetUpdatedAt() {
  47285. m.updated_at = nil
  47286. }
  47287. // SetDeletedAt sets the "deleted_at" field.
  47288. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  47289. m.deleted_at = &t
  47290. }
  47291. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47292. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  47293. v := m.deleted_at
  47294. if v == nil {
  47295. return
  47296. }
  47297. return *v, true
  47298. }
  47299. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  47300. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47302. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47303. if !m.op.Is(OpUpdateOne) {
  47304. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47305. }
  47306. if m.id == nil || m.oldValue == nil {
  47307. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47308. }
  47309. oldValue, err := m.oldValue(ctx)
  47310. if err != nil {
  47311. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47312. }
  47313. return oldValue.DeletedAt, nil
  47314. }
  47315. // ClearDeletedAt clears the value of the "deleted_at" field.
  47316. func (m *WxCardUserMutation) ClearDeletedAt() {
  47317. m.deleted_at = nil
  47318. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  47319. }
  47320. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47321. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  47322. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  47323. return ok
  47324. }
  47325. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47326. func (m *WxCardUserMutation) ResetDeletedAt() {
  47327. m.deleted_at = nil
  47328. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  47329. }
  47330. // SetWxid sets the "wxid" field.
  47331. func (m *WxCardUserMutation) SetWxid(s string) {
  47332. m.wxid = &s
  47333. }
  47334. // Wxid returns the value of the "wxid" field in the mutation.
  47335. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  47336. v := m.wxid
  47337. if v == nil {
  47338. return
  47339. }
  47340. return *v, true
  47341. }
  47342. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  47343. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47345. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  47346. if !m.op.Is(OpUpdateOne) {
  47347. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47348. }
  47349. if m.id == nil || m.oldValue == nil {
  47350. return v, errors.New("OldWxid requires an ID field in the mutation")
  47351. }
  47352. oldValue, err := m.oldValue(ctx)
  47353. if err != nil {
  47354. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47355. }
  47356. return oldValue.Wxid, nil
  47357. }
  47358. // ResetWxid resets all changes to the "wxid" field.
  47359. func (m *WxCardUserMutation) ResetWxid() {
  47360. m.wxid = nil
  47361. }
  47362. // SetAccount sets the "account" field.
  47363. func (m *WxCardUserMutation) SetAccount(s string) {
  47364. m.account = &s
  47365. }
  47366. // Account returns the value of the "account" field in the mutation.
  47367. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  47368. v := m.account
  47369. if v == nil {
  47370. return
  47371. }
  47372. return *v, true
  47373. }
  47374. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  47375. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47377. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  47378. if !m.op.Is(OpUpdateOne) {
  47379. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47380. }
  47381. if m.id == nil || m.oldValue == nil {
  47382. return v, errors.New("OldAccount requires an ID field in the mutation")
  47383. }
  47384. oldValue, err := m.oldValue(ctx)
  47385. if err != nil {
  47386. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47387. }
  47388. return oldValue.Account, nil
  47389. }
  47390. // ResetAccount resets all changes to the "account" field.
  47391. func (m *WxCardUserMutation) ResetAccount() {
  47392. m.account = nil
  47393. }
  47394. // SetAvatar sets the "avatar" field.
  47395. func (m *WxCardUserMutation) SetAvatar(s string) {
  47396. m.avatar = &s
  47397. }
  47398. // Avatar returns the value of the "avatar" field in the mutation.
  47399. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  47400. v := m.avatar
  47401. if v == nil {
  47402. return
  47403. }
  47404. return *v, true
  47405. }
  47406. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  47407. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47409. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  47410. if !m.op.Is(OpUpdateOne) {
  47411. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  47412. }
  47413. if m.id == nil || m.oldValue == nil {
  47414. return v, errors.New("OldAvatar requires an ID field in the mutation")
  47415. }
  47416. oldValue, err := m.oldValue(ctx)
  47417. if err != nil {
  47418. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  47419. }
  47420. return oldValue.Avatar, nil
  47421. }
  47422. // ResetAvatar resets all changes to the "avatar" field.
  47423. func (m *WxCardUserMutation) ResetAvatar() {
  47424. m.avatar = nil
  47425. }
  47426. // SetNickname sets the "nickname" field.
  47427. func (m *WxCardUserMutation) SetNickname(s string) {
  47428. m.nickname = &s
  47429. }
  47430. // Nickname returns the value of the "nickname" field in the mutation.
  47431. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  47432. v := m.nickname
  47433. if v == nil {
  47434. return
  47435. }
  47436. return *v, true
  47437. }
  47438. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  47439. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47441. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  47442. if !m.op.Is(OpUpdateOne) {
  47443. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47444. }
  47445. if m.id == nil || m.oldValue == nil {
  47446. return v, errors.New("OldNickname requires an ID field in the mutation")
  47447. }
  47448. oldValue, err := m.oldValue(ctx)
  47449. if err != nil {
  47450. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47451. }
  47452. return oldValue.Nickname, nil
  47453. }
  47454. // ResetNickname resets all changes to the "nickname" field.
  47455. func (m *WxCardUserMutation) ResetNickname() {
  47456. m.nickname = nil
  47457. }
  47458. // SetRemark sets the "remark" field.
  47459. func (m *WxCardUserMutation) SetRemark(s string) {
  47460. m.remark = &s
  47461. }
  47462. // Remark returns the value of the "remark" field in the mutation.
  47463. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  47464. v := m.remark
  47465. if v == nil {
  47466. return
  47467. }
  47468. return *v, true
  47469. }
  47470. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  47471. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47473. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  47474. if !m.op.Is(OpUpdateOne) {
  47475. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  47476. }
  47477. if m.id == nil || m.oldValue == nil {
  47478. return v, errors.New("OldRemark requires an ID field in the mutation")
  47479. }
  47480. oldValue, err := m.oldValue(ctx)
  47481. if err != nil {
  47482. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  47483. }
  47484. return oldValue.Remark, nil
  47485. }
  47486. // ResetRemark resets all changes to the "remark" field.
  47487. func (m *WxCardUserMutation) ResetRemark() {
  47488. m.remark = nil
  47489. }
  47490. // SetPhone sets the "phone" field.
  47491. func (m *WxCardUserMutation) SetPhone(s string) {
  47492. m.phone = &s
  47493. }
  47494. // Phone returns the value of the "phone" field in the mutation.
  47495. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  47496. v := m.phone
  47497. if v == nil {
  47498. return
  47499. }
  47500. return *v, true
  47501. }
  47502. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  47503. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47505. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  47506. if !m.op.Is(OpUpdateOne) {
  47507. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  47508. }
  47509. if m.id == nil || m.oldValue == nil {
  47510. return v, errors.New("OldPhone requires an ID field in the mutation")
  47511. }
  47512. oldValue, err := m.oldValue(ctx)
  47513. if err != nil {
  47514. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  47515. }
  47516. return oldValue.Phone, nil
  47517. }
  47518. // ResetPhone resets all changes to the "phone" field.
  47519. func (m *WxCardUserMutation) ResetPhone() {
  47520. m.phone = nil
  47521. }
  47522. // SetOpenID sets the "open_id" field.
  47523. func (m *WxCardUserMutation) SetOpenID(s string) {
  47524. m.open_id = &s
  47525. }
  47526. // OpenID returns the value of the "open_id" field in the mutation.
  47527. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  47528. v := m.open_id
  47529. if v == nil {
  47530. return
  47531. }
  47532. return *v, true
  47533. }
  47534. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  47535. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47537. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  47538. if !m.op.Is(OpUpdateOne) {
  47539. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  47540. }
  47541. if m.id == nil || m.oldValue == nil {
  47542. return v, errors.New("OldOpenID requires an ID field in the mutation")
  47543. }
  47544. oldValue, err := m.oldValue(ctx)
  47545. if err != nil {
  47546. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  47547. }
  47548. return oldValue.OpenID, nil
  47549. }
  47550. // ResetOpenID resets all changes to the "open_id" field.
  47551. func (m *WxCardUserMutation) ResetOpenID() {
  47552. m.open_id = nil
  47553. }
  47554. // SetUnionID sets the "union_id" field.
  47555. func (m *WxCardUserMutation) SetUnionID(s string) {
  47556. m.union_id = &s
  47557. }
  47558. // UnionID returns the value of the "union_id" field in the mutation.
  47559. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  47560. v := m.union_id
  47561. if v == nil {
  47562. return
  47563. }
  47564. return *v, true
  47565. }
  47566. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  47567. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47569. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  47570. if !m.op.Is(OpUpdateOne) {
  47571. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  47572. }
  47573. if m.id == nil || m.oldValue == nil {
  47574. return v, errors.New("OldUnionID requires an ID field in the mutation")
  47575. }
  47576. oldValue, err := m.oldValue(ctx)
  47577. if err != nil {
  47578. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  47579. }
  47580. return oldValue.UnionID, nil
  47581. }
  47582. // ResetUnionID resets all changes to the "union_id" field.
  47583. func (m *WxCardUserMutation) ResetUnionID() {
  47584. m.union_id = nil
  47585. }
  47586. // SetSessionKey sets the "session_key" field.
  47587. func (m *WxCardUserMutation) SetSessionKey(s string) {
  47588. m.session_key = &s
  47589. }
  47590. // SessionKey returns the value of the "session_key" field in the mutation.
  47591. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  47592. v := m.session_key
  47593. if v == nil {
  47594. return
  47595. }
  47596. return *v, true
  47597. }
  47598. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  47599. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47601. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  47602. if !m.op.Is(OpUpdateOne) {
  47603. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  47604. }
  47605. if m.id == nil || m.oldValue == nil {
  47606. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  47607. }
  47608. oldValue, err := m.oldValue(ctx)
  47609. if err != nil {
  47610. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  47611. }
  47612. return oldValue.SessionKey, nil
  47613. }
  47614. // ResetSessionKey resets all changes to the "session_key" field.
  47615. func (m *WxCardUserMutation) ResetSessionKey() {
  47616. m.session_key = nil
  47617. }
  47618. // SetIsVip sets the "is_vip" field.
  47619. func (m *WxCardUserMutation) SetIsVip(i int) {
  47620. m.is_vip = &i
  47621. m.addis_vip = nil
  47622. }
  47623. // IsVip returns the value of the "is_vip" field in the mutation.
  47624. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  47625. v := m.is_vip
  47626. if v == nil {
  47627. return
  47628. }
  47629. return *v, true
  47630. }
  47631. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  47632. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47634. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  47635. if !m.op.Is(OpUpdateOne) {
  47636. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  47637. }
  47638. if m.id == nil || m.oldValue == nil {
  47639. return v, errors.New("OldIsVip requires an ID field in the mutation")
  47640. }
  47641. oldValue, err := m.oldValue(ctx)
  47642. if err != nil {
  47643. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  47644. }
  47645. return oldValue.IsVip, nil
  47646. }
  47647. // AddIsVip adds i to the "is_vip" field.
  47648. func (m *WxCardUserMutation) AddIsVip(i int) {
  47649. if m.addis_vip != nil {
  47650. *m.addis_vip += i
  47651. } else {
  47652. m.addis_vip = &i
  47653. }
  47654. }
  47655. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  47656. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  47657. v := m.addis_vip
  47658. if v == nil {
  47659. return
  47660. }
  47661. return *v, true
  47662. }
  47663. // ResetIsVip resets all changes to the "is_vip" field.
  47664. func (m *WxCardUserMutation) ResetIsVip() {
  47665. m.is_vip = nil
  47666. m.addis_vip = nil
  47667. }
  47668. // Where appends a list predicates to the WxCardUserMutation builder.
  47669. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  47670. m.predicates = append(m.predicates, ps...)
  47671. }
  47672. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  47673. // users can use type-assertion to append predicates that do not depend on any generated package.
  47674. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  47675. p := make([]predicate.WxCardUser, len(ps))
  47676. for i := range ps {
  47677. p[i] = ps[i]
  47678. }
  47679. m.Where(p...)
  47680. }
  47681. // Op returns the operation name.
  47682. func (m *WxCardUserMutation) Op() Op {
  47683. return m.op
  47684. }
  47685. // SetOp allows setting the mutation operation.
  47686. func (m *WxCardUserMutation) SetOp(op Op) {
  47687. m.op = op
  47688. }
  47689. // Type returns the node type of this mutation (WxCardUser).
  47690. func (m *WxCardUserMutation) Type() string {
  47691. return m.typ
  47692. }
  47693. // Fields returns all fields that were changed during this mutation. Note that in
  47694. // order to get all numeric fields that were incremented/decremented, call
  47695. // AddedFields().
  47696. func (m *WxCardUserMutation) Fields() []string {
  47697. fields := make([]string, 0, 13)
  47698. if m.created_at != nil {
  47699. fields = append(fields, wxcarduser.FieldCreatedAt)
  47700. }
  47701. if m.updated_at != nil {
  47702. fields = append(fields, wxcarduser.FieldUpdatedAt)
  47703. }
  47704. if m.deleted_at != nil {
  47705. fields = append(fields, wxcarduser.FieldDeletedAt)
  47706. }
  47707. if m.wxid != nil {
  47708. fields = append(fields, wxcarduser.FieldWxid)
  47709. }
  47710. if m.account != nil {
  47711. fields = append(fields, wxcarduser.FieldAccount)
  47712. }
  47713. if m.avatar != nil {
  47714. fields = append(fields, wxcarduser.FieldAvatar)
  47715. }
  47716. if m.nickname != nil {
  47717. fields = append(fields, wxcarduser.FieldNickname)
  47718. }
  47719. if m.remark != nil {
  47720. fields = append(fields, wxcarduser.FieldRemark)
  47721. }
  47722. if m.phone != nil {
  47723. fields = append(fields, wxcarduser.FieldPhone)
  47724. }
  47725. if m.open_id != nil {
  47726. fields = append(fields, wxcarduser.FieldOpenID)
  47727. }
  47728. if m.union_id != nil {
  47729. fields = append(fields, wxcarduser.FieldUnionID)
  47730. }
  47731. if m.session_key != nil {
  47732. fields = append(fields, wxcarduser.FieldSessionKey)
  47733. }
  47734. if m.is_vip != nil {
  47735. fields = append(fields, wxcarduser.FieldIsVip)
  47736. }
  47737. return fields
  47738. }
  47739. // Field returns the value of a field with the given name. The second boolean
  47740. // return value indicates that this field was not set, or was not defined in the
  47741. // schema.
  47742. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  47743. switch name {
  47744. case wxcarduser.FieldCreatedAt:
  47745. return m.CreatedAt()
  47746. case wxcarduser.FieldUpdatedAt:
  47747. return m.UpdatedAt()
  47748. case wxcarduser.FieldDeletedAt:
  47749. return m.DeletedAt()
  47750. case wxcarduser.FieldWxid:
  47751. return m.Wxid()
  47752. case wxcarduser.FieldAccount:
  47753. return m.Account()
  47754. case wxcarduser.FieldAvatar:
  47755. return m.Avatar()
  47756. case wxcarduser.FieldNickname:
  47757. return m.Nickname()
  47758. case wxcarduser.FieldRemark:
  47759. return m.Remark()
  47760. case wxcarduser.FieldPhone:
  47761. return m.Phone()
  47762. case wxcarduser.FieldOpenID:
  47763. return m.OpenID()
  47764. case wxcarduser.FieldUnionID:
  47765. return m.UnionID()
  47766. case wxcarduser.FieldSessionKey:
  47767. return m.SessionKey()
  47768. case wxcarduser.FieldIsVip:
  47769. return m.IsVip()
  47770. }
  47771. return nil, false
  47772. }
  47773. // OldField returns the old value of the field from the database. An error is
  47774. // returned if the mutation operation is not UpdateOne, or the query to the
  47775. // database failed.
  47776. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47777. switch name {
  47778. case wxcarduser.FieldCreatedAt:
  47779. return m.OldCreatedAt(ctx)
  47780. case wxcarduser.FieldUpdatedAt:
  47781. return m.OldUpdatedAt(ctx)
  47782. case wxcarduser.FieldDeletedAt:
  47783. return m.OldDeletedAt(ctx)
  47784. case wxcarduser.FieldWxid:
  47785. return m.OldWxid(ctx)
  47786. case wxcarduser.FieldAccount:
  47787. return m.OldAccount(ctx)
  47788. case wxcarduser.FieldAvatar:
  47789. return m.OldAvatar(ctx)
  47790. case wxcarduser.FieldNickname:
  47791. return m.OldNickname(ctx)
  47792. case wxcarduser.FieldRemark:
  47793. return m.OldRemark(ctx)
  47794. case wxcarduser.FieldPhone:
  47795. return m.OldPhone(ctx)
  47796. case wxcarduser.FieldOpenID:
  47797. return m.OldOpenID(ctx)
  47798. case wxcarduser.FieldUnionID:
  47799. return m.OldUnionID(ctx)
  47800. case wxcarduser.FieldSessionKey:
  47801. return m.OldSessionKey(ctx)
  47802. case wxcarduser.FieldIsVip:
  47803. return m.OldIsVip(ctx)
  47804. }
  47805. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  47806. }
  47807. // SetField sets the value of a field with the given name. It returns an error if
  47808. // the field is not defined in the schema, or if the type mismatched the field
  47809. // type.
  47810. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  47811. switch name {
  47812. case wxcarduser.FieldCreatedAt:
  47813. v, ok := value.(time.Time)
  47814. if !ok {
  47815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47816. }
  47817. m.SetCreatedAt(v)
  47818. return nil
  47819. case wxcarduser.FieldUpdatedAt:
  47820. v, ok := value.(time.Time)
  47821. if !ok {
  47822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47823. }
  47824. m.SetUpdatedAt(v)
  47825. return nil
  47826. case wxcarduser.FieldDeletedAt:
  47827. v, ok := value.(time.Time)
  47828. if !ok {
  47829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47830. }
  47831. m.SetDeletedAt(v)
  47832. return nil
  47833. case wxcarduser.FieldWxid:
  47834. v, ok := value.(string)
  47835. if !ok {
  47836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47837. }
  47838. m.SetWxid(v)
  47839. return nil
  47840. case wxcarduser.FieldAccount:
  47841. v, ok := value.(string)
  47842. if !ok {
  47843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47844. }
  47845. m.SetAccount(v)
  47846. return nil
  47847. case wxcarduser.FieldAvatar:
  47848. v, ok := value.(string)
  47849. if !ok {
  47850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47851. }
  47852. m.SetAvatar(v)
  47853. return nil
  47854. case wxcarduser.FieldNickname:
  47855. v, ok := value.(string)
  47856. if !ok {
  47857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47858. }
  47859. m.SetNickname(v)
  47860. return nil
  47861. case wxcarduser.FieldRemark:
  47862. v, ok := value.(string)
  47863. if !ok {
  47864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47865. }
  47866. m.SetRemark(v)
  47867. return nil
  47868. case wxcarduser.FieldPhone:
  47869. v, ok := value.(string)
  47870. if !ok {
  47871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47872. }
  47873. m.SetPhone(v)
  47874. return nil
  47875. case wxcarduser.FieldOpenID:
  47876. v, ok := value.(string)
  47877. if !ok {
  47878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47879. }
  47880. m.SetOpenID(v)
  47881. return nil
  47882. case wxcarduser.FieldUnionID:
  47883. v, ok := value.(string)
  47884. if !ok {
  47885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47886. }
  47887. m.SetUnionID(v)
  47888. return nil
  47889. case wxcarduser.FieldSessionKey:
  47890. v, ok := value.(string)
  47891. if !ok {
  47892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47893. }
  47894. m.SetSessionKey(v)
  47895. return nil
  47896. case wxcarduser.FieldIsVip:
  47897. v, ok := value.(int)
  47898. if !ok {
  47899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47900. }
  47901. m.SetIsVip(v)
  47902. return nil
  47903. }
  47904. return fmt.Errorf("unknown WxCardUser field %s", name)
  47905. }
  47906. // AddedFields returns all numeric fields that were incremented/decremented during
  47907. // this mutation.
  47908. func (m *WxCardUserMutation) AddedFields() []string {
  47909. var fields []string
  47910. if m.addis_vip != nil {
  47911. fields = append(fields, wxcarduser.FieldIsVip)
  47912. }
  47913. return fields
  47914. }
  47915. // AddedField returns the numeric value that was incremented/decremented on a field
  47916. // with the given name. The second boolean return value indicates that this field
  47917. // was not set, or was not defined in the schema.
  47918. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  47919. switch name {
  47920. case wxcarduser.FieldIsVip:
  47921. return m.AddedIsVip()
  47922. }
  47923. return nil, false
  47924. }
  47925. // AddField adds the value to the field with the given name. It returns an error if
  47926. // the field is not defined in the schema, or if the type mismatched the field
  47927. // type.
  47928. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  47929. switch name {
  47930. case wxcarduser.FieldIsVip:
  47931. v, ok := value.(int)
  47932. if !ok {
  47933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47934. }
  47935. m.AddIsVip(v)
  47936. return nil
  47937. }
  47938. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  47939. }
  47940. // ClearedFields returns all nullable fields that were cleared during this
  47941. // mutation.
  47942. func (m *WxCardUserMutation) ClearedFields() []string {
  47943. var fields []string
  47944. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  47945. fields = append(fields, wxcarduser.FieldDeletedAt)
  47946. }
  47947. return fields
  47948. }
  47949. // FieldCleared returns a boolean indicating if a field with the given name was
  47950. // cleared in this mutation.
  47951. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  47952. _, ok := m.clearedFields[name]
  47953. return ok
  47954. }
  47955. // ClearField clears the value of the field with the given name. It returns an
  47956. // error if the field is not defined in the schema.
  47957. func (m *WxCardUserMutation) ClearField(name string) error {
  47958. switch name {
  47959. case wxcarduser.FieldDeletedAt:
  47960. m.ClearDeletedAt()
  47961. return nil
  47962. }
  47963. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  47964. }
  47965. // ResetField resets all changes in the mutation for the field with the given name.
  47966. // It returns an error if the field is not defined in the schema.
  47967. func (m *WxCardUserMutation) ResetField(name string) error {
  47968. switch name {
  47969. case wxcarduser.FieldCreatedAt:
  47970. m.ResetCreatedAt()
  47971. return nil
  47972. case wxcarduser.FieldUpdatedAt:
  47973. m.ResetUpdatedAt()
  47974. return nil
  47975. case wxcarduser.FieldDeletedAt:
  47976. m.ResetDeletedAt()
  47977. return nil
  47978. case wxcarduser.FieldWxid:
  47979. m.ResetWxid()
  47980. return nil
  47981. case wxcarduser.FieldAccount:
  47982. m.ResetAccount()
  47983. return nil
  47984. case wxcarduser.FieldAvatar:
  47985. m.ResetAvatar()
  47986. return nil
  47987. case wxcarduser.FieldNickname:
  47988. m.ResetNickname()
  47989. return nil
  47990. case wxcarduser.FieldRemark:
  47991. m.ResetRemark()
  47992. return nil
  47993. case wxcarduser.FieldPhone:
  47994. m.ResetPhone()
  47995. return nil
  47996. case wxcarduser.FieldOpenID:
  47997. m.ResetOpenID()
  47998. return nil
  47999. case wxcarduser.FieldUnionID:
  48000. m.ResetUnionID()
  48001. return nil
  48002. case wxcarduser.FieldSessionKey:
  48003. m.ResetSessionKey()
  48004. return nil
  48005. case wxcarduser.FieldIsVip:
  48006. m.ResetIsVip()
  48007. return nil
  48008. }
  48009. return fmt.Errorf("unknown WxCardUser field %s", name)
  48010. }
  48011. // AddedEdges returns all edge names that were set/added in this mutation.
  48012. func (m *WxCardUserMutation) AddedEdges() []string {
  48013. edges := make([]string, 0, 0)
  48014. return edges
  48015. }
  48016. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48017. // name in this mutation.
  48018. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  48019. return nil
  48020. }
  48021. // RemovedEdges returns all edge names that were removed in this mutation.
  48022. func (m *WxCardUserMutation) RemovedEdges() []string {
  48023. edges := make([]string, 0, 0)
  48024. return edges
  48025. }
  48026. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48027. // the given name in this mutation.
  48028. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  48029. return nil
  48030. }
  48031. // ClearedEdges returns all edge names that were cleared in this mutation.
  48032. func (m *WxCardUserMutation) ClearedEdges() []string {
  48033. edges := make([]string, 0, 0)
  48034. return edges
  48035. }
  48036. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48037. // was cleared in this mutation.
  48038. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  48039. return false
  48040. }
  48041. // ClearEdge clears the value of the edge with the given name. It returns an error
  48042. // if that edge is not defined in the schema.
  48043. func (m *WxCardUserMutation) ClearEdge(name string) error {
  48044. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  48045. }
  48046. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48047. // It returns an error if the edge is not defined in the schema.
  48048. func (m *WxCardUserMutation) ResetEdge(name string) error {
  48049. return fmt.Errorf("unknown WxCardUser edge %s", name)
  48050. }
  48051. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  48052. type WxCardVisitMutation struct {
  48053. config
  48054. op Op
  48055. typ string
  48056. id *uint64
  48057. created_at *time.Time
  48058. updated_at *time.Time
  48059. deleted_at *time.Time
  48060. user_id *uint64
  48061. adduser_id *int64
  48062. bot_id *uint64
  48063. addbot_id *int64
  48064. bot_type *uint8
  48065. addbot_type *int8
  48066. clearedFields map[string]struct{}
  48067. done bool
  48068. oldValue func(context.Context) (*WxCardVisit, error)
  48069. predicates []predicate.WxCardVisit
  48070. }
  48071. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  48072. // wxcardvisitOption allows management of the mutation configuration using functional options.
  48073. type wxcardvisitOption func(*WxCardVisitMutation)
  48074. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  48075. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  48076. m := &WxCardVisitMutation{
  48077. config: c,
  48078. op: op,
  48079. typ: TypeWxCardVisit,
  48080. clearedFields: make(map[string]struct{}),
  48081. }
  48082. for _, opt := range opts {
  48083. opt(m)
  48084. }
  48085. return m
  48086. }
  48087. // withWxCardVisitID sets the ID field of the mutation.
  48088. func withWxCardVisitID(id uint64) wxcardvisitOption {
  48089. return func(m *WxCardVisitMutation) {
  48090. var (
  48091. err error
  48092. once sync.Once
  48093. value *WxCardVisit
  48094. )
  48095. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  48096. once.Do(func() {
  48097. if m.done {
  48098. err = errors.New("querying old values post mutation is not allowed")
  48099. } else {
  48100. value, err = m.Client().WxCardVisit.Get(ctx, id)
  48101. }
  48102. })
  48103. return value, err
  48104. }
  48105. m.id = &id
  48106. }
  48107. }
  48108. // withWxCardVisit sets the old WxCardVisit of the mutation.
  48109. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  48110. return func(m *WxCardVisitMutation) {
  48111. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  48112. return node, nil
  48113. }
  48114. m.id = &node.ID
  48115. }
  48116. }
  48117. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48118. // executed in a transaction (ent.Tx), a transactional client is returned.
  48119. func (m WxCardVisitMutation) Client() *Client {
  48120. client := &Client{config: m.config}
  48121. client.init()
  48122. return client
  48123. }
  48124. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48125. // it returns an error otherwise.
  48126. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  48127. if _, ok := m.driver.(*txDriver); !ok {
  48128. return nil, errors.New("ent: mutation is not running in a transaction")
  48129. }
  48130. tx := &Tx{config: m.config}
  48131. tx.init()
  48132. return tx, nil
  48133. }
  48134. // SetID sets the value of the id field. Note that this
  48135. // operation is only accepted on creation of WxCardVisit entities.
  48136. func (m *WxCardVisitMutation) SetID(id uint64) {
  48137. m.id = &id
  48138. }
  48139. // ID returns the ID value in the mutation. Note that the ID is only available
  48140. // if it was provided to the builder or after it was returned from the database.
  48141. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  48142. if m.id == nil {
  48143. return
  48144. }
  48145. return *m.id, true
  48146. }
  48147. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48148. // That means, if the mutation is applied within a transaction with an isolation level such
  48149. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48150. // or updated by the mutation.
  48151. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  48152. switch {
  48153. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48154. id, exists := m.ID()
  48155. if exists {
  48156. return []uint64{id}, nil
  48157. }
  48158. fallthrough
  48159. case m.op.Is(OpUpdate | OpDelete):
  48160. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  48161. default:
  48162. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48163. }
  48164. }
  48165. // SetCreatedAt sets the "created_at" field.
  48166. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  48167. m.created_at = &t
  48168. }
  48169. // CreatedAt returns the value of the "created_at" field in the mutation.
  48170. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  48171. v := m.created_at
  48172. if v == nil {
  48173. return
  48174. }
  48175. return *v, true
  48176. }
  48177. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  48178. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48180. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48181. if !m.op.Is(OpUpdateOne) {
  48182. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48183. }
  48184. if m.id == nil || m.oldValue == nil {
  48185. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48186. }
  48187. oldValue, err := m.oldValue(ctx)
  48188. if err != nil {
  48189. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48190. }
  48191. return oldValue.CreatedAt, nil
  48192. }
  48193. // ResetCreatedAt resets all changes to the "created_at" field.
  48194. func (m *WxCardVisitMutation) ResetCreatedAt() {
  48195. m.created_at = nil
  48196. }
  48197. // SetUpdatedAt sets the "updated_at" field.
  48198. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  48199. m.updated_at = &t
  48200. }
  48201. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48202. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  48203. v := m.updated_at
  48204. if v == nil {
  48205. return
  48206. }
  48207. return *v, true
  48208. }
  48209. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  48210. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48212. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48213. if !m.op.Is(OpUpdateOne) {
  48214. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48215. }
  48216. if m.id == nil || m.oldValue == nil {
  48217. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48218. }
  48219. oldValue, err := m.oldValue(ctx)
  48220. if err != nil {
  48221. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48222. }
  48223. return oldValue.UpdatedAt, nil
  48224. }
  48225. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48226. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  48227. m.updated_at = nil
  48228. }
  48229. // SetDeletedAt sets the "deleted_at" field.
  48230. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  48231. m.deleted_at = &t
  48232. }
  48233. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48234. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  48235. v := m.deleted_at
  48236. if v == nil {
  48237. return
  48238. }
  48239. return *v, true
  48240. }
  48241. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  48242. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48244. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48245. if !m.op.Is(OpUpdateOne) {
  48246. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48247. }
  48248. if m.id == nil || m.oldValue == nil {
  48249. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48250. }
  48251. oldValue, err := m.oldValue(ctx)
  48252. if err != nil {
  48253. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48254. }
  48255. return oldValue.DeletedAt, nil
  48256. }
  48257. // ClearDeletedAt clears the value of the "deleted_at" field.
  48258. func (m *WxCardVisitMutation) ClearDeletedAt() {
  48259. m.deleted_at = nil
  48260. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  48261. }
  48262. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48263. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  48264. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  48265. return ok
  48266. }
  48267. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48268. func (m *WxCardVisitMutation) ResetDeletedAt() {
  48269. m.deleted_at = nil
  48270. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  48271. }
  48272. // SetUserID sets the "user_id" field.
  48273. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  48274. m.user_id = &u
  48275. m.adduser_id = nil
  48276. }
  48277. // UserID returns the value of the "user_id" field in the mutation.
  48278. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  48279. v := m.user_id
  48280. if v == nil {
  48281. return
  48282. }
  48283. return *v, true
  48284. }
  48285. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  48286. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48288. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48289. if !m.op.Is(OpUpdateOne) {
  48290. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48291. }
  48292. if m.id == nil || m.oldValue == nil {
  48293. return v, errors.New("OldUserID requires an ID field in the mutation")
  48294. }
  48295. oldValue, err := m.oldValue(ctx)
  48296. if err != nil {
  48297. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48298. }
  48299. return oldValue.UserID, nil
  48300. }
  48301. // AddUserID adds u to the "user_id" field.
  48302. func (m *WxCardVisitMutation) AddUserID(u int64) {
  48303. if m.adduser_id != nil {
  48304. *m.adduser_id += u
  48305. } else {
  48306. m.adduser_id = &u
  48307. }
  48308. }
  48309. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48310. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  48311. v := m.adduser_id
  48312. if v == nil {
  48313. return
  48314. }
  48315. return *v, true
  48316. }
  48317. // ClearUserID clears the value of the "user_id" field.
  48318. func (m *WxCardVisitMutation) ClearUserID() {
  48319. m.user_id = nil
  48320. m.adduser_id = nil
  48321. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  48322. }
  48323. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48324. func (m *WxCardVisitMutation) UserIDCleared() bool {
  48325. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  48326. return ok
  48327. }
  48328. // ResetUserID resets all changes to the "user_id" field.
  48329. func (m *WxCardVisitMutation) ResetUserID() {
  48330. m.user_id = nil
  48331. m.adduser_id = nil
  48332. delete(m.clearedFields, wxcardvisit.FieldUserID)
  48333. }
  48334. // SetBotID sets the "bot_id" field.
  48335. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  48336. m.bot_id = &u
  48337. m.addbot_id = nil
  48338. }
  48339. // BotID returns the value of the "bot_id" field in the mutation.
  48340. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  48341. v := m.bot_id
  48342. if v == nil {
  48343. return
  48344. }
  48345. return *v, true
  48346. }
  48347. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  48348. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48350. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  48351. if !m.op.Is(OpUpdateOne) {
  48352. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  48353. }
  48354. if m.id == nil || m.oldValue == nil {
  48355. return v, errors.New("OldBotID requires an ID field in the mutation")
  48356. }
  48357. oldValue, err := m.oldValue(ctx)
  48358. if err != nil {
  48359. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  48360. }
  48361. return oldValue.BotID, nil
  48362. }
  48363. // AddBotID adds u to the "bot_id" field.
  48364. func (m *WxCardVisitMutation) AddBotID(u int64) {
  48365. if m.addbot_id != nil {
  48366. *m.addbot_id += u
  48367. } else {
  48368. m.addbot_id = &u
  48369. }
  48370. }
  48371. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  48372. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  48373. v := m.addbot_id
  48374. if v == nil {
  48375. return
  48376. }
  48377. return *v, true
  48378. }
  48379. // ResetBotID resets all changes to the "bot_id" field.
  48380. func (m *WxCardVisitMutation) ResetBotID() {
  48381. m.bot_id = nil
  48382. m.addbot_id = nil
  48383. }
  48384. // SetBotType sets the "bot_type" field.
  48385. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  48386. m.bot_type = &u
  48387. m.addbot_type = nil
  48388. }
  48389. // BotType returns the value of the "bot_type" field in the mutation.
  48390. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  48391. v := m.bot_type
  48392. if v == nil {
  48393. return
  48394. }
  48395. return *v, true
  48396. }
  48397. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  48398. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48400. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  48401. if !m.op.Is(OpUpdateOne) {
  48402. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  48403. }
  48404. if m.id == nil || m.oldValue == nil {
  48405. return v, errors.New("OldBotType requires an ID field in the mutation")
  48406. }
  48407. oldValue, err := m.oldValue(ctx)
  48408. if err != nil {
  48409. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  48410. }
  48411. return oldValue.BotType, nil
  48412. }
  48413. // AddBotType adds u to the "bot_type" field.
  48414. func (m *WxCardVisitMutation) AddBotType(u int8) {
  48415. if m.addbot_type != nil {
  48416. *m.addbot_type += u
  48417. } else {
  48418. m.addbot_type = &u
  48419. }
  48420. }
  48421. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  48422. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  48423. v := m.addbot_type
  48424. if v == nil {
  48425. return
  48426. }
  48427. return *v, true
  48428. }
  48429. // ResetBotType resets all changes to the "bot_type" field.
  48430. func (m *WxCardVisitMutation) ResetBotType() {
  48431. m.bot_type = nil
  48432. m.addbot_type = nil
  48433. }
  48434. // Where appends a list predicates to the WxCardVisitMutation builder.
  48435. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  48436. m.predicates = append(m.predicates, ps...)
  48437. }
  48438. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  48439. // users can use type-assertion to append predicates that do not depend on any generated package.
  48440. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  48441. p := make([]predicate.WxCardVisit, len(ps))
  48442. for i := range ps {
  48443. p[i] = ps[i]
  48444. }
  48445. m.Where(p...)
  48446. }
  48447. // Op returns the operation name.
  48448. func (m *WxCardVisitMutation) Op() Op {
  48449. return m.op
  48450. }
  48451. // SetOp allows setting the mutation operation.
  48452. func (m *WxCardVisitMutation) SetOp(op Op) {
  48453. m.op = op
  48454. }
  48455. // Type returns the node type of this mutation (WxCardVisit).
  48456. func (m *WxCardVisitMutation) Type() string {
  48457. return m.typ
  48458. }
  48459. // Fields returns all fields that were changed during this mutation. Note that in
  48460. // order to get all numeric fields that were incremented/decremented, call
  48461. // AddedFields().
  48462. func (m *WxCardVisitMutation) Fields() []string {
  48463. fields := make([]string, 0, 6)
  48464. if m.created_at != nil {
  48465. fields = append(fields, wxcardvisit.FieldCreatedAt)
  48466. }
  48467. if m.updated_at != nil {
  48468. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  48469. }
  48470. if m.deleted_at != nil {
  48471. fields = append(fields, wxcardvisit.FieldDeletedAt)
  48472. }
  48473. if m.user_id != nil {
  48474. fields = append(fields, wxcardvisit.FieldUserID)
  48475. }
  48476. if m.bot_id != nil {
  48477. fields = append(fields, wxcardvisit.FieldBotID)
  48478. }
  48479. if m.bot_type != nil {
  48480. fields = append(fields, wxcardvisit.FieldBotType)
  48481. }
  48482. return fields
  48483. }
  48484. // Field returns the value of a field with the given name. The second boolean
  48485. // return value indicates that this field was not set, or was not defined in the
  48486. // schema.
  48487. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  48488. switch name {
  48489. case wxcardvisit.FieldCreatedAt:
  48490. return m.CreatedAt()
  48491. case wxcardvisit.FieldUpdatedAt:
  48492. return m.UpdatedAt()
  48493. case wxcardvisit.FieldDeletedAt:
  48494. return m.DeletedAt()
  48495. case wxcardvisit.FieldUserID:
  48496. return m.UserID()
  48497. case wxcardvisit.FieldBotID:
  48498. return m.BotID()
  48499. case wxcardvisit.FieldBotType:
  48500. return m.BotType()
  48501. }
  48502. return nil, false
  48503. }
  48504. // OldField returns the old value of the field from the database. An error is
  48505. // returned if the mutation operation is not UpdateOne, or the query to the
  48506. // database failed.
  48507. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48508. switch name {
  48509. case wxcardvisit.FieldCreatedAt:
  48510. return m.OldCreatedAt(ctx)
  48511. case wxcardvisit.FieldUpdatedAt:
  48512. return m.OldUpdatedAt(ctx)
  48513. case wxcardvisit.FieldDeletedAt:
  48514. return m.OldDeletedAt(ctx)
  48515. case wxcardvisit.FieldUserID:
  48516. return m.OldUserID(ctx)
  48517. case wxcardvisit.FieldBotID:
  48518. return m.OldBotID(ctx)
  48519. case wxcardvisit.FieldBotType:
  48520. return m.OldBotType(ctx)
  48521. }
  48522. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  48523. }
  48524. // SetField sets the value of a field with the given name. It returns an error if
  48525. // the field is not defined in the schema, or if the type mismatched the field
  48526. // type.
  48527. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  48528. switch name {
  48529. case wxcardvisit.FieldCreatedAt:
  48530. v, ok := value.(time.Time)
  48531. if !ok {
  48532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48533. }
  48534. m.SetCreatedAt(v)
  48535. return nil
  48536. case wxcardvisit.FieldUpdatedAt:
  48537. v, ok := value.(time.Time)
  48538. if !ok {
  48539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48540. }
  48541. m.SetUpdatedAt(v)
  48542. return nil
  48543. case wxcardvisit.FieldDeletedAt:
  48544. v, ok := value.(time.Time)
  48545. if !ok {
  48546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48547. }
  48548. m.SetDeletedAt(v)
  48549. return nil
  48550. case wxcardvisit.FieldUserID:
  48551. v, ok := value.(uint64)
  48552. if !ok {
  48553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48554. }
  48555. m.SetUserID(v)
  48556. return nil
  48557. case wxcardvisit.FieldBotID:
  48558. v, ok := value.(uint64)
  48559. if !ok {
  48560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48561. }
  48562. m.SetBotID(v)
  48563. return nil
  48564. case wxcardvisit.FieldBotType:
  48565. v, ok := value.(uint8)
  48566. if !ok {
  48567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48568. }
  48569. m.SetBotType(v)
  48570. return nil
  48571. }
  48572. return fmt.Errorf("unknown WxCardVisit field %s", name)
  48573. }
  48574. // AddedFields returns all numeric fields that were incremented/decremented during
  48575. // this mutation.
  48576. func (m *WxCardVisitMutation) AddedFields() []string {
  48577. var fields []string
  48578. if m.adduser_id != nil {
  48579. fields = append(fields, wxcardvisit.FieldUserID)
  48580. }
  48581. if m.addbot_id != nil {
  48582. fields = append(fields, wxcardvisit.FieldBotID)
  48583. }
  48584. if m.addbot_type != nil {
  48585. fields = append(fields, wxcardvisit.FieldBotType)
  48586. }
  48587. return fields
  48588. }
  48589. // AddedField returns the numeric value that was incremented/decremented on a field
  48590. // with the given name. The second boolean return value indicates that this field
  48591. // was not set, or was not defined in the schema.
  48592. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  48593. switch name {
  48594. case wxcardvisit.FieldUserID:
  48595. return m.AddedUserID()
  48596. case wxcardvisit.FieldBotID:
  48597. return m.AddedBotID()
  48598. case wxcardvisit.FieldBotType:
  48599. return m.AddedBotType()
  48600. }
  48601. return nil, false
  48602. }
  48603. // AddField adds the value to the field with the given name. It returns an error if
  48604. // the field is not defined in the schema, or if the type mismatched the field
  48605. // type.
  48606. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  48607. switch name {
  48608. case wxcardvisit.FieldUserID:
  48609. v, ok := value.(int64)
  48610. if !ok {
  48611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48612. }
  48613. m.AddUserID(v)
  48614. return nil
  48615. case wxcardvisit.FieldBotID:
  48616. v, ok := value.(int64)
  48617. if !ok {
  48618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48619. }
  48620. m.AddBotID(v)
  48621. return nil
  48622. case wxcardvisit.FieldBotType:
  48623. v, ok := value.(int8)
  48624. if !ok {
  48625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48626. }
  48627. m.AddBotType(v)
  48628. return nil
  48629. }
  48630. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  48631. }
  48632. // ClearedFields returns all nullable fields that were cleared during this
  48633. // mutation.
  48634. func (m *WxCardVisitMutation) ClearedFields() []string {
  48635. var fields []string
  48636. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  48637. fields = append(fields, wxcardvisit.FieldDeletedAt)
  48638. }
  48639. if m.FieldCleared(wxcardvisit.FieldUserID) {
  48640. fields = append(fields, wxcardvisit.FieldUserID)
  48641. }
  48642. return fields
  48643. }
  48644. // FieldCleared returns a boolean indicating if a field with the given name was
  48645. // cleared in this mutation.
  48646. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  48647. _, ok := m.clearedFields[name]
  48648. return ok
  48649. }
  48650. // ClearField clears the value of the field with the given name. It returns an
  48651. // error if the field is not defined in the schema.
  48652. func (m *WxCardVisitMutation) ClearField(name string) error {
  48653. switch name {
  48654. case wxcardvisit.FieldDeletedAt:
  48655. m.ClearDeletedAt()
  48656. return nil
  48657. case wxcardvisit.FieldUserID:
  48658. m.ClearUserID()
  48659. return nil
  48660. }
  48661. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  48662. }
  48663. // ResetField resets all changes in the mutation for the field with the given name.
  48664. // It returns an error if the field is not defined in the schema.
  48665. func (m *WxCardVisitMutation) ResetField(name string) error {
  48666. switch name {
  48667. case wxcardvisit.FieldCreatedAt:
  48668. m.ResetCreatedAt()
  48669. return nil
  48670. case wxcardvisit.FieldUpdatedAt:
  48671. m.ResetUpdatedAt()
  48672. return nil
  48673. case wxcardvisit.FieldDeletedAt:
  48674. m.ResetDeletedAt()
  48675. return nil
  48676. case wxcardvisit.FieldUserID:
  48677. m.ResetUserID()
  48678. return nil
  48679. case wxcardvisit.FieldBotID:
  48680. m.ResetBotID()
  48681. return nil
  48682. case wxcardvisit.FieldBotType:
  48683. m.ResetBotType()
  48684. return nil
  48685. }
  48686. return fmt.Errorf("unknown WxCardVisit field %s", name)
  48687. }
  48688. // AddedEdges returns all edge names that were set/added in this mutation.
  48689. func (m *WxCardVisitMutation) AddedEdges() []string {
  48690. edges := make([]string, 0, 0)
  48691. return edges
  48692. }
  48693. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48694. // name in this mutation.
  48695. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  48696. return nil
  48697. }
  48698. // RemovedEdges returns all edge names that were removed in this mutation.
  48699. func (m *WxCardVisitMutation) RemovedEdges() []string {
  48700. edges := make([]string, 0, 0)
  48701. return edges
  48702. }
  48703. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48704. // the given name in this mutation.
  48705. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  48706. return nil
  48707. }
  48708. // ClearedEdges returns all edge names that were cleared in this mutation.
  48709. func (m *WxCardVisitMutation) ClearedEdges() []string {
  48710. edges := make([]string, 0, 0)
  48711. return edges
  48712. }
  48713. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48714. // was cleared in this mutation.
  48715. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  48716. return false
  48717. }
  48718. // ClearEdge clears the value of the edge with the given name. It returns an error
  48719. // if that edge is not defined in the schema.
  48720. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  48721. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  48722. }
  48723. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48724. // It returns an error if the edge is not defined in the schema.
  48725. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  48726. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  48727. }